summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2010-10-22 20:30:48 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2010-10-22 20:30:48 -0700
commit5cc103506289de7ee0a0b526ae0381541990cad4 (patch)
treeae8a4958e70c6d1295030b40e333dcc007b3c074 /drivers
parent73ecf3a6e3f0206bf56a0fefe3b3eda042fb7034 (diff)
parent92ca0dc5ee022e4c0e488177e1d8865a0778c6c2 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6: (141 commits) USB: mct_u232: fix broken close USB: gadget: amd5536udc.c: fix error path USB: imx21-hcd - fix off by one resource size calculation usb: gadget: fix Kconfig warning usb: r8a66597-udc: Add processing when USB was removed. mxc_udc: add workaround for ENGcm09152 for i.MX35 USB: ftdi_sio: add device ids for ScienceScope USB: musb: AM35x: Workaround for fifo read issue USB: musb: add musb support for AM35x USB: AM35x: Add musb support usb: Fix linker errors with CONFIG_PM=n USB: ohci-sh - use resource_size instead of defining its own resource_len macro USB: isp1362-hcd - use resource_size instead of defining its own resource_len macro USB: isp116x-hcd - use resource_size instead of defining its own resource_len macro USB: xhci: Fix compile error when CONFIG_PM=n USB: accept some invalid ep0-maxpacket values USB: xHCI: PCI power management implementation USB: xHCI: bus power management implementation USB: xHCI: port remote wakeup implementation USB: xHCI: port power management implementation ... Manually fix up (non-data) conflict: the SCSI merge gad renamed the 'hw_sector_size' member to 'physical_block_size', and the USB tree brought a new use of it.
Diffstat (limited to 'drivers')
-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
155 files changed, 9252 insertions, 2500 deletions
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);
#else
static const struct usb_device_id ub_usb_ids[] = {
- { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_SCSI, US_PR_BULK) },
+ { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, USB_SC_SCSI, USB_PR_BULK) },
{ }
};
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[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1006) },
{ HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1007) },
{ HID_USB_DEVICE(USB_VENDOR_ID_IMATION, USB_DEVICE_ID_DISC_STAKKA) },
+ { HID_USB_DEVICE(USB_VENDOR_ID_JESS, USB_DEVICE_ID_JESS_YUREX) },
{ HID_USB_DEVICE(USB_VENDOR_ID_KBGEAR, USB_DEVICE_ID_KBGEAR_JAMSTUDIO) },
{ HID_USB_DEVICE(USB_VENDOR_ID_KWORLD, USB_DEVICE_ID_KWORLD_RADIO_FM700) },
{ 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 @@
#define USB_VENDOR_ID_IMATION 0x0718
#define USB_DEVICE_ID_DISC_STAKKA 0xd000
+#define USB_VENDOR_ID_JESS 0x0c45
+#define USB_DEVICE_ID_JESS_YUREX 0x1010
+
#define USB_VENDOR_ID_KBGEAR 0x084e
#define USB_DEVICE_ID_KBGEAR_JAMSTUDIO 0x1001
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,
unsigned long long lba;
unsigned sector_size;
+ if (sdp->no_read_capacity_16)
+ return -EINVAL;
+
do {
memset(cmd, 0, 16);
cmd[0] = SERVICE_ACTION_IN;
@@ -1626,6 +1629,15 @@ static int read_capacity_10(struct scsi_disk *sdkp, struct scsi_device *sdp,
sector_size = get_unaligned_be32(&buffer[4]);
lba = get_unaligned_be32(&buffer[0]);
+ if (sdp->no_read_capacity_16 && (lba == 0xffffffff)) {
+ /* Some buggy (usb cardreader) devices return an lba of
+ 0xffffffff when the want to report a size of 0 (with
+ which they really mean no media is present) */
+ sdkp->capacity = 0;
+ sdkp->physical_block_size = sector_size;
+ return sector_size;
+ }
+
if ((sizeof(sdkp->capacity) == 4) && (lba == 0xffffffff)) {
sd_printk(KERN_ERR, sdkp, "Too big for this kernel. Use a "
"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)
static int sr_packet(struct cdrom_device_info *cdi,
struct packet_command *cgc)
{
+ struct scsi_cd *cd = cdi->handle;
+ struct scsi_device *sdev = cd->device;
+
+ if (cgc->cmd[0] == GPCMD_READ_DISC_INFO && sdev->no_read_disc_info)
+ return -EDRIVE_CANT_DO_THIS;
+
if (cgc->timeout <= 0)
cgc->timeout = IOCTL_TIMEOUT;
- sr_do_ioctl(cdi->handle, cgc);
+ sr_do_ioctl(cd, cgc);
return cgc->stat;
}
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
config USB_ARCH_HAS_EHCI
boolean
default y if PPC_83xx
+ default y if PPC_MPC512x
default y if SOC_AU1200
default y if ARCH_IXP4XX
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 @@
# Makefile for USB ATM/xDSL drivers
#
+ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG
+
obj-$(CONFIG_USB_CXACRU) += cxacru.o
obj-$(CONFIG_USB_SPEEDTOUCH) += speedtch.o
obj-$(CONFIG_USB_UEAGLEATM) += ueagle-atm.o
obj-$(CONFIG_USB_ATM) += usbatm.o
obj-$(CONFIG_USB_XUSBATM) += xusbatm.o
-
-ifeq ($(CONFIG_USB_DEBUG),y)
-EXTRA_CFLAGS += -DDEBUG
-endif
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 @@
# Makefile for Cypress C67X00 USB Controller
#
-ccflags-$(CONFIG_USB_DEBUG) += -DDEBUG
+ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG
-obj-$(CONFIG_USB_C67X00_HCD) += c67x00.o
+obj-$(CONFIG_USB_C67X00_HCD) += c67x00.o
-c67x00-objs := c67x00-drv.o c67x00-ll-hpi.o c67x00-hcd.o c67x00-sched.o
+c67x00-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[] = {
/* Support Lego NXT using pbLua firmware */
{ USB_DEVICE(0x0694, 0xff00),
.driver_info = NOT_A_MODEM,
- },
+ },
/* control interfaces without any protocol set */
{ 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 @@
# Makefile for USB Core files and filesystem
#
-usbcore-objs := usb.o hub.o hcd.o urb.o message.o driver.o \
- config.o file.o buffer.o sysfs.o endpoint.o \
- devio.o notify.o generic.o quirks.o devices.o
+ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG
-ifeq ($(CONFIG_PCI),y)
- usbcore-objs += hcd-pci.o
-endif
+usbcore-y := usb.o hub.o hcd.o urb.o message.o driver.o
+usbcore-y += config.o file.o buffer.o sysfs.o endpoint.o
+usbcore-y += devio.o notify.o generic.o quirks.o devices.o
-ifeq ($(CONFIG_USB_DEVICEFS),y)
- usbcore-objs += inode.o
-endif
+usbcore-$(CONFIG_PCI) += hcd-pci.o
+usbcore-$(CONFIG_USB_DEVICEFS) += inode.o
-obj-$(CONFIG_USB) += usbcore.o
-
-ifeq ($(CONFIG_USB_DEBUG),y)
-EXTRA_CFLAGS += -DDEBUG
-endif
+obj-$(CONFIG_USB) += usbcore.o
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 @@
#define ALLOW_SERIAL_NUMBER
static const char *format_topo =
-/* T: Bus=dd Lev=dd Prnt=dd Port=dd Cnt=dd Dev#=ddd Spd=ddd MxCh=dd */
-"\nT: Bus=%2.2d Lev=%2.2d Prnt=%2.2d Port=%2.2d Cnt=%2.2d Dev#=%3d Spd=%3s MxCh=%2d\n";
+/* T: Bus=dd Lev=dd Prnt=dd Port=dd Cnt=dd Dev#=ddd Spd=dddd MxCh=dd */
+"\nT: Bus=%2.2d Lev=%2.2d Prnt=%2.2d Port=%2.2d Cnt=%2.2d Dev#=%3d Spd=%-4s MxCh=%2d\n";
static const char *format_string_manufacturer =
/* S: Manufacturer=xxxx */
@@ -520,11 +520,14 @@ static ssize_t usb_device_dump(char __user **buffer, size_t *nbytes,
speed = "1.5"; break;
case USB_SPEED_UNKNOWN: /* usb 1.1 root hub code */
case USB_SPEED_FULL:
- speed = "12 "; break;
+ speed = "12"; break;
+ case USB_SPEED_WIRELESS: /* Wireless has no real fixed speed */
case USB_SPEED_HIGH:
speed = "480"; break;
+ case USB_SPEED_SUPER:
+ speed = "5000"; break;
default:
- speed = "?? ";
+ speed = "??";
}
data_end = pages_start + sprintf(pages_start, format_topo,
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)
/* Avoid PM error messages for devices disconnected while suspended
* as we'll display regular disconnect messages just a bit later.
*/
- if (status == -ENODEV)
+ if (status == -ENODEV || status == -ESHUTDOWN)
status = 0;
return status;
}
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,
return retval;
error_register:
- kfree(ep_dev);
+ put_device(&ep_dev->dev);
exit:
return retval;
}
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)
return;
if (test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags) &&
- hcd->driver->shutdown)
+ hcd->driver->shutdown) {
hcd->driver->shutdown(hcd);
+ pci_disable_device(dev);
+ }
}
EXPORT_SYMBOL_GPL(usb_hcd_pci_shutdown);
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,
*dma_handle = 0;
}
-static void unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb)
+void unmap_urb_setup_for_dma(struct usb_hcd *hcd, struct urb *urb)
{
- enum dma_data_direction dir;
-
if (urb->transfer_flags & URB_SETUP_MAP_SINGLE)
dma_unmap_single(hcd->self.controller,
urb->setup_dma,
@@ -1279,6 +1277,17 @@ static void unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb)
sizeof(struct usb_ctrlrequest),
DMA_TO_DEVICE);
+ /* Make it safe to call this routine more than once */
+ urb->transfer_flags &= ~(URB_SETUP_MAP_SINGLE | URB_SETUP_MAP_LOCAL);
+}
+EXPORT_SYMBOL_GPL(unmap_urb_setup_for_dma);
+
+void unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb)
+{
+ enum dma_data_direction dir;
+
+ unmap_urb_setup_for_dma(hcd, urb);
+
dir = usb_urb_dir_in(urb) ? DMA_FROM_DEVICE : DMA_TO_DEVICE;
if (urb->transfer_flags & URB_DMA_MAP_SG)
dma_unmap_sg(hcd->self.controller,
@@ -1303,10 +1312,10 @@ static void unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb)
dir);
/* Make it safe to call this routine more than once */
- urb->transfer_flags &= ~(URB_SETUP_MAP_SINGLE | URB_SETUP_MAP_LOCAL |
- URB_DMA_MAP_SG | URB_DMA_MAP_PAGE |
+ urb->transfer_flags &= ~(URB_DMA_MAP_SG | URB_DMA_MAP_PAGE |
URB_DMA_MAP_SINGLE | URB_MAP_LOCAL);
}
+EXPORT_SYMBOL_GPL(unmap_urb_for_dma);
static int map_urb_for_dma(struct usb_hcd *hcd, struct urb *urb,
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)
clear_port_feature(hdev, port1,
USB_PORT_FEAT_ENABLE);
portstatus &= ~USB_PORT_STAT_ENABLE;
+ } else {
+ /* Pretend that power was lost for USB3 devs */
+ portstatus &= ~USB_PORT_STAT_ENABLE;
}
}
@@ -2594,16 +2597,14 @@ static int hub_set_address(struct usb_device *udev, int devnum)
return 0;
if (udev->state != USB_STATE_DEFAULT)
return -EINVAL;
- if (hcd->driver->address_device) {
+ if (hcd->driver->address_device)
retval = hcd->driver->address_device(hcd, udev);
- } else {
+ else
retval = usb_control_msg(udev, usb_sndaddr0pipe(),
USB_REQ_SET_ADDRESS, 0, devnum, 0,
NULL, 0, USB_CTRL_SET_TIMEOUT);
- if (retval == 0)
- update_address(udev, devnum);
- }
if (retval == 0) {
+ update_address(udev, devnum);
/* Device now using proper address. */
usb_set_device_state(udev, USB_STATE_ADDRESS);
usb_ep0_reinit(udev);
@@ -2860,13 +2861,16 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
else
i = udev->descriptor.bMaxPacketSize0;
if (le16_to_cpu(udev->ep0.desc.wMaxPacketSize) != i) {
- if (udev->speed != USB_SPEED_FULL ||
+ if (udev->speed == USB_SPEED_LOW ||
!(i == 8 || i == 16 || i == 32 || i == 64)) {
- dev_err(&udev->dev, "ep0 maxpacket = %d\n", i);
+ dev_err(&udev->dev, "Invalid ep0 maxpacket: %d\n", i);
retval = -EMSGSIZE;
goto fail;
}
- dev_dbg(&udev->dev, "ep0 maxpacket = %d\n", i);
+ if (udev->speed == USB_SPEED_FULL)
+ dev_dbg(&udev->dev, "ep0 maxpacket = %d\n", i);
+ else
+ dev_warn(&udev->dev, "Using ep0 maxpacket: %d\n", i);
udev->ep0.desc.wMaxPacketSize = cpu_to_le16(i);
usb_ep0_reinit(udev);
}
@@ -3097,16 +3101,17 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
udev->speed = USB_SPEED_UNKNOWN;
/*
- * xHCI needs to issue an address device command later
- * in the hub_port_init sequence for SS/HS/FS/LS devices.
+ * Set the address.
+ * Note xHCI needs to issue an address device command later
+ * in the hub_port_init sequence for SS/HS/FS/LS devices,
+ * and xHC will assign an address to the device. But use
+ * kernel assigned address here, to avoid any address conflict
+ * issue.
*/
- if (!(hcd->driver->flags & HCD_USB3)) {
- /* set the address */
- choose_address(udev);
- if (udev->devnum <= 0) {
- status = -ENOTCONN; /* Don't retry */
- goto loop;
- }
+ choose_address(udev);
+ if (udev->devnum <= 0) {
+ status = -ENOTCONN; /* Don't retry */
+ goto loop;
}
/* reset (non-USB 3.0 devices) and get descriptor */
@@ -3629,7 +3634,7 @@ static int usb_reset_and_verify_device(struct usb_device *udev)
}
if (!parent_hdev) {
- /* this requires hcd-specific logic; see OHCI hc_restart() */
+ /* this requires hcd-specific logic; see ohci_restart() */
dev_dbg(&udev->dev, "%s for root hub!\n", __func__);
return -EISDIR;
}
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)
{
int i;
- dev_dbg(&dev->dev, "%s nuking %s URBs\n", __func__,
- skip_ep0 ? "non-ep0" : "all");
- for (i = skip_ep0; i < 16; ++i) {
- usb_disable_endpoint(dev, i, true);
- usb_disable_endpoint(dev, i + USB_DIR_IN, true);
- }
-
/* getting rid of interfaces will disconnect
* any drivers bound to them (a key side effect)
*/
@@ -1176,6 +1169,13 @@ void usb_disable_device(struct usb_device *dev, int skip_ep0)
if (dev->state == USB_STATE_CONFIGURED)
usb_set_device_state(dev, USB_STATE_ADDRESS);
}
+
+ dev_dbg(&dev->dev, "%s nuking %s URBs\n", __func__,
+ skip_ep0 ? "non-ep0" : "all");
+ for (i = skip_ep0; i < 16; ++i) {
+ usb_disable_endpoint(dev, i, true);
+ usb_disable_endpoint(dev, i + USB_DIR_IN, true);
+ }
}
/**
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)
};
/* Check that the pipe's type matches the endpoint's type */
- if (usb_pipetype(urb->pipe) != pipetypes[xfertype])
+ if (usb_pipetype(urb->pipe) != pipetypes[xfertype]) {
+ dev_err(&dev->dev, "BOGUS urb xfer, pipe %x != type %x\n",
+ usb_pipetype(urb->pipe), pipetypes[xfertype]);
return -EPIPE; /* The most suitable error code :-) */
+ }
/* enforce simple/standard policy */
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 @@
# Makefile for early USB devices
#
-obj-$(CONFIG_EARLY_PRINTK_DBGP) += ehci-dbgp.o
+obj-$(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
boolean "Freescale Highspeed USB DR Peripheral Controller"
depends on FSL_SOC || ARCH_MXC
select USB_GADGET_DUALSPEED
+ select USB_FSL_MPH_DR_OF
help
Some of Freescale PowerPC processors have a High Speed
Dual-Role(DR) USB controller, which supports device mode.
@@ -209,17 +210,6 @@ config USB_OMAP
default USB_GADGET
select USB_GADGET_SELECTED
-config USB_OTG
- boolean "OTG Support"
- depends on USB_GADGET_OMAP && ARCH_OMAP_OTG && USB_OHCI_HCD
- help
- The most notable feature of USB OTG is support for a
- "Dual-Role" device, which can act as either a device
- or a host. The initial role choice can be changed
- later, when two dual-role devices talk to each other.
-
- Select this only if your OMAP board has a Mini-AB connector.
-
config USB_GADGET_PXA25X
boolean "PXA 25x or IXP 4xx"
depends on (ARCH_PXA && PXA25x) || ARCH_IXP4XX
@@ -716,8 +706,8 @@ config USB_FUNCTIONFS
depends on EXPERIMENTAL
select USB_FUNCTIONFS_GENERIC if !(USB_FUNCTIONFS_ETH || USB_FUNCTIONFS_RNDIS)
help
- The Function Filesystem (FunctioFS) lets one create USB
- composite functions in user space in the same way as GadgetFS
+ The Function Filesystem (FunctionFS) lets one create USB
+ composite functions in user space in the same way GadgetFS
lets one create USB gadgets in user space. This allows creation
of composite gadgets such that some of the functions are
implemented in kernel space (for instance Ethernet, serial or
@@ -733,14 +723,14 @@ config USB_FUNCTIONFS_ETH
bool "Include configuration with CDC ECM (Ethernet)"
depends on USB_FUNCTIONFS && NET
help
- Include a configuration with CDC ECM funcion (Ethernet) and the
- Funcion Filesystem.
+ Include a configuration with CDC ECM function (Ethernet) and the
+ Function Filesystem.
config USB_FUNCTIONFS_RNDIS
bool "Include configuration with RNDIS (Ethernet)"
depends on USB_FUNCTIONFS && NET
help
- Include a configuration with RNDIS funcion (Ethernet) and the Filesystem.
+ Include a configuration with RNDIS function (Ethernet) and the Filesystem.
config USB_FUNCTIONFS_GENERIC
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 @@
#
# USB peripheral controller drivers
#
-ifeq ($(CONFIG_USB_GADGET_DEBUG),y)
- EXTRA_CFLAGS += -DDEBUG
-endif
+ccflags-$(CONFIG_USB_GADGET_DEBUG) := -DDEBUG
obj-$(CONFIG_USB_DUMMY_HCD) += dummy_hcd.o
obj-$(CONFIG_USB_NET2280) += net2280.o
@@ -18,10 +16,8 @@ obj-$(CONFIG_USB_S3C2410) += s3c2410_udc.o
obj-$(CONFIG_USB_AT91) += at91_udc.o
obj-$(CONFIG_USB_ATMEL_USBA) += atmel_usba_udc.o
obj-$(CONFIG_USB_FSL_USB2) += fsl_usb2_udc.o
-fsl_usb2_udc-objs := fsl_udc_core.o
-ifeq ($(CONFIG_ARCH_MXC),y)
-fsl_usb2_udc-objs += fsl_mxc_udc.o
-endif
+fsl_usb2_udc-y := fsl_udc_core.o
+fsl_usb2_udc-$(CONFIG_ARCH_MXC) += fsl_mxc_udc.o
obj-$(CONFIG_USB_M66592) += m66592-udc.o
obj-$(CONFIG_USB_R8A66597) += r8a66597-udc.o
obj-$(CONFIG_USB_FSL_QE) += fsl_qe_udc.o
@@ -32,21 +28,21 @@ obj-$(CONFIG_USB_LANGWELL) += langwell_udc.o
#
# USB gadget drivers
#
-g_zero-objs := zero.o
-g_audio-objs := audio.o
-g_ether-objs := ether.o
-g_serial-objs := serial.o
-g_midi-objs := gmidi.o
-gadgetfs-objs := inode.o
-g_file_storage-objs := file_storage.o
-g_mass_storage-objs := mass_storage.o
-g_printer-objs := printer.o
-g_cdc-objs := cdc2.o
-g_multi-objs := multi.o
-g_hid-objs := hid.o
-g_dbgp-objs := dbgp.o
-g_nokia-objs := nokia.o
-g_webcam-objs := webcam.o
+g_zero-y := zero.o
+g_audio-y := audio.o
+g_ether-y := ether.o
+g_serial-y := serial.o
+g_midi-y := gmidi.o
+gadgetfs-y := inode.o
+g_file_storage-y := file_storage.o
+g_mass_storage-y := mass_storage.o
+g_printer-y := printer.o
+g_cdc-y := cdc2.o
+g_multi-y := multi.o
+g_hid-y := hid.o
+g_dbgp-y := dbgp.o
+g_nokia-y := nokia.o
+g_webcam-y := webcam.o
obj-$(CONFIG_USB_ZERO) += g_zero.o
obj-$(CONFIG_USB_AUDIO) += g_audio.o
@@ -64,4 +60,3 @@ obj-$(CONFIG_USB_G_DBGP) += g_dbgp.o
obj-$(CONFIG_USB_G_MULTI) += g_multi.o
obj-$(CONFIG_USB_G_NOKIA) += g_nokia.o
obj-$(CONFIG_USB_G_WEBCAM) += g_webcam.o
-
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)
DBG(dev, "DMA mode = PPBNDU (packet per buffer "
"WITHOUT desc. update)\n");
dev_info(&dev->pdev->dev, "DMA mode (%s)\n", "PPBNDU");
- } else if (use_dma && use_dma_ppb_du && use_dma_ppb_du) {
+ } else if (use_dma && use_dma_ppb && use_dma_ppb_du) {
DBG(dev, "DMA mode = PPBDU (packet per buffer "
"WITH desc. update)\n");
dev_info(&dev->pdev->dev, "DMA mode (%s)\n", "PPBDU");
@@ -1954,13 +1954,14 @@ static int setup_ep0(struct udc *dev)
}
/* Called by gadget driver to register itself */
-int usb_gadget_register_driver(struct usb_gadget_driver *driver)
+int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
+ int (*bind)(struct usb_gadget *))
{
struct udc *dev = udc;
int retval;
u32 tmp;
- if (!driver || !driver->bind || !driver->setup
+ if (!driver || !bind || !driver->setup
|| driver->speed != USB_SPEED_HIGH)
return -EINVAL;
if (!dev)
@@ -1972,7 +1973,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
dev->driver = driver;
dev->gadget.dev.driver = &driver->driver;
- retval = driver->bind(&dev->gadget);
+ retval = bind(&dev->gadget);
/* Some gadget drivers use both ep0 directions.
* NOTE: to gadget driver, ep0 is just one endpoint...
@@ -2000,7 +2001,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
return 0;
}
-EXPORT_SYMBOL(usb_gadget_register_driver);
+EXPORT_SYMBOL(usb_gadget_probe_driver);
/* shutdown requests and disconnect from gadget */
static void
@@ -3382,8 +3383,10 @@ static int udc_probe(struct udc *dev)
udc = dev;
retval = device_register(&dev->gadget.dev);
- if (retval)
+ if (retval) {
+ put_device(&dev->gadget.dev);
goto finished;
+ }
/* timer init */
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)
schedule_work(&udc->vbus_timer_work);
}
-int usb_gadget_register_driver (struct usb_gadget_driver *driver)
+int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
+ int (*bind)(struct usb_gadget *))
{
struct at91_udc *udc = &controller;
int retval;
@@ -1636,7 +1637,7 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver)
if (!driver
|| driver->speed < USB_SPEED_FULL
- || !driver->bind
+ || !bind
|| !driver->setup) {
DBG("bad parameter.\n");
return -EINVAL;
@@ -1653,9 +1654,9 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver)
udc->enabled = 1;
udc->selfpowered = 1;
- retval = driver->bind(&udc->gadget);
+ retval = bind(&udc->gadget);
if (retval) {
- DBG("driver->bind() returned %d\n", retval);
+ DBG("bind() returned %d\n", retval);
udc->driver = NULL;
udc->gadget.dev.driver = NULL;
dev_set_drvdata(&udc->gadget.dev, NULL);
@@ -1671,7 +1672,7 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver)
DBG("bound to %s\n", driver->driver.name);
return 0;
}
-EXPORT_SYMBOL (usb_gadget_register_driver);
+EXPORT_SYMBOL(usb_gadget_probe_driver);
int usb_gadget_unregister_driver (struct usb_gadget_driver *driver)
{
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:
return IRQ_HANDLED;
}
-int usb_gadget_register_driver(struct usb_gadget_driver *driver)
+int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
+ int (*bind)(struct usb_gadget *))
{
struct usba_udc *udc = &the_udc;
unsigned long flags;
@@ -1812,7 +1813,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
clk_enable(udc->pclk);
clk_enable(udc->hclk);
- ret = driver->bind(&udc->gadget);
+ ret = bind(&udc->gadget);
if (ret) {
DBG(DBG_ERR, "Could not bind to driver %s: error %d\n",
driver->driver.name, ret);
@@ -1841,7 +1842,7 @@ err_driver_bind:
udc->gadget.dev.driver = NULL;
return ret;
}
-EXPORT_SYMBOL(usb_gadget_register_driver);
+EXPORT_SYMBOL(usb_gadget_probe_driver);
int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
{
@@ -2014,6 +2015,9 @@ static int __init usba_udc_probe(struct platform_device *pdev)
} else {
disable_irq(gpio_to_irq(udc->vbus_pin));
}
+ } else {
+ /* gpio_request fail so use -EINVAL for gpio_is_valid */
+ ubc->vbus_pin = -EINVAL;
}
}
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[] = {
/*-------------------------------------------------------------------------*/
-static int __ref audio_do_config(struct usb_configuration *c)
+static int __init audio_do_config(struct usb_configuration *c)
{
/* FIXME alloc iConfiguration string, set it in c->strings */
@@ -105,7 +105,6 @@ static int __ref audio_do_config(struct usb_configuration *c)
static struct usb_configuration audio_config_driver = {
.label = DRIVER_DESC,
- .bind = audio_do_config,
.bConfigurationValue = 1,
/* .iConfiguration = DYNAMIC */
.bmAttributes = USB_CONFIG_ATT_SELFPOWER,
@@ -113,7 +112,7 @@ static struct usb_configuration audio_config_driver = {
/*-------------------------------------------------------------------------*/
-static int __ref audio_bind(struct usb_composite_dev *cdev)
+static int __init audio_bind(struct usb_composite_dev *cdev)
{
int gcnum;
int status;
@@ -145,7 +144,7 @@ static int __ref audio_bind(struct usb_composite_dev *cdev)
strings_dev[STRING_PRODUCT_IDX].id = status;
device_desc.iProduct = status;
- status = usb_add_config(cdev, &audio_config_driver);
+ status = usb_add_config(cdev, &audio_config_driver, audio_do_config);
if (status < 0)
goto fail;
@@ -166,13 +165,12 @@ static struct usb_composite_driver audio_driver = {
.name = "g_audio",
.dev = &device_desc,
.strings = audio_strings,
- .bind = audio_bind,
.unbind = __exit_p(audio_unbind),
};
static int __init init(void)
{
- return usb_composite_register(&audio_driver);
+ return usb_composite_probe(&audio_driver, audio_bind);
}
module_init(init);
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];
/*
* We _always_ have both CDC ECM and CDC ACM functions.
*/
-static int __ref cdc_do_config(struct usb_configuration *c)
+static int __init cdc_do_config(struct usb_configuration *c)
{
int status;
@@ -151,7 +151,6 @@ static int __ref cdc_do_config(struct usb_configuration *c)
static struct usb_configuration cdc_config_driver = {
.label = "CDC Composite (ECM + ACM)",
- .bind = cdc_do_config,
.bConfigurationValue = 1,
/* .iConfiguration = DYNAMIC */
.bmAttributes = USB_CONFIG_ATT_SELFPOWER,
@@ -159,7 +158,7 @@ static struct usb_configuration cdc_config_driver = {
/*-------------------------------------------------------------------------*/
-static int __ref cdc_bind(struct usb_composite_dev *cdev)
+static int __init cdc_bind(struct usb_composite_dev *cdev)
{
int gcnum;
struct usb_gadget *gadget = cdev->gadget;
@@ -218,7 +217,7 @@ static int __ref cdc_bind(struct usb_composite_dev *cdev)
device_desc.iProduct = status;
/* register our configuration */
- status = usb_add_config(cdev, &cdc_config_driver);
+ status = usb_add_config(cdev, &cdc_config_driver, cdc_do_config);
if (status < 0)
goto fail1;
@@ -245,7 +244,6 @@ static struct usb_composite_driver cdc_driver = {
.name = "g_cdc",
.dev = &device_desc,
.strings = dev_strings,
- .bind = cdc_bind,
.unbind = __exit_p(cdc_unbind),
};
@@ -255,7 +253,7 @@ MODULE_LICENSE("GPL");
static int __init init(void)
{
- return usb_composite_register(&cdc_driver);
+ return usb_composite_probe(&cdc_driver, cdc_bind);
}
module_init(init);
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 = {
static const struct usb_gadget_ops usb_gadget_ops;
/**
- * usb_gadget_register_driver: register a gadget driver
+ * usb_gadget_probe_driver: register a gadget driver
+ * @driver: the driver being registered
+ * @bind: the driver's bind callback
*
- * Check usb_gadget_register_driver() at "usb_gadget.h" for details
- * Interrupts are enabled here
+ * Check usb_gadget_probe_driver() at <linux/usb/gadget.h> for details.
+ * Interrupts are enabled here.
*/
-int usb_gadget_register_driver(struct usb_gadget_driver *driver)
+int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
+ int (*bind)(struct usb_gadget *))
{
struct ci13xxx *udc = _udc;
unsigned long i, k, flags;
@@ -2354,7 +2357,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
trace("%p", driver);
if (driver == NULL ||
- driver->bind == NULL ||
+ bind == NULL ||
driver->unbind == NULL ||
driver->setup == NULL ||
driver->disconnect == NULL ||
@@ -2430,7 +2433,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
udc->gadget.dev.driver = &driver->driver;
spin_unlock_irqrestore(udc->lock, flags);
- retval = driver->bind(&udc->gadget); /* MAY SLEEP */
+ retval = bind(&udc->gadget); /* MAY SLEEP */
spin_lock_irqsave(udc->lock, flags);
if (retval) {
@@ -2447,7 +2450,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
usb_gadget_unregister_driver(driver);
return retval;
}
-EXPORT_SYMBOL(usb_gadget_register_driver);
+EXPORT_SYMBOL(usb_gadget_probe_driver);
/**
* usb_gadget_unregister_driver: unregister a gadget driver
@@ -2462,7 +2465,6 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
trace("%p", driver);
if (driver == NULL ||
- driver->bind == NULL ||
driver->unbind == NULL ||
driver->setup == NULL ||
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 @@
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/device.h>
+#include <linux/utsname.h>
#include <linux/usb/composite.h>
@@ -39,6 +40,7 @@
#define USB_BUFSIZ 1024
static struct usb_composite_driver *composite;
+static int (*composite_gadget_bind)(struct usb_composite_dev *cdev);
/* Some systems will need runtime overrides for the product identifers
* published in the device descriptor, either numbers or strings or both.
@@ -69,6 +71,8 @@ static char *iSerialNumber;
module_param(iSerialNumber, charp, 0);
MODULE_PARM_DESC(iSerialNumber, "SerialNumber string");
+static char composite_manufacturer[50];
+
/*-------------------------------------------------------------------------*/
/**
@@ -470,18 +474,20 @@ done:
* usb_add_config() - add a configuration to a device.
* @cdev: wraps the USB gadget
* @config: the configuration, with bConfigurationValue assigned
+ * @bind: the configuration's bind function
* Context: single threaded during gadget setup
*
- * One of the main tasks of a composite driver's bind() routine is to
+ * One of the main tasks of a composite @bind() routine is to
* add each of the configurations it supports, using this routine.
*
- * This function returns the value of the configuration's bind(), which
+ * This function returns the value of the configuration's @bind(), which
* is zero for success else a negative errno value. Binding configurations
* assigns global resources including string IDs, and per-configuration
* resources such as interface IDs and endpoints.
*/
int usb_add_config(struct usb_composite_dev *cdev,
- struct usb_configuration *config)
+ struct usb_configuration *config,
+ int (*bind)(struct usb_configuration *))
{
int status = -EINVAL;
struct usb_configuration *c;
@@ -490,7 +496,7 @@ int usb_add_config(struct usb_composite_dev *cdev,
config->bConfigurationValue,
config->label, config);
- if (!config->bConfigurationValue || !config->bind)
+ if (!config->bConfigurationValue || !bind)
goto done;
/* Prevent duplicate configuration identifiers */
@@ -507,7 +513,7 @@ int usb_add_config(struct usb_composite_dev *cdev,
INIT_LIST_HEAD(&config->functions);
config->next_interface_id = 0;
- status = config->bind(config);
+ status = bind(config);
if (status < 0) {
list_del(&config->list);
config->cdev = NULL;
@@ -533,7 +539,7 @@ int usb_add_config(struct usb_composite_dev *cdev,
}
}
- /* set_alt(), or next config->bind(), sets up
+ /* set_alt(), or next bind(), sets up
* ep->driver_data as needed.
*/
usb_ep_autoconfig_reset(cdev->gadget);
@@ -599,6 +605,7 @@ static int get_string(struct usb_composite_dev *cdev,
struct usb_configuration *c;
struct usb_function *f;
int len;
+ const char *str;
/* Yes, not only is USB's I18N support probably more than most
* folk will ever care about ... also, it's all supported here.
@@ -638,9 +645,29 @@ static int get_string(struct usb_composite_dev *cdev,
return s->bLength;
}
- /* Otherwise, look up and return a specified string. String IDs
- * are device-scoped, so we look up each string table we're told
- * about. These lookups are infrequent; simpler-is-better here.
+ /* Otherwise, look up and return a specified string. First
+ * check if the string has not been overridden.
+ */
+ if (cdev->manufacturer_override == id)
+ str = iManufacturer ?: composite->iManufacturer ?:
+ composite_manufacturer;
+ else if (cdev->product_override == id)
+ str = iProduct ?: composite->iProduct;
+ else if (cdev->serial_override == id)
+ str = iSerialNumber;
+ else
+ str = NULL;
+ if (str) {
+ struct usb_gadget_strings strings = {
+ .language = language,
+ .strings = &(struct usb_string) { 0xff, str }
+ };
+ return usb_gadget_get_string(&strings, 0xff, buf);
+ }
+
+ /* String IDs are device-scoped, so we look up each string
+ * table we're told about. These lookups are infrequent;
+ * simpler-is-better here.
*/
if (composite->strings) {
len = lookup_string(composite->strings, buf, language, id);
@@ -901,7 +928,8 @@ unknown:
*/
switch (ctrl->bRequestType & USB_RECIP_MASK) {
case USB_RECIP_INTERFACE:
- f = cdev->config->interface[intf];
+ if (cdev->config)
+ f = cdev->config->interface[intf];
break;
case USB_RECIP_ENDPOINT:
@@ -1025,26 +1053,17 @@ composite_unbind(struct usb_gadget *gadget)
composite = NULL;
}
-static void
-string_override_one(struct usb_gadget_strings *tab, u8 id, const char *s)
+static u8 override_id(struct usb_composite_dev *cdev, u8 *desc)
{
- struct usb_string *str = tab->strings;
-
- for (str = tab->strings; str->s; str++) {
- if (str->id == id) {
- str->s = s;
- return;
- }
+ if (!*desc) {
+ int ret = usb_string_id(cdev);
+ if (unlikely(ret < 0))
+ WARNING(cdev, "failed to override string ID\n");
+ else
+ *desc = ret;
}
-}
-static void
-string_override(struct usb_gadget_strings **tab, u8 id, const char *s)
-{
- while (*tab) {
- string_override_one(*tab, id, s);
- tab++;
- }
+ return *desc;
}
static int composite_bind(struct usb_gadget *gadget)
@@ -1074,7 +1093,13 @@ static int composite_bind(struct usb_gadget *gadget)
cdev->bufsiz = USB_BUFSIZ;
cdev->driver = composite;
- usb_gadget_set_selfpowered(gadget);
+ /*
+ * As per USB compliance update, a device that is actively drawing
+ * more than 100mA from USB must report itself as bus-powered in
+ * the GetStatus(DEVICE) call.
+ */
+ if (CONFIG_USB_GADGET_VBUS_DRAW <= USB_SELF_POWER_VBUS_MAX_DRAW)
+ usb_gadget_set_selfpowered(gadget);
/* interface and string IDs start at zero via kzalloc.
* we force endpoints to start unassigned; few controller
@@ -1094,26 +1119,41 @@ static int composite_bind(struct usb_gadget *gadget)
* serial number), register function drivers, potentially update
* power state and consumption, etc
*/
- status = composite->bind(cdev);
+ status = composite_gadget_bind(cdev);
if (status < 0)
goto fail;
cdev->desc = *composite->dev;
cdev->desc.bMaxPacketSize0 = gadget->ep0->maxpacket;
- /* strings can't be assigned before bind() allocates the
- * releavnt identifiers
- */
- if (cdev->desc.iManufacturer && iManufacturer)
- string_override(composite->strings,
- cdev->desc.iManufacturer, iManufacturer);
- if (cdev->desc.iProduct && iProduct)
- string_override(composite->strings,
- cdev->desc.iProduct, iProduct);
- if (cdev->desc.iSerialNumber && iSerialNumber)
- string_override(composite->strings,
- cdev->desc.iSerialNumber, iSerialNumber);
+ /* stirng overrides */
+ if (iManufacturer || !cdev->desc.iManufacturer) {
+ if (!iManufacturer && !composite->iManufacturer &&
+ !*composite_manufacturer)
+ snprintf(composite_manufacturer,
+ sizeof composite_manufacturer,
+ "%s %s with %s",
+ init_utsname()->sysname,
+ init_utsname()->release,
+ gadget->name);
+
+ cdev->manufacturer_override =
+ override_id(cdev, &cdev->desc.iManufacturer);
+ }
+
+ if (iProduct || (!cdev->desc.iProduct && composite->iProduct))
+ cdev->product_override =
+ override_id(cdev, &cdev->desc.iProduct);
+
+ if (iSerialNumber)
+ cdev->serial_override =
+ override_id(cdev, &cdev->desc.iSerialNumber);
+
+ /* has userspace failed to provide a serial number? */
+ if (composite->needs_serial && !cdev->desc.iSerialNumber)
+ WARNING(cdev, "userspace failed to provide iSerialNumber\n");
+ /* finish up */
status = device_create_file(&gadget->dev, &dev_attr_suspended);
if (status)
goto fail;
@@ -1177,7 +1217,6 @@ composite_resume(struct usb_gadget *gadget)
static struct usb_gadget_driver composite_driver = {
.speed = USB_SPEED_HIGH,
- .bind = composite_bind,
.unbind = composite_unbind,
.setup = composite_setup,
@@ -1192,8 +1231,12 @@ static struct usb_gadget_driver composite_driver = {
};
/**
- * usb_composite_register() - register a composite driver
+ * usb_composite_probe() - register a composite driver
* @driver: the driver to register
+ * @bind: the callback used to allocate resources that are shared across the
+ * whole device, such as string IDs, and add its configurations using
+ * @usb_add_config(). This may fail by returning a negative errno
+ * value; it should return zero on successful initialization.
* Context: single threaded during gadget setup
*
* This function is used to register drivers using the composite driver
@@ -1206,18 +1249,22 @@ static struct usb_gadget_driver composite_driver = {
* while it was binding. That would usually be done in order to wait for
* some userspace participation.
*/
-int usb_composite_register(struct usb_composite_driver *driver)
+extern int usb_composite_probe(struct usb_composite_driver *driver,
+ int (*bind)(struct usb_composite_dev *cdev))
{
- if (!driver || !driver->dev || !driver->bind || composite)
+ if (!driver || !driver->dev || !bind || composite)
return -EINVAL;
+ if (!driver->iProduct)
+ driver->iProduct = driver->name;
if (!driver->name)
driver->name = "composite";
composite_driver.function = (char *) driver->name;
composite_driver.driver.name = driver->name;
composite = driver;
+ composite_gadget_bind = bind;
- return usb_gadget_register_driver(&composite_driver);
+ return usb_gadget_probe_driver(&composite_driver, composite_bind);
}
/**
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,
} else
goto fail;
- if (len >= 0) {
- req->length = min(length, len);
- req->zero = len < req->length;
- if (data && req->length)
- memcpy(req->buf, data, req->length);
-
- req->complete = dbgp_setup_complete;
- return usb_ep_queue(gadget->ep0, req, GFP_ATOMIC);
- }
+ req->length = min(length, len);
+ req->zero = len < req->length;
+ if (data && req->length)
+ memcpy(req->buf, data, req->length);
+
+ req->complete = dbgp_setup_complete;
+ return usb_ep_queue(gadget->ep0, req, GFP_ATOMIC);
fail:
dev_dbg(&dbgp.gadget->dev,
@@ -405,7 +403,6 @@ fail:
static struct usb_gadget_driver dbgp_driver = {
.function = "dbgp",
.speed = USB_SPEED_HIGH,
- .bind = dbgp_bind,
.unbind = dbgp_unbind,
.setup = dbgp_setup,
.disconnect = dbgp_disconnect,
@@ -417,7 +414,7 @@ static struct usb_gadget_driver dbgp_driver = {
static int __init dbgp_init(void)
{
- return usb_gadget_register_driver(&dbgp_driver);
+ return usb_gadget_probe_driver(&dbgp_driver, dbgp_bind);
}
static 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);
*/
int
-usb_gadget_register_driver (struct usb_gadget_driver *driver)
+usb_gadget_probe_driver(struct usb_gadget_driver *driver,
+ int (*bind)(struct usb_gadget *))
{
struct dummy *dum = the_controller;
int retval, i;
@@ -757,8 +758,7 @@ usb_gadget_register_driver (struct usb_gadget_driver *driver)
return -EINVAL;
if (dum->driver)
return -EBUSY;
- if (!driver->bind || !driver->setup
- || driver->speed == USB_SPEED_UNKNOWN)
+ if (!bind || !driver->setup || driver->speed == USB_SPEED_UNKNOWN)
return -EINVAL;
/*
@@ -796,7 +796,7 @@ usb_gadget_register_driver (struct usb_gadget_driver *driver)
dum->gadget.dev.driver = &driver->driver;
dev_dbg (udc_dev(dum), "binding gadget driver '%s'\n",
driver->driver.name);
- retval = driver->bind(&dum->gadget);
+ retval = bind(&dum->gadget);
if (retval) {
dum->driver = NULL;
dum->gadget.dev.driver = NULL;
@@ -812,7 +812,7 @@ usb_gadget_register_driver (struct usb_gadget_driver *driver)
usb_hcd_poll_rh_status (dummy_to_hcd (dum));
return 0;
}
-EXPORT_SYMBOL (usb_gadget_register_driver);
+EXPORT_SYMBOL(usb_gadget_probe_driver);
int
usb_gadget_unregister_driver (struct usb_gadget_driver *driver)
@@ -874,6 +874,8 @@ static int dummy_udc_probe (struct platform_device *pdev)
struct dummy *dum = the_controller;
int rc;
+ usb_get_hcd(dummy_to_hcd(dum));
+
dum->gadget.name = gadget_name;
dum->gadget.ops = &dummy_ops;
dum->gadget.is_dualspeed = 1;
@@ -885,10 +887,10 @@ static int dummy_udc_probe (struct platform_device *pdev)
dum->gadget.dev.parent = &pdev->dev;
dum->gadget.dev.release = dummy_gadget_release;
rc = device_register (&dum->gadget.dev);
- if (rc < 0)
+ if (rc < 0) {
+ put_device(&dum->gadget.dev);
return rc;
-
- usb_get_hcd (dummy_to_hcd (dum));
+ }
platform_set_drvdata (pdev, dum);
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];
* the first one present. That's to make Microsoft's drivers happy,
* and to follow DOCSIS 1.0 (cable modem standard).
*/
-static int __ref rndis_do_config(struct usb_configuration *c)
+static int __init rndis_do_config(struct usb_configuration *c)
{
/* FIXME alloc iConfiguration string, set it in c->strings */
@@ -251,7 +251,6 @@ static int __ref rndis_do_config(struct usb_configuration *c)
static struct usb_configuration rndis_config_driver = {
.label = "RNDIS",
- .bind = rndis_do_config,
.bConfigurationValue = 2,
/* .iConfiguration = DYNAMIC */
.bmAttributes = USB_CONFIG_ATT_SELFPOWER,
@@ -270,7 +269,7 @@ MODULE_PARM_DESC(use_eem, "use CDC EEM mode");
/*
* We _always_ have an ECM, CDC Subset, or EEM configuration.
*/
-static int __ref eth_do_config(struct usb_configuration *c)
+static int __init eth_do_config(struct usb_configuration *c)
{
/* FIXME alloc iConfiguration string, set it in c->strings */
@@ -289,7 +288,6 @@ static int __ref eth_do_config(struct usb_configuration *c)
static struct usb_configuration eth_config_driver = {
/* .label = f(hardware) */
- .bind = eth_do_config,
.bConfigurationValue = 1,
/* .iConfiguration = DYNAMIC */
.bmAttributes = USB_CONFIG_ATT_SELFPOWER,
@@ -297,7 +295,7 @@ static struct usb_configuration eth_config_driver = {
/*-------------------------------------------------------------------------*/
-static int __ref eth_bind(struct usb_composite_dev *cdev)
+static int __init eth_bind(struct usb_composite_dev *cdev)
{
int gcnum;
struct usb_gadget *gadget = cdev->gadget;
@@ -373,12 +371,13 @@ static int __ref eth_bind(struct usb_composite_dev *cdev)
/* register our configuration(s); RNDIS first, if it's used */
if (has_rndis()) {
- status = usb_add_config(cdev, &rndis_config_driver);
+ status = usb_add_config(cdev, &rndis_config_driver,
+ rndis_do_config);
if (status < 0)
goto fail;
}
- status = usb_add_config(cdev, &eth_config_driver);
+ status = usb_add_config(cdev, &eth_config_driver, eth_do_config);
if (status < 0)
goto fail;
@@ -402,7 +401,6 @@ static struct usb_composite_driver eth_driver = {
.name = "g_ether",
.dev = &device_desc,
.strings = dev_strings,
- .bind = eth_bind,
.unbind = __exit_p(eth_unbind),
};
@@ -412,7 +410,7 @@ MODULE_LICENSE("GPL");
static int __init init(void)
{
- return usb_composite_register(&eth_driver);
+ return usb_composite_probe(&eth_driver, eth_bind);
}
module_init(init);
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 = {
.bInterfaceCount = 2, // control + data
.bFunctionClass = USB_CLASS_COMM,
.bFunctionSubClass = USB_CDC_SUBCLASS_ACM,
- .bFunctionProtocol = USB_CDC_PROTO_NONE,
+ .bFunctionProtocol = USB_CDC_ACM_PROTO_AT_V25TER,
/* .iFunction = DYNAMIC */
};
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)
/*-------------------------------------------------------------------------*/
-static int __ref loopback_bind_config(struct usb_configuration *c)
+static int __init loopback_bind_config(struct usb_configuration *c)
{
struct f_loopback *loop;
int status;
@@ -346,10 +346,9 @@ static int __ref loopback_bind_config(struct usb_configuration *c)
return status;
}
-static struct usb_configuration loopback_driver = {
+static struct usb_configuration loopback_driver = {
.label = "loopback",
.strings = loopback_strings,
- .bind = loopback_bind_config,
.bConfigurationValue = 2,
.bmAttributes = USB_CONFIG_ATT_SELFPOWER,
/* .iConfiguration = DYNAMIC */
@@ -382,5 +381,5 @@ int __init loopback_add(struct usb_composite_dev *cdev, bool autoresume)
loopback_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
}
- return usb_add_config(cdev, &loopback_driver);
+ return usb_add_config(cdev, &loopback_driver, loopback_bind_config);
}
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 @@
* being removable.
* ->cdrom Flag specifying that LUN shall be reported as
* being a CD-ROM.
+ * ->nofua Flag specifying that FUA flag in SCSI WRITE(10,12)
+ * commands for this LUN shall be ignored.
*
* lun_name_format A printf-like format for names of the LUN
* devices. This determines how the
@@ -127,6 +129,8 @@
* Default true, boolean for removable media.
* cdrom=b[,b...] Default false, boolean for whether to emulate
* a CD-ROM drive.
+ * nofua=b[,b...] Default false, booleans for ignore FUA flag
+ * in SCSI WRITE(10,12) commands
* luns=N Default N = number of filenames, number of
* LUNs to support.
* stall Default determined according to the type of
@@ -409,6 +413,7 @@ struct fsg_config {
char ro;
char removable;
char cdrom;
+ char nofua;
} luns[FSG_MAX_LUNS];
const char *lun_name_format;
@@ -736,7 +741,7 @@ static int do_read(struct fsg_common *common)
/* Get the starting Logical Block Address and check that it's
* not too big */
- if (common->cmnd[0] == SC_READ_6)
+ if (common->cmnd[0] == READ_6)
lba = get_unaligned_be24(&common->cmnd[1]);
else {
lba = get_unaligned_be32(&common->cmnd[2]);
@@ -874,7 +879,7 @@ static int do_write(struct fsg_common *common)
/* Get the starting Logical Block Address and check that it's
* not too big */
- if (common->cmnd[0] == SC_WRITE_6)
+ if (common->cmnd[0] == WRITE_6)
lba = get_unaligned_be24(&common->cmnd[1]);
else {
lba = get_unaligned_be32(&common->cmnd[2]);
@@ -887,7 +892,7 @@ static int do_write(struct fsg_common *common)
curlun->sense_data = SS_INVALID_FIELD_IN_CDB;
return -EINVAL;
}
- if (common->cmnd[1] & 0x08) { /* FUA */
+ if (!curlun->nofua && (common->cmnd[1] & 0x08)) { /* FUA */
spin_lock(&curlun->filp->f_lock);
curlun->filp->f_flags |= O_SYNC;
spin_unlock(&curlun->filp->f_lock);
@@ -1181,7 +1186,7 @@ static int do_inquiry(struct fsg_common *common, struct fsg_buffhd *bh)
return 36;
}
- buf[0] = curlun->cdrom ? TYPE_CDROM : TYPE_DISK;
+ buf[0] = curlun->cdrom ? TYPE_ROM : TYPE_DISK;
buf[1] = curlun->removable ? 0x80 : 0;
buf[2] = 2; /* ANSI SCSI level 2 */
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)
* The only variable value is the WriteProtect bit. We will fill in
* the mode data length later. */
memset(buf, 0, 8);
- if (mscmnd == SC_MODE_SENSE_6) {
+ if (mscmnd == MODE_SENSE) {
buf[2] = (curlun->ro ? 0x80 : 0x00); /* WP, DPOFUA */
buf += 4;
limit = 255;
- } else { /* SC_MODE_SENSE_10 */
+ } else { /* MODE_SENSE_10 */
buf[3] = (curlun->ro ? 0x80 : 0x00); /* WP, DPOFUA */
buf += 8;
limit = 65535; /* Should really be FSG_BUFLEN */
@@ -1392,7 +1397,7 @@ static int do_mode_sense(struct fsg_common *common, struct fsg_buffhd *bh)
}
/* Store the mode data length */
- if (mscmnd == SC_MODE_SENSE_6)
+ if (mscmnd == MODE_SENSE)
buf0[0] = len - 1;
else
put_unaligned_be16(len - 2, buf0);
@@ -1881,7 +1886,7 @@ static int check_command(struct fsg_common *common, int cmnd_size,
if (common->lun >= 0 && common->lun < common->nluns) {
curlun = &common->luns[common->lun];
common->curlun = curlun;
- if (common->cmnd[0] != SC_REQUEST_SENSE) {
+ if (common->cmnd[0] != REQUEST_SENSE) {
curlun->sense_data = SS_NO_SENSE;
curlun->sense_data_info = 0;
curlun->info_valid = 0;
@@ -1893,8 +1898,8 @@ static int check_command(struct fsg_common *common, int cmnd_size,
/* INQUIRY and REQUEST SENSE commands are explicitly allowed
* to use unsupported LUNs; all others may not. */
- if (common->cmnd[0] != SC_INQUIRY &&
- common->cmnd[0] != SC_REQUEST_SENSE) {
+ if (common->cmnd[0] != INQUIRY &&
+ common->cmnd[0] != REQUEST_SENSE) {
DBG(common, "unsupported LUN %d\n", common->lun);
return -EINVAL;
}
@@ -1903,8 +1908,8 @@ static int check_command(struct fsg_common *common, int cmnd_size,
/* If a unit attention condition exists, only INQUIRY and
* REQUEST SENSE commands are allowed; anything else must fail. */
if (curlun && curlun->unit_attention_data != SS_NO_SENSE &&
- common->cmnd[0] != SC_INQUIRY &&
- common->cmnd[0] != SC_REQUEST_SENSE) {
+ common->cmnd[0] != INQUIRY &&
+ common->cmnd[0] != REQUEST_SENSE) {
curlun->sense_data = curlun->unit_attention_data;
curlun->unit_attention_data = SS_NO_SENSE;
return -EINVAL;
@@ -1955,7 +1960,7 @@ static int do_scsi_command(struct fsg_common *common)
down_read(&common->filesem); /* We're using the backing file */
switch (common->cmnd[0]) {
- case SC_INQUIRY:
+ case INQUIRY:
common->data_size_from_cmnd = common->cmnd[4];
reply = check_command(common, 6, DATA_DIR_TO_HOST,
(1<<4), 0,
@@ -1964,7 +1969,7 @@ static int do_scsi_command(struct fsg_common *common)
reply = do_inquiry(common, bh);
break;
- case SC_MODE_SELECT_6:
+ case MODE_SELECT:
common->data_size_from_cmnd = common->cmnd[4];
reply = check_command(common, 6, DATA_DIR_FROM_HOST,
(1<<1) | (1<<4), 0,
@@ -1973,7 +1978,7 @@ static int do_scsi_command(struct fsg_common *common)
reply = do_mode_select(common, bh);
break;
- case SC_MODE_SELECT_10:
+ case MODE_SELECT_10:
common->data_size_from_cmnd =
get_unaligned_be16(&common->cmnd[7]);
reply = check_command(common, 10, DATA_DIR_FROM_HOST,
@@ -1983,7 +1988,7 @@ static int do_scsi_command(struct fsg_common *common)
reply = do_mode_select(common, bh);
break;
- case SC_MODE_SENSE_6:
+ case MODE_SENSE:
common->data_size_from_cmnd = common->cmnd[4];
reply = check_command(common, 6, DATA_DIR_TO_HOST,
(1<<1) | (1<<2) | (1<<4), 0,
@@ -1992,7 +1997,7 @@ static int do_scsi_command(struct fsg_common *common)
reply = do_mode_sense(common, bh);
break;
- case SC_MODE_SENSE_10:
+ case MODE_SENSE_10:
common->data_size_from_cmnd =
get_unaligned_be16(&common->cmnd[7]);
reply = check_command(common, 10, DATA_DIR_TO_HOST,
@@ -2002,7 +2007,7 @@ static int do_scsi_command(struct fsg_common *common)
reply = do_mode_sense(common, bh);
break;
- case SC_PREVENT_ALLOW_MEDIUM_REMOVAL:
+ case ALLOW_MEDIUM_REMOVAL:
common->data_size_from_cmnd = 0;
reply = check_command(common, 6, DATA_DIR_NONE,
(1<<4), 0,
@@ -2011,7 +2016,7 @@ static int do_scsi_command(struct fsg_common *common)
reply = do_prevent_allow(common);
break;
- case SC_READ_6:
+ case READ_6:
i = common->cmnd[4];
common->data_size_from_cmnd = (i == 0 ? 256 : i) << 9;
reply = check_command(common, 6, DATA_DIR_TO_HOST,
@@ -2021,7 +2026,7 @@ static int do_scsi_command(struct fsg_common *common)
reply = do_read(common);
break;
- case SC_READ_10:
+ case READ_10:
common->data_size_from_cmnd =
get_unaligned_be16(&common->cmnd[7]) << 9;
reply = check_command(common, 10, DATA_DIR_TO_HOST,
@@ -2031,7 +2036,7 @@ static int do_scsi_command(struct fsg_common *common)
reply = do_read(common);
break;
- case SC_READ_12:
+ case READ_12:
common->data_size_from_cmnd =
get_unaligned_be32(&common->cmnd[6]) << 9;
reply = check_command(common, 12, DATA_DIR_TO_HOST,
@@ -2041,7 +2046,7 @@ static int do_scsi_command(struct fsg_common *common)
reply = do_read(common);
break;
- case SC_READ_CAPACITY:
+ case READ_CAPACITY:
common->data_size_from_cmnd = 8;
reply = check_command(common, 10, DATA_DIR_TO_HOST,
(0xf<<2) | (1<<8), 1,
@@ -2050,7 +2055,7 @@ static int do_scsi_command(struct fsg_common *common)
reply = do_read_capacity(common, bh);
break;
- case SC_READ_HEADER:
+ case READ_HEADER:
if (!common->curlun || !common->curlun->cdrom)
goto unknown_cmnd;
common->data_size_from_cmnd =
@@ -2062,7 +2067,7 @@ static int do_scsi_command(struct fsg_common *common)
reply = do_read_header(common, bh);
break;
- case SC_READ_TOC:
+ case READ_TOC:
if (!common->curlun || !common->curlun->cdrom)
goto unknown_cmnd;
common->data_size_from_cmnd =
@@ -2074,7 +2079,7 @@ static int do_scsi_command(struct fsg_common *common)
reply = do_read_toc(common, bh);
break;
- case SC_READ_FORMAT_CAPACITIES:
+ case READ_FORMAT_CAPACITIES:
common->data_size_from_cmnd =
get_unaligned_be16(&common->cmnd[7]);
reply = check_command(common, 10, DATA_DIR_TO_HOST,
@@ -2084,7 +2089,7 @@ static int do_scsi_command(struct fsg_common *common)
reply = do_read_format_capacities(common, bh);
break;
- case SC_REQUEST_SENSE:
+ case REQUEST_SENSE:
common->data_size_from_cmnd = common->cmnd[4];
reply = check_command(common, 6, DATA_DIR_TO_HOST,
(1<<4), 0,
@@ -2093,7 +2098,7 @@ static int do_scsi_command(struct fsg_common *common)
reply = do_request_sense(common, bh);
break;
- case SC_START_STOP_UNIT:
+ case START_STOP:
common->data_size_from_cmnd = 0;
reply = check_command(common, 6, DATA_DIR_NONE,
(1<<1) | (1<<4), 0,
@@ -2102,7 +2107,7 @@ static int do_scsi_command(struct fsg_common *common)
reply = do_start_stop(common);
break;
- case SC_SYNCHRONIZE_CACHE:
+ case SYNCHRONIZE_CACHE:
common->data_size_from_cmnd = 0;
reply = check_command(common, 10, DATA_DIR_NONE,
(0xf<<2) | (3<<7), 1,
@@ -2111,7 +2116,7 @@ static int do_scsi_command(struct fsg_common *common)
reply = do_synchronize_cache(common);
break;
- case SC_TEST_UNIT_READY:
+ case TEST_UNIT_READY:
common->data_size_from_cmnd = 0;
reply = check_command(common, 6, DATA_DIR_NONE,
0, 1,
@@ -2120,7 +2125,7 @@ static int do_scsi_command(struct fsg_common *common)
/* Although optional, this command is used by MS-Windows. We
* support a minimal version: BytChk must be 0. */
- case SC_VERIFY:
+ case VERIFY:
common->data_size_from_cmnd = 0;
reply = check_command(common, 10, DATA_DIR_NONE,
(1<<1) | (0xf<<2) | (3<<7), 1,
@@ -2129,7 +2134,7 @@ static int do_scsi_command(struct fsg_common *common)
reply = do_verify(common);
break;
- case SC_WRITE_6:
+ case WRITE_6:
i = common->cmnd[4];
common->data_size_from_cmnd = (i == 0 ? 256 : i) << 9;
reply = check_command(common, 6, DATA_DIR_FROM_HOST,
@@ -2139,7 +2144,7 @@ static int do_scsi_command(struct fsg_common *common)
reply = do_write(common);
break;
- case SC_WRITE_10:
+ case WRITE_10:
common->data_size_from_cmnd =
get_unaligned_be16(&common->cmnd[7]) << 9;
reply = check_command(common, 10, DATA_DIR_FROM_HOST,
@@ -2149,7 +2154,7 @@ static int do_scsi_command(struct fsg_common *common)
reply = do_write(common);
break;
- case SC_WRITE_12:
+ case WRITE_12:
common->data_size_from_cmnd =
get_unaligned_be32(&common->cmnd[6]) << 9;
reply = check_command(common, 12, DATA_DIR_FROM_HOST,
@@ -2163,10 +2168,10 @@ static int do_scsi_command(struct fsg_common *common)
* They don't mean much in this setting. It's left as an exercise
* for anyone interested to implement RESERVE and RELEASE in terms
* of Posix locks. */
- case SC_FORMAT_UNIT:
- case SC_RELEASE:
- case SC_RESERVE:
- case SC_SEND_DIAGNOSTIC:
+ case FORMAT_UNIT:
+ case RELEASE:
+ case RESERVE:
+ case SEND_DIAGNOSTIC:
/* Fall through */
default:
@@ -2662,6 +2667,7 @@ static int fsg_main_thread(void *common_)
/* Write permission is checked per LUN in store_*() functions. */
static DEVICE_ATTR(ro, 0644, fsg_show_ro, fsg_store_ro);
+static DEVICE_ATTR(nofua, 0644, fsg_show_nofua, fsg_store_nofua);
static DEVICE_ATTR(file, 0644, fsg_show_file, fsg_store_file);
@@ -2768,6 +2774,9 @@ static struct fsg_common *fsg_common_init(struct fsg_common *common,
rc = device_create_file(&curlun->dev, &dev_attr_file);
if (rc)
goto error_luns;
+ rc = device_create_file(&curlun->dev, &dev_attr_nofua);
+ if (rc)
+ goto error_luns;
if (lcfg->filename) {
rc = fsg_lun_open(curlun, lcfg->filename);
@@ -2911,6 +2920,7 @@ static void fsg_common_release(struct kref *ref)
/* In error recovery common->nluns may be zero. */
for (; i; --i, ++lun) {
+ device_remove_file(&lun->dev, &dev_attr_nofua);
device_remove_file(&lun->dev, &dev_attr_ro);
device_remove_file(&lun->dev, &dev_attr_file);
fsg_lun_close(lun);
@@ -3069,8 +3079,10 @@ struct fsg_module_parameters {
int ro[FSG_MAX_LUNS];
int removable[FSG_MAX_LUNS];
int cdrom[FSG_MAX_LUNS];
+ int nofua[FSG_MAX_LUNS];
unsigned int file_count, ro_count, removable_count, cdrom_count;
+ unsigned int nofua_count;
unsigned int luns; /* nluns */
int stall; /* can_stall */
};
@@ -3096,6 +3108,8 @@ struct fsg_module_parameters {
"true to simulate removable media"); \
_FSG_MODULE_PARAM_ARRAY(prefix, params, cdrom, bool, \
"true to simulate CD-ROM instead of disk"); \
+ _FSG_MODULE_PARAM_ARRAY(prefix, params, nofua, bool, \
+ "true to ignore SCSI WRITE(10,12) FUA bit"); \
_FSG_MODULE_PARAM(prefix, params, luns, uint, \
"number of LUNs"); \
_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)
/*-------------------------------------------------------------------------*/
-static int __ref sourcesink_bind_config(struct usb_configuration *c)
+static int __init sourcesink_bind_config(struct usb_configuration *c)
{
struct f_sourcesink *ss;
int status;
@@ -498,7 +498,6 @@ unknown:
static struct usb_configuration sourcesink_driver = {
.label = "source/sink",
.strings = sourcesink_strings,
- .bind = sourcesink_bind_config,
.setup = sourcesink_setup,
.bConfigurationValue = 3,
.bmAttributes = USB_CONFIG_ATT_SELFPOWER,
@@ -532,5 +531,5 @@ int __init sourcesink_add(struct usb_composite_dev *cdev, bool autoresume)
sourcesink_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
}
- return usb_add_config(cdev, &sourcesink_driver);
+ return usb_add_config(cdev, &sourcesink_driver, sourcesink_bind_config);
}
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 @@
* Required if "removable" is not set, names of
* the files or block devices used for
* backing storage
+ * serial=HHHH... Required serial number (string of hex chars)
* ro=b[,b...] Default false, booleans for read-only access
* removable Default false, boolean for removable media
* luns=N Default N = number of filenames, number of
@@ -108,12 +109,11 @@
* vendor=0xVVVV Default 0x0525 (NetChip), USB Vendor ID
* product=0xPPPP Default 0xa4a5 (FSG), USB Product ID
* release=0xRRRR Override the USB release number (bcdDevice)
- * serial=HHHH... Override serial number (string of hex chars)
* buflen=N Default N=16384, buffer size used (will be
* rounded down to a multiple of
* PAGE_CACHE_SIZE)
*
- * If CONFIG_USB_FILE_STORAGE_TEST is not set, only the "file", "ro",
+ * If CONFIG_USB_FILE_STORAGE_TEST is not set, only the "file", "serial", "ro",
* "removable", "luns", "nofua", "stall", and "cdrom" options are available;
* default values are used for everything else.
*
@@ -273,13 +273,10 @@
#define DRIVER_DESC "File-backed Storage Gadget"
#define DRIVER_NAME "g_file_storage"
-/* DRIVER_VERSION must be at least 6 characters long, as it is used
- * to generate a fallback serial number. */
-#define DRIVER_VERSION "20 November 2008"
+#define DRIVER_VERSION "1 September 2010"
static char fsg_string_manufacturer[64];
static const char fsg_string_product[] = DRIVER_DESC;
-static char fsg_string_serial[13];
static const char fsg_string_config[] = "Self-powered";
static const char fsg_string_interface[] = "Mass Storage";
@@ -305,6 +302,7 @@ MODULE_LICENSE("Dual BSD/GPL");
static struct {
char *file[FSG_MAX_LUNS];
+ char *serial;
int ro[FSG_MAX_LUNS];
int nofua[FSG_MAX_LUNS];
unsigned int num_filenames;
@@ -321,7 +319,6 @@ static struct {
unsigned short vendor;
unsigned short product;
unsigned short release;
- char *serial;
unsigned int buflen;
int transport_type;
@@ -346,6 +343,9 @@ module_param_array_named(file, mod_data.file, charp, &mod_data.num_filenames,
S_IRUGO);
MODULE_PARM_DESC(file, "names of backing files or devices");
+module_param_named(serial, mod_data.serial, charp, S_IRUGO);
+MODULE_PARM_DESC(serial, "USB serial number");
+
module_param_array_named(ro, mod_data.ro, bool, &mod_data.num_ros, S_IRUGO);
MODULE_PARM_DESC(ro, "true to force read-only");
@@ -365,9 +365,6 @@ MODULE_PARM_DESC(stall, "false to prevent bulk stalls");
module_param_named(cdrom, mod_data.cdrom, bool, S_IRUGO);
MODULE_PARM_DESC(cdrom, "true to emulate cdrom instead of disk");
-module_param_named(serial, mod_data.serial, charp, S_IRUGO);
-MODULE_PARM_DESC(serial, "USB serial number");
-
/* In the non-TEST version, only the module parameters listed above
* are available. */
#ifdef CONFIG_USB_FILE_STORAGE_TEST
@@ -786,7 +783,7 @@ static void received_cbi_adsc(struct fsg_dev *fsg, struct fsg_buffhd *bh)
{
struct usb_request *req = fsg->ep0req;
static u8 cbi_reset_cmnd[6] = {
- SC_SEND_DIAGNOSTIC, 4, 0xff, 0xff, 0xff, 0xff};
+ SEND_DIAGNOSTIC, 4, 0xff, 0xff, 0xff, 0xff};
/* Error in command transfer? */
if (req->status || req->length != req->actual ||
@@ -1138,7 +1135,7 @@ static int do_read(struct fsg_dev *fsg)
/* Get the starting Logical Block Address and check that it's
* not too big */
- if (fsg->cmnd[0] == SC_READ_6)
+ if (fsg->cmnd[0] == READ_6)
lba = get_unaligned_be24(&fsg->cmnd[1]);
else {
lba = get_unaligned_be32(&fsg->cmnd[2]);
@@ -1273,7 +1270,7 @@ static int do_write(struct fsg_dev *fsg)
/* Get the starting Logical Block Address and check that it's
* not too big */
- if (fsg->cmnd[0] == SC_WRITE_6)
+ if (fsg->cmnd[0] == WRITE_6)
lba = get_unaligned_be24(&fsg->cmnd[1]);
else {
lba = get_unaligned_be32(&fsg->cmnd[2]);
@@ -1581,7 +1578,7 @@ static int do_inquiry(struct fsg_dev *fsg, struct fsg_buffhd *bh)
}
memset(buf, 0, 8);
- buf[0] = (mod_data.cdrom ? TYPE_CDROM : TYPE_DISK);
+ buf[0] = (mod_data.cdrom ? TYPE_ROM : TYPE_DISK);
if (mod_data.removable)
buf[1] = 0x80;
buf[2] = 2; // ANSI SCSI level 2
@@ -1750,11 +1747,11 @@ static int do_mode_sense(struct fsg_dev *fsg, struct fsg_buffhd *bh)
* The only variable value is the WriteProtect bit. We will fill in
* the mode data length later. */
memset(buf, 0, 8);
- if (mscmnd == SC_MODE_SENSE_6) {
+ if (mscmnd == MODE_SENSE) {
buf[2] = (curlun->ro ? 0x80 : 0x00); // WP, DPOFUA
buf += 4;
limit = 255;
- } else { // SC_MODE_SENSE_10
+ } else { // MODE_SENSE_10
buf[3] = (curlun->ro ? 0x80 : 0x00); // WP, DPOFUA
buf += 8;
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)
}
/* Store the mode data length */
- if (mscmnd == SC_MODE_SENSE_6)
+ if (mscmnd == MODE_SENSE)
buf0[0] = len - 1;
else
put_unaligned_be16(len - 2, buf0);
@@ -2319,7 +2316,7 @@ static int check_command(struct fsg_dev *fsg, int cmnd_size,
/* Check the LUN */
if (fsg->lun >= 0 && fsg->lun < fsg->nluns) {
fsg->curlun = curlun = &fsg->luns[fsg->lun];
- if (fsg->cmnd[0] != SC_REQUEST_SENSE) {
+ if (fsg->cmnd[0] != REQUEST_SENSE) {
curlun->sense_data = SS_NO_SENSE;
curlun->sense_data_info = 0;
curlun->info_valid = 0;
@@ -2330,8 +2327,8 @@ static int check_command(struct fsg_dev *fsg, int cmnd_size,
/* INQUIRY and REQUEST SENSE commands are explicitly allowed
* to use unsupported LUNs; all others may not. */
- if (fsg->cmnd[0] != SC_INQUIRY &&
- fsg->cmnd[0] != SC_REQUEST_SENSE) {
+ if (fsg->cmnd[0] != INQUIRY &&
+ fsg->cmnd[0] != REQUEST_SENSE) {
DBG(fsg, "unsupported LUN %d\n", fsg->lun);
return -EINVAL;
}
@@ -2340,8 +2337,8 @@ static int check_command(struct fsg_dev *fsg, int cmnd_size,
/* If a unit attention condition exists, only INQUIRY and
* REQUEST SENSE commands are allowed; anything else must fail. */
if (curlun && curlun->unit_attention_data != SS_NO_SENSE &&
- fsg->cmnd[0] != SC_INQUIRY &&
- fsg->cmnd[0] != SC_REQUEST_SENSE) {
+ fsg->cmnd[0] != INQUIRY &&
+ fsg->cmnd[0] != REQUEST_SENSE) {
curlun->sense_data = curlun->unit_attention_data;
curlun->unit_attention_data = SS_NO_SENSE;
return -EINVAL;
@@ -2391,7 +2388,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
down_read(&fsg->filesem); // We're using the backing file
switch (fsg->cmnd[0]) {
- case SC_INQUIRY:
+ case INQUIRY:
fsg->data_size_from_cmnd = fsg->cmnd[4];
if ((reply = check_command(fsg, 6, DATA_DIR_TO_HOST,
(1<<4), 0,
@@ -2399,7 +2396,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
reply = do_inquiry(fsg, bh);
break;
- case SC_MODE_SELECT_6:
+ case MODE_SELECT:
fsg->data_size_from_cmnd = fsg->cmnd[4];
if ((reply = check_command(fsg, 6, DATA_DIR_FROM_HOST,
(1<<1) | (1<<4), 0,
@@ -2407,7 +2404,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
reply = do_mode_select(fsg, bh);
break;
- case SC_MODE_SELECT_10:
+ case MODE_SELECT_10:
fsg->data_size_from_cmnd = get_unaligned_be16(&fsg->cmnd[7]);
if ((reply = check_command(fsg, 10, DATA_DIR_FROM_HOST,
(1<<1) | (3<<7), 0,
@@ -2415,7 +2412,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
reply = do_mode_select(fsg, bh);
break;
- case SC_MODE_SENSE_6:
+ case MODE_SENSE:
fsg->data_size_from_cmnd = fsg->cmnd[4];
if ((reply = check_command(fsg, 6, DATA_DIR_TO_HOST,
(1<<1) | (1<<2) | (1<<4), 0,
@@ -2423,7 +2420,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
reply = do_mode_sense(fsg, bh);
break;
- case SC_MODE_SENSE_10:
+ case MODE_SENSE_10:
fsg->data_size_from_cmnd = get_unaligned_be16(&fsg->cmnd[7]);
if ((reply = check_command(fsg, 10, DATA_DIR_TO_HOST,
(1<<1) | (1<<2) | (3<<7), 0,
@@ -2431,7 +2428,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
reply = do_mode_sense(fsg, bh);
break;
- case SC_PREVENT_ALLOW_MEDIUM_REMOVAL:
+ case ALLOW_MEDIUM_REMOVAL:
fsg->data_size_from_cmnd = 0;
if ((reply = check_command(fsg, 6, DATA_DIR_NONE,
(1<<4), 0,
@@ -2439,7 +2436,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
reply = do_prevent_allow(fsg);
break;
- case SC_READ_6:
+ case READ_6:
i = fsg->cmnd[4];
fsg->data_size_from_cmnd = (i == 0 ? 256 : i) << 9;
if ((reply = check_command(fsg, 6, DATA_DIR_TO_HOST,
@@ -2448,7 +2445,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
reply = do_read(fsg);
break;
- case SC_READ_10:
+ case READ_10:
fsg->data_size_from_cmnd =
get_unaligned_be16(&fsg->cmnd[7]) << 9;
if ((reply = check_command(fsg, 10, DATA_DIR_TO_HOST,
@@ -2457,7 +2454,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
reply = do_read(fsg);
break;
- case SC_READ_12:
+ case READ_12:
fsg->data_size_from_cmnd =
get_unaligned_be32(&fsg->cmnd[6]) << 9;
if ((reply = check_command(fsg, 12, DATA_DIR_TO_HOST,
@@ -2466,7 +2463,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
reply = do_read(fsg);
break;
- case SC_READ_CAPACITY:
+ case READ_CAPACITY:
fsg->data_size_from_cmnd = 8;
if ((reply = check_command(fsg, 10, DATA_DIR_TO_HOST,
(0xf<<2) | (1<<8), 1,
@@ -2474,7 +2471,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
reply = do_read_capacity(fsg, bh);
break;
- case SC_READ_HEADER:
+ case READ_HEADER:
if (!mod_data.cdrom)
goto unknown_cmnd;
fsg->data_size_from_cmnd = get_unaligned_be16(&fsg->cmnd[7]);
@@ -2484,7 +2481,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
reply = do_read_header(fsg, bh);
break;
- case SC_READ_TOC:
+ case READ_TOC:
if (!mod_data.cdrom)
goto unknown_cmnd;
fsg->data_size_from_cmnd = get_unaligned_be16(&fsg->cmnd[7]);
@@ -2494,7 +2491,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
reply = do_read_toc(fsg, bh);
break;
- case SC_READ_FORMAT_CAPACITIES:
+ case READ_FORMAT_CAPACITIES:
fsg->data_size_from_cmnd = get_unaligned_be16(&fsg->cmnd[7]);
if ((reply = check_command(fsg, 10, DATA_DIR_TO_HOST,
(3<<7), 1,
@@ -2502,7 +2499,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
reply = do_read_format_capacities(fsg, bh);
break;
- case SC_REQUEST_SENSE:
+ case REQUEST_SENSE:
fsg->data_size_from_cmnd = fsg->cmnd[4];
if ((reply = check_command(fsg, 6, DATA_DIR_TO_HOST,
(1<<4), 0,
@@ -2510,7 +2507,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
reply = do_request_sense(fsg, bh);
break;
- case SC_START_STOP_UNIT:
+ case START_STOP:
fsg->data_size_from_cmnd = 0;
if ((reply = check_command(fsg, 6, DATA_DIR_NONE,
(1<<1) | (1<<4), 0,
@@ -2518,7 +2515,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
reply = do_start_stop(fsg);
break;
- case SC_SYNCHRONIZE_CACHE:
+ case SYNCHRONIZE_CACHE:
fsg->data_size_from_cmnd = 0;
if ((reply = check_command(fsg, 10, DATA_DIR_NONE,
(0xf<<2) | (3<<7), 1,
@@ -2526,7 +2523,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
reply = do_synchronize_cache(fsg);
break;
- case SC_TEST_UNIT_READY:
+ case TEST_UNIT_READY:
fsg->data_size_from_cmnd = 0;
reply = check_command(fsg, 6, DATA_DIR_NONE,
0, 1,
@@ -2535,7 +2532,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
/* Although optional, this command is used by MS-Windows. We
* support a minimal version: BytChk must be 0. */
- case SC_VERIFY:
+ case VERIFY:
fsg->data_size_from_cmnd = 0;
if ((reply = check_command(fsg, 10, DATA_DIR_NONE,
(1<<1) | (0xf<<2) | (3<<7), 1,
@@ -2543,7 +2540,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
reply = do_verify(fsg);
break;
- case SC_WRITE_6:
+ case WRITE_6:
i = fsg->cmnd[4];
fsg->data_size_from_cmnd = (i == 0 ? 256 : i) << 9;
if ((reply = check_command(fsg, 6, DATA_DIR_FROM_HOST,
@@ -2552,7 +2549,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
reply = do_write(fsg);
break;
- case SC_WRITE_10:
+ case WRITE_10:
fsg->data_size_from_cmnd =
get_unaligned_be16(&fsg->cmnd[7]) << 9;
if ((reply = check_command(fsg, 10, DATA_DIR_FROM_HOST,
@@ -2561,7 +2558,7 @@ static int do_scsi_command(struct fsg_dev *fsg)
reply = do_write(fsg);
break;
- case SC_WRITE_12:
+ case WRITE_12:
fsg->data_size_from_cmnd =
get_unaligned_be32(&fsg->cmnd[6]) << 9;
if ((reply = check_command(fsg, 12, DATA_DIR_FROM_HOST,
@@ -2574,10 +2571,10 @@ static int do_scsi_command(struct fsg_dev *fsg)
* They don't mean much in this setting. It's left as an exercise
* for anyone interested to implement RESERVE and RELEASE in terms
* of Posix locks. */
- case SC_FORMAT_UNIT:
- case SC_RELEASE:
- case SC_RESERVE:
- case SC_SEND_DIAGNOSTIC:
+ case FORMAT_UNIT:
+ case RELEASE:
+ case RESERVE:
+ case SEND_DIAGNOSTIC:
// Fall through
default:
@@ -3178,6 +3175,7 @@ static void /* __init_or_exit */ fsg_unbind(struct usb_gadget *gadget)
for (i = 0; i < fsg->nluns; ++i) {
curlun = &fsg->luns[i];
if (curlun->registered) {
+ device_remove_file(&curlun->dev, &dev_attr_nofua);
device_remove_file(&curlun->dev, &dev_attr_ro);
device_remove_file(&curlun->dev, &dev_attr_file);
fsg_lun_close(curlun);
@@ -3213,7 +3211,6 @@ static int __init check_parameters(struct fsg_dev *fsg)
{
int prot;
int gcnum;
- int i;
/* Store the default values */
mod_data.transport_type = USB_PR_BULK;
@@ -3309,45 +3306,29 @@ static int __init check_parameters(struct fsg_dev *fsg)
if ((*ch < '0' || *ch > '9') &&
(*ch < 'A' || *ch > 'F')) { /* not uppercase hex */
WARNING(fsg,
- "Invalid serial string character: %c; "
- "Failing back to default\n",
+ "Invalid serial string character: %c\n",
*ch);
- goto fill_serial;
+ goto no_serial;
}
}
if (len > 126 ||
(mod_data.transport_type == USB_PR_BULK && len < 12) ||
(mod_data.transport_type != USB_PR_BULK && len > 12)) {
- WARNING(fsg,
- "Invalid serial string length; "
- "Failing back to default\n");
- goto fill_serial;
+ WARNING(fsg, "Invalid serial string length!\n");
+ goto no_serial;
}
fsg_strings[FSG_STRING_SERIAL - 1].s = mod_data.serial;
} else {
- WARNING(fsg,
- "Userspace failed to provide serial number; "
- "Failing back to default\n");
-fill_serial:
- /* Serial number not specified or invalid, make our own.
- * We just encode it from the driver version string,
- * 12 characters to comply with both CB[I] and BBB spec.
- * Warning : Two devices running the same kernel will have
- * the same fallback serial number. */
- for (i = 0; i < 12; i += 2) {
- unsigned char c = DRIVER_VERSION[i / 2];
-
- if (!c)
- break;
- sprintf(&fsg_string_serial[i], "%02X", c);
- }
+ WARNING(fsg, "No serial-number string provided!\n");
+ no_serial:
+ device_desc.iSerialNumber = 0;
}
return 0;
}
-static int __ref fsg_bind(struct usb_gadget *gadget)
+static int __init fsg_bind(struct usb_gadget *gadget)
{
struct fsg_dev *fsg = the_fsg;
int rc;
@@ -3607,7 +3588,6 @@ static struct usb_gadget_driver fsg_driver = {
.speed = USB_SPEED_FULL,
#endif
.function = (char *) fsg_string_product,
- .bind = fsg_bind,
.unbind = fsg_unbind,
.disconnect = fsg_disconnect,
.setup = fsg_setup,
@@ -3649,7 +3629,7 @@ static int __init fsg_init(void)
if ((rc = fsg_alloc()) != 0)
return rc;
fsg = the_fsg;
- if ((rc = usb_gadget_register_driver(&fsg_driver)) != 0)
+ if ((rc = usb_gadget_probe_driver(&fsg_driver, fsg_bind)) != 0)
kref_put(&fsg->ref, fsg_release);
return rc;
}
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 @@
static struct clk *mxc_ahb_clk;
static struct clk *mxc_usb_clk;
+/* workaround ENGcm09152 for i.MX35 */
+#define USBPHYCTRL_OTGBASE_OFFSET 0x608
+#define USBPHYCTRL_EVDO (1 << 23)
+
int fsl_udc_clk_init(struct platform_device *pdev)
{
struct fsl_usb2_platform_data *pdata;
@@ -84,6 +88,17 @@ eenahb:
void fsl_udc_clk_finalize(struct platform_device *pdev)
{
struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data;
+#if defined(CONFIG_ARCH_MX35)
+ unsigned int v;
+
+ /* workaround ENGcm09152 for i.MX35 */
+ if (pdata->workaround & FLS_USB2_WORKAROUND_ENGCM09152) {
+ v = readl(MX35_IO_ADDRESS(MX35_OTG_BASE_ADDR +
+ USBPHYCTRL_OTGBASE_OFFSET));
+ writel(v | USBPHYCTRL_EVDO, MX35_IO_ADDRESS(MX35_OTG_BASE_ADDR +
+ USBPHYCTRL_OTGBASE_OFFSET));
+ }
+#endif
/* ULPI transceivers don't need usbpll */
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)
}
/*-------------------------------------------------------------------------
- Gadget driver register and unregister.
+ Gadget driver probe and unregister.
--------------------------------------------------------------------------*/
-int usb_gadget_register_driver(struct usb_gadget_driver *driver)
+int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
+ int (*bind)(struct usb_gadget *))
{
int retval;
unsigned long flags = 0;
@@ -2315,8 +2316,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
if (!driver || (driver->speed != USB_SPEED_FULL
&& driver->speed != USB_SPEED_HIGH)
- || !driver->bind || !driver->disconnect
- || !driver->setup)
+ || !bind || !driver->disconnect || !driver->setup)
return -EINVAL;
if (udc_controller->driver)
@@ -2332,7 +2332,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
udc_controller->gadget.speed = (enum usb_device_speed)(driver->speed);
spin_unlock_irqrestore(&udc_controller->lock, flags);
- retval = driver->bind(&udc_controller->gadget);
+ retval = bind(&udc_controller->gadget);
if (retval) {
dev_err(udc_controller->dev, "bind to %s --> %d",
driver->driver.name, retval);
@@ -2353,7 +2353,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
udc_controller->gadget.name, driver->driver.name);
return 0;
}
-EXPORT_SYMBOL(usb_gadget_register_driver);
+EXPORT_SYMBOL(usb_gadget_probe_driver);
int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
{
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)
* Hook to gadget drivers
* Called by initialization code of gadget drivers
*----------------------------------------------------------------*/
-int usb_gadget_register_driver(struct usb_gadget_driver *driver)
+int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
+ int (*bind)(struct usb_gadget *))
{
int retval = -ENODEV;
unsigned long flags = 0;
@@ -1775,8 +1776,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
if (!driver || (driver->speed != USB_SPEED_FULL
&& driver->speed != USB_SPEED_HIGH)
- || !driver->bind || !driver->disconnect
- || !driver->setup)
+ || !bind || !driver->disconnect || !driver->setup)
return -EINVAL;
if (udc_controller->driver)
@@ -1792,7 +1792,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
spin_unlock_irqrestore(&udc_controller->lock, flags);
/* bind udc driver to gadget driver */
- retval = driver->bind(&udc_controller->gadget);
+ retval = bind(&udc_controller->gadget);
if (retval) {
VDBG("bind to %s --> %d", driver->driver.name, retval);
udc_controller->gadget.dev.driver = NULL;
@@ -1814,7 +1814,7 @@ out:
retval);
return retval;
}
-EXPORT_SYMBOL(usb_gadget_register_driver);
+EXPORT_SYMBOL(usb_gadget_probe_driver);
/* Disconnect from gadget driver */
int 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);
MODULE_AUTHOR("Michal Nazarewicz");
MODULE_LICENSE("GPL");
-
-static unsigned short gfs_vendor_id = 0x0525; /* XXX NetChip */
-static unsigned short gfs_product_id = 0xa4ac; /* XXX */
+#define GFS_VENDOR_ID 0x1d6b /* Linux Foundation */
+#define GFS_PRODUCT_ID 0x0105 /* FunctionFS Gadget */
static struct usb_device_descriptor gfs_dev_desc = {
.bLength = sizeof gfs_dev_desc,
@@ -63,29 +62,16 @@ static struct usb_device_descriptor gfs_dev_desc = {
.bcdUSB = cpu_to_le16(0x0200),
.bDeviceClass = USB_CLASS_PER_INTERFACE,
- /* Vendor and product id can be overridden by module parameters. */
- /* .idVendor = cpu_to_le16(gfs_vendor_id), */
- /* .idProduct = cpu_to_le16(gfs_product_id), */
- /* .bcdDevice = f(hardware) */
- /* .iManufacturer = DYNAMIC */
- /* .iProduct = DYNAMIC */
- /* NO SERIAL NUMBER */
- .bNumConfigurations = 1,
+ .idVendor = cpu_to_le16(GFS_VENDOR_ID),
+ .idProduct = cpu_to_le16(GFS_PRODUCT_ID),
};
-#define GFS_MODULE_PARAM_DESC(name, field) \
- 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.")
-
-module_param_named(usb_class, gfs_dev_desc.bDeviceClass, byte, 0644);
-GFS_MODULE_PARAM_DESC(usb_class, bDeviceClass);
-module_param_named(usb_subclass, gfs_dev_desc.bDeviceSubClass, byte, 0644);
-GFS_MODULE_PARAM_DESC(usb_subclass, bDeviceSubClass);
-module_param_named(usb_protocol, gfs_dev_desc.bDeviceProtocol, byte, 0644);
-GFS_MODULE_PARAM_DESC(usb_protocol, bDeviceProtocol);
-module_param_named(usb_vendor, gfs_vendor_id, ushort, 0644);
-GFS_MODULE_PARAM_DESC(usb_vendor, idVendor);
-module_param_named(usb_product, gfs_product_id, ushort, 0644);
-GFS_MODULE_PARAM_DESC(usb_product, idProduct);
+module_param_named(bDeviceClass, gfs_dev_desc.bDeviceClass, byte, 0644);
+MODULE_PARM_DESC(bDeviceClass, "USB Device class");
+module_param_named(bDeviceSubClass, gfs_dev_desc.bDeviceSubClass, byte, 0644);
+MODULE_PARM_DESC(bDeviceSubClass, "USB Device subclass");
+module_param_named(bDeviceProtocol, gfs_dev_desc.bDeviceProtocol, byte, 0644);
+MODULE_PARM_DESC(bDeviceProtocol, "USB Device protocol");
@@ -95,8 +81,10 @@ static const struct usb_descriptor_header *gfs_otg_desc[] = {
.bLength = sizeof(struct usb_otg_descriptor),
.bDescriptorType = USB_DT_OTG,
- /* REVISIT SRP-only hardware is possible, although
- * it would not be called "OTG" ... */
+ /*
+ * REVISIT SRP-only hardware is possible, although
+ * it would not be called "OTG" ...
+ */
.bmAttributes = USB_OTG_SRP | USB_OTG_HNP,
},
@@ -105,19 +93,7 @@ static const struct usb_descriptor_header *gfs_otg_desc[] = {
/* string IDs are assigned dynamically */
-enum {
- GFS_STRING_MANUFACTURER_IDX,
- GFS_STRING_PRODUCT_IDX,
- GFS_STRING_FIRST_CONFIG_IDX,
-};
-
-static char gfs_manufacturer[50];
-static const char gfs_driver_desc[] = DRIVER_DESC;
-static const char gfs_short_name[] = DRIVER_NAME;
-
static struct usb_string gfs_strings[] = {
- [GFS_STRING_MANUFACTURER_IDX].s = gfs_manufacturer,
- [GFS_STRING_PRODUCT_IDX].s = gfs_driver_desc,
#ifdef CONFIG_USB_FUNCTIONFS_RNDIS
{ .s = "FunctionFS + RNDIS" },
#endif
@@ -168,11 +144,11 @@ static int gfs_unbind(struct usb_composite_dev *cdev);
static int gfs_do_config(struct usb_configuration *c);
static struct usb_composite_driver gfs_driver = {
- .name = gfs_short_name,
+ .name = DRIVER_NAME,
.dev = &gfs_dev_desc,
.strings = gfs_dev_strings,
- .bind = gfs_bind,
.unbind = gfs_unbind,
+ .iProduct = DRIVER_DESC,
};
@@ -210,7 +186,7 @@ static int functionfs_ready_callback(struct ffs_data *ffs)
return -EBUSY;
gfs_ffs_data = ffs;
- ret = usb_composite_register(&gfs_driver);
+ ret = usb_composite_probe(&gfs_driver, gfs_bind);
if (unlikely(ret < 0))
clear_bit(0, &gfs_registered);
return ret;
@@ -245,20 +221,10 @@ static int gfs_bind(struct usb_composite_dev *cdev)
if (unlikely(ret < 0))
goto error_quick;
- gfs_dev_desc.idVendor = cpu_to_le16(gfs_vendor_id);
- gfs_dev_desc.idProduct = cpu_to_le16(gfs_product_id);
-
- snprintf(gfs_manufacturer, sizeof gfs_manufacturer, "%s %s with %s",
- init_utsname()->sysname, init_utsname()->release,
- cdev->gadget->name);
-
ret = usb_string_ids_tab(cdev, gfs_strings);
if (unlikely(ret < 0))
goto error;
- gfs_dev_desc.iManufacturer = gfs_strings[GFS_STRING_MANUFACTURER_IDX].id;
- gfs_dev_desc.iProduct = gfs_strings[GFS_STRING_PRODUCT_IDX].id;
-
ret = functionfs_bind(gfs_ffs_data, cdev);
if (unlikely(ret < 0))
goto error;
@@ -266,14 +232,12 @@ static int gfs_bind(struct usb_composite_dev *cdev)
for (i = 0; i < ARRAY_SIZE(gfs_configurations); ++i) {
struct gfs_configuration *c = gfs_configurations + i;
- ret = GFS_STRING_FIRST_CONFIG_IDX + i;
- c->c.label = gfs_strings[ret].s;
- c->c.iConfiguration = gfs_strings[ret].id;
- c->c.bind = gfs_do_config;
+ c->c.label = gfs_strings[i].s;
+ c->c.iConfiguration = gfs_strings[i].id;
c->c.bConfigurationValue = 1 + i;
c->c.bmAttributes = USB_CONFIG_ATT_SELFPOWER;
- ret = usb_add_config(cdev, &c->c);
+ ret = usb_add_config(cdev, &c->c, gfs_do_config);
if (unlikely(ret < 0))
goto error_unbind;
}
@@ -293,13 +257,14 @@ static int gfs_unbind(struct usb_composite_dev *cdev)
{
ENTER();
- /* We may have been called in an error recovery frem
+ /*
+ * We may have been called in an error recovery from
* composite_bind() after gfs_unbind() failure so we need to
* check if gfs_ffs_data is not NULL since gfs_bind() handles
* all error recovery itself. I'd rather we werent called
* from composite on orror recovery, but what you're gonna
- * do...? */
-
+ * do...?
+ */
if (gfs_ffs_data) {
gether_cleanup();
functionfs_unbind(gfs_ffs_data);
@@ -334,14 +299,16 @@ static int gfs_do_config(struct usb_configuration *c)
if (unlikely(ret < 0))
return ret;
- /* After previous do_configs there may be some invalid
+ /*
+ * After previous do_configs there may be some invalid
* pointers in c->interface array. This happens every time
* a user space function with fewer interfaces than a user
* space function that was run before the new one is run. The
* compasit's set_config() assumes that if there is no more
* then MAX_CONFIG_INTERFACES interfaces in a configuration
* then there is a NULL pointer after the last interface in
- * c->interface array. We need to make sure this is true. */
+ * c->interface array. We need to make sure this is true.
+ */
if (c->next_interface_id < ARRAY_SIZE(c->interface))
c->interface[c->next_interface_id] = NULL;
@@ -350,10 +317,12 @@ static int gfs_do_config(struct usb_configuration *c)
#ifdef CONFIG_USB_FUNCTIONFS_ETH
+
static int eth_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN])
{
return can_support_ecm(c->cdev->gadget)
? ecm_bind_config(c, ethaddr)
: geth_bind_config(c, ethaddr);
}
+
#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:
/*
* Creates an output endpoint, and initializes output ports.
*/
-static int __ref gmidi_bind(struct usb_gadget *gadget)
+static int __init gmidi_bind(struct usb_gadget *gadget)
{
struct gmidi_device *dev;
struct usb_ep *in_ep, *out_ep;
@@ -1292,7 +1292,6 @@ static void gmidi_resume(struct usb_gadget *gadget)
static struct usb_gadget_driver gmidi_driver = {
.speed = USB_SPEED_FULL,
.function = (char *)longname,
- .bind = gmidi_bind,
.unbind = gmidi_unbind,
.setup = gmidi_setup,
@@ -1309,7 +1308,7 @@ static struct usb_gadget_driver gmidi_driver = {
static int __init gmidi_init(void)
{
- return usb_gadget_register_driver(&gmidi_driver);
+ return usb_gadget_probe_driver(&gmidi_driver, gmidi_bind);
}
module_init(gmidi_init);
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;
* disconnect is reported. then a host may connect again, or
* the driver might get unbound.
*/
-int usb_gadget_register_driver(struct usb_gadget_driver *driver)
+int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
+ int (*bind)(struct usb_gadget *))
{
struct goku_udc *dev = the_controller;
int retval;
if (!driver
|| driver->speed < USB_SPEED_FULL
- || !driver->bind
+ || !bind
|| !driver->disconnect
|| !driver->setup)
return -EINVAL;
@@ -1363,7 +1364,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
driver->driver.bus = NULL;
dev->driver = driver;
dev->gadget.dev.driver = &driver->driver;
- retval = driver->bind(&dev->gadget);
+ retval = bind(&dev->gadget);
if (retval) {
DBG(dev, "bind to driver %s --> error %d\n",
driver->driver.name, retval);
@@ -1380,7 +1381,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
DBG(dev, "registered gadget driver '%s'\n", driver->driver.name);
return 0;
}
-EXPORT_SYMBOL(usb_gadget_register_driver);
+EXPORT_SYMBOL(usb_gadget_probe_driver);
static void
stop_activity(struct goku_udc *dev, struct usb_gadget_driver *driver)
@@ -1744,7 +1745,8 @@ static void goku_remove(struct pci_dev *pdev)
pci_resource_len (pdev, 0));
if (dev->enabled)
pci_disable_device(pdev);
- device_unregister(&dev->gadget.dev);
+ if (dev->registered)
+ device_unregister(&dev->gadget.dev);
pci_set_drvdata(pdev, NULL);
dev->regs = NULL;
@@ -1774,7 +1776,7 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id)
if (!pdev->irq) {
printk(KERN_ERR "Check PCI %s IRQ setup!\n", pci_name(pdev));
retval = -ENODEV;
- goto done;
+ goto err;
}
/* alloc, and start init */
@@ -1782,7 +1784,7 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id)
if (dev == NULL){
pr_debug("enomem %s\n", pci_name(pdev));
retval = -ENOMEM;
- goto done;
+ goto err;
}
spin_lock_init(&dev->lock);
@@ -1800,7 +1802,7 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id)
retval = pci_enable_device(pdev);
if (retval < 0) {
DBG(dev, "can't enable, %d\n", retval);
- goto done;
+ goto err;
}
dev->enabled = 1;
@@ -1809,7 +1811,7 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id)
if (!request_mem_region(resource, len, driver_name)) {
DBG(dev, "controller already in use\n");
retval = -EBUSY;
- goto done;
+ goto err;
}
dev->got_region = 1;
@@ -1817,7 +1819,7 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id)
if (base == NULL) {
DBG(dev, "can't map memory\n");
retval = -EFAULT;
- goto done;
+ goto err;
}
dev->regs = (struct goku_udc_regs __iomem *) base;
@@ -1833,7 +1835,7 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id)
driver_name, dev) != 0) {
DBG(dev, "request interrupt %d failed\n", pdev->irq);
retval = -EBUSY;
- goto done;
+ goto err;
}
dev->got_irq = 1;
if (use_dma)
@@ -1844,13 +1846,16 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id)
create_proc_read_entry(proc_node_name, 0, NULL, udc_proc_read, dev);
#endif
- /* done */
the_controller = dev;
retval = device_register(&dev->gadget.dev);
- if (retval == 0)
- return 0;
+ if (retval) {
+ put_device(&dev->gadget.dev);
+ goto err;
+ }
+ dev->registered = 1;
+ return 0;
-done:
+err:
if (dev)
goku_remove (pdev);
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[] = {
/****************************** Configurations ******************************/
-static int __ref do_config(struct usb_configuration *c)
+static int __init do_config(struct usb_configuration *c)
{
struct hidg_func_node *e;
int func = 0, status = 0;
@@ -148,7 +148,6 @@ static int __ref do_config(struct usb_configuration *c)
static struct usb_configuration config_driver = {
.label = "HID Gadget",
- .bind = do_config,
.bConfigurationValue = 1,
/* .iConfiguration = DYNAMIC */
.bmAttributes = USB_CONFIG_ATT_SELFPOWER,
@@ -156,7 +155,7 @@ static struct usb_configuration config_driver = {
/****************************** Gadget Bind ******************************/
-static int __ref hid_bind(struct usb_composite_dev *cdev)
+static int __init hid_bind(struct usb_composite_dev *cdev)
{
struct usb_gadget *gadget = cdev->gadget;
struct list_head *tmp;
@@ -201,7 +200,7 @@ static int __ref hid_bind(struct usb_composite_dev *cdev)
device_desc.iProduct = status;
/* register our configuration */
- status = usb_add_config(cdev, &config_driver);
+ status = usb_add_config(cdev, &config_driver, do_config);
if (status < 0)
return status;
@@ -256,7 +255,6 @@ static struct usb_composite_driver hidg_driver = {
.name = "g_hid",
.dev = &device_desc,
.strings = dev_strings,
- .bind = hid_bind,
.unbind = __exit_p(hid_unbind),
};
@@ -282,7 +280,7 @@ static int __init hidg_init(void)
if (status < 0)
return status;
- status = usb_composite_register(&hidg_driver);
+ status = usb_composite_probe(&hidg_driver, hid_bind);
if (status < 0)
platform_driver_unregister(&hidg_plat_driver);
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 = {
* USB gadged driver functions
*******************************************************************************
*/
-int usb_gadget_register_driver(struct usb_gadget_driver *driver)
+int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
+ int (*bind)(struct usb_gadget *))
{
struct imx_udc_struct *imx_usb = &controller;
int retval;
if (!driver
|| driver->speed < USB_SPEED_FULL
- || !driver->bind
+ || !bind
|| !driver->disconnect
|| !driver->setup)
return -EINVAL;
@@ -1342,7 +1343,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
retval = device_add(&imx_usb->gadget.dev);
if (retval)
goto fail;
- retval = driver->bind(&imx_usb->gadget);
+ retval = bind(&imx_usb->gadget);
if (retval) {
D_ERR(imx_usb->dev, "<%s> bind to driver %s --> error %d\n",
__func__, driver->driver.name, retval);
@@ -1362,7 +1363,7 @@ fail:
imx_usb->gadget.dev.driver = NULL;
return retval;
}
-EXPORT_SYMBOL(usb_gadget_register_driver);
+EXPORT_SYMBOL(usb_gadget_probe_driver);
int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
{
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 = {
.speed = USB_SPEED_FULL,
#endif
.function = (char *) driver_desc,
- .bind = gadgetfs_bind,
.unbind = gadgetfs_unbind,
.setup = gadgetfs_setup,
.disconnect = gadgetfs_disconnect,
@@ -1797,7 +1796,6 @@ static int gadgetfs_probe (struct usb_gadget *gadget)
static struct usb_gadget_driver probe_driver = {
.speed = USB_SPEED_HIGH,
- .bind = gadgetfs_probe,
.unbind = gadgetfs_nop,
.setup = (void *)gadgetfs_nop,
.disconnect = gadgetfs_nop,
@@ -1907,7 +1905,7 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
/* triggers gadgetfs_bind(); then we can enumerate. */
spin_unlock_irq (&dev->lock);
- value = usb_gadget_register_driver (&gadgetfs_driver);
+ value = usb_gadget_probe_driver(&gadgetfs_driver, gadgetfs_bind);
if (value != 0) {
kfree (dev->buf);
dev->buf = NULL;
@@ -2046,7 +2044,7 @@ gadgetfs_fill_super (struct super_block *sb, void *opts, int silent)
return -ESRCH;
/* fake probe to determine $CHIP */
- (void) usb_gadget_register_driver (&probe_driver);
+ (void) usb_gadget_probe_driver(&probe_driver, gadgetfs_probe);
if (!CHIP)
return -ENODEV;
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 @@
/* #undef DEBUG */
-/* #undef VERBOSE */
+/* #undef VERBOSE_DEBUG */
#if defined(CONFIG_USB_LANGWELL_OTG)
#define OTG_TRANSCEIVER
@@ -77,141 +77,110 @@ langwell_ep0_desc = {
/*-------------------------------------------------------------------------*/
/* debugging */
-#ifdef DEBUG
-#define DBG(dev, fmt, args...) \
- pr_debug("%s %s: " fmt , driver_name, \
- pci_name(dev->pdev), ## args)
-#else
-#define DBG(dev, fmt, args...) \
- do { } while (0)
-#endif /* DEBUG */
-
-
-#ifdef VERBOSE
-#define VDBG DBG
-#else
-#define VDBG(dev, fmt, args...) \
- do { } while (0)
-#endif /* VERBOSE */
-
-
-#define ERROR(dev, fmt, args...) \
- pr_err("%s %s: " fmt , driver_name, \
- pci_name(dev->pdev), ## args)
-
-#define WARNING(dev, fmt, args...) \
- pr_warning("%s %s: " fmt , driver_name, \
- pci_name(dev->pdev), ## args)
-
-#define INFO(dev, fmt, args...) \
- pr_info("%s %s: " fmt , driver_name, \
- pci_name(dev->pdev), ## args)
-
-
-#ifdef VERBOSE
+#ifdef VERBOSE_DEBUG
static inline void print_all_registers(struct langwell_udc *dev)
{
int i;
/* Capability Registers */
- printk(KERN_DEBUG "Capability Registers (offset: "
- "0x%04x, length: 0x%08x)\n",
- CAP_REG_OFFSET,
- (u32)sizeof(struct langwell_cap_regs));
- printk(KERN_DEBUG "caplength=0x%02x\n",
+ dev_dbg(&dev->pdev->dev,
+ "Capability Registers (offset: 0x%04x, length: 0x%08x)\n",
+ CAP_REG_OFFSET, (u32)sizeof(struct langwell_cap_regs));
+ dev_dbg(&dev->pdev->dev, "caplength=0x%02x\n",
readb(&dev->cap_regs->caplength));
- printk(KERN_DEBUG "hciversion=0x%04x\n",
+ dev_dbg(&dev->pdev->dev, "hciversion=0x%04x\n",
readw(&dev->cap_regs->hciversion));
- printk(KERN_DEBUG "hcsparams=0x%08x\n",
+ dev_dbg(&dev->pdev->dev, "hcsparams=0x%08x\n",
readl(&dev->cap_regs->hcsparams));
- printk(KERN_DEBUG "hccparams=0x%08x\n",
+ dev_dbg(&dev->pdev->dev, "hccparams=0x%08x\n",
readl(&dev->cap_regs->hccparams));
- printk(KERN_DEBUG "dciversion=0x%04x\n",
+ dev_dbg(&dev->pdev->dev, "dciversion=0x%04x\n",
readw(&dev->cap_regs->dciversion));
- printk(KERN_DEBUG "dccparams=0x%08x\n",
+ dev_dbg(&dev->pdev->dev, "dccparams=0x%08x\n",
readl(&dev->cap_regs->dccparams));
/* Operational Registers */
- printk(KERN_DEBUG "Operational Registers (offset: "
- "0x%04x, length: 0x%08x)\n",
- OP_REG_OFFSET,
- (u32)sizeof(struct langwell_op_regs));
- printk(KERN_DEBUG "extsts=0x%08x\n",
+ dev_dbg(&dev->pdev->dev,
+ "Operational Registers (offset: 0x%04x, length: 0x%08x)\n",
+ OP_REG_OFFSET, (u32)sizeof(struct langwell_op_regs));
+ dev_dbg(&dev->pdev->dev, "extsts=0x%08x\n",
readl(&dev->op_regs->extsts));
- printk(KERN_DEBUG "extintr=0x%08x\n",
+ dev_dbg(&dev->pdev->dev, "extintr=0x%08x\n",
readl(&dev->op_regs->extintr));
- printk(KERN_DEBUG "usbcmd=0x%08x\n",
+ dev_dbg(&dev->pdev->dev, "usbcmd=0x%08x\n",
readl(&dev->op_regs->usbcmd));
- printk(KERN_DEBUG "usbsts=0x%08x\n",
+ dev_dbg(&dev->pdev->dev, "usbsts=0x%08x\n",
readl(&dev->op_regs->usbsts));
- printk(KERN_DEBUG "usbintr=0x%08x\n",
+ dev_dbg(&dev->pdev->dev, "usbintr=0x%08x\n",
readl(&dev->op_regs->usbintr));
- printk(KERN_DEBUG "frindex=0x%08x\n",
+ dev_dbg(&dev->pdev->dev, "frindex=0x%08x\n",
readl(&dev->op_regs->frindex));
- printk(KERN_DEBUG "ctrldssegment=0x%08x\n",
+ dev_dbg(&dev->pdev->dev, "ctrldssegment=0x%08x\n",
readl(&dev->op_regs->ctrldssegment));
- printk(KERN_DEBUG "deviceaddr=0x%08x\n",
+ dev_dbg(&dev->pdev->dev, "deviceaddr=0x%08x\n",
readl(&dev->op_regs->deviceaddr));
- printk(KERN_DEBUG "endpointlistaddr=0x%08x\n",
+ dev_dbg(&dev->pdev->dev, "endpointlistaddr=0x%08x\n",
readl(&dev->op_regs->endpointlistaddr));
- printk(KERN_DEBUG "ttctrl=0x%08x\n",
+ dev_dbg(&dev->pdev->dev, "ttctrl=0x%08x\n",
readl(&dev->op_regs->ttctrl));
- printk(KERN_DEBUG "burstsize=0x%08x\n",
+ dev_dbg(&dev->pdev->dev, "burstsize=0x%08x\n",
readl(&dev->op_regs->burstsize));
- printk(KERN_DEBUG "txfilltuning=0x%08x\n",
+ dev_dbg(&dev->pdev->dev, "txfilltuning=0x%08x\n",
readl(&dev->op_regs->txfilltuning));
- printk(KERN_DEBUG "txttfilltuning=0x%08x\n",
+ dev_dbg(&dev->pdev->dev, "txttfilltuning=0x%08x\n",
readl(&dev->op_regs->txttfilltuning));
- printk(KERN_DEBUG "ic_usb=0x%08x\n",
+ dev_dbg(&dev->pdev->dev, "ic_usb=0x%08x\n",
readl(&dev->op_regs->ic_usb));
- printk(KERN_DEBUG "ulpi_viewport=0x%08x\n",
+ dev_dbg(&dev->pdev->dev, "ulpi_viewport=0x%08x\n",
readl(&dev->op_regs->ulpi_viewport));
- printk(KERN_DEBUG "configflag=0x%08x\n",
+ dev_dbg(&dev->pdev->dev, "configflag=0x%08x\n",
readl(&dev->op_regs->configflag));
- printk(KERN_DEBUG "portsc1=0x%08x\n",
+ dev_dbg(&dev->pdev->dev, "portsc1=0x%08x\n",
readl(&dev->op_regs->portsc1));
- printk(KERN_DEBUG "devlc=0x%08x\n",
+ dev_dbg(&dev->pdev->dev, "devlc=0x%08x\n",
readl(&dev->op_regs->devlc));
- printk(KERN_DEBUG "otgsc=0x%08x\n",
+ dev_dbg(&dev->pdev->dev, "otgsc=0x%08x\n",
readl(&dev->op_regs->otgsc));
- printk(KERN_DEBUG "usbmode=0x%08x\n",
+ dev_dbg(&dev->pdev->dev, "usbmode=0x%08x\n",
readl(&dev->op_regs->usbmode));
- printk(KERN_DEBUG "endptnak=0x%08x\n",
+ dev_dbg(&dev->pdev->dev, "endptnak=0x%08x\n",
readl(&dev->op_regs->endptnak));
- printk(KERN_DEBUG "endptnaken=0x%08x\n",
+ dev_dbg(&dev->pdev->dev, "endptnaken=0x%08x\n",
readl(&dev->op_regs->endptnaken));
- printk(KERN_DEBUG "endptsetupstat=0x%08x\n",
+ dev_dbg(&dev->pdev->dev, "endptsetupstat=0x%08x\n",
readl(&dev->op_regs->endptsetupstat));
- printk(KERN_DEBUG "endptprime=0x%08x\n",
+ dev_dbg(&dev->pdev->dev, "endptprime=0x%08x\n",
readl(&dev->op_regs->endptprime));
- printk(KERN_DEBUG "endptflush=0x%08x\n",
+ dev_dbg(&dev->pdev->dev, "endptflush=0x%08x\n",
readl(&dev->op_regs->endptflush));
- printk(KERN_DEBUG "endptstat=0x%08x\n",
+ dev_dbg(&dev->pdev->dev, "endptstat=0x%08x\n",
readl(&dev->op_regs->endptstat));
- printk(KERN_DEBUG "endptcomplete=0x%08x\n",
+ dev_dbg(&dev->pdev->dev, "endptcomplete=0x%08x\n",
readl(&dev->op_regs->endptcomplete));
for (i = 0; i < dev->ep_max / 2; i++) {
- printk(KERN_DEBUG "endptctrl[%d]=0x%08x\n",
+ dev_dbg(&dev->pdev->dev, "endptctrl[%d]=0x%08x\n",
i, readl(&dev->op_regs->endptctrl[i]));
}
}
-#endif /* VERBOSE */
+#else
+
+#define print_all_registers(dev) do { } while (0)
+
+#endif /* VERBOSE_DEBUG */
/*-------------------------------------------------------------------------*/
-#define DIR_STRING(bAddress) (((bAddress) & USB_DIR_IN) ? "in" : "out")
+#define is_in(ep) (((ep)->ep_num == 0) ? ((ep)->dev->ep0_dir == \
+ USB_DIR_IN) : (usb_endpoint_dir_in((ep)->desc)))
-#define is_in(ep) (((ep)->ep_num == 0) ? ((ep)->dev->ep0_dir == \
- USB_DIR_IN) : ((ep)->desc->bEndpointAddress \
- & USB_DIR_IN) == USB_DIR_IN)
+#define DIR_STRING(ep) (is_in(ep) ? "in" : "out")
-#ifdef DEBUG
-static char *type_string(u8 bmAttributes)
+static char *type_string(const struct usb_endpoint_descriptor *desc)
{
- switch ((bmAttributes) & USB_ENDPOINT_XFERTYPE_MASK) {
+ switch (usb_endpoint_type(desc)) {
case USB_ENDPOINT_XFER_BULK:
return "bulk";
case USB_ENDPOINT_XFER_ISOC:
@@ -222,7 +191,6 @@ static char *type_string(u8 bmAttributes)
return "control";
}
-#endif
/* configure endpoint control registers */
@@ -233,7 +201,7 @@ static void ep_reset(struct langwell_ep *ep, unsigned char ep_num,
u32 endptctrl;
dev = ep->dev;
- VDBG(dev, "---> %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
endptctrl = readl(&dev->op_regs->endptctrl[ep_num]);
if (is_in) { /* TX */
@@ -250,7 +218,7 @@ static void ep_reset(struct langwell_ep *ep, unsigned char ep_num,
writel(endptctrl, &dev->op_regs->endptctrl[ep_num]);
- VDBG(dev, "<--- %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
}
@@ -260,7 +228,7 @@ static void ep0_reset(struct langwell_udc *dev)
struct langwell_ep *ep;
int i;
- VDBG(dev, "---> %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
/* ep0 in and out */
for (i = 0; i < 2; i++) {
@@ -274,17 +242,18 @@ static void ep0_reset(struct langwell_udc *dev)
ep->dqh->dqh_ios = 1;
ep->dqh->dqh_mpl = EP0_MAX_PKT_SIZE;
- /* FIXME: enable ep0-in HW zero length termination select */
+ /* enable ep0-in HW zero length termination select */
if (is_in(ep))
ep->dqh->dqh_zlt = 0;
ep->dqh->dqh_mult = 0;
+ ep->dqh->dtd_next = DTD_TERM;
+
/* configure ep0 control registers */
ep_reset(&dev->ep[0], 0, i, USB_ENDPOINT_XFER_CONTROL);
}
- VDBG(dev, "<--- %s()\n", __func__);
- return;
+ dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
}
@@ -300,12 +269,12 @@ static int langwell_ep_enable(struct usb_ep *_ep,
struct langwell_ep *ep;
u16 max = 0;
unsigned long flags;
- int retval = 0;
+ int i, retval = 0;
unsigned char zlt, ios = 0, mult = 0;
ep = container_of(_ep, struct langwell_ep, ep);
dev = ep->dev;
- VDBG(dev, "---> %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
if (!_ep || !desc || ep->desc
|| desc->bDescriptorType != USB_DT_ENDPOINT)
@@ -326,7 +295,7 @@ static int langwell_ep_enable(struct usb_ep *_ep,
* sanity check type, direction, address, and then
* initialize the endpoint capabilities fields in dQH
*/
- switch (desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) {
+ switch (usb_endpoint_type(desc)) {
case USB_ENDPOINT_XFER_CONTROL:
ios = 1;
break;
@@ -386,33 +355,36 @@ static int langwell_ep_enable(struct usb_ep *_ep,
spin_lock_irqsave(&dev->lock, flags);
- /* configure endpoint capabilities in dQH */
- ep->dqh->dqh_ios = ios;
- ep->dqh->dqh_mpl = cpu_to_le16(max);
- ep->dqh->dqh_zlt = zlt;
- ep->dqh->dqh_mult = mult;
-
ep->ep.maxpacket = max;
ep->desc = desc;
ep->stopped = 0;
- ep->ep_num = desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
+ ep->ep_num = usb_endpoint_num(desc);
/* ep_type */
- ep->ep_type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
+ ep->ep_type = usb_endpoint_type(desc);
/* configure endpoint control registers */
ep_reset(ep, ep->ep_num, is_in(ep), ep->ep_type);
- DBG(dev, "enabled %s (ep%d%s-%s), max %04x\n",
+ /* configure endpoint capabilities in dQH */
+ i = ep->ep_num * 2 + is_in(ep);
+ ep->dqh = &dev->ep_dqh[i];
+ ep->dqh->dqh_ios = ios;
+ ep->dqh->dqh_mpl = cpu_to_le16(max);
+ ep->dqh->dqh_zlt = zlt;
+ ep->dqh->dqh_mult = mult;
+ ep->dqh->dtd_next = DTD_TERM;
+
+ dev_dbg(&dev->pdev->dev, "enabled %s (ep%d%s-%s), max %04x\n",
_ep->name,
ep->ep_num,
- DIR_STRING(desc->bEndpointAddress),
- type_string(desc->bmAttributes),
+ DIR_STRING(ep),
+ type_string(desc),
max);
spin_unlock_irqrestore(&dev->lock, flags);
done:
- VDBG(dev, "<--- %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return retval;
}
@@ -428,7 +400,7 @@ static void done(struct langwell_ep *ep, struct langwell_request *req,
struct langwell_dtd *curr_dtd, *next_dtd;
int i;
- VDBG(dev, "---> %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
/* remove the req from ep->queue */
list_del_init(&req->queue);
@@ -448,7 +420,8 @@ static void done(struct langwell_ep *ep, struct langwell_request *req,
}
if (req->mapped) {
- dma_unmap_single(&dev->pdev->dev, req->req.dma, req->req.length,
+ dma_unmap_single(&dev->pdev->dev,
+ req->req.dma, req->req.length,
is_in(ep) ? PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE);
req->req.dma = DMA_ADDR_INVALID;
req->mapped = 0;
@@ -458,9 +431,10 @@ static void done(struct langwell_ep *ep, struct langwell_request *req,
is_in(ep) ? DMA_TO_DEVICE : DMA_FROM_DEVICE);
if (status != -ESHUTDOWN)
- DBG(dev, "complete %s, req %p, stat %d, len %u/%u\n",
- ep->ep.name, &req->req, status,
- req->req.actual, req->req.length);
+ dev_dbg(&dev->pdev->dev,
+ "complete %s, req %p, stat %d, len %u/%u\n",
+ ep->ep.name, &req->req, status,
+ req->req.actual, req->req.length);
/* don't modify queue heads during completion callback */
ep->stopped = 1;
@@ -473,7 +447,7 @@ static void done(struct langwell_ep *ep, struct langwell_request *req,
spin_lock(&dev->lock);
ep->stopped = stopped;
- VDBG(dev, "<--- %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
}
@@ -511,7 +485,7 @@ static int langwell_ep_disable(struct usb_ep *_ep)
ep = container_of(_ep, struct langwell_ep, ep);
dev = ep->dev;
- VDBG(dev, "---> %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
if (!_ep || !ep->desc)
return -EINVAL;
@@ -535,8 +509,8 @@ static int langwell_ep_disable(struct usb_ep *_ep)
spin_unlock_irqrestore(&dev->lock, flags);
- DBG(dev, "disabled %s\n", _ep->name);
- VDBG(dev, "<--- %s()\n", __func__);
+ dev_dbg(&dev->pdev->dev, "disabled %s\n", _ep->name);
+ dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return 0;
}
@@ -555,7 +529,7 @@ static struct usb_request *langwell_alloc_request(struct usb_ep *_ep,
ep = container_of(_ep, struct langwell_ep, ep);
dev = ep->dev;
- VDBG(dev, "---> %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
req = kzalloc(sizeof(*req), gfp_flags);
if (!req)
@@ -564,8 +538,8 @@ static struct usb_request *langwell_alloc_request(struct usb_ep *_ep,
req->req.dma = DMA_ADDR_INVALID;
INIT_LIST_HEAD(&req->queue);
- VDBG(dev, "alloc request for %s\n", _ep->name);
- VDBG(dev, "<--- %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "alloc request for %s\n", _ep->name);
+ dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return &req->req;
}
@@ -580,7 +554,7 @@ static void langwell_free_request(struct usb_ep *_ep,
ep = container_of(_ep, struct langwell_ep, ep);
dev = ep->dev;
- VDBG(dev, "---> %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
if (!_ep || !_req)
return;
@@ -591,8 +565,8 @@ static void langwell_free_request(struct usb_ep *_ep,
if (_req)
kfree(req);
- VDBG(dev, "free request for %s\n", _ep->name);
- VDBG(dev, "<--- %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "free request for %s\n", _ep->name);
+ dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
}
@@ -608,23 +582,24 @@ static int queue_dtd(struct langwell_ep *ep, struct langwell_request *req)
struct langwell_udc *dev;
dev = ep->dev;
- VDBG(dev, "---> %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
i = ep->ep_num * 2 + is_in(ep);
dqh = &dev->ep_dqh[i];
if (ep->ep_num)
- VDBG(dev, "%s\n", ep->name);
+ dev_vdbg(&dev->pdev->dev, "%s\n", ep->name);
else
/* ep0 */
- VDBG(dev, "%s-%s\n", ep->name, is_in(ep) ? "in" : "out");
+ dev_vdbg(&dev->pdev->dev, "%s-%s\n", ep->name, DIR_STRING(ep));
- VDBG(dev, "ep_dqh[%d] addr: 0x%08x\n", i, (u32)&(dev->ep_dqh[i]));
+ dev_vdbg(&dev->pdev->dev, "ep_dqh[%d] addr: 0x%08x\n",
+ i, (u32)&(dev->ep_dqh[i]));
bit_mask = is_in(ep) ?
(1 << (ep->ep_num + 16)) : (1 << (ep->ep_num));
- VDBG(dev, "bit_mask = 0x%08x\n", bit_mask);
+ dev_vdbg(&dev->pdev->dev, "bit_mask = 0x%08x\n", bit_mask);
/* check if the pipe is empty */
if (!(list_empty(&ep->queue))) {
@@ -665,14 +640,17 @@ static int queue_dtd(struct langwell_ep *ep, struct langwell_request *req)
/* clear active and halt bit */
dtd_status = (u8) ~(DTD_STS_ACTIVE | DTD_STS_HALTED);
dqh->dtd_status &= dtd_status;
- VDBG(dev, "dqh->dtd_status = 0x%x\n", dqh->dtd_status);
+ dev_vdbg(&dev->pdev->dev, "dqh->dtd_status = 0x%x\n", dqh->dtd_status);
+
+ /* ensure that updates to the dQH will occure before priming */
+ wmb();
/* write 1 to endptprime register to PRIME endpoint */
bit_mask = is_in(ep) ? (1 << (ep->ep_num + 16)) : (1 << ep->ep_num);
- VDBG(dev, "endprime bit_mask = 0x%08x\n", bit_mask);
+ dev_vdbg(&dev->pdev->dev, "endprime bit_mask = 0x%08x\n", bit_mask);
writel(bit_mask, &dev->op_regs->endptprime);
out:
- VDBG(dev, "<--- %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return 0;
}
@@ -687,7 +665,7 @@ static struct langwell_dtd *build_dtd(struct langwell_request *req,
int i;
dev = req->ep->dev;
- VDBG(dev, "---> %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
/* the maximum transfer length, up to 16k bytes */
*length = min(req->req.length - req->req.actual,
@@ -708,7 +686,7 @@ static struct langwell_dtd *build_dtd(struct langwell_request *req,
/* fill in total bytes with transfer size */
dtd->dtd_total = cpu_to_le16(*length);
- VDBG(dev, "dtd->dtd_total = %d\n", dtd->dtd_total);
+ dev_vdbg(&dev->pdev->dev, "dtd->dtd_total = %d\n", dtd->dtd_total);
/* set is_last flag if req->req.zero is set or not */
if (req->req.zero) {
@@ -722,7 +700,7 @@ static struct langwell_dtd *build_dtd(struct langwell_request *req,
*is_last = 0;
if (*is_last == 0)
- VDBG(dev, "multi-dtd request!\n");
+ dev_vdbg(&dev->pdev->dev, "multi-dtd request!\n");
/* set interrupt on complete bit for the last dTD */
if (*is_last && !req->req.no_interrupt)
@@ -733,10 +711,12 @@ static struct langwell_dtd *build_dtd(struct langwell_request *req,
/* set the active bit of status field to 1 */
dtd->dtd_status = DTD_STS_ACTIVE;
- VDBG(dev, "dtd->dtd_status = 0x%02x\n", dtd->dtd_status);
+ dev_vdbg(&dev->pdev->dev, "dtd->dtd_status = 0x%02x\n",
+ dtd->dtd_status);
- VDBG(dev, "length = %d, dma addr= 0x%08x\n", *length, (int)*dma);
- VDBG(dev, "<--- %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "length = %d, dma addr= 0x%08x\n",
+ *length, (int)*dma);
+ dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return dtd;
}
@@ -751,7 +731,7 @@ static int req_to_dtd(struct langwell_request *req)
dma_addr_t dma;
dev = req->ep->dev;
- VDBG(dev, "---> %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
do {
dtd = build_dtd(req, &count, &dma, &is_last);
if (dtd == NULL)
@@ -773,7 +753,7 @@ static int req_to_dtd(struct langwell_request *req)
req->tail = dtd;
- VDBG(dev, "<--- %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return 0;
}
@@ -803,9 +783,9 @@ static int langwell_ep_queue(struct usb_ep *_ep, struct usb_request *_req,
dev = ep->dev;
req->ep = ep;
- VDBG(dev, "---> %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
- if (ep->desc->bmAttributes == USB_ENDPOINT_XFER_ISOC) {
+ if (usb_endpoint_xfer_isoc(ep->desc)) {
if (req->req.length > ep->ep.maxpacket)
return -EMSGSIZE;
is_iso = 1;
@@ -818,7 +798,7 @@ static int langwell_ep_queue(struct usb_ep *_ep, struct usb_request *_req,
if (_req->dma == DMA_ADDR_INVALID) {
/* WORKAROUND: WARN_ON(size == 0) */
if (_req->length == 0) {
- VDBG(dev, "req->length: 0->1\n");
+ dev_vdbg(&dev->pdev->dev, "req->length: 0->1\n");
zlflag = 1;
_req->length++;
}
@@ -827,24 +807,25 @@ static int langwell_ep_queue(struct usb_ep *_ep, struct usb_request *_req,
_req->buf, _req->length,
is_in(ep) ? DMA_TO_DEVICE : DMA_FROM_DEVICE);
if (zlflag && (_req->length == 1)) {
- VDBG(dev, "req->length: 1->0\n");
+ dev_vdbg(&dev->pdev->dev, "req->length: 1->0\n");
zlflag = 0;
_req->length = 0;
}
req->mapped = 1;
- VDBG(dev, "req->mapped = 1\n");
+ dev_vdbg(&dev->pdev->dev, "req->mapped = 1\n");
} else {
dma_sync_single_for_device(&dev->pdev->dev,
_req->dma, _req->length,
is_in(ep) ? DMA_TO_DEVICE : DMA_FROM_DEVICE);
req->mapped = 0;
- VDBG(dev, "req->mapped = 0\n");
+ dev_vdbg(&dev->pdev->dev, "req->mapped = 0\n");
}
- DBG(dev, "%s queue req %p, len %u, buf %p, dma 0x%08llx\n",
- _ep->name,
- _req, _req->length, _req->buf, (unsigned long long)_req->dma);
+ dev_dbg(&dev->pdev->dev,
+ "%s queue req %p, len %u, buf %p, dma 0x%08x\n",
+ _ep->name,
+ _req, _req->length, _req->buf, (int)_req->dma);
_req->status = -EINPROGRESS;
_req->actual = 0;
@@ -866,12 +847,12 @@ static int langwell_ep_queue(struct usb_ep *_ep, struct usb_request *_req,
if (likely(req != NULL)) {
list_add_tail(&req->queue, &ep->queue);
- VDBG(dev, "list_add_tail() \n");
+ dev_vdbg(&dev->pdev->dev, "list_add_tail()\n");
}
spin_unlock_irqrestore(&dev->lock, flags);
- VDBG(dev, "<--- %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return 0;
}
@@ -888,7 +869,7 @@ static int langwell_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
ep = container_of(_ep, struct langwell_ep, ep);
dev = ep->dev;
- VDBG(dev, "---> %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
if (!_ep || !ep->desc || !_req)
return -EINVAL;
@@ -924,7 +905,7 @@ static int langwell_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
/* queue head may be partially complete. */
if (ep->queue.next == &req->queue) {
- DBG(dev, "unlink (%s) dma\n", _ep->name);
+ dev_dbg(&dev->pdev->dev, "unlink (%s) dma\n", _ep->name);
_req->status = -ECONNRESET;
langwell_ep_fifo_flush(&ep->ep);
@@ -963,7 +944,7 @@ done:
ep->stopped = stopped;
spin_unlock_irqrestore(&dev->lock, flags);
- VDBG(dev, "<--- %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return retval;
}
@@ -976,7 +957,7 @@ static void ep_set_halt(struct langwell_ep *ep, int value)
u32 endptctrl = 0;
int ep_num;
struct langwell_udc *dev = ep->dev;
- VDBG(dev, "---> %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
ep_num = ep->ep_num;
endptctrl = readl(&dev->op_regs->endptctrl[ep_num]);
@@ -1001,7 +982,7 @@ static void ep_set_halt(struct langwell_ep *ep, int value)
writel(endptctrl, &dev->op_regs->endptctrl[ep_num]);
- VDBG(dev, "<--- %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
}
@@ -1016,7 +997,7 @@ static int langwell_ep_set_halt(struct usb_ep *_ep, int value)
ep = container_of(_ep, struct langwell_ep, ep);
dev = ep->dev;
- VDBG(dev, "---> %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
if (!_ep || !ep->desc)
return -EINVAL;
@@ -1024,8 +1005,7 @@ static int langwell_ep_set_halt(struct usb_ep *_ep, int value)
if (!dev->driver || dev->gadget.speed == USB_SPEED_UNKNOWN)
return -ESHUTDOWN;
- if (ep->desc && (ep->desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
- == USB_ENDPOINT_XFER_ISOC)
+ if (usb_endpoint_xfer_isoc(ep->desc))
return -EOPNOTSUPP;
spin_lock_irqsave(&dev->lock, flags);
@@ -1036,7 +1016,7 @@ static int langwell_ep_set_halt(struct usb_ep *_ep, int value)
*/
if (!list_empty(&ep->queue) && is_in(ep) && value) {
/* IN endpoint FIFO holds bytes */
- DBG(dev, "%s FIFO holds bytes\n", _ep->name);
+ dev_dbg(&dev->pdev->dev, "%s FIFO holds bytes\n", _ep->name);
retval = -EAGAIN;
goto done;
}
@@ -1050,8 +1030,9 @@ static int langwell_ep_set_halt(struct usb_ep *_ep, int value)
}
done:
spin_unlock_irqrestore(&dev->lock, flags);
- DBG(dev, "%s %s halt\n", _ep->name, value ? "set" : "clear");
- VDBG(dev, "<--- %s()\n", __func__);
+ dev_dbg(&dev->pdev->dev, "%s %s halt\n",
+ _ep->name, value ? "set" : "clear");
+ dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return retval;
}
@@ -1065,12 +1046,12 @@ static int langwell_ep_set_wedge(struct usb_ep *_ep)
ep = container_of(_ep, struct langwell_ep, ep);
dev = ep->dev;
- VDBG(dev, "---> %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
if (!_ep || !ep->desc)
return -EINVAL;
- VDBG(dev, "<--- %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return usb_ep_set_halt(_ep);
}
@@ -1086,15 +1067,16 @@ static void langwell_ep_fifo_flush(struct usb_ep *_ep)
ep = container_of(_ep, struct langwell_ep, ep);
dev = ep->dev;
- VDBG(dev, "---> %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
if (!_ep || !ep->desc) {
- VDBG(dev, "ep or ep->desc is NULL\n");
- VDBG(dev, "<--- %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "ep or ep->desc is NULL\n");
+ dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return;
}
- VDBG(dev, "%s-%s fifo flush\n", _ep->name, is_in(ep) ? "in" : "out");
+ dev_vdbg(&dev->pdev->dev, "%s-%s fifo flush\n",
+ _ep->name, DIR_STRING(ep));
/* flush endpoint buffer */
if (ep->ep_num == 0)
@@ -1110,14 +1092,14 @@ static void langwell_ep_fifo_flush(struct usb_ep *_ep)
writel(flush_bit, &dev->op_regs->endptflush);
while (readl(&dev->op_regs->endptflush)) {
if (time_after(jiffies, timeout)) {
- ERROR(dev, "ep flush timeout\n");
+ dev_err(&dev->pdev->dev, "ep flush timeout\n");
goto done;
}
cpu_relax();
}
} while (readl(&dev->op_regs->endptstat) & flush_bit);
done:
- VDBG(dev, "<--- %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
}
@@ -1167,31 +1149,59 @@ static int langwell_get_frame(struct usb_gadget *_gadget)
return -ENODEV;
dev = container_of(_gadget, struct langwell_udc, gadget);
- VDBG(dev, "---> %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
retval = readl(&dev->op_regs->frindex) & FRINDEX_MASK;
- VDBG(dev, "<--- %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return retval;
}
+/* enter or exit PHY low power state */
+static void langwell_phy_low_power(struct langwell_udc *dev, bool flag)
+{
+ u32 devlc;
+ u8 devlc_byte2;
+ dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
+
+ devlc = readl(&dev->op_regs->devlc);
+ dev_vdbg(&dev->pdev->dev, "devlc = 0x%08x\n", devlc);
+
+ if (flag)
+ devlc |= LPM_PHCD;
+ else
+ devlc &= ~LPM_PHCD;
+
+ /* FIXME: workaround for Langwell A1/A2/A3 sighting */
+ devlc_byte2 = (devlc >> 16) & 0xff;
+ writeb(devlc_byte2, (u8 *)&dev->op_regs->devlc + 2);
+
+ devlc = readl(&dev->op_regs->devlc);
+ dev_vdbg(&dev->pdev->dev,
+ "%s PHY low power suspend, devlc = 0x%08x\n",
+ flag ? "enter" : "exit", devlc);
+}
+
+
/* tries to wake up the host connected to this gadget */
static int langwell_wakeup(struct usb_gadget *_gadget)
{
struct langwell_udc *dev;
- u32 portsc1, devlc;
- unsigned long flags;
+ u32 portsc1;
+ unsigned long flags;
if (!_gadget)
return 0;
dev = container_of(_gadget, struct langwell_udc, gadget);
- VDBG(dev, "---> %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
- /* Remote Wakeup feature not enabled by host */
- if (!dev->remote_wakeup)
+ /* remote wakeup feature not enabled by host */
+ if (!dev->remote_wakeup) {
+ dev_info(&dev->pdev->dev, "remote wakeup is disabled\n");
return -ENOTSUPP;
+ }
spin_lock_irqsave(&dev->lock, flags);
@@ -1201,27 +1211,23 @@ static int langwell_wakeup(struct usb_gadget *_gadget)
return 0;
}
- /* LPM L1 to L0, remote wakeup */
- if (dev->lpm && dev->lpm_state == LPM_L1) {
- portsc1 |= PORTS_SLP;
- writel(portsc1, &dev->op_regs->portsc1);
- }
-
- /* force port resume */
- if (dev->usb_state == USB_STATE_SUSPENDED) {
- portsc1 |= PORTS_FPR;
- writel(portsc1, &dev->op_regs->portsc1);
- }
+ /* LPM L1 to L0 or legacy remote wakeup */
+ if (dev->lpm && dev->lpm_state == LPM_L1)
+ dev_info(&dev->pdev->dev, "LPM L1 to L0 remote wakeup\n");
+ else
+ dev_info(&dev->pdev->dev, "device remote wakeup\n");
/* exit PHY low power suspend */
- devlc = readl(&dev->op_regs->devlc);
- VDBG(dev, "devlc = 0x%08x\n", devlc);
- devlc &= ~LPM_PHCD;
- writel(devlc, &dev->op_regs->devlc);
+ if (dev->pdev->device != 0x0829)
+ langwell_phy_low_power(dev, 0);
+
+ /* force port resume */
+ portsc1 |= PORTS_FPR;
+ writel(portsc1, &dev->op_regs->portsc1);
spin_unlock_irqrestore(&dev->lock, flags);
- VDBG(dev, "<--- %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return 0;
}
@@ -1231,16 +1237,17 @@ static int langwell_vbus_session(struct usb_gadget *_gadget, int is_active)
{
struct langwell_udc *dev;
unsigned long flags;
- u32 usbcmd;
+ u32 usbcmd;
if (!_gadget)
return -ENODEV;
dev = container_of(_gadget, struct langwell_udc, gadget);
- VDBG(dev, "---> %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
spin_lock_irqsave(&dev->lock, flags);
- VDBG(dev, "VBUS status: %s\n", is_active ? "on" : "off");
+ dev_vdbg(&dev->pdev->dev, "VBUS status: %s\n",
+ is_active ? "on" : "off");
dev->vbus_active = (is_active != 0);
if (dev->driver && dev->softconnected && dev->vbus_active) {
@@ -1255,7 +1262,7 @@ static int langwell_vbus_session(struct usb_gadget *_gadget, int is_active)
spin_unlock_irqrestore(&dev->lock, flags);
- VDBG(dev, "<--- %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return 0;
}
@@ -1269,15 +1276,15 @@ static int langwell_vbus_draw(struct usb_gadget *_gadget, unsigned mA)
return -ENODEV;
dev = container_of(_gadget, struct langwell_udc, gadget);
- VDBG(dev, "---> %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
if (dev->transceiver) {
- VDBG(dev, "otg_set_power\n");
- VDBG(dev, "<--- %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "otg_set_power\n");
+ dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return otg_set_power(dev->transceiver, mA);
}
- VDBG(dev, "<--- %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return -ENOTSUPP;
}
@@ -1286,15 +1293,15 @@ static int langwell_vbus_draw(struct usb_gadget *_gadget, unsigned mA)
static int langwell_pullup(struct usb_gadget *_gadget, int is_on)
{
struct langwell_udc *dev;
- u32 usbcmd;
- unsigned long flags;
+ u32 usbcmd;
+ unsigned long flags;
if (!_gadget)
return -ENODEV;
dev = container_of(_gadget, struct langwell_udc, gadget);
- VDBG(dev, "---> %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
spin_lock_irqsave(&dev->lock, flags);
dev->softconnected = (is_on != 0);
@@ -1310,7 +1317,7 @@ static int langwell_pullup(struct usb_gadget *_gadget, int is_on)
}
spin_unlock_irqrestore(&dev->lock, flags);
- VDBG(dev, "<--- %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return 0;
}
@@ -1346,12 +1353,13 @@ static const struct usb_gadget_ops langwell_ops = {
static int langwell_udc_reset(struct langwell_udc *dev)
{
u32 usbcmd, usbmode, devlc, endpointlistaddr;
+ u8 devlc_byte0, devlc_byte2;
unsigned long timeout;
if (!dev)
return -EINVAL;
- DBG(dev, "---> %s()\n", __func__);
+ dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
/* set controller to stop state */
usbcmd = readl(&dev->op_regs->usbcmd);
@@ -1367,7 +1375,7 @@ static int langwell_udc_reset(struct langwell_udc *dev)
timeout = jiffies + RESET_TIMEOUT;
while (readl(&dev->op_regs->usbcmd) & CMD_RST) {
if (time_after(jiffies, timeout)) {
- ERROR(dev, "device reset timeout\n");
+ dev_err(&dev->pdev->dev, "device reset timeout\n");
return -ETIMEDOUT;
}
cpu_relax();
@@ -1382,7 +1390,7 @@ static int langwell_udc_reset(struct langwell_udc *dev)
writel(usbmode, &dev->op_regs->usbmode);
usbmode = readl(&dev->op_regs->usbmode);
- VDBG(dev, "usbmode=0x%08x\n", usbmode);
+ dev_vdbg(&dev->pdev->dev, "usbmode=0x%08x\n", usbmode);
/* Write-Clear setup status */
writel(0, &dev->op_regs->usbsts);
@@ -1390,9 +1398,17 @@ static int langwell_udc_reset(struct langwell_udc *dev)
/* if support USB LPM, ACK all LPM token */
if (dev->lpm) {
devlc = readl(&dev->op_regs->devlc);
+ dev_vdbg(&dev->pdev->dev, "devlc = 0x%08x\n", devlc);
+ /* FIXME: workaround for Langwell A1/A2/A3 sighting */
devlc &= ~LPM_STL; /* don't STALL LPM token */
devlc &= ~LPM_NYT_ACK; /* ACK LPM token */
- writel(devlc, &dev->op_regs->devlc);
+ devlc_byte0 = devlc & 0xff;
+ devlc_byte2 = (devlc >> 16) & 0xff;
+ writeb(devlc_byte0, (u8 *)&dev->op_regs->devlc);
+ writeb(devlc_byte2, (u8 *)&dev->op_regs->devlc + 2);
+ devlc = readl(&dev->op_regs->devlc);
+ dev_vdbg(&dev->pdev->dev,
+ "ACK LPM token, devlc = 0x%08x\n", devlc);
}
/* fill endpointlistaddr register */
@@ -1400,10 +1416,11 @@ static int langwell_udc_reset(struct langwell_udc *dev)
endpointlistaddr &= ENDPOINTLISTADDR_MASK;
writel(endpointlistaddr, &dev->op_regs->endpointlistaddr);
- VDBG(dev, "dQH base (vir: %p, phy: 0x%08x), endpointlistaddr=0x%08x\n",
- dev->ep_dqh, endpointlistaddr,
- readl(&dev->op_regs->endpointlistaddr));
- DBG(dev, "<--- %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev,
+ "dQH base (vir: %p, phy: 0x%08x), endpointlistaddr=0x%08x\n",
+ dev->ep_dqh, endpointlistaddr,
+ readl(&dev->op_regs->endpointlistaddr));
+ dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return 0;
}
@@ -1415,7 +1432,7 @@ static int eps_reinit(struct langwell_udc *dev)
char name[14];
int i;
- VDBG(dev, "---> %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
/* initialize ep0 */
ep = &dev->ep[0];
@@ -1449,11 +1466,9 @@ static int eps_reinit(struct langwell_udc *dev)
INIT_LIST_HEAD(&ep->queue);
list_add_tail(&ep->ep.ep_list, &dev->gadget.ep_list);
-
- ep->dqh = &dev->ep_dqh[i];
}
- VDBG(dev, "<--- %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return 0;
}
@@ -1462,7 +1477,7 @@ static int eps_reinit(struct langwell_udc *dev)
static void langwell_udc_start(struct langwell_udc *dev)
{
u32 usbintr, usbcmd;
- DBG(dev, "---> %s()\n", __func__);
+ dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
/* enable interrupts */
usbintr = INTR_ULPIE /* ULPI */
@@ -1485,8 +1500,7 @@ static void langwell_udc_start(struct langwell_udc *dev)
usbcmd |= CMD_RUNSTOP;
writel(usbcmd, &dev->op_regs->usbcmd);
- DBG(dev, "<--- %s()\n", __func__);
- return;
+ dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
}
@@ -1495,7 +1509,7 @@ static void langwell_udc_stop(struct langwell_udc *dev)
{
u32 usbcmd;
- DBG(dev, "---> %s()\n", __func__);
+ dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
/* disable all interrupts */
writel(0, &dev->op_regs->usbintr);
@@ -1508,8 +1522,7 @@ static void langwell_udc_stop(struct langwell_udc *dev)
usbcmd &= ~CMD_RUNSTOP;
writel(usbcmd, &dev->op_regs->usbcmd);
- DBG(dev, "<--- %s()\n", __func__);
- return;
+ dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
}
@@ -1518,7 +1531,7 @@ static void stop_activity(struct langwell_udc *dev,
struct usb_gadget_driver *driver)
{
struct langwell_ep *ep;
- DBG(dev, "---> %s()\n", __func__);
+ dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
nuke(&dev->ep[0], -ESHUTDOWN);
@@ -1533,7 +1546,7 @@ static void stop_activity(struct langwell_udc *dev,
spin_lock(&dev->lock);
}
- DBG(dev, "<--- %s()\n", __func__);
+ dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
}
@@ -1659,13 +1672,15 @@ static ssize_t show_langwell_udc(struct device *_dev,
"Over-current Change: %s\n"
"Port Enable/Disable Change: %s\n"
"Port Enabled/Disabled: %s\n"
- "Current Connect Status: %s\n\n",
+ "Current Connect Status: %s\n"
+ "LPM Suspend Status: %s\n\n",
(tmp_reg & PORTS_PR) ? "Reset" : "Not Reset",
(tmp_reg & PORTS_SUSP) ? "Suspend " : "Not Suspend",
(tmp_reg & PORTS_OCC) ? "Detected" : "No",
(tmp_reg & PORTS_PEC) ? "Changed" : "Not Changed",
(tmp_reg & PORTS_PE) ? "Enable" : "Not Correct",
- (tmp_reg & PORTS_CCS) ? "Attached" : "Not Attached");
+ (tmp_reg & PORTS_CCS) ? "Attached" : "Not Attached",
+ (tmp_reg & PORTS_SLP) ? "LPM L1" : "LPM L0");
size -= t;
next += t;
@@ -1676,7 +1691,7 @@ static ssize_t show_langwell_udc(struct device *_dev,
"Serial Transceiver : %d\n"
"Port Speed: %s\n"
"Port Force Full Speed Connenct: %s\n"
- "PHY Low Power Suspend Clock Disable: %s\n"
+ "PHY Low Power Suspend Clock: %s\n"
"BmAttributes: %d\n\n",
LPM_PTS(tmp_reg),
(tmp_reg & LPM_STS) ? 1 : 0,
@@ -1797,6 +1812,36 @@ static ssize_t show_langwell_udc(struct device *_dev,
static DEVICE_ATTR(langwell_udc, S_IRUGO, show_langwell_udc, NULL);
+/* device "remote_wakeup" sysfs attribute file */
+static ssize_t store_remote_wakeup(struct device *_dev,
+ struct device_attribute *attr, const char *buf, size_t count)
+{
+ struct langwell_udc *dev = the_controller;
+ unsigned long flags;
+ ssize_t rc = count;
+
+ if (count > 2)
+ return -EINVAL;
+
+ if (count > 0 && buf[count-1] == '\n')
+ ((char *) buf)[count-1] = 0;
+
+ if (buf[0] != '1')
+ return -EINVAL;
+
+ /* force remote wakeup enabled in case gadget driver doesn't support */
+ spin_lock_irqsave(&dev->lock, flags);
+ dev->remote_wakeup = 1;
+ dev->dev_status |= (1 << USB_DEVICE_REMOTE_WAKEUP);
+ spin_unlock_irqrestore(&dev->lock, flags);
+
+ langwell_wakeup(&dev->gadget);
+
+ return rc;
+}
+static DEVICE_ATTR(remote_wakeup, S_IWUSR, NULL, store_remote_wakeup);
+
+
/*-------------------------------------------------------------------------*/
/*
@@ -1807,7 +1852,8 @@ static DEVICE_ATTR(langwell_udc, S_IRUGO, show_langwell_udc, NULL);
* the driver might get unbound.
*/
-int usb_gadget_register_driver(struct usb_gadget_driver *driver)
+int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
+ int (*bind)(struct usb_gadget *))
{
struct langwell_udc *dev = the_controller;
unsigned long flags;
@@ -1816,7 +1862,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
if (!dev)
return -ENODEV;
- DBG(dev, "---> %s()\n", __func__);
+ dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
if (dev->driver)
return -EBUSY;
@@ -1830,9 +1876,9 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
spin_unlock_irqrestore(&dev->lock, flags);
- retval = driver->bind(&dev->gadget);
+ retval = bind(&dev->gadget);
if (retval) {
- DBG(dev, "bind to driver %s --> %d\n",
+ dev_dbg(&dev->pdev->dev, "bind to driver %s --> %d\n",
driver->driver.name, retval);
dev->driver = NULL;
dev->gadget.dev.driver = NULL;
@@ -1851,13 +1897,13 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
if (dev->got_irq)
langwell_udc_start(dev);
- VDBG(dev, "After langwell_udc_start(), print all registers:\n");
-#ifdef VERBOSE
+ dev_vdbg(&dev->pdev->dev,
+ "After langwell_udc_start(), print all registers:\n");
print_all_registers(dev);
-#endif
- INFO(dev, "register driver: %s\n", driver->driver.name);
- VDBG(dev, "<--- %s()\n", __func__);
+ dev_info(&dev->pdev->dev, "register driver: %s\n",
+ driver->driver.name);
+ dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return 0;
err_unbind:
@@ -1865,10 +1911,10 @@ err_unbind:
dev->gadget.dev.driver = NULL;
dev->driver = NULL;
- DBG(dev, "<--- %s()\n", __func__);
+ dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return retval;
}
-EXPORT_SYMBOL(usb_gadget_register_driver);
+EXPORT_SYMBOL(usb_gadget_probe_driver);
/* unregister gadget driver */
@@ -1880,11 +1926,15 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
if (!dev)
return -ENODEV;
- DBG(dev, "---> %s()\n", __func__);
+ dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
- if (unlikely(!driver || !driver->bind || !driver->unbind))
+ if (unlikely(!driver || !driver->unbind))
return -EINVAL;
+ /* exit PHY low power suspend */
+ if (dev->pdev->device != 0x0829)
+ langwell_phy_low_power(dev, 0);
+
/* unbind OTG transceiver */
if (dev->transceiver)
(void)otg_set_peripheral(dev->transceiver, 0);
@@ -1910,8 +1960,9 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
device_remove_file(&dev->pdev->dev, &dev_attr_function);
- INFO(dev, "unregistered driver '%s'\n", driver->driver.name);
- DBG(dev, "<--- %s()\n", __func__);
+ dev_info(&dev->pdev->dev, "unregistered driver '%s'\n",
+ driver->driver.name);
+ dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return 0;
}
EXPORT_SYMBOL(usb_gadget_unregister_driver);
@@ -1930,7 +1981,7 @@ static void setup_tripwire(struct langwell_udc *dev)
unsigned long timeout;
struct langwell_dqh *dqh;
- VDBG(dev, "---> %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
/* ep0 OUT dQH */
dqh = &dev->ep_dqh[EP_DIR_OUT];
@@ -1943,7 +1994,7 @@ static void setup_tripwire(struct langwell_udc *dev)
timeout = jiffies + SETUPSTAT_TIMEOUT;
while (readl(&dev->op_regs->endptsetupstat)) {
if (time_after(jiffies, timeout)) {
- ERROR(dev, "setup_tripwire timeout\n");
+ dev_err(&dev->pdev->dev, "setup_tripwire timeout\n");
break;
}
cpu_relax();
@@ -1963,7 +2014,7 @@ static void setup_tripwire(struct langwell_udc *dev)
usbcmd = readl(&dev->op_regs->usbcmd);
writel(usbcmd & ~CMD_SUTW, &dev->op_regs->usbcmd);
- VDBG(dev, "<--- %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
}
@@ -1972,7 +2023,7 @@ static void ep0_stall(struct langwell_udc *dev)
{
u32 endptctrl;
- VDBG(dev, "---> %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
/* set TX and RX to stall */
endptctrl = readl(&dev->op_regs->endptctrl[0]);
@@ -1983,7 +2034,7 @@ static void ep0_stall(struct langwell_udc *dev)
dev->ep0_state = WAIT_FOR_SETUP;
dev->ep0_dir = USB_DIR_OUT;
- VDBG(dev, "<--- %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
}
@@ -1994,7 +2045,7 @@ static int prime_status_phase(struct langwell_udc *dev, int dir)
struct langwell_ep *ep;
int status = 0;
- VDBG(dev, "---> %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
if (dir == EP_DIR_IN)
dev->ep0_dir = USB_DIR_IN;
@@ -2019,11 +2070,11 @@ static int prime_status_phase(struct langwell_udc *dev, int dir)
return -ENOMEM;
if (status)
- ERROR(dev, "can't queue ep0 status request\n");
+ dev_err(&dev->pdev->dev, "can't queue ep0 status request\n");
list_add_tail(&req->queue, &ep->queue);
- VDBG(dev, "<--- %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return status;
}
@@ -2032,11 +2083,11 @@ static int prime_status_phase(struct langwell_udc *dev, int dir)
static void set_address(struct langwell_udc *dev, u16 value,
u16 index, u16 length)
{
- VDBG(dev, "---> %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
/* save the new address to device struct */
dev->dev_addr = (u8) value;
- VDBG(dev, "dev->dev_addr = %d\n", dev->dev_addr);
+ dev_vdbg(&dev->pdev->dev, "dev->dev_addr = %d\n", dev->dev_addr);
/* update usb state */
dev->usb_state = USB_STATE_ADDRESS;
@@ -2045,7 +2096,7 @@ static void set_address(struct langwell_udc *dev, u16 value,
if (prime_status_phase(dev, EP_DIR_IN))
ep0_stall(dev);
- VDBG(dev, "<--- %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
}
@@ -2054,7 +2105,7 @@ static struct langwell_ep *get_ep_by_windex(struct langwell_udc *dev,
u16 wIndex)
{
struct langwell_ep *ep;
- VDBG(dev, "---> %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
if ((wIndex & USB_ENDPOINT_NUMBER_MASK) == 0)
return &dev->ep[0];
@@ -2073,7 +2124,7 @@ static struct langwell_ep *get_ep_by_windex(struct langwell_udc *dev,
return ep;
}
- VDBG(dev, "<--- %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return NULL;
}
@@ -2085,7 +2136,7 @@ static int ep_is_stall(struct langwell_ep *ep)
u32 endptctrl;
int retval;
- VDBG(dev, "---> %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
endptctrl = readl(&dev->op_regs->endptctrl[ep->ep_num]);
if (is_in(ep))
@@ -2093,7 +2144,7 @@ static int ep_is_stall(struct langwell_ep *ep)
else
retval = endptctrl & EPCTRL_RXS ? 1 : 0;
- VDBG(dev, "<--- %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return retval;
}
@@ -2107,14 +2158,13 @@ static void get_status(struct langwell_udc *dev, u8 request_type, u16 value,
u16 status_data = 0; /* 16 bits cpu view status data */
int status = 0;
- VDBG(dev, "---> %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
ep = &dev->ep[0];
if ((request_type & USB_RECIP_MASK) == USB_RECIP_DEVICE) {
/* get device status */
- status_data = 1 << USB_DEVICE_SELF_POWERED;
- status_data |= dev->remote_wakeup << USB_DEVICE_REMOTE_WAKEUP;
+ status_data = dev->dev_status;
} else if ((request_type & USB_RECIP_MASK) == USB_RECIP_INTERFACE) {
/* get interface status */
status_data = 0;
@@ -2129,6 +2179,8 @@ static void get_status(struct langwell_udc *dev, u8 request_type, u16 value,
status_data = ep_is_stall(epn) << USB_ENDPOINT_HALT;
}
+ dev_dbg(&dev->pdev->dev, "get status data: 0x%04x\n", status_data);
+
dev->ep0_dir = USB_DIR_IN;
/* borrow the per device status_req */
@@ -2150,18 +2202,19 @@ static void get_status(struct langwell_udc *dev, u8 request_type, u16 value,
goto stall;
if (status) {
- ERROR(dev, "response error on GET_STATUS request\n");
+ dev_err(&dev->pdev->dev,
+ "response error on GET_STATUS request\n");
goto stall;
}
list_add_tail(&req->queue, &ep->queue);
dev->ep0_state = DATA_STATE_XMIT;
- VDBG(dev, "<--- %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return;
stall:
ep0_stall(dev);
- VDBG(dev, "<--- %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
}
@@ -2173,12 +2226,12 @@ static void handle_setup_packet(struct langwell_udc *dev,
u16 wIndex = le16_to_cpu(setup->wIndex);
u16 wLength = le16_to_cpu(setup->wLength);
- VDBG(dev, "---> %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
/* ep0 fifo flush */
nuke(&dev->ep[0], -ESHUTDOWN);
- DBG(dev, "SETUP %02x.%02x v%04x i%04x l%04x\n",
+ dev_dbg(&dev->pdev->dev, "SETUP %02x.%02x v%04x i%04x l%04x\n",
setup->bRequestType, setup->bRequest,
wValue, wIndex, wLength);
@@ -2197,7 +2250,7 @@ static void handle_setup_packet(struct langwell_udc *dev,
/* We process some stardard setup requests here */
switch (setup->bRequest) {
case USB_REQ_GET_STATUS:
- DBG(dev, "SETUP: USB_REQ_GET_STATUS\n");
+ dev_dbg(&dev->pdev->dev, "SETUP: USB_REQ_GET_STATUS\n");
/* get status, DATA and STATUS phase */
if ((setup->bRequestType & (USB_DIR_IN | USB_TYPE_MASK))
!= (USB_DIR_IN | USB_TYPE_STANDARD))
@@ -2206,7 +2259,7 @@ static void handle_setup_packet(struct langwell_udc *dev,
goto end;
case USB_REQ_SET_ADDRESS:
- DBG(dev, "SETUP: USB_REQ_SET_ADDRESS\n");
+ dev_dbg(&dev->pdev->dev, "SETUP: USB_REQ_SET_ADDRESS\n");
/* STATUS phase */
if (setup->bRequestType != (USB_DIR_OUT | USB_TYPE_STANDARD
| USB_RECIP_DEVICE))
@@ -2220,9 +2273,11 @@ static void handle_setup_packet(struct langwell_udc *dev,
{
int rc = -EOPNOTSUPP;
if (setup->bRequest == USB_REQ_SET_FEATURE)
- DBG(dev, "SETUP: USB_REQ_SET_FEATURE\n");
+ dev_dbg(&dev->pdev->dev,
+ "SETUP: USB_REQ_SET_FEATURE\n");
else if (setup->bRequest == USB_REQ_CLEAR_FEATURE)
- DBG(dev, "SETUP: USB_REQ_CLEAR_FEATURE\n");
+ dev_dbg(&dev->pdev->dev,
+ "SETUP: USB_REQ_CLEAR_FEATURE\n");
if ((setup->bRequestType & (USB_RECIP_MASK | USB_TYPE_MASK))
== (USB_RECIP_ENDPOINT | USB_TYPE_STANDARD)) {
@@ -2240,13 +2295,29 @@ static void handle_setup_packet(struct langwell_udc *dev,
spin_unlock(&dev->lock);
rc = langwell_ep_set_halt(&epn->ep,
- (setup->bRequest == USB_REQ_SET_FEATURE)
- ? 1 : 0);
+ (setup->bRequest == USB_REQ_SET_FEATURE)
+ ? 1 : 0);
spin_lock(&dev->lock);
} else if ((setup->bRequestType & (USB_RECIP_MASK
| USB_TYPE_MASK)) == (USB_RECIP_DEVICE
| USB_TYPE_STANDARD)) {
+ rc = 0;
+ switch (wValue) {
+ case USB_DEVICE_REMOTE_WAKEUP:
+ if (setup->bRequest == USB_REQ_SET_FEATURE) {
+ dev->remote_wakeup = 1;
+ dev->dev_status |= (1 << wValue);
+ } else {
+ dev->remote_wakeup = 0;
+ dev->dev_status &= ~(1 << wValue);
+ }
+ break;
+ default:
+ rc = -EOPNOTSUPP;
+ break;
+ }
+
if (!gadget_is_otg(&dev->gadget))
break;
else if (setup->bRequest == USB_DEVICE_B_HNP_ENABLE) {
@@ -2262,7 +2333,6 @@ static void handle_setup_packet(struct langwell_udc *dev,
dev->gadget.a_alt_hnp_support = 1;
else
break;
- rc = 0;
} else
break;
@@ -2274,31 +2344,38 @@ static void handle_setup_packet(struct langwell_udc *dev,
}
case USB_REQ_GET_DESCRIPTOR:
- DBG(dev, "SETUP: USB_REQ_GET_DESCRIPTOR\n");
+ dev_dbg(&dev->pdev->dev,
+ "SETUP: USB_REQ_GET_DESCRIPTOR\n");
goto delegate;
case USB_REQ_SET_DESCRIPTOR:
- DBG(dev, "SETUP: USB_REQ_SET_DESCRIPTOR unsupported\n");
+ dev_dbg(&dev->pdev->dev,
+ "SETUP: USB_REQ_SET_DESCRIPTOR unsupported\n");
goto delegate;
case USB_REQ_GET_CONFIGURATION:
- DBG(dev, "SETUP: USB_REQ_GET_CONFIGURATION\n");
+ dev_dbg(&dev->pdev->dev,
+ "SETUP: USB_REQ_GET_CONFIGURATION\n");
goto delegate;
case USB_REQ_SET_CONFIGURATION:
- DBG(dev, "SETUP: USB_REQ_SET_CONFIGURATION\n");
+ dev_dbg(&dev->pdev->dev,
+ "SETUP: USB_REQ_SET_CONFIGURATION\n");
goto delegate;
case USB_REQ_GET_INTERFACE:
- DBG(dev, "SETUP: USB_REQ_GET_INTERFACE\n");
+ dev_dbg(&dev->pdev->dev,
+ "SETUP: USB_REQ_GET_INTERFACE\n");
goto delegate;
case USB_REQ_SET_INTERFACE:
- DBG(dev, "SETUP: USB_REQ_SET_INTERFACE\n");
+ dev_dbg(&dev->pdev->dev,
+ "SETUP: USB_REQ_SET_INTERFACE\n");
goto delegate;
case USB_REQ_SYNCH_FRAME:
- DBG(dev, "SETUP: USB_REQ_SYNCH_FRAME unsupported\n");
+ dev_dbg(&dev->pdev->dev,
+ "SETUP: USB_REQ_SYNCH_FRAME unsupported\n");
goto delegate;
default:
@@ -2310,7 +2387,8 @@ delegate:
/* DATA phase from gadget, STATUS phase from udc */
dev->ep0_dir = (setup->bRequestType & USB_DIR_IN)
? USB_DIR_IN : USB_DIR_OUT;
- VDBG(dev, "dev->ep0_dir = 0x%x, wLength = %d\n",
+ dev_vdbg(&dev->pdev->dev,
+ "dev->ep0_dir = 0x%x, wLength = %d\n",
dev->ep0_dir, wLength);
spin_unlock(&dev->lock);
if (dev->driver->setup(&dev->gadget,
@@ -2322,7 +2400,8 @@ delegate:
} else {
/* no DATA phase, IN STATUS phase from gadget */
dev->ep0_dir = USB_DIR_IN;
- VDBG(dev, "dev->ep0_dir = 0x%x, wLength = %d\n",
+ dev_vdbg(&dev->pdev->dev,
+ "dev->ep0_dir = 0x%x, wLength = %d\n",
dev->ep0_dir, wLength);
spin_unlock(&dev->lock);
if (dev->driver->setup(&dev->gadget,
@@ -2334,8 +2413,7 @@ delegate:
break;
}
end:
- VDBG(dev, "<--- %s()\n", __func__);
- return;
+ dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
}
@@ -2359,23 +2437,27 @@ static int process_ep_req(struct langwell_udc *dev, int index,
td_complete = 0;
actual = curr_req->req.length;
- VDBG(dev, "---> %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
for (i = 0; i < curr_req->dtd_count; i++) {
- remaining_length = le16_to_cpu(curr_dtd->dtd_total);
- actual -= remaining_length;
/* command execution states by dTD */
dtd_status = curr_dtd->dtd_status;
+ barrier();
+ remaining_length = le16_to_cpu(curr_dtd->dtd_total);
+ actual -= remaining_length;
+
if (!dtd_status) {
/* transfers completed successfully */
if (!remaining_length) {
td_complete++;
- VDBG(dev, "dTD transmitted successfully\n");
+ dev_vdbg(&dev->pdev->dev,
+ "dTD transmitted successfully\n");
} else {
if (dir) {
- VDBG(dev, "TX dTD remains data\n");
+ dev_vdbg(&dev->pdev->dev,
+ "TX dTD remains data\n");
retval = -EPROTO;
break;
@@ -2387,27 +2469,32 @@ static int process_ep_req(struct langwell_udc *dev, int index,
} else {
/* transfers completed with errors */
if (dtd_status & DTD_STS_ACTIVE) {
- DBG(dev, "request not completed\n");
+ dev_dbg(&dev->pdev->dev,
+ "dTD status ACTIVE dQH[%d]\n", index);
retval = 1;
return retval;
} else if (dtd_status & DTD_STS_HALTED) {
- ERROR(dev, "dTD error %08x dQH[%d]\n",
- dtd_status, index);
+ dev_err(&dev->pdev->dev,
+ "dTD error %08x dQH[%d]\n",
+ dtd_status, index);
/* clear the errors and halt condition */
curr_dqh->dtd_status = 0;
retval = -EPIPE;
break;
} else if (dtd_status & DTD_STS_DBE) {
- DBG(dev, "data buffer (overflow) error\n");
+ dev_dbg(&dev->pdev->dev,
+ "data buffer (overflow) error\n");
retval = -EPROTO;
break;
} else if (dtd_status & DTD_STS_TRE) {
- DBG(dev, "transaction(ISO) error\n");
+ dev_dbg(&dev->pdev->dev,
+ "transaction(ISO) error\n");
retval = -EILSEQ;
break;
} else
- ERROR(dev, "unknown error (0x%x)!\n",
- dtd_status);
+ dev_err(&dev->pdev->dev,
+ "unknown error (0x%x)!\n",
+ dtd_status);
}
if (i != curr_req->dtd_count - 1)
@@ -2420,7 +2507,7 @@ static int process_ep_req(struct langwell_udc *dev, int index,
curr_req->req.actual = actual;
- VDBG(dev, "<--- %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return 0;
}
@@ -2430,7 +2517,7 @@ static void ep0_req_complete(struct langwell_udc *dev,
struct langwell_ep *ep0, struct langwell_request *req)
{
u32 new_addr;
- VDBG(dev, "---> %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
if (dev->usb_state == USB_STATE_ADDRESS) {
/* set the new address */
@@ -2438,7 +2525,7 @@ static void ep0_req_complete(struct langwell_udc *dev,
writel(new_addr << USBADR_SHIFT, &dev->op_regs->deviceaddr);
new_addr = USBADR(readl(&dev->op_regs->deviceaddr));
- VDBG(dev, "new_addr = %d\n", new_addr);
+ dev_vdbg(&dev->pdev->dev, "new_addr = %d\n", new_addr);
}
done(ep0, req, 0);
@@ -2458,14 +2545,14 @@ static void ep0_req_complete(struct langwell_udc *dev,
dev->ep0_state = WAIT_FOR_SETUP;
break;
case WAIT_FOR_SETUP:
- ERROR(dev, "unexpect ep0 packets\n");
+ dev_err(&dev->pdev->dev, "unexpect ep0 packets\n");
break;
default:
ep0_stall(dev);
break;
}
- VDBG(dev, "<--- %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
}
@@ -2477,16 +2564,17 @@ static void handle_trans_complete(struct langwell_udc *dev)
struct langwell_ep *epn;
struct langwell_request *curr_req, *temp_req;
- VDBG(dev, "---> %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
complete_bits = readl(&dev->op_regs->endptcomplete);
- VDBG(dev, "endptcomplete register: 0x%08x\n", complete_bits);
+ dev_vdbg(&dev->pdev->dev, "endptcomplete register: 0x%08x\n",
+ complete_bits);
/* Write-Clear the bits in endptcomplete register */
writel(complete_bits, &dev->op_regs->endptcomplete);
if (!complete_bits) {
- DBG(dev, "complete_bits = 0\n");
+ dev_dbg(&dev->pdev->dev, "complete_bits = 0\n");
goto done;
}
@@ -2506,23 +2594,25 @@ static void handle_trans_complete(struct langwell_udc *dev)
epn = &dev->ep[i];
if (epn->name == NULL) {
- WARNING(dev, "invalid endpoint\n");
+ dev_warn(&dev->pdev->dev, "invalid endpoint\n");
continue;
}
if (i < 2)
/* ep0 in and out */
- DBG(dev, "%s-%s transfer completed\n",
+ dev_dbg(&dev->pdev->dev, "%s-%s transfer completed\n",
epn->name,
is_in(epn) ? "in" : "out");
else
- DBG(dev, "%s transfer completed\n", epn->name);
+ dev_dbg(&dev->pdev->dev, "%s transfer completed\n",
+ epn->name);
/* process the req queue until an uncomplete request */
list_for_each_entry_safe(curr_req, temp_req,
&epn->queue, queue) {
status = process_ep_req(dev, i, curr_req);
- VDBG(dev, "%s req status: %d\n", epn->name, status);
+ dev_vdbg(&dev->pdev->dev, "%s req status: %d\n",
+ epn->name, status);
if (status)
break;
@@ -2540,8 +2630,7 @@ static void handle_trans_complete(struct langwell_udc *dev)
}
}
done:
- VDBG(dev, "<--- %s()\n", __func__);
- return;
+ dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
}
@@ -2551,14 +2640,14 @@ static void handle_port_change(struct langwell_udc *dev)
u32 portsc1, devlc;
u32 speed;
- VDBG(dev, "---> %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
if (dev->bus_reset)
dev->bus_reset = 0;
portsc1 = readl(&dev->op_regs->portsc1);
devlc = readl(&dev->op_regs->devlc);
- VDBG(dev, "portsc1 = 0x%08x, devlc = 0x%08x\n",
+ dev_vdbg(&dev->pdev->dev, "portsc1 = 0x%08x, devlc = 0x%08x\n",
portsc1, devlc);
/* bus reset is finished */
@@ -2579,25 +2668,22 @@ static void handle_port_change(struct langwell_udc *dev)
dev->gadget.speed = USB_SPEED_UNKNOWN;
break;
}
- VDBG(dev, "speed = %d, dev->gadget.speed = %d\n",
+ dev_vdbg(&dev->pdev->dev,
+ "speed = %d, dev->gadget.speed = %d\n",
speed, dev->gadget.speed);
}
/* LPM L0 to L1 */
if (dev->lpm && dev->lpm_state == LPM_L0)
if (portsc1 & PORTS_SUSP && portsc1 & PORTS_SLP) {
- INFO(dev, "LPM L0 to L1\n");
- dev->lpm_state = LPM_L1;
+ dev_info(&dev->pdev->dev, "LPM L0 to L1\n");
+ dev->lpm_state = LPM_L1;
}
/* LPM L1 to L0, force resume or remote wakeup finished */
if (dev->lpm && dev->lpm_state == LPM_L1)
if (!(portsc1 & PORTS_SUSP)) {
- if (portsc1 & PORTS_SLP)
- INFO(dev, "LPM L1 to L0, force resume\n");
- else
- INFO(dev, "LPM L1 to L0, remote wakeup\n");
-
+ dev_info(&dev->pdev->dev, "LPM L1 to L0\n");
dev->lpm_state = LPM_L0;
}
@@ -2605,7 +2691,7 @@ static void handle_port_change(struct langwell_udc *dev)
if (!dev->resume_state)
dev->usb_state = USB_STATE_DEFAULT;
- VDBG(dev, "<--- %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
}
@@ -2617,7 +2703,7 @@ static void handle_usb_reset(struct langwell_udc *dev)
endptcomplete;
unsigned long timeout;
- VDBG(dev, "---> %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
/* Write-Clear the device address */
deviceaddr = readl(&dev->op_regs->deviceaddr);
@@ -2634,7 +2720,10 @@ static void handle_usb_reset(struct langwell_udc *dev)
dev->ep0_dir = USB_DIR_OUT;
dev->ep0_state = WAIT_FOR_SETUP;
- dev->remote_wakeup = 0; /* default to 0 on reset */
+
+ /* remote wakeup reset to 0 when the device is reset */
+ dev->remote_wakeup = 0;
+ dev->dev_status = 1 << USB_DEVICE_SELF_POWERED;
dev->gadget.b_hnp_enable = 0;
dev->gadget.a_hnp_support = 0;
dev->gadget.a_alt_hnp_support = 0;
@@ -2651,7 +2740,7 @@ static void handle_usb_reset(struct langwell_udc *dev)
timeout = jiffies + PRIME_TIMEOUT;
while (readl(&dev->op_regs->endptprime)) {
if (time_after(jiffies, timeout)) {
- ERROR(dev, "USB reset timeout\n");
+ dev_err(&dev->pdev->dev, "USB reset timeout\n");
break;
}
cpu_relax();
@@ -2661,7 +2750,7 @@ static void handle_usb_reset(struct langwell_udc *dev)
writel((u32) ~0, &dev->op_regs->endptflush);
if (readl(&dev->op_regs->portsc1) & PORTS_PR) {
- VDBG(dev, "USB bus reset\n");
+ dev_vdbg(&dev->pdev->dev, "USB bus reset\n");
/* bus is reseting */
dev->bus_reset = 1;
@@ -2669,7 +2758,7 @@ static void handle_usb_reset(struct langwell_udc *dev)
stop_activity(dev, dev->driver);
dev->usb_state = USB_STATE_DEFAULT;
} else {
- VDBG(dev, "device controller reset\n");
+ dev_vdbg(&dev->pdev->dev, "device controller reset\n");
/* controller reset */
langwell_udc_reset(dev);
@@ -2691,15 +2780,14 @@ static void handle_usb_reset(struct langwell_udc *dev)
dev->lotg->hsm.b_hnp_enable = 0;
#endif
- VDBG(dev, "<--- %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
}
/* USB bus suspend/resume interrupt */
static void handle_bus_suspend(struct langwell_udc *dev)
{
- u32 devlc;
- DBG(dev, "---> %s()\n", __func__);
+ dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
dev->resume_state = dev->usb_state;
dev->usb_state = USB_STATE_SUSPENDED;
@@ -2733,33 +2821,29 @@ static void handle_bus_suspend(struct langwell_udc *dev)
spin_unlock(&dev->lock);
dev->driver->suspend(&dev->gadget);
spin_lock(&dev->lock);
- DBG(dev, "suspend %s\n", dev->driver->driver.name);
+ dev_dbg(&dev->pdev->dev, "suspend %s\n",
+ dev->driver->driver.name);
}
}
/* enter PHY low power suspend */
- devlc = readl(&dev->op_regs->devlc);
- VDBG(dev, "devlc = 0x%08x\n", devlc);
- devlc |= LPM_PHCD;
- writel(devlc, &dev->op_regs->devlc);
+ if (dev->pdev->device != 0x0829)
+ langwell_phy_low_power(dev, 0);
- DBG(dev, "<--- %s()\n", __func__);
+ dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
}
static void handle_bus_resume(struct langwell_udc *dev)
{
- u32 devlc;
- DBG(dev, "---> %s()\n", __func__);
+ dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
dev->usb_state = dev->resume_state;
dev->resume_state = 0;
/* exit PHY low power suspend */
- devlc = readl(&dev->op_regs->devlc);
- VDBG(dev, "devlc = 0x%08x\n", devlc);
- devlc &= ~LPM_PHCD;
- writel(devlc, &dev->op_regs->devlc);
+ if (dev->pdev->device != 0x0829)
+ langwell_phy_low_power(dev, 0);
#ifdef OTG_TRANSCEIVER
if (dev->lotg->otg.default_a == 0)
@@ -2772,11 +2856,12 @@ static void handle_bus_resume(struct langwell_udc *dev)
spin_unlock(&dev->lock);
dev->driver->resume(&dev->gadget);
spin_lock(&dev->lock);
- DBG(dev, "resume %s\n", dev->driver->driver.name);
+ dev_dbg(&dev->pdev->dev, "resume %s\n",
+ dev->driver->driver.name);
}
}
- DBG(dev, "<--- %s()\n", __func__);
+ dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
}
@@ -2789,11 +2874,11 @@ static irqreturn_t langwell_irq(int irq, void *_dev)
irq_sts,
portsc1;
- VDBG(dev, "---> %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "---> %s()\n", __func__);
if (dev->stopped) {
- VDBG(dev, "handle IRQ_NONE\n");
- VDBG(dev, "<--- %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "handle IRQ_NONE\n");
+ dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return IRQ_NONE;
}
@@ -2806,12 +2891,13 @@ static irqreturn_t langwell_irq(int irq, void *_dev)
usbintr = readl(&dev->op_regs->usbintr);
irq_sts = usbsts & usbintr;
- VDBG(dev, "usbsts = 0x%08x, usbintr = 0x%08x, irq_sts = 0x%08x\n",
+ dev_vdbg(&dev->pdev->dev,
+ "usbsts = 0x%08x, usbintr = 0x%08x, irq_sts = 0x%08x\n",
usbsts, usbintr, irq_sts);
if (!irq_sts) {
- VDBG(dev, "handle IRQ_NONE\n");
- VDBG(dev, "<--- %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "handle IRQ_NONE\n");
+ dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
spin_unlock(&dev->lock);
return IRQ_NONE;
}
@@ -2827,12 +2913,13 @@ static irqreturn_t langwell_irq(int irq, void *_dev)
/* USB interrupt */
if (irq_sts & STS_UI) {
- VDBG(dev, "USB interrupt\n");
+ dev_vdbg(&dev->pdev->dev, "USB interrupt\n");
/* setup packet received from ep0 */
if (readl(&dev->op_regs->endptsetupstat)
& EP0SETUPSTAT_MASK) {
- VDBG(dev, "USB SETUP packet received interrupt\n");
+ dev_vdbg(&dev->pdev->dev,
+ "USB SETUP packet received interrupt\n");
/* setup tripwire semaphone */
setup_tripwire(dev);
handle_setup_packet(dev, &dev->local_setup_buff);
@@ -2840,7 +2927,8 @@ static irqreturn_t langwell_irq(int irq, void *_dev)
/* USB transfer completion */
if (readl(&dev->op_regs->endptcomplete)) {
- VDBG(dev, "USB transfer completion interrupt\n");
+ dev_vdbg(&dev->pdev->dev,
+ "USB transfer completion interrupt\n");
handle_trans_complete(dev);
}
}
@@ -2848,36 +2936,36 @@ static irqreturn_t langwell_irq(int irq, void *_dev)
/* SOF received interrupt (for ISO transfer) */
if (irq_sts & STS_SRI) {
/* FIXME */
- /* VDBG(dev, "SOF received interrupt\n"); */
+ /* dev_vdbg(&dev->pdev->dev, "SOF received interrupt\n"); */
}
/* port change detect interrupt */
if (irq_sts & STS_PCI) {
- VDBG(dev, "port change detect interrupt\n");
+ dev_vdbg(&dev->pdev->dev, "port change detect interrupt\n");
handle_port_change(dev);
}
/* suspend interrrupt */
if (irq_sts & STS_SLI) {
- VDBG(dev, "suspend interrupt\n");
+ dev_vdbg(&dev->pdev->dev, "suspend interrupt\n");
handle_bus_suspend(dev);
}
/* USB reset interrupt */
if (irq_sts & STS_URI) {
- VDBG(dev, "USB reset interrupt\n");
+ dev_vdbg(&dev->pdev->dev, "USB reset interrupt\n");
handle_usb_reset(dev);
}
/* USB error or system error interrupt */
if (irq_sts & (STS_UEI | STS_SEI)) {
/* FIXME */
- WARNING(dev, "error IRQ, irq_sts: %x\n", irq_sts);
+ dev_warn(&dev->pdev->dev, "error IRQ, irq_sts: %x\n", irq_sts);
}
spin_unlock(&dev->lock);
- VDBG(dev, "<--- %s()\n", __func__);
+ dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return IRQ_HANDLED;
}
@@ -2889,15 +2977,59 @@ static void gadget_release(struct device *_dev)
{
struct langwell_udc *dev = the_controller;
- DBG(dev, "---> %s()\n", __func__);
+ dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
complete(dev->done);
- DBG(dev, "<--- %s()\n", __func__);
+ dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
kfree(dev);
}
+/* enable SRAM caching if SRAM detected */
+static void sram_init(struct langwell_udc *dev)
+{
+ struct pci_dev *pdev = dev->pdev;
+
+ dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
+
+ dev->sram_addr = pci_resource_start(pdev, 1);
+ dev->sram_size = pci_resource_len(pdev, 1);
+ dev_info(&dev->pdev->dev, "Found private SRAM at %x size:%x\n",
+ dev->sram_addr, dev->sram_size);
+ dev->got_sram = 1;
+
+ if (pci_request_region(pdev, 1, kobject_name(&pdev->dev.kobj))) {
+ dev_warn(&dev->pdev->dev, "SRAM request failed\n");
+ dev->got_sram = 0;
+ } else if (!dma_declare_coherent_memory(&pdev->dev, dev->sram_addr,
+ dev->sram_addr, dev->sram_size, DMA_MEMORY_MAP)) {
+ dev_warn(&dev->pdev->dev, "SRAM DMA declare failed\n");
+ pci_release_region(pdev, 1);
+ dev->got_sram = 0;
+ }
+
+ dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
+}
+
+
+/* release SRAM caching */
+static void sram_deinit(struct langwell_udc *dev)
+{
+ struct pci_dev *pdev = dev->pdev;
+
+ dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
+
+ dma_release_declared_memory(&pdev->dev);
+ pci_release_region(pdev, 1);
+
+ dev->got_sram = 0;
+
+ dev_info(&dev->pdev->dev, "release SRAM caching\n");
+ dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
+}
+
+
/* tear down the binding between this driver and the pci device */
static void langwell_udc_remove(struct pci_dev *pdev)
{
@@ -2906,23 +3038,29 @@ static void langwell_udc_remove(struct pci_dev *pdev)
DECLARE_COMPLETION(done);
BUG_ON(dev->driver);
- DBG(dev, "---> %s()\n", __func__);
+ dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
dev->done = &done;
- /* free memory allocated in probe */
+#ifndef OTG_TRANSCEIVER
+ /* free dTD dma_pool and dQH */
if (dev->dtd_pool)
dma_pool_destroy(dev->dtd_pool);
+ if (dev->ep_dqh)
+ dma_free_coherent(&pdev->dev, dev->ep_dqh_size,
+ dev->ep_dqh, dev->ep_dqh_dma);
+
+ /* release SRAM caching */
+ if (dev->has_sram && dev->got_sram)
+ sram_deinit(dev);
+#endif
+
if (dev->status_req) {
kfree(dev->status_req->req.buf);
kfree(dev->status_req);
}
- if (dev->ep_dqh)
- dma_free_coherent(&pdev->dev, dev->ep_dqh_size,
- dev->ep_dqh, dev->ep_dqh_dma);
-
kfree(dev->ep);
/* diable IRQ handler */
@@ -2949,11 +3087,12 @@ static void langwell_udc_remove(struct pci_dev *pdev)
dev->cap_regs = NULL;
- INFO(dev, "unbind\n");
- DBG(dev, "<--- %s()\n", __func__);
+ dev_info(&dev->pdev->dev, "unbind\n");
+ dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
device_unregister(&dev->gadget.dev);
device_remove_file(&pdev->dev, &dev_attr_langwell_udc);
+ device_remove_file(&pdev->dev, &dev_attr_remote_wakeup);
#ifndef OTG_TRANSCEIVER
pci_set_drvdata(pdev, NULL);
@@ -2997,7 +3136,7 @@ static int langwell_udc_probe(struct pci_dev *pdev,
spin_lock_init(&dev->lock);
dev->pdev = pdev;
- DBG(dev, "---> %s()\n", __func__);
+ dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
#ifdef OTG_TRANSCEIVER
/* PCI device is already enabled by otg_transceiver driver */
@@ -3022,7 +3161,7 @@ static int langwell_udc_probe(struct pci_dev *pdev,
resource = pci_resource_start(pdev, 0);
len = pci_resource_len(pdev, 0);
if (!request_mem_region(resource, len, driver_name)) {
- ERROR(dev, "controller already in use\n");
+ dev_err(&dev->pdev->dev, "controller already in use\n");
retval = -EBUSY;
goto error;
}
@@ -3031,33 +3170,43 @@ static int langwell_udc_probe(struct pci_dev *pdev,
base = ioremap_nocache(resource, len);
#endif
if (base == NULL) {
- ERROR(dev, "can't map memory\n");
+ dev_err(&dev->pdev->dev, "can't map memory\n");
retval = -EFAULT;
goto error;
}
dev->cap_regs = (struct langwell_cap_regs __iomem *) base;
- VDBG(dev, "dev->cap_regs: %p\n", dev->cap_regs);
+ dev_vdbg(&dev->pdev->dev, "dev->cap_regs: %p\n", dev->cap_regs);
dev->op_regs = (struct langwell_op_regs __iomem *)
(base + OP_REG_OFFSET);
- VDBG(dev, "dev->op_regs: %p\n", dev->op_regs);
+ dev_vdbg(&dev->pdev->dev, "dev->op_regs: %p\n", dev->op_regs);
/* irq setup after old hardware is cleaned up */
if (!pdev->irq) {
- ERROR(dev, "No IRQ. Check PCI setup!\n");
+ dev_err(&dev->pdev->dev, "No IRQ. Check PCI setup!\n");
retval = -ENODEV;
goto error;
}
+ dev->has_sram = 1;
+ dev->got_sram = 0;
+ dev_vdbg(&dev->pdev->dev, "dev->has_sram: %d\n", dev->has_sram);
+
#ifndef OTG_TRANSCEIVER
- INFO(dev, "irq %d, io mem: 0x%08lx, len: 0x%08lx, pci mem 0x%p\n",
+ /* enable SRAM caching if detected */
+ if (dev->has_sram && !dev->got_sram)
+ sram_init(dev);
+
+ dev_info(&dev->pdev->dev,
+ "irq %d, io mem: 0x%08lx, len: 0x%08lx, pci mem 0x%p\n",
pdev->irq, resource, len, base);
/* enables bus-mastering for device dev */
pci_set_master(pdev);
if (request_irq(pdev->irq, langwell_irq, IRQF_SHARED,
driver_name, dev) != 0) {
- ERROR(dev, "request interrupt %d failed\n", pdev->irq);
+ dev_err(&dev->pdev->dev,
+ "request interrupt %d failed\n", pdev->irq);
retval = -EBUSY;
goto error;
}
@@ -3071,32 +3220,34 @@ static int langwell_udc_probe(struct pci_dev *pdev,
dev->lpm = (readl(&dev->cap_regs->hccparams) & HCC_LEN) ? 1 : 0;
dev->dciversion = readw(&dev->cap_regs->dciversion);
dev->devcap = (readl(&dev->cap_regs->dccparams) & DEVCAP) ? 1 : 0;
- VDBG(dev, "dev->lpm: %d\n", dev->lpm);
- VDBG(dev, "dev->dciversion: 0x%04x\n", dev->dciversion);
- VDBG(dev, "dccparams: 0x%08x\n", readl(&dev->cap_regs->dccparams));
- VDBG(dev, "dev->devcap: %d\n", dev->devcap);
+ dev_vdbg(&dev->pdev->dev, "dev->lpm: %d\n", dev->lpm);
+ dev_vdbg(&dev->pdev->dev, "dev->dciversion: 0x%04x\n",
+ dev->dciversion);
+ dev_vdbg(&dev->pdev->dev, "dccparams: 0x%08x\n",
+ readl(&dev->cap_regs->dccparams));
+ dev_vdbg(&dev->pdev->dev, "dev->devcap: %d\n", dev->devcap);
if (!dev->devcap) {
- ERROR(dev, "can't support device mode\n");
+ dev_err(&dev->pdev->dev, "can't support device mode\n");
retval = -ENODEV;
goto error;
}
/* a pair of endpoints (out/in) for each address */
dev->ep_max = DEN(readl(&dev->cap_regs->dccparams)) * 2;
- VDBG(dev, "dev->ep_max: %d\n", dev->ep_max);
+ dev_vdbg(&dev->pdev->dev, "dev->ep_max: %d\n", dev->ep_max);
/* allocate endpoints memory */
dev->ep = kzalloc(sizeof(struct langwell_ep) * dev->ep_max,
GFP_KERNEL);
if (!dev->ep) {
- ERROR(dev, "allocate endpoints memory failed\n");
+ dev_err(&dev->pdev->dev, "allocate endpoints memory failed\n");
retval = -ENOMEM;
goto error;
}
/* allocate device dQH memory */
size = dev->ep_max * sizeof(struct langwell_dqh);
- VDBG(dev, "orig size = %d\n", size);
+ dev_vdbg(&dev->pdev->dev, "orig size = %d\n", size);
if (size < DQH_ALIGNMENT)
size = DQH_ALIGNMENT;
else if ((size % DQH_ALIGNMENT) != 0) {
@@ -3106,17 +3257,18 @@ static int langwell_udc_probe(struct pci_dev *pdev,
dev->ep_dqh = dma_alloc_coherent(&pdev->dev, size,
&dev->ep_dqh_dma, GFP_KERNEL);
if (!dev->ep_dqh) {
- ERROR(dev, "allocate dQH memory failed\n");
+ dev_err(&dev->pdev->dev, "allocate dQH memory failed\n");
retval = -ENOMEM;
goto error;
}
dev->ep_dqh_size = size;
- VDBG(dev, "ep_dqh_size = %d\n", dev->ep_dqh_size);
+ dev_vdbg(&dev->pdev->dev, "ep_dqh_size = %d\n", dev->ep_dqh_size);
/* initialize ep0 status request structure */
dev->status_req = kzalloc(sizeof(struct langwell_request), GFP_KERNEL);
if (!dev->status_req) {
- ERROR(dev, "allocate status_req memory failed\n");
+ dev_err(&dev->pdev->dev,
+ "allocate status_req memory failed\n");
retval = -ENOMEM;
goto error;
}
@@ -3129,7 +3281,10 @@ static int langwell_udc_probe(struct pci_dev *pdev,
dev->resume_state = USB_STATE_NOTATTACHED;
dev->usb_state = USB_STATE_POWERED;
dev->ep0_dir = USB_DIR_OUT;
- dev->remote_wakeup = 0; /* default to 0 on reset */
+
+ /* remote wakeup reset to 0 when the device is reset */
+ dev->remote_wakeup = 0;
+ dev->dev_status = 1 << USB_DEVICE_SELF_POWERED;
#ifndef OTG_TRANSCEIVER
/* reset device controller */
@@ -3174,18 +3329,20 @@ static int langwell_udc_probe(struct pci_dev *pdev,
}
/* done */
- INFO(dev, "%s\n", driver_desc);
- INFO(dev, "irq %d, pci mem %p\n", pdev->irq, base);
- INFO(dev, "Driver version: " DRIVER_VERSION "\n");
- INFO(dev, "Support (max) %d endpoints\n", dev->ep_max);
- INFO(dev, "Device interface version: 0x%04x\n", dev->dciversion);
- INFO(dev, "Controller mode: %s\n", dev->devcap ? "Device" : "Host");
- INFO(dev, "Support USB LPM: %s\n", dev->lpm ? "Yes" : "No");
-
- VDBG(dev, "After langwell_udc_probe(), print all registers:\n");
-#ifdef VERBOSE
+ dev_info(&dev->pdev->dev, "%s\n", driver_desc);
+ dev_info(&dev->pdev->dev, "irq %d, pci mem %p\n", pdev->irq, base);
+ dev_info(&dev->pdev->dev, "Driver version: " DRIVER_VERSION "\n");
+ dev_info(&dev->pdev->dev, "Support (max) %d endpoints\n", dev->ep_max);
+ dev_info(&dev->pdev->dev, "Device interface version: 0x%04x\n",
+ dev->dciversion);
+ dev_info(&dev->pdev->dev, "Controller mode: %s\n",
+ dev->devcap ? "Device" : "Host");
+ dev_info(&dev->pdev->dev, "Support USB LPM: %s\n",
+ dev->lpm ? "Yes" : "No");
+
+ dev_vdbg(&dev->pdev->dev,
+ "After langwell_udc_probe(), print all registers:\n");
print_all_registers(dev);
-#endif
the_controller = dev;
@@ -3197,12 +3354,18 @@ static int langwell_udc_probe(struct pci_dev *pdev,
if (retval)
goto error;
- VDBG(dev, "<--- %s()\n", __func__);
+ retval = device_create_file(&pdev->dev, &dev_attr_remote_wakeup);
+ if (retval)
+ goto error_attr1;
+
+ dev_vdbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return 0;
+error_attr1:
+ device_remove_file(&pdev->dev, &dev_attr_langwell_udc);
error:
if (dev) {
- DBG(dev, "<--- %s()\n", __func__);
+ dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
langwell_udc_remove(pdev);
}
@@ -3214,9 +3377,8 @@ error:
static int langwell_udc_suspend(struct pci_dev *pdev, pm_message_t state)
{
struct langwell_udc *dev = the_controller;
- u32 devlc;
- DBG(dev, "---> %s()\n", __func__);
+ dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
/* disable interrupt and set controller to stop state */
langwell_udc_stop(dev);
@@ -3226,20 +3388,34 @@ static int langwell_udc_suspend(struct pci_dev *pdev, pm_message_t state)
free_irq(pdev->irq, dev);
dev->got_irq = 0;
-
/* save PCI state */
pci_save_state(pdev);
+ spin_lock_irq(&dev->lock);
+ /* stop all usb activities */
+ stop_activity(dev, dev->driver);
+ spin_unlock_irq(&dev->lock);
+
+ /* free dTD dma_pool and dQH */
+ if (dev->dtd_pool)
+ dma_pool_destroy(dev->dtd_pool);
+
+ if (dev->ep_dqh)
+ dma_free_coherent(&pdev->dev, dev->ep_dqh_size,
+ dev->ep_dqh, dev->ep_dqh_dma);
+
+ /* release SRAM caching */
+ if (dev->has_sram && dev->got_sram)
+ sram_deinit(dev);
+
/* set device power state */
pci_set_power_state(pdev, PCI_D3hot);
/* enter PHY low power suspend */
- devlc = readl(&dev->op_regs->devlc);
- VDBG(dev, "devlc = 0x%08x\n", devlc);
- devlc |= LPM_PHCD;
- writel(devlc, &dev->op_regs->devlc);
+ if (dev->pdev->device != 0x0829)
+ langwell_phy_low_power(dev, 1);
- DBG(dev, "<--- %s()\n", __func__);
+ dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return 0;
}
@@ -3248,27 +3424,58 @@ static int langwell_udc_suspend(struct pci_dev *pdev, pm_message_t state)
static int langwell_udc_resume(struct pci_dev *pdev)
{
struct langwell_udc *dev = the_controller;
- u32 devlc;
+ size_t size;
- DBG(dev, "---> %s()\n", __func__);
+ dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
/* exit PHY low power suspend */
- devlc = readl(&dev->op_regs->devlc);
- VDBG(dev, "devlc = 0x%08x\n", devlc);
- devlc &= ~LPM_PHCD;
- writel(devlc, &dev->op_regs->devlc);
+ if (dev->pdev->device != 0x0829)
+ langwell_phy_low_power(dev, 0);
/* set device D0 power state */
pci_set_power_state(pdev, PCI_D0);
+ /* enable SRAM caching if detected */
+ if (dev->has_sram && !dev->got_sram)
+ sram_init(dev);
+
+ /* allocate device dQH memory */
+ size = dev->ep_max * sizeof(struct langwell_dqh);
+ dev_vdbg(&dev->pdev->dev, "orig size = %d\n", size);
+ if (size < DQH_ALIGNMENT)
+ size = DQH_ALIGNMENT;
+ else if ((size % DQH_ALIGNMENT) != 0) {
+ size += DQH_ALIGNMENT + 1;
+ size &= ~(DQH_ALIGNMENT - 1);
+ }
+ dev->ep_dqh = dma_alloc_coherent(&pdev->dev, size,
+ &dev->ep_dqh_dma, GFP_KERNEL);
+ if (!dev->ep_dqh) {
+ dev_err(&dev->pdev->dev, "allocate dQH memory failed\n");
+ return -ENOMEM;
+ }
+ dev->ep_dqh_size = size;
+ dev_vdbg(&dev->pdev->dev, "ep_dqh_size = %d\n", dev->ep_dqh_size);
+
+ /* create dTD dma_pool resource */
+ dev->dtd_pool = dma_pool_create("langwell_dtd",
+ &dev->pdev->dev,
+ sizeof(struct langwell_dtd),
+ DTD_ALIGNMENT,
+ DMA_BOUNDARY);
+
+ if (!dev->dtd_pool)
+ return -ENOMEM;
+
/* restore PCI state */
pci_restore_state(pdev);
/* enable IRQ handler */
- if (request_irq(pdev->irq, langwell_irq, IRQF_SHARED, driver_name, dev)
- != 0) {
- ERROR(dev, "request interrupt %d failed\n", pdev->irq);
- return -1;
+ if (request_irq(pdev->irq, langwell_irq, IRQF_SHARED,
+ driver_name, dev) != 0) {
+ dev_err(&dev->pdev->dev, "request interrupt %d failed\n",
+ pdev->irq);
+ return -EBUSY;
}
dev->got_irq = 1;
@@ -3290,7 +3497,7 @@ static int langwell_udc_resume(struct pci_dev *pdev)
dev->ep0_state = WAIT_FOR_SETUP;
dev->ep0_dir = USB_DIR_OUT;
- DBG(dev, "<--- %s()\n", __func__);
+ dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
return 0;
}
@@ -3301,15 +3508,15 @@ static void langwell_udc_shutdown(struct pci_dev *pdev)
struct langwell_udc *dev = the_controller;
u32 usbmode;
- DBG(dev, "---> %s()\n", __func__);
+ dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
/* reset controller mode to IDLE */
usbmode = readl(&dev->op_regs->usbmode);
- DBG(dev, "usbmode = 0x%08x\n", usbmode);
+ dev_dbg(&dev->pdev->dev, "usbmode = 0x%08x\n", usbmode);
usbmode &= (~3 | MODE_IDLE);
writel(usbmode, &dev->op_regs->usbmode);
- DBG(dev, "<--- %s()\n", __func__);
+ dev_dbg(&dev->pdev->dev, "<--- %s()\n", __func__);
}
/*-------------------------------------------------------------------------*/
@@ -3324,7 +3531,6 @@ static const struct pci_device_id pci_ids[] = { {
}, { /* end: all zeroes */ }
};
-
MODULE_DEVICE_TABLE(pci, pci_ids);
@@ -3343,12 +3549,6 @@ static struct pci_driver langwell_pci_driver = {
};
-MODULE_DESCRIPTION(DRIVER_DESC);
-MODULE_AUTHOR("Xiaochen Shen <xiaochen.shen@intel.com>");
-MODULE_VERSION(DRIVER_VERSION);
-MODULE_LICENSE("GPL");
-
-
static int __init init(void)
{
#ifdef OTG_TRANSCEIVER
@@ -3370,3 +3570,9 @@ static void __exit cleanup(void)
}
module_exit(cleanup);
+
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_AUTHOR("Xiaochen Shen <xiaochen.shen@intel.com>");
+MODULE_VERSION(DRIVER_VERSION);
+MODULE_LICENSE("GPL");
+
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 @@
*/
#include <linux/usb/langwell_udc.h>
-
-#if defined(CONFIG_USB_LANGWELL_OTG)
#include <linux/usb/langwell_otg.h>
-#endif
-
/*-------------------------------------------------------------------------*/
@@ -199,7 +195,9 @@ struct langwell_udc {
vbus_active:1,
suspended:1,
stopped:1,
- lpm:1; /* LPM capability */
+ lpm:1, /* LPM capability */
+ has_sram:1, /* SRAM caching */
+ got_sram:1;
/* pci state used to access those endpoints */
struct pci_dev *pdev;
@@ -224,5 +222,12 @@ struct langwell_udc {
/* make sure release() is done */
struct completion *done;
+
+ /* for private SRAM caching */
+ unsigned int sram_addr;
+ unsigned int sram_size;
+
+ /* device status data for get_status request */
+ u16 dev_status;
};
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)
/*
Register entry point for the peripheral controller driver.
*/
-int usb_gadget_register_driver(struct usb_gadget_driver *driver)
+int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
+ int (*bind)(struct usb_gadget *))
{
struct lh7a40x_udc *dev = the_controller;
int retval;
@@ -417,7 +418,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
if (!driver
|| driver->speed != USB_SPEED_FULL
- || !driver->bind
+ || !bind
|| !driver->disconnect
|| !driver->setup)
return -EINVAL;
@@ -431,7 +432,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
dev->gadget.dev.driver = &driver->driver;
device_add(&dev->gadget.dev);
- retval = driver->bind(&dev->gadget);
+ retval = bind(&dev->gadget);
if (retval) {
printk(KERN_WARNING "%s: bind to driver %s --> error %d\n",
dev->gadget.name, driver->driver.name, retval);
@@ -453,8 +454,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
return 0;
}
-
-EXPORT_SYMBOL(usb_gadget_register_driver);
+EXPORT_SYMBOL(usb_gadget_probe_driver);
/*
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 = {
/*-------------------------------------------------------------------------*/
static struct m66592 *the_controller;
-int usb_gadget_register_driver(struct usb_gadget_driver *driver)
+int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
+ int (*bind)(struct usb_gadget *))
{
struct m66592 *m66592 = the_controller;
int retval;
if (!driver
|| driver->speed != USB_SPEED_HIGH
- || !driver->bind
+ || !bind
|| !driver->setup)
return -EINVAL;
if (!m66592)
@@ -1480,7 +1481,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
goto error;
}
- retval = driver->bind (&m66592->gadget);
+ retval = bind(&m66592->gadget);
if (retval) {
pr_err("bind to driver error (%d)\n", retval);
device_del(&m66592->gadget.dev);
@@ -1505,7 +1506,7 @@ error:
return retval;
}
-EXPORT_SYMBOL(usb_gadget_register_driver);
+EXPORT_SYMBOL(usb_gadget_probe_driver);
int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
{
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 = {
/* Vendor and product id can be overridden by module parameters. */
.idVendor = cpu_to_le16(FSG_VENDOR_ID),
.idProduct = cpu_to_le16(FSG_PRODUCT_ID),
- /* .bcdDevice = f(hardware) */
- /* .iManufacturer = DYNAMIC */
- /* .iProduct = DYNAMIC */
- /* NO SERIAL NUMBER */
.bNumConfigurations = 1,
};
@@ -86,7 +82,8 @@ static struct usb_otg_descriptor otg_descriptor = {
.bLength = sizeof otg_descriptor,
.bDescriptorType = USB_DT_OTG,
- /* REVISIT SRP-only hardware is possible, although
+ /*
+ * REVISIT SRP-only hardware is possible, although
* it would not be called "OTG" ...
*/
.bmAttributes = USB_OTG_SRP | USB_OTG_HNP,
@@ -98,33 +95,6 @@ static const struct usb_descriptor_header *otg_desc[] = {
};
-/* string IDs are assigned dynamically */
-
-#define STRING_MANUFACTURER_IDX 0
-#define STRING_PRODUCT_IDX 1
-#define STRING_CONFIGURATION_IDX 2
-
-static char manufacturer[50];
-
-static struct usb_string strings_dev[] = {
- [STRING_MANUFACTURER_IDX].s = manufacturer,
- [STRING_PRODUCT_IDX].s = DRIVER_DESC,
- [STRING_CONFIGURATION_IDX].s = "Self Powered",
- { } /* end of list */
-};
-
-static struct usb_gadget_strings stringtab_dev = {
- .language = 0x0409, /* en-us */
- .strings = strings_dev,
-};
-
-static struct usb_gadget_strings *dev_strings[] = {
- &stringtab_dev,
- NULL,
-};
-
-
-
/****************************** Configurations ******************************/
static struct fsg_module_parameters mod_data = {
@@ -141,7 +111,7 @@ static int msg_thread_exits(struct fsg_common *common)
return 0;
}
-static int __ref msg_do_config(struct usb_configuration *c)
+static int __init msg_do_config(struct usb_configuration *c)
{
static const struct fsg_operations ops = {
.thread_exits = msg_thread_exits,
@@ -171,54 +141,23 @@ static int __ref msg_do_config(struct usb_configuration *c)
static struct usb_configuration msg_config_driver = {
.label = "Linux File-Backed Storage",
- .bind = msg_do_config,
.bConfigurationValue = 1,
- /* .iConfiguration = DYNAMIC */
.bmAttributes = USB_CONFIG_ATT_SELFPOWER,
};
-
/****************************** Gadget Bind ******************************/
-
-static int __ref msg_bind(struct usb_composite_dev *cdev)
+static int __init msg_bind(struct usb_composite_dev *cdev)
{
- struct usb_gadget *gadget = cdev->gadget;
int status;
- /* Allocate string descriptor numbers ... note that string
- * contents can be overridden by the composite_dev glue.
- */
-
- /* device descriptor strings: manufacturer, product */
- snprintf(manufacturer, sizeof manufacturer, "%s %s with %s",
- init_utsname()->sysname, init_utsname()->release,
- gadget->name);
- status = usb_string_id(cdev);
+ status = usb_add_config(cdev, &msg_config_driver, msg_do_config);
if (status < 0)
return status;
- strings_dev[STRING_MANUFACTURER_IDX].id = status;
- msg_device_desc.iManufacturer = status;
- status = usb_string_id(cdev);
- if (status < 0)
- return status;
- strings_dev[STRING_PRODUCT_IDX].id = status;
- msg_device_desc.iProduct = status;
-
- status = usb_string_id(cdev);
- if (status < 0)
- return status;
- strings_dev[STRING_CONFIGURATION_IDX].id = status;
- msg_config_driver.iConfiguration = status;
-
- /* register our second configuration */
- status = usb_add_config(cdev, &msg_config_driver);
- if (status < 0)
- return status;
-
- dev_info(&gadget->dev, DRIVER_DESC ", version: " DRIVER_VERSION "\n");
+ dev_info(&cdev->gadget->dev,
+ DRIVER_DESC ", version: " DRIVER_VERSION "\n");
set_bit(0, &msg_registered);
return 0;
}
@@ -226,12 +165,11 @@ static int __ref msg_bind(struct usb_composite_dev *cdev)
/****************************** Some noise ******************************/
-
static struct usb_composite_driver msg_driver = {
.name = "g_mass_storage",
.dev = &msg_device_desc,
- .strings = dev_strings,
- .bind = msg_bind,
+ .iProduct = DRIVER_DESC,
+ .needs_serial = 1,
};
MODULE_DESCRIPTION(DRIVER_DESC);
@@ -240,7 +178,7 @@ MODULE_LICENSE("GPL");
static int __init msg_init(void)
{
- return usb_composite_register(&msg_driver);
+ return usb_composite_probe(&msg_driver, msg_bind);
}
module_init(msg_init);
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");
/***************************** Device Descriptor ****************************/
-#define MULTI_VENDOR_NUM 0x0525 /* XXX NetChip */
-#define MULTI_PRODUCT_NUM 0xa4ab /* XXX */
+#define MULTI_VENDOR_NUM 0x1d6b /* Linux Foundation */
+#define MULTI_PRODUCT_NUM 0x0104 /* Multifunction Composite Gadget */
enum {
@@ -121,8 +121,6 @@ static const struct usb_descriptor_header *otg_desc[] = {
enum {
- MULTI_STRING_MANUFACTURER_IDX,
- MULTI_STRING_PRODUCT_IDX,
#ifdef CONFIG_USB_G_MULTI_RNDIS
MULTI_STRING_RNDIS_CONFIG_IDX,
#endif
@@ -131,11 +129,7 @@ enum {
#endif
};
-static char manufacturer[50];
-
static struct usb_string strings_dev[] = {
- [MULTI_STRING_MANUFACTURER_IDX].s = manufacturer,
- [MULTI_STRING_PRODUCT_IDX].s = DRIVER_DESC,
#ifdef CONFIG_USB_G_MULTI_RNDIS
[MULTI_STRING_RNDIS_CONFIG_IDX].s = "Multifunction with RNDIS",
#endif
@@ -170,7 +164,7 @@ static u8 hostaddr[ETH_ALEN];
#ifdef USB_ETH_RNDIS
-static __ref int rndis_do_config(struct usb_configuration *c)
+static __init int rndis_do_config(struct usb_configuration *c)
{
int ret;
@@ -197,7 +191,6 @@ static __ref int rndis_do_config(struct usb_configuration *c)
static int rndis_config_register(struct usb_composite_dev *cdev)
{
static struct usb_configuration config = {
- .bind = rndis_do_config,
.bConfigurationValue = MULTI_RNDIS_CONFIG_NUM,
.bmAttributes = USB_CONFIG_ATT_SELFPOWER,
};
@@ -205,7 +198,7 @@ static int rndis_config_register(struct usb_composite_dev *cdev)
config.label = strings_dev[MULTI_STRING_RNDIS_CONFIG_IDX].s;
config.iConfiguration = strings_dev[MULTI_STRING_RNDIS_CONFIG_IDX].id;
- return usb_add_config(cdev, &config);
+ return usb_add_config(cdev, &config, rndis_do_config);
}
#else
@@ -222,7 +215,7 @@ static int rndis_config_register(struct usb_composite_dev *cdev)
#ifdef CONFIG_USB_G_MULTI_CDC
-static __ref int cdc_do_config(struct usb_configuration *c)
+static __init int cdc_do_config(struct usb_configuration *c)
{
int ret;
@@ -249,7 +242,6 @@ static __ref int cdc_do_config(struct usb_configuration *c)
static int cdc_config_register(struct usb_composite_dev *cdev)
{
static struct usb_configuration config = {
- .bind = cdc_do_config,
.bConfigurationValue = MULTI_CDC_CONFIG_NUM,
.bmAttributes = USB_CONFIG_ATT_SELFPOWER,
};
@@ -257,7 +249,7 @@ static int cdc_config_register(struct usb_composite_dev *cdev)
config.label = strings_dev[MULTI_STRING_CDC_CONFIG_IDX].s;
config.iConfiguration = strings_dev[MULTI_STRING_CDC_CONFIG_IDX].id;
- return usb_add_config(cdev, &config);
+ return usb_add_config(cdev, &config, cdc_do_config);
}
#else
@@ -314,20 +306,11 @@ static int __ref multi_bind(struct usb_composite_dev *cdev)
device_desc.bcdDevice = cpu_to_le16(0x0300 | 0x0099);
}
- /* allocate string descriptor numbers */
- snprintf(manufacturer, sizeof manufacturer, "%s %s with %s",
- init_utsname()->sysname, init_utsname()->release,
- gadget->name);
-
+ /* allocate string IDs */
status = usb_string_ids_tab(cdev, strings_dev);
if (unlikely(status < 0))
goto fail2;
- device_desc.iManufacturer =
- strings_dev[MULTI_STRING_MANUFACTURER_IDX].id;
- device_desc.iProduct =
- strings_dev[MULTI_STRING_PRODUCT_IDX].id;
-
/* register configurations */
status = rndis_config_register(cdev);
if (unlikely(status < 0))
@@ -368,14 +351,15 @@ static struct usb_composite_driver multi_driver = {
.name = "g_multi",
.dev = &device_desc,
.strings = dev_strings,
- .bind = multi_bind,
.unbind = __exit_p(multi_unbind),
+ .iProduct = DRIVER_DESC,
+ .needs_serial = 1,
};
static int __init multi_init(void)
{
- return usb_composite_register(&multi_driver);
+ return usb_composite_probe(&multi_driver, multi_bind);
}
module_init(multi_init);
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)
* disconnect is reported. then a host may connect again, or
* the driver might get unbound.
*/
-int usb_gadget_register_driver (struct usb_gadget_driver *driver)
+int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
+ int (*bind)(struct usb_gadget *))
{
struct net2280 *dev = the_controller;
int retval;
@@ -1941,8 +1942,7 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver)
*/
if (!driver
|| driver->speed != USB_SPEED_HIGH
- || !driver->bind
- || !driver->setup)
+ || !bind || !driver->setup)
return -EINVAL;
if (!dev)
return -ENODEV;
@@ -1957,7 +1957,7 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver)
driver->driver.bus = NULL;
dev->driver = driver;
dev->gadget.dev.driver = &driver->driver;
- retval = driver->bind (&dev->gadget);
+ retval = bind(&dev->gadget);
if (retval) {
DEBUG (dev, "bind to driver %s --> %d\n",
driver->driver.name, retval);
@@ -1993,7 +1993,7 @@ err_unbind:
dev->driver = NULL;
return retval;
}
-EXPORT_SYMBOL (usb_gadget_register_driver);
+EXPORT_SYMBOL(usb_gadget_probe_driver);
static void
stop_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)
static struct usb_configuration nokia_config_500ma_driver = {
.label = "Bus Powered",
- .bind = nokia_bind_config,
.bConfigurationValue = 1,
/* .iConfiguration = DYNAMIC */
.bmAttributes = USB_CONFIG_ATT_ONE,
@@ -144,7 +143,6 @@ static struct usb_configuration nokia_config_500ma_driver = {
static struct usb_configuration nokia_config_100ma_driver = {
.label = "Self Powered",
- .bind = nokia_bind_config,
.bConfigurationValue = 2,
/* .iConfiguration = DYNAMIC */
.bmAttributes = USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER,
@@ -206,11 +204,13 @@ static int __init nokia_bind(struct usb_composite_dev *cdev)
}
/* finaly register the configuration */
- status = usb_add_config(cdev, &nokia_config_500ma_driver);
+ status = usb_add_config(cdev, &nokia_config_500ma_driver,
+ nokia_bind_config);
if (status < 0)
goto err_usb;
- status = usb_add_config(cdev, &nokia_config_100ma_driver);
+ status = usb_add_config(cdev, &nokia_config_100ma_driver,
+ nokia_bind_config);
if (status < 0)
goto err_usb;
@@ -241,13 +241,12 @@ static struct usb_composite_driver nokia_driver = {
.name = "g_nokia",
.dev = &device_desc,
.strings = dev_strings,
- .bind = nokia_bind,
.unbind = __exit_p(nokia_unbind),
};
static int __init nokia_init(void)
{
- return usb_composite_register(&nokia_driver);
+ return usb_composite_probe(&nokia_driver, nokia_bind);
}
module_init(nokia_init);
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)
);
}
-int usb_gadget_register_driver (struct usb_gadget_driver *driver)
+int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
+ int (*bind)(struct usb_gadget *))
{
int status = -ENODEV;
struct omap_ep *ep;
@@ -2114,8 +2115,7 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver)
if (!driver
// FIXME if otg, check: driver->is_otg
|| driver->speed < USB_SPEED_FULL
- || !driver->bind
- || !driver->setup)
+ || !bind || !driver->setup)
return -EINVAL;
spin_lock_irqsave(&udc->lock, flags);
@@ -2145,7 +2145,7 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver)
if (udc->dc_clk != NULL)
omap_udc_enable_clock(1);
- status = driver->bind (&udc->gadget);
+ status = bind(&udc->gadget);
if (status) {
DBG("bind to %s --> %d\n", driver->driver.name, status);
udc->gadget.dev.driver = NULL;
@@ -2186,7 +2186,7 @@ done:
omap_udc_enable_clock(0);
return status;
}
-EXPORT_SYMBOL(usb_gadget_register_driver);
+EXPORT_SYMBOL(usb_gadget_probe_driver);
int usb_gadget_unregister_driver (struct usb_gadget_driver *driver)
{
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)
set_gadget_data(gadget, NULL);
}
-static int __ref
+static int __init
printer_bind(struct usb_gadget *gadget)
{
struct printer_dev *dev;
@@ -1544,7 +1544,6 @@ static struct usb_gadget_driver printer_driver = {
.speed = DEVSPEED,
.function = (char *) driver_desc,
- .bind = printer_bind,
.unbind = printer_unbind,
.setup = printer_setup,
@@ -1580,11 +1579,11 @@ init(void)
return status;
}
- status = usb_gadget_register_driver(&printer_driver);
+ status = usb_gadget_probe_driver(&printer_driver, printer_bind);
if (status) {
class_destroy(usb_gadget_class);
unregister_chrdev_region(g_printer_devno, 1);
- DBG(dev, "usb_gadget_register_driver %x\n", status);
+ DBG(dev, "usb_gadget_probe_driver %x\n", status);
}
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)
* disconnect is reported. then a host may connect again, or
* the driver might get unbound.
*/
-int usb_gadget_register_driver(struct usb_gadget_driver *driver)
+int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
+ int (*bind)(struct usb_gadget *))
{
struct pxa25x_udc *dev = the_controller;
int retval;
if (!driver
|| driver->speed < USB_SPEED_FULL
- || !driver->bind
+ || !bind
|| !driver->disconnect
|| !driver->setup)
return -EINVAL;
@@ -1308,7 +1309,7 @@ fail:
dev->gadget.dev.driver = NULL;
return retval;
}
- retval = driver->bind(&dev->gadget);
+ retval = bind(&dev->gadget);
if (retval) {
DMSG("bind to driver %s --> error %d\n",
driver->driver.name, retval);
@@ -1338,7 +1339,7 @@ fail:
bind_fail:
return retval;
}
-EXPORT_SYMBOL(usb_gadget_register_driver);
+EXPORT_SYMBOL(usb_gadget_probe_driver);
static void
stop_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)
}
/**
- * usb_gadget_register_driver - Register gadget driver
+ * usb_gadget_probe_driver - Register gadget driver
* @driver: gadget driver
+ * @bind: bind function
*
* When a driver is successfully registered, it will receive control requests
* including set_configuration(), which enables non-control requests. Then
@@ -1805,12 +1806,13 @@ static void udc_enable(struct pxa_udc *udc)
*
* Returns 0 if no error, -EINVAL, -ENODEV, -EBUSY otherwise
*/
-int usb_gadget_register_driver(struct usb_gadget_driver *driver)
+int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
+ int (*bind)(struct usb_gadget *))
{
struct pxa_udc *udc = the_controller;
int retval;
- if (!driver || driver->speed < USB_SPEED_FULL || !driver->bind
+ if (!driver || driver->speed < USB_SPEED_FULL || !bind
|| !driver->disconnect || !driver->setup)
return -EINVAL;
if (!udc)
@@ -1828,7 +1830,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
dev_err(udc->dev, "device_add error %d\n", retval);
goto add_fail;
}
- retval = driver->bind(&udc->gadget);
+ retval = bind(&udc->gadget);
if (retval) {
dev_err(udc->dev, "bind to driver %s --> error %d\n",
driver->driver.name, retval);
@@ -1859,7 +1861,7 @@ add_fail:
udc->gadget.dev.driver = NULL;
return retval;
}
-EXPORT_SYMBOL(usb_gadget_register_driver);
+EXPORT_SYMBOL(usb_gadget_probe_driver);
/**
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[] = {
"ep8", "ep9",
};
+static void init_controller(struct r8a66597 *r8a66597);
static void disable_controller(struct r8a66597 *r8a66597);
static void irq_ep0_write(struct r8a66597_ep *ep, struct r8a66597_request *req);
static void irq_packet_write(struct r8a66597_ep *ep,
@@ -104,6 +105,8 @@ __acquires(r8a66597->lock)
spin_lock(&r8a66597->lock);
disable_controller(r8a66597);
+ init_controller(r8a66597);
+ r8a66597_bset(r8a66597, VBSE, INTENB0);
INIT_LIST_HEAD(&r8a66597->ep[0].queue);
}
@@ -274,7 +277,7 @@ static int pipe_buffer_setting(struct r8a66597 *r8a66597,
}
if (buf_bsize && ((bufnum + 16) >= R8A66597_MAX_BUFNUM)) {
- pr_err(KERN_ERR "r8a66597 pipe memory is insufficient\n");
+ pr_err("r8a66597 pipe memory is insufficient\n");
return -ENOMEM;
}
@@ -1405,14 +1408,15 @@ static struct usb_ep_ops r8a66597_ep_ops = {
/*-------------------------------------------------------------------------*/
static struct r8a66597 *the_controller;
-int usb_gadget_register_driver(struct usb_gadget_driver *driver)
+int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
+ int (*bind)(struct usb_gadget *))
{
struct r8a66597 *r8a66597 = the_controller;
int retval;
if (!driver
|| driver->speed != USB_SPEED_HIGH
- || !driver->bind
+ || !bind
|| !driver->setup)
return -EINVAL;
if (!r8a66597)
@@ -1431,7 +1435,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
goto error;
}
- retval = driver->bind(&r8a66597->gadget);
+ retval = bind(&r8a66597->gadget);
if (retval) {
printk(KERN_ERR "bind to driver error (%d)\n", retval);
device_del(&r8a66597->gadget.dev);
@@ -1456,7 +1460,7 @@ error:
return retval;
}
-EXPORT_SYMBOL(usb_gadget_register_driver);
+EXPORT_SYMBOL(usb_gadget_probe_driver);
int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
{
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,
int len)
{
void __iomem *fifoaddr = r8a66597->reg + offset;
- unsigned int data;
+ unsigned int data = 0;
int i;
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");
#define RNDIS_MAX_CONFIGS 1
-static rndis_params rndis_per_dev_params [RNDIS_MAX_CONFIGS];
+static rndis_params rndis_per_dev_params[RNDIS_MAX_CONFIGS];
/* Driver Version */
-static const __le32 rndis_driver_version = cpu_to_le32 (1);
+static const __le32 rndis_driver_version = cpu_to_le32(1);
/* Function Prototypes */
-static rndis_resp_t *rndis_add_response (int configNr, u32 length);
+static rndis_resp_t *rndis_add_response(int configNr, u32 length);
/* supported OIDs */
-static const u32 oid_supported_list [] =
+static const u32 oid_supported_list[] =
{
/* the general stuff */
OID_GEN_SUPPORTED_LIST,
@@ -161,21 +161,20 @@ static const u32 oid_supported_list [] =
/* NDIS Functions */
-static int
-gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
- rndis_resp_t *r)
+static int gen_ndis_query_resp(int configNr, u32 OID, u8 *buf,
+ unsigned buf_len, rndis_resp_t *r)
{
- int retval = -ENOTSUPP;
- u32 length = 4; /* usually */
- __le32 *outbuf;
- int i, count;
- rndis_query_cmplt_type *resp;
- struct net_device *net;
+ int retval = -ENOTSUPP;
+ u32 length = 4; /* usually */
+ __le32 *outbuf;
+ int i, count;
+ rndis_query_cmplt_type *resp;
+ struct net_device *net;
struct rtnl_link_stats64 temp;
const struct rtnl_link_stats64 *stats;
if (!r) return -ENOMEM;
- resp = (rndis_query_cmplt_type *) r->buf;
+ resp = (rndis_query_cmplt_type *)r->buf;
if (!resp) return -ENOMEM;
@@ -191,8 +190,8 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
}
/* response goes here, right after the header */
- outbuf = (__le32 *) &resp[1];
- resp->InformationBufferOffset = cpu_to_le32 (16);
+ outbuf = (__le32 *)&resp[1];
+ resp->InformationBufferOffset = cpu_to_le32(16);
net = rndis_per_dev_params[configNr].dev;
stats = dev_get_stats(net, &temp);
@@ -204,10 +203,10 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
/* mandatory */
case OID_GEN_SUPPORTED_LIST:
pr_debug("%s: OID_GEN_SUPPORTED_LIST\n", __func__);
- length = sizeof (oid_supported_list);
- count = length / sizeof (u32);
+ length = sizeof(oid_supported_list);
+ count = length / sizeof(u32);
for (i = 0; i < count; i++)
- outbuf[i] = cpu_to_le32 (oid_supported_list[i]);
+ outbuf[i] = cpu_to_le32(oid_supported_list[i]);
retval = 0;
break;
@@ -220,14 +219,14 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
* reddite ergo quae sunt Caesaris Caesari
* et quae sunt Dei Deo!
*/
- *outbuf = cpu_to_le32 (0);
+ *outbuf = cpu_to_le32(0);
retval = 0;
break;
/* mandatory */
case OID_GEN_MEDIA_SUPPORTED:
pr_debug("%s: OID_GEN_MEDIA_SUPPORTED\n", __func__);
- *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr].medium);
+ *outbuf = cpu_to_le32(rndis_per_dev_params[configNr].medium);
retval = 0;
break;
@@ -235,16 +234,16 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
case OID_GEN_MEDIA_IN_USE:
pr_debug("%s: OID_GEN_MEDIA_IN_USE\n", __func__);
/* one medium, one transport... (maybe you do it better) */
- *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr].medium);
+ *outbuf = cpu_to_le32(rndis_per_dev_params[configNr].medium);
retval = 0;
break;
/* mandatory */
case OID_GEN_MAXIMUM_FRAME_SIZE:
pr_debug("%s: OID_GEN_MAXIMUM_FRAME_SIZE\n", __func__);
- if (rndis_per_dev_params [configNr].dev) {
- *outbuf = cpu_to_le32 (
- rndis_per_dev_params [configNr].dev->mtu);
+ if (rndis_per_dev_params[configNr].dev) {
+ *outbuf = cpu_to_le32(
+ rndis_per_dev_params[configNr].dev->mtu);
retval = 0;
}
break;
@@ -253,21 +252,21 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
case OID_GEN_LINK_SPEED:
if (rndis_debug > 1)
pr_debug("%s: OID_GEN_LINK_SPEED\n", __func__);
- if (rndis_per_dev_params [configNr].media_state
+ if (rndis_per_dev_params[configNr].media_state
== NDIS_MEDIA_STATE_DISCONNECTED)
- *outbuf = cpu_to_le32 (0);
+ *outbuf = cpu_to_le32(0);
else
- *outbuf = cpu_to_le32 (
- rndis_per_dev_params [configNr].speed);
+ *outbuf = cpu_to_le32(
+ rndis_per_dev_params[configNr].speed);
retval = 0;
break;
/* mandatory */
case OID_GEN_TRANSMIT_BLOCK_SIZE:
pr_debug("%s: OID_GEN_TRANSMIT_BLOCK_SIZE\n", __func__);
- if (rndis_per_dev_params [configNr].dev) {
- *outbuf = cpu_to_le32 (
- rndis_per_dev_params [configNr].dev->mtu);
+ if (rndis_per_dev_params[configNr].dev) {
+ *outbuf = cpu_to_le32(
+ rndis_per_dev_params[configNr].dev->mtu);
retval = 0;
}
break;
@@ -275,9 +274,9 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
/* mandatory */
case OID_GEN_RECEIVE_BLOCK_SIZE:
pr_debug("%s: OID_GEN_RECEIVE_BLOCK_SIZE\n", __func__);
- if (rndis_per_dev_params [configNr].dev) {
- *outbuf = cpu_to_le32 (
- rndis_per_dev_params [configNr].dev->mtu);
+ if (rndis_per_dev_params[configNr].dev) {
+ *outbuf = cpu_to_le32(
+ rndis_per_dev_params[configNr].dev->mtu);
retval = 0;
}
break;
@@ -285,18 +284,20 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
/* mandatory */
case OID_GEN_VENDOR_ID:
pr_debug("%s: OID_GEN_VENDOR_ID\n", __func__);
- *outbuf = cpu_to_le32 (
- rndis_per_dev_params [configNr].vendorID);
+ *outbuf = cpu_to_le32(
+ rndis_per_dev_params[configNr].vendorID);
retval = 0;
break;
/* mandatory */
case OID_GEN_VENDOR_DESCRIPTION:
pr_debug("%s: OID_GEN_VENDOR_DESCRIPTION\n", __func__);
- if ( rndis_per_dev_params [configNr].vendorDescr ) {
- length = strlen (rndis_per_dev_params [configNr].vendorDescr);
- memcpy (outbuf,
- rndis_per_dev_params [configNr].vendorDescr, length);
+ if (rndis_per_dev_params[configNr].vendorDescr) {
+ length = strlen(rndis_per_dev_params[configNr].
+ vendorDescr);
+ memcpy(outbuf,
+ rndis_per_dev_params[configNr].vendorDescr,
+ length);
} else {
outbuf[0] = 0;
}
@@ -313,7 +314,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
/* mandatory */
case OID_GEN_CURRENT_PACKET_FILTER:
pr_debug("%s: OID_GEN_CURRENT_PACKET_FILTER\n", __func__);
- *outbuf = cpu_to_le32 (*rndis_per_dev_params[configNr].filter);
+ *outbuf = cpu_to_le32(*rndis_per_dev_params[configNr].filter);
retval = 0;
break;
@@ -328,14 +329,14 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
case OID_GEN_MEDIA_CONNECT_STATUS:
if (rndis_debug > 1)
pr_debug("%s: OID_GEN_MEDIA_CONNECT_STATUS\n", __func__);
- *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr]
+ *outbuf = cpu_to_le32(rndis_per_dev_params[configNr]
.media_state);
retval = 0;
break;
case OID_GEN_PHYSICAL_MEDIUM:
pr_debug("%s: OID_GEN_PHYSICAL_MEDIUM\n", __func__);
- *outbuf = cpu_to_le32 (0);
+ *outbuf = cpu_to_le32(0);
retval = 0;
break;
@@ -409,10 +410,10 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
/* mandatory */
case OID_802_3_PERMANENT_ADDRESS:
pr_debug("%s: OID_802_3_PERMANENT_ADDRESS\n", __func__);
- if (rndis_per_dev_params [configNr].dev) {
+ if (rndis_per_dev_params[configNr].dev) {
length = ETH_ALEN;
- memcpy (outbuf,
- rndis_per_dev_params [configNr].host_mac,
+ memcpy(outbuf,
+ rndis_per_dev_params[configNr].host_mac,
length);
retval = 0;
}
@@ -421,9 +422,9 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
/* mandatory */
case OID_802_3_CURRENT_ADDRESS:
pr_debug("%s: OID_802_3_CURRENT_ADDRESS\n", __func__);
- if (rndis_per_dev_params [configNr].dev) {
+ if (rndis_per_dev_params[configNr].dev) {
length = ETH_ALEN;
- memcpy (outbuf,
+ memcpy(outbuf,
rndis_per_dev_params [configNr].host_mac,
length);
retval = 0;
@@ -434,7 +435,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
case OID_802_3_MULTICAST_LIST:
pr_debug("%s: OID_802_3_MULTICAST_LIST\n", __func__);
/* Multicast base address only */
- *outbuf = cpu_to_le32 (0xE0000000);
+ *outbuf = cpu_to_le32(0xE0000000);
retval = 0;
break;
@@ -442,7 +443,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
case OID_802_3_MAXIMUM_LIST_SIZE:
pr_debug("%s: OID_802_3_MAXIMUM_LIST_SIZE\n", __func__);
/* Multicast base address only */
- *outbuf = cpu_to_le32 (1);
+ *outbuf = cpu_to_le32(1);
retval = 0;
break;
@@ -466,14 +467,14 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
/* mandatory */
case OID_802_3_XMIT_ONE_COLLISION:
pr_debug("%s: OID_802_3_XMIT_ONE_COLLISION\n", __func__);
- *outbuf = cpu_to_le32 (0);
+ *outbuf = cpu_to_le32(0);
retval = 0;
break;
/* mandatory */
case OID_802_3_XMIT_MORE_COLLISIONS:
pr_debug("%s: OID_802_3_XMIT_MORE_COLLISIONS\n", __func__);
- *outbuf = cpu_to_le32 (0);
+ *outbuf = cpu_to_le32(0);
retval = 0;
break;
@@ -484,22 +485,22 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len,
if (retval < 0)
length = 0;
- resp->InformationBufferLength = cpu_to_le32 (length);
- r->length = length + sizeof *resp;
- resp->MessageLength = cpu_to_le32 (r->length);
+ resp->InformationBufferLength = cpu_to_le32(length);
+ r->length = length + sizeof(*resp);
+ resp->MessageLength = cpu_to_le32(r->length);
return retval;
}
-static int gen_ndis_set_resp (u8 configNr, u32 OID, u8 *buf, u32 buf_len,
- rndis_resp_t *r)
+static int gen_ndis_set_resp(u8 configNr, u32 OID, u8 *buf, u32 buf_len,
+ rndis_resp_t *r)
{
- rndis_set_cmplt_type *resp;
- int i, retval = -ENOTSUPP;
- struct rndis_params *params;
+ rndis_set_cmplt_type *resp;
+ int i, retval = -ENOTSUPP;
+ struct rndis_params *params;
if (!r)
return -ENOMEM;
- resp = (rndis_set_cmplt_type *) r->buf;
+ resp = (rndis_set_cmplt_type *)r->buf;
if (!resp)
return -ENOMEM;
@@ -514,7 +515,7 @@ static int gen_ndis_set_resp (u8 configNr, u32 OID, u8 *buf, u32 buf_len,
}
}
- params = &rndis_per_dev_params [configNr];
+ params = &rndis_per_dev_params[configNr];
switch (OID) {
case OID_GEN_CURRENT_PACKET_FILTER:
@@ -537,11 +538,11 @@ static int gen_ndis_set_resp (u8 configNr, u32 OID, u8 *buf, u32 buf_len,
params->state = RNDIS_DATA_INITIALIZED;
netif_carrier_on(params->dev);
if (netif_running(params->dev))
- netif_wake_queue (params->dev);
+ netif_wake_queue(params->dev);
} else {
params->state = RNDIS_INITIALIZED;
- netif_carrier_off (params->dev);
- netif_stop_queue (params->dev);
+ netif_carrier_off(params->dev);
+ netif_stop_queue(params->dev);
}
break;
@@ -563,48 +564,47 @@ static int gen_ndis_set_resp (u8 configNr, u32 OID, u8 *buf, u32 buf_len,
* Response Functions
*/
-static int rndis_init_response (int configNr, rndis_init_msg_type *buf)
+static int rndis_init_response(int configNr, rndis_init_msg_type *buf)
{
- rndis_init_cmplt_type *resp;
- rndis_resp_t *r;
- struct rndis_params *params = rndis_per_dev_params + configNr;
+ rndis_init_cmplt_type *resp;
+ rndis_resp_t *r;
+ struct rndis_params *params = rndis_per_dev_params + configNr;
if (!params->dev)
return -ENOTSUPP;
- r = rndis_add_response (configNr, sizeof (rndis_init_cmplt_type));
+ r = rndis_add_response(configNr, sizeof(rndis_init_cmplt_type));
if (!r)
return -ENOMEM;
- resp = (rndis_init_cmplt_type *) r->buf;
+ resp = (rndis_init_cmplt_type *)r->buf;
- resp->MessageType = cpu_to_le32 (
- REMOTE_NDIS_INITIALIZE_CMPLT);
- resp->MessageLength = cpu_to_le32 (52);
+ resp->MessageType = cpu_to_le32(REMOTE_NDIS_INITIALIZE_CMPLT);
+ resp->MessageLength = cpu_to_le32(52);
resp->RequestID = buf->RequestID; /* Still LE in msg buffer */
- resp->Status = cpu_to_le32 (RNDIS_STATUS_SUCCESS);
- resp->MajorVersion = cpu_to_le32 (RNDIS_MAJOR_VERSION);
- resp->MinorVersion = cpu_to_le32 (RNDIS_MINOR_VERSION);
- resp->DeviceFlags = cpu_to_le32 (RNDIS_DF_CONNECTIONLESS);
- resp->Medium = cpu_to_le32 (RNDIS_MEDIUM_802_3);
- resp->MaxPacketsPerTransfer = cpu_to_le32 (1);
- resp->MaxTransferSize = cpu_to_le32 (
+ resp->Status = cpu_to_le32(RNDIS_STATUS_SUCCESS);
+ resp->MajorVersion = cpu_to_le32(RNDIS_MAJOR_VERSION);
+ resp->MinorVersion = cpu_to_le32(RNDIS_MINOR_VERSION);
+ resp->DeviceFlags = cpu_to_le32(RNDIS_DF_CONNECTIONLESS);
+ resp->Medium = cpu_to_le32(RNDIS_MEDIUM_802_3);
+ resp->MaxPacketsPerTransfer = cpu_to_le32(1);
+ resp->MaxTransferSize = cpu_to_le32(
params->dev->mtu
- + sizeof (struct ethhdr)
- + sizeof (struct rndis_packet_msg_type)
+ + sizeof(struct ethhdr)
+ + sizeof(struct rndis_packet_msg_type)
+ 22);
- resp->PacketAlignmentFactor = cpu_to_le32 (0);
- resp->AFListOffset = cpu_to_le32 (0);
- resp->AFListSize = cpu_to_le32 (0);
+ resp->PacketAlignmentFactor = cpu_to_le32(0);
+ resp->AFListOffset = cpu_to_le32(0);
+ resp->AFListSize = cpu_to_le32(0);
params->resp_avail(params->v);
return 0;
}
-static int rndis_query_response (int configNr, rndis_query_msg_type *buf)
+static int rndis_query_response(int configNr, rndis_query_msg_type *buf)
{
rndis_query_cmplt_type *resp;
- rndis_resp_t *r;
- struct rndis_params *params = rndis_per_dev_params + configNr;
+ rndis_resp_t *r;
+ struct rndis_params *params = rndis_per_dev_params + configNr;
/* pr_debug("%s: OID = %08X\n", __func__, cpu_to_le32(buf->OID)); */
if (!params->dev)
@@ -616,47 +616,46 @@ static int rndis_query_response (int configNr, rndis_query_msg_type *buf)
* rndis_query_cmplt_type followed by data.
* oid_supported_list is the largest data reply
*/
- r = rndis_add_response (configNr,
- sizeof (oid_supported_list) + sizeof(rndis_query_cmplt_type));
+ r = rndis_add_response(configNr,
+ sizeof(oid_supported_list) + sizeof(rndis_query_cmplt_type));
if (!r)
return -ENOMEM;
- resp = (rndis_query_cmplt_type *) r->buf;
+ resp = (rndis_query_cmplt_type *)r->buf;
- resp->MessageType = cpu_to_le32 (REMOTE_NDIS_QUERY_CMPLT);
+ resp->MessageType = cpu_to_le32(REMOTE_NDIS_QUERY_CMPLT);
resp->RequestID = buf->RequestID; /* Still LE in msg buffer */
- if (gen_ndis_query_resp (configNr, le32_to_cpu (buf->OID),
+ if (gen_ndis_query_resp(configNr, le32_to_cpu(buf->OID),
le32_to_cpu(buf->InformationBufferOffset)
- + 8 + (u8 *) buf,
+ + 8 + (u8 *)buf,
le32_to_cpu(buf->InformationBufferLength),
r)) {
/* OID not supported */
- resp->Status = cpu_to_le32 (
- RNDIS_STATUS_NOT_SUPPORTED);
- resp->MessageLength = cpu_to_le32 (sizeof *resp);
- resp->InformationBufferLength = cpu_to_le32 (0);
- resp->InformationBufferOffset = cpu_to_le32 (0);
+ resp->Status = cpu_to_le32(RNDIS_STATUS_NOT_SUPPORTED);
+ resp->MessageLength = cpu_to_le32(sizeof *resp);
+ resp->InformationBufferLength = cpu_to_le32(0);
+ resp->InformationBufferOffset = cpu_to_le32(0);
} else
- resp->Status = cpu_to_le32 (RNDIS_STATUS_SUCCESS);
+ resp->Status = cpu_to_le32(RNDIS_STATUS_SUCCESS);
params->resp_avail(params->v);
return 0;
}
-static int rndis_set_response (int configNr, rndis_set_msg_type *buf)
+static int rndis_set_response(int configNr, rndis_set_msg_type *buf)
{
- u32 BufLength, BufOffset;
- rndis_set_cmplt_type *resp;
- rndis_resp_t *r;
- struct rndis_params *params = rndis_per_dev_params + configNr;
+ u32 BufLength, BufOffset;
+ rndis_set_cmplt_type *resp;
+ rndis_resp_t *r;
+ struct rndis_params *params = rndis_per_dev_params + configNr;
- r = rndis_add_response (configNr, sizeof (rndis_set_cmplt_type));
+ r = rndis_add_response(configNr, sizeof(rndis_set_cmplt_type));
if (!r)
return -ENOMEM;
- resp = (rndis_set_cmplt_type *) r->buf;
+ resp = (rndis_set_cmplt_type *)r->buf;
- BufLength = le32_to_cpu (buf->InformationBufferLength);
- BufOffset = le32_to_cpu (buf->InformationBufferOffset);
+ BufLength = le32_to_cpu(buf->InformationBufferLength);
+ BufOffset = le32_to_cpu(buf->InformationBufferOffset);
#ifdef VERBOSE_DEBUG
pr_debug("%s: Length: %d\n", __func__, BufLength);
@@ -670,59 +669,59 @@ static int rndis_set_response (int configNr, rndis_set_msg_type *buf)
pr_debug("\n");
#endif
- resp->MessageType = cpu_to_le32 (REMOTE_NDIS_SET_CMPLT);
- resp->MessageLength = cpu_to_le32 (16);
+ resp->MessageType = cpu_to_le32(REMOTE_NDIS_SET_CMPLT);
+ resp->MessageLength = cpu_to_le32(16);
resp->RequestID = buf->RequestID; /* Still LE in msg buffer */
- if (gen_ndis_set_resp (configNr, le32_to_cpu (buf->OID),
- ((u8 *) buf) + 8 + BufOffset, BufLength, r))
- resp->Status = cpu_to_le32 (RNDIS_STATUS_NOT_SUPPORTED);
+ if (gen_ndis_set_resp(configNr, le32_to_cpu(buf->OID),
+ ((u8 *)buf) + 8 + BufOffset, BufLength, r))
+ resp->Status = cpu_to_le32(RNDIS_STATUS_NOT_SUPPORTED);
else
- resp->Status = cpu_to_le32 (RNDIS_STATUS_SUCCESS);
+ resp->Status = cpu_to_le32(RNDIS_STATUS_SUCCESS);
params->resp_avail(params->v);
return 0;
}
-static int rndis_reset_response (int configNr, rndis_reset_msg_type *buf)
+static int rndis_reset_response(int configNr, rndis_reset_msg_type *buf)
{
- rndis_reset_cmplt_type *resp;
- rndis_resp_t *r;
- struct rndis_params *params = rndis_per_dev_params + configNr;
+ rndis_reset_cmplt_type *resp;
+ rndis_resp_t *r;
+ struct rndis_params *params = rndis_per_dev_params + configNr;
- r = rndis_add_response (configNr, sizeof (rndis_reset_cmplt_type));
+ r = rndis_add_response(configNr, sizeof(rndis_reset_cmplt_type));
if (!r)
return -ENOMEM;
- resp = (rndis_reset_cmplt_type *) r->buf;
+ resp = (rndis_reset_cmplt_type *)r->buf;
- resp->MessageType = cpu_to_le32 (REMOTE_NDIS_RESET_CMPLT);
- resp->MessageLength = cpu_to_le32 (16);
- resp->Status = cpu_to_le32 (RNDIS_STATUS_SUCCESS);
+ resp->MessageType = cpu_to_le32(REMOTE_NDIS_RESET_CMPLT);
+ resp->MessageLength = cpu_to_le32(16);
+ resp->Status = cpu_to_le32(RNDIS_STATUS_SUCCESS);
/* resent information */
- resp->AddressingReset = cpu_to_le32 (1);
+ resp->AddressingReset = cpu_to_le32(1);
params->resp_avail(params->v);
return 0;
}
-static int rndis_keepalive_response (int configNr,
- rndis_keepalive_msg_type *buf)
+static int rndis_keepalive_response(int configNr,
+ rndis_keepalive_msg_type *buf)
{
- rndis_keepalive_cmplt_type *resp;
- rndis_resp_t *r;
- struct rndis_params *params = rndis_per_dev_params + configNr;
+ rndis_keepalive_cmplt_type *resp;
+ rndis_resp_t *r;
+ struct rndis_params *params = rndis_per_dev_params + configNr;
/* host "should" check only in RNDIS_DATA_INITIALIZED state */
- r = rndis_add_response (configNr, sizeof (rndis_keepalive_cmplt_type));
+ r = rndis_add_response(configNr, sizeof(rndis_keepalive_cmplt_type));
if (!r)
return -ENOMEM;
- resp = (rndis_keepalive_cmplt_type *) r->buf;
+ resp = (rndis_keepalive_cmplt_type *)r->buf;
- resp->MessageType = cpu_to_le32 (
+ resp->MessageType = cpu_to_le32(
REMOTE_NDIS_KEEPALIVE_CMPLT);
- resp->MessageLength = cpu_to_le32 (16);
+ resp->MessageLength = cpu_to_le32(16);
resp->RequestID = buf->RequestID; /* Still LE in msg buffer */
- resp->Status = cpu_to_le32 (RNDIS_STATUS_SUCCESS);
+ resp->Status = cpu_to_le32(RNDIS_STATUS_SUCCESS);
params->resp_avail(params->v);
return 0;
@@ -732,86 +731,85 @@ static int rndis_keepalive_response (int configNr,
/*
* Device to Host Comunication
*/
-static int rndis_indicate_status_msg (int configNr, u32 status)
+static int rndis_indicate_status_msg(int configNr, u32 status)
{
- rndis_indicate_status_msg_type *resp;
- rndis_resp_t *r;
- struct rndis_params *params = rndis_per_dev_params + configNr;
+ rndis_indicate_status_msg_type *resp;
+ rndis_resp_t *r;
+ struct rndis_params *params = rndis_per_dev_params + configNr;
if (params->state == RNDIS_UNINITIALIZED)
return -ENOTSUPP;
- r = rndis_add_response (configNr,
- sizeof (rndis_indicate_status_msg_type));
+ r = rndis_add_response(configNr,
+ sizeof(rndis_indicate_status_msg_type));
if (!r)
return -ENOMEM;
- resp = (rndis_indicate_status_msg_type *) r->buf;
+ resp = (rndis_indicate_status_msg_type *)r->buf;
- resp->MessageType = cpu_to_le32 (
- REMOTE_NDIS_INDICATE_STATUS_MSG);
- resp->MessageLength = cpu_to_le32 (20);
- resp->Status = cpu_to_le32 (status);
- resp->StatusBufferLength = cpu_to_le32 (0);
- resp->StatusBufferOffset = cpu_to_le32 (0);
+ resp->MessageType = cpu_to_le32(REMOTE_NDIS_INDICATE_STATUS_MSG);
+ resp->MessageLength = cpu_to_le32(20);
+ resp->Status = cpu_to_le32(status);
+ resp->StatusBufferLength = cpu_to_le32(0);
+ resp->StatusBufferOffset = cpu_to_le32(0);
params->resp_avail(params->v);
return 0;
}
-int rndis_signal_connect (int configNr)
+int rndis_signal_connect(int configNr)
{
- rndis_per_dev_params [configNr].media_state
+ rndis_per_dev_params[configNr].media_state
= NDIS_MEDIA_STATE_CONNECTED;
- return rndis_indicate_status_msg (configNr,
+ return rndis_indicate_status_msg(configNr,
RNDIS_STATUS_MEDIA_CONNECT);
}
-int rndis_signal_disconnect (int configNr)
+int rndis_signal_disconnect(int configNr)
{
- rndis_per_dev_params [configNr].media_state
+ rndis_per_dev_params[configNr].media_state
= NDIS_MEDIA_STATE_DISCONNECTED;
- return rndis_indicate_status_msg (configNr,
+ return rndis_indicate_status_msg(configNr,
RNDIS_STATUS_MEDIA_DISCONNECT);
}
-void rndis_uninit (int configNr)
+void rndis_uninit(int configNr)
{
u8 *buf;
u32 length;
if (configNr >= RNDIS_MAX_CONFIGS)
return;
- rndis_per_dev_params [configNr].state = RNDIS_UNINITIALIZED;
+ rndis_per_dev_params[configNr].state = RNDIS_UNINITIALIZED;
/* drain the response queue */
while ((buf = rndis_get_next_response(configNr, &length)))
rndis_free_response(configNr, buf);
}
-void rndis_set_host_mac (int configNr, const u8 *addr)
+void rndis_set_host_mac(int configNr, const u8 *addr)
{
- rndis_per_dev_params [configNr].host_mac = addr;
+ rndis_per_dev_params[configNr].host_mac = addr;
}
/*
* Message Parser
*/
-int rndis_msg_parser (u8 configNr, u8 *buf)
+int rndis_msg_parser(u8 configNr, u8 *buf)
{
u32 MsgType, MsgLength;
__le32 *tmp;
- struct rndis_params *params;
+ struct rndis_params *params;
if (!buf)
return -ENOMEM;
- tmp = (__le32 *) buf;
+ tmp = (__le32 *)buf;
MsgType = get_unaligned_le32(tmp++);
MsgLength = get_unaligned_le32(tmp++);
if (configNr >= RNDIS_MAX_CONFIGS)
return -ENOTSUPP;
- params = &rndis_per_dev_params [configNr];
+ params = &rndis_per_dev_params[configNr];
/* NOTE: RNDIS is *EXTREMELY* chatty ... Windows constantly polls for
* rx/tx statistics and link status, in addition to KEEPALIVE traffic
@@ -822,41 +820,41 @@ int rndis_msg_parser (u8 configNr, u8 *buf)
switch (MsgType) {
case REMOTE_NDIS_INITIALIZE_MSG:
pr_debug("%s: REMOTE_NDIS_INITIALIZE_MSG\n",
- __func__ );
+ __func__);
params->state = RNDIS_INITIALIZED;
- return rndis_init_response (configNr,
- (rndis_init_msg_type *) buf);
+ return rndis_init_response(configNr,
+ (rndis_init_msg_type *)buf);
case REMOTE_NDIS_HALT_MSG:
pr_debug("%s: REMOTE_NDIS_HALT_MSG\n",
- __func__ );
+ __func__);
params->state = RNDIS_UNINITIALIZED;
if (params->dev) {
- netif_carrier_off (params->dev);
- netif_stop_queue (params->dev);
+ netif_carrier_off(params->dev);
+ netif_stop_queue(params->dev);
}
return 0;
case REMOTE_NDIS_QUERY_MSG:
- return rndis_query_response (configNr,
- (rndis_query_msg_type *) buf);
+ return rndis_query_response(configNr,
+ (rndis_query_msg_type *)buf);
case REMOTE_NDIS_SET_MSG:
- return rndis_set_response (configNr,
- (rndis_set_msg_type *) buf);
+ return rndis_set_response(configNr,
+ (rndis_set_msg_type *)buf);
case REMOTE_NDIS_RESET_MSG:
pr_debug("%s: REMOTE_NDIS_RESET_MSG\n",
- __func__ );
- return rndis_reset_response (configNr,
- (rndis_reset_msg_type *) buf);
+ __func__);
+ return rndis_reset_response(configNr,
+ (rndis_reset_msg_type *)buf);
case REMOTE_NDIS_KEEPALIVE_MSG:
/* For USB: host does this every 5 seconds */
if (rndis_debug > 1)
pr_debug("%s: REMOTE_NDIS_KEEPALIVE_MSG\n",
- __func__ );
- return rndis_keepalive_response (configNr,
+ __func__);
+ return rndis_keepalive_response(configNr,
(rndis_keepalive_msg_type *)
buf);
@@ -866,7 +864,7 @@ int rndis_msg_parser (u8 configNr, u8 *buf)
* suspending itself.
*/
pr_warning("%s: unknown RNDIS message 0x%08X len %d\n",
- __func__ , MsgType, MsgLength);
+ __func__, MsgType, MsgLength);
{
unsigned i;
for (i = 0; i < MsgLength; i += 16) {
@@ -901,10 +899,10 @@ int rndis_register(void (*resp_avail)(void *v), void *v)
return -EINVAL;
for (i = 0; i < RNDIS_MAX_CONFIGS; i++) {
- if (!rndis_per_dev_params [i].used) {
- rndis_per_dev_params [i].used = 1;
- rndis_per_dev_params [i].resp_avail = resp_avail;
- rndis_per_dev_params [i].v = v;
+ if (!rndis_per_dev_params[i].used) {
+ rndis_per_dev_params[i].used = 1;
+ rndis_per_dev_params[i].resp_avail = resp_avail;
+ rndis_per_dev_params[i].v = v;
pr_debug("%s: configNr = %d\n", __func__, i);
return i;
}
@@ -914,12 +912,12 @@ int rndis_register(void (*resp_avail)(void *v), void *v)
return -ENODEV;
}
-void rndis_deregister (int configNr)
+void rndis_deregister(int configNr)
{
- pr_debug("%s: \n", __func__);
+ pr_debug("%s:\n", __func__);
if (configNr >= RNDIS_MAX_CONFIGS) return;
- rndis_per_dev_params [configNr].used = 0;
+ rndis_per_dev_params[configNr].used = 0;
return;
}
@@ -931,76 +929,76 @@ int rndis_set_param_dev(u8 configNr, struct net_device *dev, u16 *cdc_filter)
return -EINVAL;
if (configNr >= RNDIS_MAX_CONFIGS) return -1;
- rndis_per_dev_params [configNr].dev = dev;
- rndis_per_dev_params [configNr].filter = cdc_filter;
+ rndis_per_dev_params[configNr].dev = dev;
+ rndis_per_dev_params[configNr].filter = cdc_filter;
return 0;
}
-int rndis_set_param_vendor (u8 configNr, u32 vendorID, const char *vendorDescr)
+int rndis_set_param_vendor(u8 configNr, u32 vendorID, const char *vendorDescr)
{
pr_debug("%s:\n", __func__);
if (!vendorDescr) return -1;
if (configNr >= RNDIS_MAX_CONFIGS) return -1;
- rndis_per_dev_params [configNr].vendorID = vendorID;
- rndis_per_dev_params [configNr].vendorDescr = vendorDescr;
+ rndis_per_dev_params[configNr].vendorID = vendorID;
+ rndis_per_dev_params[configNr].vendorDescr = vendorDescr;
return 0;
}
-int rndis_set_param_medium (u8 configNr, u32 medium, u32 speed)
+int rndis_set_param_medium(u8 configNr, u32 medium, u32 speed)
{
pr_debug("%s: %u %u\n", __func__, medium, speed);
if (configNr >= RNDIS_MAX_CONFIGS) return -1;
- rndis_per_dev_params [configNr].medium = medium;
- rndis_per_dev_params [configNr].speed = speed;
+ rndis_per_dev_params[configNr].medium = medium;
+ rndis_per_dev_params[configNr].speed = speed;
return 0;
}
-void rndis_add_hdr (struct sk_buff *skb)
+void rndis_add_hdr(struct sk_buff *skb)
{
- struct rndis_packet_msg_type *header;
+ struct rndis_packet_msg_type *header;
if (!skb)
return;
- header = (void *) skb_push (skb, sizeof *header);
- memset (header, 0, sizeof *header);
+ header = (void *)skb_push(skb, sizeof(*header));
+ memset(header, 0, sizeof *header);
header->MessageType = cpu_to_le32(REMOTE_NDIS_PACKET_MSG);
header->MessageLength = cpu_to_le32(skb->len);
- header->DataOffset = cpu_to_le32 (36);
- header->DataLength = cpu_to_le32(skb->len - sizeof *header);
+ header->DataOffset = cpu_to_le32(36);
+ header->DataLength = cpu_to_le32(skb->len - sizeof(*header));
}
-void rndis_free_response (int configNr, u8 *buf)
+void rndis_free_response(int configNr, u8 *buf)
{
- rndis_resp_t *r;
- struct list_head *act, *tmp;
+ rndis_resp_t *r;
+ struct list_head *act, *tmp;
- list_for_each_safe (act, tmp,
- &(rndis_per_dev_params [configNr].resp_queue))
+ list_for_each_safe(act, tmp,
+ &(rndis_per_dev_params[configNr].resp_queue))
{
- r = list_entry (act, rndis_resp_t, list);
+ r = list_entry(act, rndis_resp_t, list);
if (r && r->buf == buf) {
- list_del (&r->list);
- kfree (r);
+ list_del(&r->list);
+ kfree(r);
}
}
}
-u8 *rndis_get_next_response (int configNr, u32 *length)
+u8 *rndis_get_next_response(int configNr, u32 *length)
{
- rndis_resp_t *r;
- struct list_head *act, *tmp;
+ rndis_resp_t *r;
+ struct list_head *act, *tmp;
if (!length) return NULL;
- list_for_each_safe (act, tmp,
- &(rndis_per_dev_params [configNr].resp_queue))
+ list_for_each_safe(act, tmp,
+ &(rndis_per_dev_params[configNr].resp_queue))
{
- r = list_entry (act, rndis_resp_t, list);
+ r = list_entry(act, rndis_resp_t, list);
if (!r->send) {
r->send = 1;
*length = r->length;
@@ -1011,20 +1009,20 @@ u8 *rndis_get_next_response (int configNr, u32 *length)
return NULL;
}
-static rndis_resp_t *rndis_add_response (int configNr, u32 length)
+static rndis_resp_t *rndis_add_response(int configNr, u32 length)
{
- rndis_resp_t *r;
+ rndis_resp_t *r;
- /* NOTE: this gets copied into ether.c USB_BUFSIZ bytes ... */
- r = kmalloc (sizeof (rndis_resp_t) + length, GFP_ATOMIC);
+ /* NOTE: this gets copied into ether.c USB_BUFSIZ bytes ... */
+ r = kmalloc(sizeof(rndis_resp_t) + length, GFP_ATOMIC);
if (!r) return NULL;
- r->buf = (u8 *) (r + 1);
+ r->buf = (u8 *)(r + 1);
r->length = length;
r->send = 0;
- list_add_tail (&r->list,
- &(rndis_per_dev_params [configNr].resp_queue));
+ list_add_tail(&r->list,
+ &(rndis_per_dev_params[configNr].resp_queue));
return r;
}
@@ -1033,7 +1031,7 @@ int rndis_rm_hdr(struct gether *port,
struct sk_buff_head *list)
{
/* tmp points to a struct rndis_packet_msg_type */
- __le32 *tmp = (void *) skb->data;
+ __le32 *tmp = (void *)skb->data;
/* MessageType, MessageLength */
if (cpu_to_le32(REMOTE_NDIS_PACKET_MSG)
@@ -1054,7 +1052,7 @@ int rndis_rm_hdr(struct gether *port,
return 0;
}
-#ifdef CONFIG_USB_GADGET_DEBUG_FILES
+#ifdef CONFIG_USB_GADGET_DEBUG_FILES
static int rndis_proc_show(struct seq_file *m, void *v)
{
@@ -1087,7 +1085,7 @@ static int rndis_proc_show(struct seq_file *m, void *v)
}
static ssize_t rndis_proc_write(struct file *file, const char __user *buffer,
- size_t count, loff_t *ppos)
+ size_t count, loff_t *ppos)
{
rndis_params *p = PDE(file->f_path.dentry->d_inode)->data;
u32 speed = 0;
@@ -1109,11 +1107,11 @@ static ssize_t rndis_proc_write(struct file *file, const char __user *buffer,
case '8':
case '9':
fl_speed = 1;
- speed = speed*10 + c - '0';
+ speed = speed * 10 + c - '0';
break;
case 'C':
case 'c':
- rndis_signal_connect (p->confignr);
+ rndis_signal_connect(p->confignr);
break;
case 'D':
case 'd':
@@ -1145,11 +1143,11 @@ static const struct file_operations rndis_proc_fops = {
.write = rndis_proc_write,
};
-#define NAME_TEMPLATE "driver/rndis-%03d"
+#define NAME_TEMPLATE "driver/rndis-%03d"
static struct proc_dir_entry *rndis_connect_state [RNDIS_MAX_CONFIGS];
-#endif /* CONFIG_USB_GADGET_DEBUG_FILES */
+#endif /* CONFIG_USB_GADGET_DEBUG_FILES */
int rndis_init(void)
@@ -1160,42 +1158,40 @@ int rndis_init(void)
#ifdef CONFIG_USB_GADGET_DEBUG_FILES
char name [20];
- sprintf (name, NAME_TEMPLATE, i);
- if (!(rndis_connect_state [i]
- = proc_create_data(name, 0660, NULL,
+ sprintf(name, NAME_TEMPLATE, i);
+ rndis_connect_state[i] = proc_create_data(name, 0660, NULL,
&rndis_proc_fops,
- (void *)(rndis_per_dev_params + i))))
- {
- pr_debug("%s :remove entries", __func__);
+ (void *)(rndis_per_dev_params + i));
+ if (!rndis_connect_state[i]) {
+ pr_debug("%s: remove entries", __func__);
while (i) {
- sprintf (name, NAME_TEMPLATE, --i);
- remove_proc_entry (name, NULL);
+ sprintf(name, NAME_TEMPLATE, --i);
+ remove_proc_entry(name, NULL);
}
pr_debug("\n");
return -EIO;
}
#endif
- rndis_per_dev_params [i].confignr = i;
- rndis_per_dev_params [i].used = 0;
- rndis_per_dev_params [i].state = RNDIS_UNINITIALIZED;
- rndis_per_dev_params [i].media_state
+ rndis_per_dev_params[i].confignr = i;
+ rndis_per_dev_params[i].used = 0;
+ rndis_per_dev_params[i].state = RNDIS_UNINITIALIZED;
+ rndis_per_dev_params[i].media_state
= NDIS_MEDIA_STATE_DISCONNECTED;
- INIT_LIST_HEAD (&(rndis_per_dev_params [i].resp_queue));
+ INIT_LIST_HEAD(&(rndis_per_dev_params[i].resp_queue));
}
return 0;
}
-void rndis_exit (void)
+void rndis_exit(void)
{
-#ifdef CONFIG_USB_GADGET_DEBUG_FILES
+#ifdef CONFIG_USB_GADGET_DEBUG_FILES
u8 i;
- char name [20];
+ char name[20];
for (i = 0; i < RNDIS_MAX_CONFIGS; i++) {
- sprintf (name, NAME_TEMPLATE, i);
- remove_proc_entry (name, NULL);
+ sprintf(name, NAME_TEMPLATE, i);
+ remove_proc_entry(name, NULL);
}
#endif
}
-
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)
return 0;
}
-int usb_gadget_register_driver(struct usb_gadget_driver *driver)
+int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
+ int (*bind)(struct usb_gadget *))
{
struct s3c_hsotg *hsotg = our_hsotg;
int ret;
@@ -2543,7 +2544,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
dev_err(hsotg->dev, "%s: bad speed\n", __func__);
}
- if (!driver->bind || !driver->setup) {
+ if (!bind || !driver->setup) {
dev_err(hsotg->dev, "%s: missing entry points\n", __func__);
return -EINVAL;
}
@@ -2562,7 +2563,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
goto err;
}
- ret = driver->bind(&hsotg->gadget);
+ ret = bind(&hsotg->gadget);
if (ret) {
dev_err(hsotg->dev, "failed bind %s\n", driver->driver.name);
@@ -2687,7 +2688,7 @@ err:
hsotg->gadget.dev.driver = NULL;
return ret;
}
-EXPORT_SYMBOL(usb_gadget_register_driver);
+EXPORT_SYMBOL(usb_gadget_probe_driver);
int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
{
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)
}
/*
- * usb_gadget_register_driver
+ * usb_gadget_probe_driver
*/
-int usb_gadget_register_driver(struct usb_gadget_driver *driver)
+int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
+ int (*bind)(struct usb_gadget *))
{
struct s3c2410_udc *udc = the_controller;
int retval;
- dprintk(DEBUG_NORMAL, "usb_gadget_register_driver() '%s'\n",
- driver->driver.name);
+ dprintk(DEBUG_NORMAL, "%s() '%s'\n", __func__, driver->driver.name);
/* Sanity checks */
if (!udc)
@@ -1649,10 +1649,9 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
if (udc->driver)
return -EBUSY;
- if (!driver->bind || !driver->setup
- || driver->speed < USB_SPEED_FULL) {
+ if (!bind || !driver->setup || driver->speed < USB_SPEED_FULL) {
printk(KERN_ERR "Invalid driver: bind %p setup %p speed %d\n",
- driver->bind, driver->setup, driver->speed);
+ bind, driver->setup, driver->speed);
return -EINVAL;
}
#if defined(MODULE)
@@ -1675,7 +1674,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
dprintk(DEBUG_NORMAL, "binding gadget driver '%s'\n",
driver->driver.name);
- if ((retval = driver->bind (&udc->gadget)) != 0) {
+ if ((retval = bind(&udc->gadget)) != 0) {
device_del(&udc->gadget.dev);
goto register_error;
}
@@ -1690,6 +1689,7 @@ register_error:
udc->gadget.dev.driver = NULL;
return retval;
}
+EXPORT_SYMBOL(usb_gadget_probe_driver);
/*
* usb_gadget_unregister_driver
@@ -2049,7 +2049,6 @@ static void __exit udc_exit(void)
}
EXPORT_SYMBOL(usb_gadget_unregister_driver);
-EXPORT_SYMBOL(usb_gadget_register_driver);
module_init(udc_init);
module_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");
/*-------------------------------------------------------------------------*/
-static int __ref serial_bind_config(struct usb_configuration *c)
+static int __init serial_bind_config(struct usb_configuration *c)
{
unsigned i;
int status = 0;
@@ -155,13 +155,12 @@ static int __ref serial_bind_config(struct usb_configuration *c)
static struct usb_configuration serial_config_driver = {
/* .label = f(use_acm) */
- .bind = serial_bind_config,
/* .bConfigurationValue = f(use_acm) */
/* .iConfiguration = DYNAMIC */
.bmAttributes = USB_CONFIG_ATT_SELFPOWER,
};
-static int __ref gs_bind(struct usb_composite_dev *cdev)
+static int __init gs_bind(struct usb_composite_dev *cdev)
{
int gcnum;
struct usb_gadget *gadget = cdev->gadget;
@@ -225,7 +224,8 @@ static int __ref gs_bind(struct usb_composite_dev *cdev)
}
/* register our configuration */
- status = usb_add_config(cdev, &serial_config_driver);
+ status = usb_add_config(cdev, &serial_config_driver,
+ serial_bind_config);
if (status < 0)
goto fail;
@@ -242,7 +242,6 @@ static struct usb_composite_driver gserial_driver = {
.name = "g_serial",
.dev = &device_desc,
.strings = dev_strings,
- .bind = gs_bind,
};
static int __init init(void)
@@ -271,7 +270,7 @@ static int __init init(void)
}
strings_dev[STRING_DESCRIPTION_IDX].s = serial_config_driver.label;
- return usb_composite_register(&gserial_driver);
+ return usb_composite_probe(&gserial_driver, gs_bind);
}
module_init(init);
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 @@
* be defined (each of type pointer to char):
* - fsg_string_manufacturer -- name of the manufacturer
* - fsg_string_product -- name of the product
- * - fsg_string_serial -- product's serial
* - fsg_string_config -- name of the configuration
* - fsg_string_interface -- name of the interface
* The first four are only needed when FSG_DESCRIPTORS_DEVICE_STRINGS
@@ -54,6 +53,8 @@
*/
+#include <linux/usb/storage.h>
+#include <scsi/scsi.h>
#include <asm/unaligned.h>
@@ -153,23 +154,6 @@
/*-------------------------------------------------------------------------*/
-/* SCSI device types */
-#define TYPE_DISK 0x00
-#define TYPE_CDROM 0x05
-
-/* USB protocol value = the transport method */
-#define USB_PR_CBI 0x00 /* Control/Bulk/Interrupt */
-#define USB_PR_CB 0x01 /* Control/Bulk w/o interrupt */
-#define USB_PR_BULK 0x50 /* Bulk-only */
-
-/* USB subclass value = the protocol encapsulation */
-#define USB_SC_RBC 0x01 /* Reduced Block Commands (flash) */
-#define USB_SC_8020 0x02 /* SFF-8020i, MMC-2, ATAPI (CD-ROM) */
-#define USB_SC_QIC 0x03 /* QIC-157 (tape) */
-#define USB_SC_UFI 0x04 /* UFI (floppy) */
-#define USB_SC_8070 0x05 /* SFF-8070i (removable) */
-#define USB_SC_SCSI 0x06 /* Transparent SCSI */
-
/* Bulk-only data structures */
/* Command Block Wrapper */
@@ -221,33 +205,6 @@ struct interrupt_data {
/* Length of a SCSI Command Data Block */
#define MAX_COMMAND_SIZE 16
-/* SCSI commands that we recognize */
-#define SC_FORMAT_UNIT 0x04
-#define SC_INQUIRY 0x12
-#define SC_MODE_SELECT_6 0x15
-#define SC_MODE_SELECT_10 0x55
-#define SC_MODE_SENSE_6 0x1a
-#define SC_MODE_SENSE_10 0x5a
-#define SC_PREVENT_ALLOW_MEDIUM_REMOVAL 0x1e
-#define SC_READ_6 0x08
-#define SC_READ_10 0x28
-#define SC_READ_12 0xa8
-#define SC_READ_CAPACITY 0x25
-#define SC_READ_FORMAT_CAPACITIES 0x23
-#define SC_READ_HEADER 0x44
-#define SC_READ_TOC 0x43
-#define SC_RELEASE 0x17
-#define SC_REQUEST_SENSE 0x03
-#define SC_RESERVE 0x16
-#define SC_SEND_DIAGNOSTIC 0x1d
-#define SC_START_STOP_UNIT 0x1b
-#define SC_SYNCHRONIZE_CACHE 0x35
-#define SC_TEST_UNIT_READY 0x00
-#define SC_VERIFY 0x2f
-#define SC_WRITE_6 0x0a
-#define SC_WRITE_10 0x2a
-#define SC_WRITE_12 0xaa
-
/* SCSI Sense Key/Additional Sense Code/ASC Qualifier values */
#define SS_NO_SENSE 0
#define SS_COMMUNICATION_FAILURE 0x040800
@@ -552,7 +509,7 @@ static struct usb_string fsg_strings[] = {
#ifndef FSG_NO_DEVICE_STRINGS
{FSG_STRING_MANUFACTURER, fsg_string_manufacturer},
{FSG_STRING_PRODUCT, fsg_string_product},
- {FSG_STRING_SERIAL, fsg_string_serial},
+ {FSG_STRING_SERIAL, ""},
{FSG_STRING_CONFIG, fsg_string_config},
#endif
{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[] = {
* USB configuration
*/
-static int __ref
+static int __init
webcam_config_bind(struct usb_configuration *c)
{
return uvc_bind_config(c, uvc_control_cls, uvc_fs_streaming_cls,
@@ -317,7 +317,6 @@ webcam_config_bind(struct usb_configuration *c)
static struct usb_configuration webcam_config_driver = {
.label = webcam_config_label,
- .bind = webcam_config_bind,
.bConfigurationValue = 1,
.iConfiguration = 0, /* dynamic */
.bmAttributes = USB_CONFIG_ATT_SELFPOWER,
@@ -330,7 +329,7 @@ webcam_unbind(struct usb_composite_dev *cdev)
return 0;
}
-static int __ref
+static int __init
webcam_bind(struct usb_composite_dev *cdev)
{
int ret;
@@ -354,7 +353,8 @@ webcam_bind(struct usb_composite_dev *cdev)
webcam_config_driver.iConfiguration = ret;
/* Register our configuration. */
- if ((ret = usb_add_config(cdev, &webcam_config_driver)) < 0)
+ if ((ret = usb_add_config(cdev, &webcam_config_driver,
+ webcam_config_bind)) < 0)
goto error;
INFO(cdev, "Webcam Video Gadget\n");
@@ -373,14 +373,13 @@ static struct usb_composite_driver webcam_driver = {
.name = "g_webcam",
.dev = &webcam_device_descriptor,
.strings = webcam_device_strings,
- .bind = webcam_bind,
.unbind = webcam_unbind,
};
static int __init
webcam_init(void)
{
- return usb_composite_register(&webcam_driver);
+ return usb_composite_probe(&webcam_driver, webcam_bind);
}
static 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)
/*-------------------------------------------------------------------------*/
-static int __ref zero_bind(struct usb_composite_dev *cdev)
+static int __init zero_bind(struct usb_composite_dev *cdev)
{
int gcnum;
struct usb_gadget *gadget = cdev->gadget;
@@ -340,7 +340,6 @@ static struct usb_composite_driver zero_driver = {
.name = "zero",
.dev = &device_desc,
.strings = dev_strings,
- .bind = zero_bind,
.unbind = zero_unbind,
.suspend = zero_suspend,
.resume = zero_resume,
@@ -351,7 +350,7 @@ MODULE_LICENSE("GPL");
static int __init init(void)
{
- return usb_composite_register(&zero_driver);
+ return usb_composite_probe(&zero_driver, zero_bind);
}
module_init(init);
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
config USB_EHCI_BIG_ENDIAN_MMIO
bool
- depends on USB_EHCI_HCD && (PPC_CELLEB || PPC_PS3 || 440EPX || ARCH_IXP4XX || XPS_USB_HCD_XILINX)
+ depends on USB_EHCI_HCD && (PPC_CELLEB || PPC_PS3 || 440EPX || ARCH_IXP4XX || \
+ XPS_USB_HCD_XILINX || PPC_MPC512x)
default y
config USB_EHCI_BIG_ENDIAN_DESC
bool
- depends on USB_EHCI_HCD && (440EPX || ARCH_IXP4XX || XPS_USB_HCD_XILINX)
+ depends on USB_EHCI_HCD && (440EPX || ARCH_IXP4XX || XPS_USB_HCD_XILINX || \
+ PPC_MPC512x)
default y
config XPS_USB_HCD_XILINX
@@ -112,10 +114,14 @@ config XPS_USB_HCD_XILINX
support both high speed and full speed devices, or high speed
devices only.
+config USB_FSL_MPH_DR_OF
+ tristate
+
config USB_EHCI_FSL
bool "Support for Freescale on-chip EHCI USB controller"
depends on USB_EHCI_HCD && FSL_SOC
select USB_EHCI_ROOT_HUB_TT
+ select USB_FSL_MPH_DR_OF
---help---
Variation of ARC USB block used in some Freescale chips.
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 @@
# Makefile for USB Host Controller Drivers
#
-ifeq ($(CONFIG_USB_DEBUG),y)
- EXTRA_CFLAGS += -DDEBUG
-endif
-
-isp1760-objs := isp1760-hcd.o isp1760-if.o
-fhci-objs := fhci-hcd.o fhci-hub.o fhci-q.o fhci-mem.o \
- fhci-tds.o fhci-sched.o
-ifeq ($(CONFIG_FHCI_DEBUG),y)
-fhci-objs += fhci-dbg.o
-endif
-xhci-hcd-objs := xhci.o xhci-mem.o xhci-pci.o xhci-ring.o xhci-hub.o xhci-dbg.o
+ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG
+
+isp1760-y := isp1760-hcd.o isp1760-if.o
+
+fhci-y := fhci-hcd.o fhci-hub.o fhci-q.o
+fhci-y += fhci-mem.o fhci-tds.o fhci-sched.o
+
+fhci-$(CONFIG_FHCI_DEBUG) += fhci-dbg.o
+
+xhci-hcd-y := xhci.o xhci-mem.o xhci-pci.o
+xhci-hcd-y += xhci-ring.o xhci-hub.o xhci-dbg.o
obj-$(CONFIG_USB_WHCI_HCD) += whci/
@@ -33,4 +33,4 @@ obj-$(CONFIG_USB_R8A66597_HCD) += r8a66597-hcd.o
obj-$(CONFIG_USB_ISP1760_HCD) += isp1760.o
obj-$(CONFIG_USB_HWA_HCD) += hwa-hc.o
obj-$(CONFIG_USB_IMX21_HCD) += imx21-hcd.o
-
+obj-$(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,
goto err3;
}
- /* Enable USB controller */
- temp = in_be32(hcd->regs + 0x500);
- out_be32(hcd->regs + 0x500, temp | 0x4);
+ pdata->regs = hcd->regs;
- /* Set to Host mode */
- temp = in_le32(hcd->regs + 0x1a8);
- out_le32(hcd->regs + 0x1a8, temp | 0x3);
+ /*
+ * do platform specific init: check the clock, grab/config pins, etc.
+ */
+ if (pdata->init && pdata->init(pdev)) {
+ retval = -ENODEV;
+ goto err3;
+ }
+
+ /*
+ * Check if it is MPC5121 SoC, otherwise set pdata->have_sysif_regs
+ * flag for 83xx or 8536 system interface registers.
+ */
+ if (pdata->big_endian_mmio)
+ temp = in_be32(hcd->regs + FSL_SOC_USB_ID);
+ else
+ temp = in_le32(hcd->regs + FSL_SOC_USB_ID);
+
+ if ((temp & ID_MSK) != (~((temp & NID_MSK) >> 8) & ID_MSK))
+ pdata->have_sysif_regs = 1;
+
+ /* Enable USB controller, 83xx or 8536 */
+ if (pdata->have_sysif_regs)
+ setbits32(hcd->regs + FSL_SOC_USB_CTRL, 0x4);
+
+ /* Don't need to set host mode here. It will be done by tdi_reset() */
retval = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED);
if (retval != 0)
@@ -137,6 +157,8 @@ static int usb_hcd_fsl_probe(const struct hc_driver *driver,
usb_put_hcd(hcd);
err1:
dev_err(&pdev->dev, "init %s fail, %d\n", dev_name(&pdev->dev), retval);
+ if (pdata->exit)
+ pdata->exit(pdev);
return retval;
}
@@ -154,17 +176,30 @@ static int usb_hcd_fsl_probe(const struct hc_driver *driver,
static void usb_hcd_fsl_remove(struct usb_hcd *hcd,
struct platform_device *pdev)
{
+ struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data;
+
usb_remove_hcd(hcd);
+
+ /*
+ * do platform specific un-initialization:
+ * release iomux pins, disable clock, etc.
+ */
+ if (pdata->exit)
+ pdata->exit(pdev);
iounmap(hcd->regs);
release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
usb_put_hcd(hcd);
}
-static void mpc83xx_setup_phy(struct ehci_hcd *ehci,
- enum fsl_usb2_phy_modes phy_mode,
- unsigned int port_offset)
+static void ehci_fsl_setup_phy(struct ehci_hcd *ehci,
+ enum fsl_usb2_phy_modes phy_mode,
+ unsigned int port_offset)
{
- u32 portsc = 0;
+ u32 portsc;
+
+ portsc = ehci_readl(ehci, &ehci->regs->port_status[port_offset]);
+ portsc &= ~(PORT_PTS_MSK | PORT_PTS_PTW);
+
switch (phy_mode) {
case FSL_USB2_PHY_ULPI:
portsc |= PORT_PTS_ULPI;
@@ -184,20 +219,21 @@ static void mpc83xx_setup_phy(struct ehci_hcd *ehci,
ehci_writel(ehci, portsc, &ehci->regs->port_status[port_offset]);
}
-static void mpc83xx_usb_setup(struct usb_hcd *hcd)
+static void ehci_fsl_usb_setup(struct ehci_hcd *ehci)
{
- struct ehci_hcd *ehci = hcd_to_ehci(hcd);
+ struct usb_hcd *hcd = ehci_to_hcd(ehci);
struct fsl_usb2_platform_data *pdata;
void __iomem *non_ehci = hcd->regs;
u32 temp;
- pdata =
- (struct fsl_usb2_platform_data *)hcd->self.controller->
- platform_data;
+ pdata = hcd->self.controller->platform_data;
+
/* Enable PHY interface in the control reg. */
- temp = in_be32(non_ehci + FSL_SOC_USB_CTRL);
- out_be32(non_ehci + FSL_SOC_USB_CTRL, temp | 0x00000004);
- out_be32(non_ehci + FSL_SOC_USB_SNOOP1, 0x0000001b);
+ if (pdata->have_sysif_regs) {
+ temp = in_be32(non_ehci + FSL_SOC_USB_CTRL);
+ out_be32(non_ehci + FSL_SOC_USB_CTRL, temp | 0x00000004);
+ out_be32(non_ehci + FSL_SOC_USB_SNOOP1, 0x0000001b);
+ }
#if defined(CONFIG_PPC32) && !defined(CONFIG_NOT_COHERENT_CACHE)
/*
@@ -214,7 +250,7 @@ static void mpc83xx_usb_setup(struct usb_hcd *hcd)
if ((pdata->operating_mode == FSL_USB2_DR_HOST) ||
(pdata->operating_mode == FSL_USB2_DR_OTG))
- mpc83xx_setup_phy(ehci, pdata->phy_mode, 0);
+ ehci_fsl_setup_phy(ehci, pdata->phy_mode, 0);
if (pdata->operating_mode == FSL_USB2_MPH_HOST) {
unsigned int chip, rev, svr;
@@ -228,27 +264,27 @@ static void mpc83xx_usb_setup(struct usb_hcd *hcd)
ehci->has_fsl_port_bug = 1;
if (pdata->port_enables & FSL_USB2_PORT0_ENABLED)
- mpc83xx_setup_phy(ehci, pdata->phy_mode, 0);
+ ehci_fsl_setup_phy(ehci, pdata->phy_mode, 0);
if (pdata->port_enables & FSL_USB2_PORT1_ENABLED)
- mpc83xx_setup_phy(ehci, pdata->phy_mode, 1);
+ ehci_fsl_setup_phy(ehci, pdata->phy_mode, 1);
}
- /* put controller in host mode. */
- ehci_writel(ehci, 0x00000003, non_ehci + FSL_SOC_USB_USBMODE);
+ if (pdata->have_sysif_regs) {
#ifdef CONFIG_PPC_85xx
- out_be32(non_ehci + FSL_SOC_USB_PRICTRL, 0x00000008);
- out_be32(non_ehci + FSL_SOC_USB_AGECNTTHRSH, 0x00000080);
+ out_be32(non_ehci + FSL_SOC_USB_PRICTRL, 0x00000008);
+ out_be32(non_ehci + FSL_SOC_USB_AGECNTTHRSH, 0x00000080);
#else
- out_be32(non_ehci + FSL_SOC_USB_PRICTRL, 0x0000000c);
- out_be32(non_ehci + FSL_SOC_USB_AGECNTTHRSH, 0x00000040);
+ out_be32(non_ehci + FSL_SOC_USB_PRICTRL, 0x0000000c);
+ out_be32(non_ehci + FSL_SOC_USB_AGECNTTHRSH, 0x00000040);
#endif
- out_be32(non_ehci + FSL_SOC_USB_SICTRL, 0x00000001);
+ out_be32(non_ehci + FSL_SOC_USB_SICTRL, 0x00000001);
+ }
}
/* called after powerup, by probe or system-pm "wakeup" */
static int ehci_fsl_reinit(struct ehci_hcd *ehci)
{
- mpc83xx_usb_setup(ehci_to_hcd(ehci));
+ ehci_fsl_usb_setup(ehci);
ehci_port_power(ehci, 0);
return 0;
@@ -259,6 +295,11 @@ static int ehci_fsl_setup(struct usb_hcd *hcd)
{
struct ehci_hcd *ehci = hcd_to_ehci(hcd);
int retval;
+ struct fsl_usb2_platform_data *pdata;
+
+ pdata = hcd->self.controller->platform_data;
+ ehci->big_endian_desc = pdata->big_endian_desc;
+ ehci->big_endian_mmio = pdata->big_endian_mmio;
/* EHCI registers start at offset 0x100 */
ehci->caps = hcd->regs + 0x100;
@@ -270,6 +311,8 @@ static int ehci_fsl_setup(struct usb_hcd *hcd)
/* cache this readonly data; minimize chip reads */
ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params);
+ hcd->has_tt = 1;
+
retval = ehci_halt(ehci);
if (retval)
return retval;
@@ -279,8 +322,6 @@ static int ehci_fsl_setup(struct usb_hcd *hcd)
if (retval)
return retval;
- hcd->has_tt = 1;
-
ehci->sbrn = 0x20;
ehci_reset(ehci);
@@ -372,7 +413,7 @@ static const struct hc_driver ehci_fsl_hc_driver = {
* generic hardware linkage
*/
.irq = ehci_irq,
- .flags = HCD_USB2,
+ .flags = HCD_USB2 | HCD_MEMORY,
/*
* 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 @@
-/* Copyright (c) 2005 freescale semiconductor
+/* Copyright (C) 2005-2010 Freescale Semiconductor, Inc.
* Copyright (c) 2005 MontaVista Software
*
* This program is free software; you can redistribute it and/or modify it
@@ -19,6 +19,9 @@
#define _EHCI_FSL_H
/* offsets for the non-ehci registers in the FSL SOC USB controller */
+#define FSL_SOC_USB_ID 0x0
+#define ID_MSK 0x3f
+#define NID_MSK 0x3f00
#define FSL_SOC_USB_ULPIVP 0x170
#define FSL_SOC_USB_PORTSC1 0x184
#define PORT_PTS_MSK (3<<30)
@@ -27,7 +30,14 @@
#define PORT_PTS_SERIAL (3<<30)
#define PORT_PTS_PTW (1<<28)
#define FSL_SOC_USB_PORTSC2 0x188
-#define FSL_SOC_USB_USBMODE 0x1a8
+
+#define FSL_SOC_USB_USBGENCTRL 0x200
+#define USBGENCTRL_PPP (1 << 3)
+#define USBGENCTRL_PFP (1 << 2)
+#define FSL_SOC_USB_ISIPHYCTRL 0x204
+#define ISIPHYCTRL_PXE (1)
+#define ISIPHYCTRL_PHYE (1 << 4)
+
#define FSL_SOC_USB_SNOOP1 0x400 /* NOTE: big-endian */
#define FSL_SOC_USB_SNOOP2 0x404 /* NOTE: big-endian */
#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,
return -ETIMEDOUT;
}
+/* check TDI/ARC silicon is in host mode */
+static int tdi_in_host_mode (struct ehci_hcd *ehci)
+{
+ u32 __iomem *reg_ptr;
+ u32 tmp;
+
+ reg_ptr = (u32 __iomem *)(((u8 __iomem *)ehci->regs) + USBMODE);
+ tmp = ehci_readl(ehci, reg_ptr);
+ return (tmp & 3) == USBMODE_CM_HC;
+}
+
/* force HC to halt state from unknown (EHCI spec section 2.3) */
static int ehci_halt (struct ehci_hcd *ehci)
{
@@ -202,6 +213,10 @@ static int ehci_halt (struct ehci_hcd *ehci)
/* disable any irqs left enabled by previous code */
ehci_writel(ehci, 0, &ehci->regs->intr_enable);
+ if (ehci_is_TDI(ehci) && tdi_in_host_mode(ehci) == 0) {
+ return 0;
+ }
+
if ((temp & STS_HALT) != 0)
return 0;
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,
{
memset (qtd, 0, sizeof *qtd);
qtd->qtd_dma = dma;
- qtd->hw_token = cpu_to_le32 (QTD_STS_HALT);
+ qtd->hw_token = cpu_to_hc32(ehci, QTD_STS_HALT);
qtd->hw_next = EHCI_LIST_END(ehci);
qtd->hw_alt_next = EHCI_LIST_END(ehci);
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 @@
#include <mach/mxc_ehci.h>
#define ULPI_VIEWPORT_OFFSET 0x170
-#define PORTSC_OFFSET 0x184
-#define USBMODE_OFFSET 0x1a8
-#define USBMODE_CM_HOST 3
struct ehci_mxc_priv {
struct clk *usbclk, *ahbclk;
@@ -51,6 +48,8 @@ static int ehci_mxc_setup(struct usb_hcd *hcd)
/* cache this readonly data; minimize chip reads */
ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params);
+ hcd->has_tt = 1;
+
retval = ehci_halt(ehci);
if (retval)
return retval;
@@ -60,8 +59,6 @@ static int ehci_mxc_setup(struct usb_hcd *hcd)
if (retval)
return retval;
- hcd->has_tt = 1;
-
ehci->sbrn = 0x20;
ehci_reset(ehci);
@@ -191,12 +188,8 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev)
clk_enable(priv->ahbclk);
}
- /* set USBMODE to host mode */
- temp = readl(hcd->regs + USBMODE_OFFSET);
- writel(temp | USBMODE_CM_HOST, hcd->regs + USBMODE_OFFSET);
-
/* set up the PORTSCx register */
- writel(pdata->portsc, hcd->regs + PORTSC_OFFSET);
+ ehci_writel(ehci, pdata->portsc, &ehci->regs->port_status[0]);
mdelay(10);
/* 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 @@
+/*
+ * Setup platform devices needed by the Freescale multi-port host
+ * and/or dual-role USB controller modules based on the description
+ * in flat device tree.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ */
+
+#include <linux/kernel.h>
+#include <linux/platform_device.h>
+#include <linux/fsl_devices.h>
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/of_platform.h>
+#include <linux/clk.h>
+
+struct fsl_usb2_dev_data {
+ char *dr_mode; /* controller mode */
+ char *drivers[3]; /* drivers to instantiate for this mode */
+ enum fsl_usb2_operating_modes op_mode; /* operating mode */
+};
+
+struct fsl_usb2_dev_data dr_mode_data[] __devinitdata = {
+ {
+ .dr_mode = "host",
+ .drivers = { "fsl-ehci", NULL, NULL, },
+ .op_mode = FSL_USB2_DR_HOST,
+ },
+ {
+ .dr_mode = "otg",
+ .drivers = { "fsl-usb2-otg", "fsl-ehci", "fsl-usb2-udc", },
+ .op_mode = FSL_USB2_DR_OTG,
+ },
+ {
+ .dr_mode = "peripheral",
+ .drivers = { "fsl-usb2-udc", NULL, NULL, },
+ .op_mode = FSL_USB2_DR_DEVICE,
+ },
+};
+
+struct fsl_usb2_dev_data * __devinit get_dr_mode_data(struct device_node *np)
+{
+ const unsigned char *prop;
+ int i;
+
+ prop = of_get_property(np, "dr_mode", NULL);
+ if (prop) {
+ for (i = 0; i < ARRAY_SIZE(dr_mode_data); i++) {
+ if (!strcmp(prop, dr_mode_data[i].dr_mode))
+ return &dr_mode_data[i];
+ }
+ }
+ pr_warn("%s: Invalid 'dr_mode' property, fallback to host mode\n",
+ np->full_name);
+ return &dr_mode_data[0]; /* mode not specified, use host */
+}
+
+static enum fsl_usb2_phy_modes __devinit determine_usb_phy(const char *phy_type)
+{
+ if (!phy_type)
+ return FSL_USB2_PHY_NONE;
+ if (!strcasecmp(phy_type, "ulpi"))
+ return FSL_USB2_PHY_ULPI;
+ if (!strcasecmp(phy_type, "utmi"))
+ return FSL_USB2_PHY_UTMI;
+ if (!strcasecmp(phy_type, "utmi_wide"))
+ return FSL_USB2_PHY_UTMI_WIDE;
+ if (!strcasecmp(phy_type, "serial"))
+ return FSL_USB2_PHY_SERIAL;
+
+ return FSL_USB2_PHY_NONE;
+}
+
+struct platform_device * __devinit fsl_usb2_device_register(
+ struct platform_device *ofdev,
+ struct fsl_usb2_platform_data *pdata,
+ const char *name, int id)
+{
+ struct platform_device *pdev;
+ const struct resource *res = ofdev->resource;
+ unsigned int num = ofdev->num_resources;
+ int retval;
+
+ pdev = platform_device_alloc(name, id);
+ if (!pdev) {
+ retval = -ENOMEM;
+ goto error;
+ }
+
+ pdev->dev.parent = &ofdev->dev;
+
+ pdev->dev.coherent_dma_mask = ofdev->dev.coherent_dma_mask;
+ pdev->dev.dma_mask = &pdev->archdata.dma_mask;
+ *pdev->dev.dma_mask = *ofdev->dev.dma_mask;
+
+ retval = platform_device_add_data(pdev, pdata, sizeof(*pdata));
+ if (retval)
+ goto error;
+
+ if (num) {
+ retval = platform_device_add_resources(pdev, res, num);
+ if (retval)
+ goto error;
+ }
+
+ retval = platform_device_add(pdev);
+ if (retval)
+ goto error;
+
+ return pdev;
+
+error:
+ platform_device_put(pdev);
+ return ERR_PTR(retval);
+}
+
+static const struct of_device_id fsl_usb2_mph_dr_of_match[];
+
+static int __devinit fsl_usb2_mph_dr_of_probe(struct platform_device *ofdev)
+{
+ struct device_node *np = ofdev->dev.of_node;
+ struct platform_device *usb_dev;
+ struct fsl_usb2_platform_data data, *pdata;
+ struct fsl_usb2_dev_data *dev_data;
+ const struct of_device_id *match;
+ const unsigned char *prop;
+ static unsigned int idx;
+ int i;
+
+ if (!of_device_is_available(np))
+ return -ENODEV;
+
+ match = of_match_device(fsl_usb2_mph_dr_of_match, &ofdev->dev);
+ if (!match)
+ return -ENODEV;
+
+ pdata = &data;
+ if (match->data)
+ memcpy(pdata, match->data, sizeof(data));
+ else
+ memset(pdata, 0, sizeof(data));
+
+ dev_data = get_dr_mode_data(np);
+
+ if (of_device_is_compatible(np, "fsl-usb2-mph")) {
+ if (of_get_property(np, "port0", NULL))
+ pdata->port_enables |= FSL_USB2_PORT0_ENABLED;
+
+ if (of_get_property(np, "port1", NULL))
+ pdata->port_enables |= FSL_USB2_PORT1_ENABLED;
+
+ pdata->operating_mode = FSL_USB2_MPH_HOST;
+ } else {
+ if (of_get_property(np, "fsl,invert-drvvbus", NULL))
+ pdata->invert_drvvbus = 1;
+
+ if (of_get_property(np, "fsl,invert-pwr-fault", NULL))
+ pdata->invert_pwr_fault = 1;
+
+ /* setup mode selected in the device tree */
+ pdata->operating_mode = dev_data->op_mode;
+ }
+
+ prop = of_get_property(np, "phy_type", NULL);
+ pdata->phy_mode = determine_usb_phy(prop);
+
+ for (i = 0; i < ARRAY_SIZE(dev_data->drivers); i++) {
+ if (!dev_data->drivers[i])
+ continue;
+ usb_dev = fsl_usb2_device_register(ofdev, pdata,
+ dev_data->drivers[i], idx);
+ if (IS_ERR(usb_dev)) {
+ dev_err(&ofdev->dev, "Can't register usb device\n");
+ return PTR_ERR(usb_dev);
+ }
+ }
+ idx++;
+ return 0;
+}
+
+static int __devexit __unregister_subdev(struct device *dev, void *d)
+{
+ platform_device_unregister(to_platform_device(dev));
+ return 0;
+}
+
+static int __devexit fsl_usb2_mph_dr_of_remove(struct platform_device *ofdev)
+{
+ device_for_each_child(&ofdev->dev, NULL, __unregister_subdev);
+ return 0;
+}
+
+#ifdef CONFIG_PPC_MPC512x
+
+#define USBGENCTRL 0x200 /* NOTE: big endian */
+#define GC_WU_INT_CLR (1 << 5) /* Wakeup int clear */
+#define GC_ULPI_SEL (1 << 4) /* ULPI i/f select (usb0 only)*/
+#define GC_PPP (1 << 3) /* Inv. Port Power Polarity */
+#define GC_PFP (1 << 2) /* Inv. Power Fault Polarity */
+#define GC_WU_ULPI_EN (1 << 1) /* Wakeup on ULPI event */
+#define GC_WU_IE (1 << 1) /* Wakeup interrupt enable */
+
+#define ISIPHYCTRL 0x204 /* NOTE: big endian */
+#define PHYCTRL_PHYE (1 << 4) /* On-chip UTMI PHY enable */
+#define PHYCTRL_BSENH (1 << 3) /* Bit Stuff Enable High */
+#define PHYCTRL_BSEN (1 << 2) /* Bit Stuff Enable */
+#define PHYCTRL_LSFE (1 << 1) /* Line State Filter Enable */
+#define PHYCTRL_PXE (1 << 0) /* PHY oscillator enable */
+
+int fsl_usb2_mpc5121_init(struct platform_device *pdev)
+{
+ struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data;
+ struct clk *clk;
+ char clk_name[10];
+ int base, clk_num;
+
+ base = pdev->resource->start & 0xf000;
+ if (base == 0x3000)
+ clk_num = 1;
+ else if (base == 0x4000)
+ clk_num = 2;
+ else
+ return -ENODEV;
+
+ snprintf(clk_name, sizeof(clk_name), "usb%d_clk", clk_num);
+ clk = clk_get(&pdev->dev, clk_name);
+ if (IS_ERR(clk)) {
+ dev_err(&pdev->dev, "failed to get clk\n");
+ return PTR_ERR(clk);
+ }
+
+ clk_enable(clk);
+ pdata->clk = clk;
+
+ if (pdata->phy_mode == FSL_USB2_PHY_UTMI_WIDE) {
+ u32 reg = 0;
+
+ if (pdata->invert_drvvbus)
+ reg |= GC_PPP;
+
+ if (pdata->invert_pwr_fault)
+ reg |= GC_PFP;
+
+ out_be32(pdata->regs + ISIPHYCTRL, PHYCTRL_PHYE | PHYCTRL_PXE);
+ out_be32(pdata->regs + USBGENCTRL, reg);
+ }
+ return 0;
+}
+
+static void fsl_usb2_mpc5121_exit(struct platform_device *pdev)
+{
+ struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data;
+
+ pdata->regs = NULL;
+
+ if (pdata->clk) {
+ clk_disable(pdata->clk);
+ clk_put(pdata->clk);
+ }
+}
+
+struct fsl_usb2_platform_data fsl_usb2_mpc5121_pd = {
+ .big_endian_desc = 1,
+ .big_endian_mmio = 1,
+ .es = 1,
+ .le_setup_buf = 1,
+ .init = fsl_usb2_mpc5121_init,
+ .exit = fsl_usb2_mpc5121_exit,
+};
+#endif /* CONFIG_PPC_MPC512x */
+
+static const struct of_device_id fsl_usb2_mph_dr_of_match[] = {
+ { .compatible = "fsl-usb2-mph", },
+ { .compatible = "fsl-usb2-dr", },
+#ifdef CONFIG_PPC_MPC512x
+ { .compatible = "fsl,mpc5121-usb2-dr", .data = &fsl_usb2_mpc5121_pd, },
+#endif
+ {},
+};
+
+static struct platform_driver fsl_usb2_mph_dr_driver = {
+ .driver = {
+ .name = "fsl-usb2-mph-dr",
+ .owner = THIS_MODULE,
+ .of_match_table = fsl_usb2_mph_dr_of_match,
+ },
+ .probe = fsl_usb2_mph_dr_of_probe,
+ .remove = __devexit_p(fsl_usb2_mph_dr_of_remove),
+};
+
+static int __init fsl_usb2_mph_dr_init(void)
+{
+ return platform_driver_register(&fsl_usb2_mph_dr_driver);
+}
+module_init(fsl_usb2_mph_dr_init);
+
+static void __exit fsl_usb2_mph_dr_exit(void)
+{
+ platform_driver_unregister(&fsl_usb2_mph_dr_driver);
+}
+module_exit(fsl_usb2_mph_dr_exit);
+
+MODULE_DESCRIPTION("FSL MPH DR OF devices driver");
+MODULE_AUTHOR("Anatolij Gustschin <agust@denx.de>");
+MODULE_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 @@
#include <linux/slab.h>
#include <linux/usb.h>
#include <linux/usb/hcd.h>
+#include <linux/dma-mapping.h>
#include "imx21-hcd.h"
@@ -136,9 +137,18 @@ static int imx21_hc_get_frame(struct usb_hcd *hcd)
return wrap_frame(readl(imx21->regs + USBH_FRMNUB));
}
+static inline bool unsuitable_for_dma(dma_addr_t addr)
+{
+ return (addr & 3) != 0;
+}
#include "imx21-dbg.c"
+static void nonisoc_urb_completed_for_etd(
+ struct imx21 *imx21, struct etd_priv *etd, int status);
+static void schedule_nonisoc_etd(struct imx21 *imx21, struct urb *urb);
+static void free_dmem(struct imx21 *imx21, struct etd_priv *etd);
+
/* =========================================== */
/* ETD management */
/* =========================================== */
@@ -185,7 +195,8 @@ static void reset_etd(struct imx21 *imx21, int num)
etd_writel(imx21, num, i, 0);
etd->urb = NULL;
etd->ep = NULL;
- etd->td = NULL;;
+ etd->td = NULL;
+ etd->bounce_buffer = NULL;
}
static void free_etd(struct imx21 *imx21, int num)
@@ -221,26 +232,94 @@ static void setup_etd_dword0(struct imx21 *imx21,
((u32) maxpacket << DW0_MAXPKTSIZ));
}
-static void activate_etd(struct imx21 *imx21,
- int etd_num, dma_addr_t dma, u8 dir)
+/**
+ * Copy buffer to data controller data memory.
+ * We cannot use memcpy_toio() because the hardware requires 32bit writes
+ */
+static void copy_to_dmem(
+ struct imx21 *imx21, int dmem_offset, void *src, int count)
+{
+ void __iomem *dmem = imx21->regs + USBOTG_DMEM + dmem_offset;
+ u32 word = 0;
+ u8 *p = src;
+ int byte = 0;
+ int i;
+
+ for (i = 0; i < count; i++) {
+ byte = i % 4;
+ word += (*p++ << (byte * 8));
+ if (byte == 3) {
+ writel(word, dmem);
+ dmem += 4;
+ word = 0;
+ }
+ }
+
+ if (count && byte != 3)
+ writel(word, dmem);
+}
+
+static void activate_etd(struct imx21 *imx21, int etd_num, u8 dir)
{
u32 etd_mask = 1 << etd_num;
struct etd_priv *etd = &imx21->etd[etd_num];
+ if (etd->dma_handle && unsuitable_for_dma(etd->dma_handle)) {
+ /* For non aligned isoc the condition below is always true */
+ if (etd->len <= etd->dmem_size) {
+ /* Fits into data memory, use PIO */
+ if (dir != TD_DIR_IN) {
+ copy_to_dmem(imx21,
+ etd->dmem_offset,
+ etd->cpu_buffer, etd->len);
+ }
+ etd->dma_handle = 0;
+
+ } else {
+ /* Too big for data memory, use bounce buffer */
+ enum dma_data_direction dmadir;
+
+ if (dir == TD_DIR_IN) {
+ dmadir = DMA_FROM_DEVICE;
+ etd->bounce_buffer = kmalloc(etd->len,
+ GFP_ATOMIC);
+ } else {
+ dmadir = DMA_TO_DEVICE;
+ etd->bounce_buffer = kmemdup(etd->cpu_buffer,
+ etd->len,
+ GFP_ATOMIC);
+ }
+ if (!etd->bounce_buffer) {
+ dev_err(imx21->dev, "failed bounce alloc\n");
+ goto err_bounce_alloc;
+ }
+
+ etd->dma_handle =
+ dma_map_single(imx21->dev,
+ etd->bounce_buffer,
+ etd->len,
+ dmadir);
+ if (dma_mapping_error(imx21->dev, etd->dma_handle)) {
+ dev_err(imx21->dev, "failed bounce map\n");
+ goto err_bounce_map;
+ }
+ }
+ }
+
clear_toggle_bit(imx21, USBH_ETDDONESTAT, etd_mask);
set_register_bits(imx21, USBH_ETDDONEEN, etd_mask);
clear_toggle_bit(imx21, USBH_XFILLSTAT, etd_mask);
clear_toggle_bit(imx21, USBH_YFILLSTAT, etd_mask);
- if (dma) {
+ if (etd->dma_handle) {
set_register_bits(imx21, USB_ETDDMACHANLCLR, etd_mask);
clear_toggle_bit(imx21, USBH_XBUFSTAT, etd_mask);
clear_toggle_bit(imx21, USBH_YBUFSTAT, etd_mask);
- writel(dma, imx21->regs + USB_ETDSMSA(etd_num));
+ writel(etd->dma_handle, imx21->regs + USB_ETDSMSA(etd_num));
set_register_bits(imx21, USB_ETDDMAEN, etd_mask);
} else {
if (dir != TD_DIR_IN) {
- /* need to set for ZLP */
+ /* need to set for ZLP and PIO */
set_toggle_bit(imx21, USBH_XFILLSTAT, etd_mask);
set_toggle_bit(imx21, USBH_YFILLSTAT, etd_mask);
}
@@ -263,6 +342,14 @@ static void activate_etd(struct imx21 *imx21,
etd->active_count = 1;
writel(etd_mask, imx21->regs + USBH_ETDENSET);
+ return;
+
+err_bounce_map:
+ kfree(etd->bounce_buffer);
+
+err_bounce_alloc:
+ free_dmem(imx21, etd);
+ nonisoc_urb_completed_for_etd(imx21, etd, -ENOMEM);
}
/* =========================================== */
@@ -323,16 +410,23 @@ static void activate_queued_etd(struct imx21 *imx21,
etd_writel(imx21, etd_num, 1,
((dmem_offset + maxpacket) << DW1_YBUFSRTAD) | dmem_offset);
+ etd->dmem_offset = dmem_offset;
urb_priv->active = 1;
- activate_etd(imx21, etd_num, etd->dma_handle, dir);
+ activate_etd(imx21, etd_num, dir);
}
-static void free_dmem(struct imx21 *imx21, int offset)
+static void free_dmem(struct imx21 *imx21, struct etd_priv *etd)
{
struct imx21_dmem_area *area;
- struct etd_priv *etd, *tmp;
+ struct etd_priv *tmp;
int found = 0;
+ int offset;
+ if (!etd->dmem_size)
+ return;
+ etd->dmem_size = 0;
+
+ offset = etd->dmem_offset;
list_for_each_entry(area, &imx21->dmem_list, list) {
if (area->offset == offset) {
debug_dmem_freed(imx21, area->size);
@@ -378,20 +472,23 @@ static void free_epdmem(struct imx21 *imx21, struct usb_host_endpoint *ep)
/* =========================================== */
/* End handling */
/* =========================================== */
-static void schedule_nonisoc_etd(struct imx21 *imx21, struct urb *urb);
/* Endpoint now idle - release it's ETD(s) or asssign to queued request */
static void ep_idle(struct imx21 *imx21, struct ep_priv *ep_priv)
{
- int etd_num;
int i;
for (i = 0; i < NUM_ISO_ETDS; i++) {
- etd_num = ep_priv->etd[i];
+ int etd_num = ep_priv->etd[i];
+ struct etd_priv *etd;
if (etd_num < 0)
continue;
+ etd = &imx21->etd[etd_num];
ep_priv->etd[i] = -1;
+
+ free_dmem(imx21, etd); /* for isoc */
+
if (list_empty(&imx21->queue_for_etd)) {
free_etd(imx21, etd_num);
continue;
@@ -437,6 +534,24 @@ __acquires(imx21->lock)
ep_idle(imx21, ep_priv);
}
+static void nonisoc_urb_completed_for_etd(
+ struct imx21 *imx21, struct etd_priv *etd, int status)
+{
+ struct usb_host_endpoint *ep = etd->ep;
+
+ urb_done(imx21->hcd, etd->urb, status);
+ etd->urb = NULL;
+
+ if (!list_empty(&ep->urb_list)) {
+ struct urb *urb = list_first_entry(
+ &ep->urb_list, struct urb, urb_list);
+
+ dev_vdbg(imx21->dev, "next URB %p\n", urb);
+ schedule_nonisoc_etd(imx21, urb);
+ }
+}
+
+
/* =========================================== */
/* ISOC Handling ... */
/* =========================================== */
@@ -489,6 +604,8 @@ too_late:
etd->ep = td->ep;
etd->urb = td->urb;
etd->len = td->len;
+ etd->dma_handle = td->dma_handle;
+ etd->cpu_buffer = td->cpu_buffer;
debug_isoc_submitted(imx21, cur_frame, td);
@@ -502,16 +619,17 @@ too_late:
(TD_NOTACCESSED << DW3_COMPCODE0) |
(td->len << DW3_PKTLEN0));
- activate_etd(imx21, etd_num, td->data, dir);
+ activate_etd(imx21, etd_num, dir);
}
}
-static void isoc_etd_done(struct usb_hcd *hcd, struct urb *urb, int etd_num)
+static void isoc_etd_done(struct usb_hcd *hcd, int etd_num)
{
struct imx21 *imx21 = hcd_to_imx21(hcd);
int etd_mask = 1 << etd_num;
- struct urb_priv *urb_priv = urb->hcpriv;
struct etd_priv *etd = imx21->etd + etd_num;
+ struct urb *urb = etd->urb;
+ struct urb_priv *urb_priv = urb->hcpriv;
struct td *td = etd->td;
struct usb_host_endpoint *ep = etd->ep;
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)
bytes_xfrd, td->len, urb, etd_num, isoc_index);
}
- if (dir_in)
+ if (dir_in) {
clear_toggle_bit(imx21, USBH_XFILLSTAT, etd_mask);
+ if (!etd->dma_handle)
+ memcpy_fromio(etd->cpu_buffer,
+ imx21->regs + USBOTG_DMEM + etd->dmem_offset,
+ bytes_xfrd);
+ }
urb->actual_length += bytes_xfrd;
urb->iso_frame_desc[isoc_index].actual_length = bytes_xfrd;
@@ -569,30 +692,43 @@ static struct ep_priv *alloc_isoc_ep(
int i;
ep_priv = kzalloc(sizeof(struct ep_priv), GFP_ATOMIC);
- if (ep_priv == NULL)
+ if (!ep_priv)
return NULL;
- /* Allocate the ETDs */
- for (i = 0; i < NUM_ISO_ETDS; i++) {
- ep_priv->etd[i] = alloc_etd(imx21);
- if (ep_priv->etd[i] < 0) {
- int j;
- dev_err(imx21->dev, "isoc: Couldn't allocate etd\n");
- for (j = 0; j < i; j++)
- free_etd(imx21, ep_priv->etd[j]);
- goto alloc_etd_failed;
- }
- imx21->etd[ep_priv->etd[i]].ep = ep;
- }
+ for (i = 0; i < NUM_ISO_ETDS; i++)
+ ep_priv->etd[i] = -1;
INIT_LIST_HEAD(&ep_priv->td_list);
ep_priv->ep = ep;
ep->hcpriv = ep_priv;
return ep_priv;
+}
+
+static int alloc_isoc_etds(struct imx21 *imx21, struct ep_priv *ep_priv)
+{
+ int i, j;
+ int etd_num;
+
+ /* Allocate the ETDs if required */
+ for (i = 0; i < NUM_ISO_ETDS; i++) {
+ if (ep_priv->etd[i] < 0) {
+ etd_num = alloc_etd(imx21);
+ if (etd_num < 0)
+ goto alloc_etd_failed;
+
+ ep_priv->etd[i] = etd_num;
+ imx21->etd[etd_num].ep = ep_priv->ep;
+ }
+ }
+ return 0;
alloc_etd_failed:
- kfree(ep_priv);
- return NULL;
+ dev_err(imx21->dev, "isoc: Couldn't allocate etd\n");
+ for (j = 0; j < i; j++) {
+ free_etd(imx21, ep_priv->etd[j]);
+ ep_priv->etd[j] = -1;
+ }
+ return -ENOMEM;
}
static 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,
ep_priv = ep->hcpriv;
}
+ ret = alloc_isoc_etds(imx21, ep_priv);
+ if (ret)
+ goto alloc_etd_failed;
+
ret = usb_hcd_link_urb_to_ep(hcd, urb);
if (ret)
goto link_failed;
@@ -688,12 +828,14 @@ static int imx21_hc_urb_enqueue_isoc(struct usb_hcd *hcd,
/* set up transfers */
td = urb_priv->isoc_td;
for (i = 0; i < urb->number_of_packets; i++, td++) {
+ unsigned int offset = urb->iso_frame_desc[i].offset;
td->ep = ep;
td->urb = urb;
td->len = urb->iso_frame_desc[i].length;
td->isoc_index = i;
td->frame = wrap_frame(urb->start_frame + urb->interval * i);
- td->data = urb->transfer_dma + urb->iso_frame_desc[i].offset;
+ td->dma_handle = urb->transfer_dma + offset;
+ td->cpu_buffer = urb->transfer_buffer + offset;
list_add_tail(&td->list, &ep_priv->td_list);
}
@@ -711,6 +853,7 @@ alloc_dmem_failed:
usb_hcd_unlink_urb_from_ep(hcd, urb);
link_failed:
+alloc_etd_failed:
alloc_ep_failed:
spin_unlock_irqrestore(&imx21->lock, flags);
kfree(urb_priv->isoc_td);
@@ -734,9 +877,7 @@ static void dequeue_isoc_urb(struct imx21 *imx21,
struct etd_priv *etd = imx21->etd + etd_num;
reset_etd(imx21, etd_num);
- if (etd->dmem_size)
- free_dmem(imx21, etd->dmem_offset);
- etd->dmem_size = 0;
+ free_dmem(imx21, etd);
}
}
}
@@ -761,7 +902,6 @@ static void schedule_nonisoc_etd(struct imx21 *imx21, struct urb *urb)
int state = urb_priv->state;
int etd_num = ep_priv->etd[0];
struct etd_priv *etd;
- int dmem_offset;
u32 count;
u16 etd_buf_size;
u16 maxpacket;
@@ -786,13 +926,15 @@ static void schedule_nonisoc_etd(struct imx21 *imx21, struct urb *urb)
if (usb_pipecontrol(pipe) && (state != US_CTRL_DATA)) {
if (state == US_CTRL_SETUP) {
dir = TD_DIR_SETUP;
+ if (unsuitable_for_dma(urb->setup_dma))
+ unmap_urb_setup_for_dma(imx21->hcd, urb);
etd->dma_handle = urb->setup_dma;
+ etd->cpu_buffer = urb->setup_packet;
bufround = 0;
count = 8;
datatoggle = TD_TOGGLE_DATA0;
} else { /* US_CTRL_ACK */
dir = usb_pipeout(pipe) ? TD_DIR_IN : TD_DIR_OUT;
- etd->dma_handle = urb->transfer_dma;
bufround = 0;
count = 0;
datatoggle = TD_TOGGLE_DATA1;
@@ -800,7 +942,11 @@ static void schedule_nonisoc_etd(struct imx21 *imx21, struct urb *urb)
} else {
dir = usb_pipeout(pipe) ? TD_DIR_OUT : TD_DIR_IN;
bufround = (dir == TD_DIR_IN) ? 1 : 0;
+ if (unsuitable_for_dma(urb->transfer_dma))
+ unmap_urb_for_dma(imx21->hcd, urb);
+
etd->dma_handle = urb->transfer_dma;
+ etd->cpu_buffer = urb->transfer_buffer;
if (usb_pipebulk(pipe) && (state == US_BULK0))
count = 0;
else
@@ -855,8 +1001,8 @@ static void schedule_nonisoc_etd(struct imx21 *imx21, struct urb *urb)
/* allocate x and y buffer space at once */
etd->dmem_size = (count > maxpacket) ? maxpacket * 2 : maxpacket;
- dmem_offset = alloc_dmem(imx21, etd->dmem_size, urb_priv->ep);
- if (dmem_offset < 0) {
+ etd->dmem_offset = alloc_dmem(imx21, etd->dmem_size, urb_priv->ep);
+ if (etd->dmem_offset < 0) {
/* Setup everything we can in HW and update when we get DMEM */
etd_writel(imx21, etd_num, 1, (u32)maxpacket << 16);
@@ -867,26 +1013,26 @@ static void schedule_nonisoc_etd(struct imx21 *imx21, struct urb *urb)
}
etd_writel(imx21, etd_num, 1,
- (((u32) dmem_offset + (u32) maxpacket) << DW1_YBUFSRTAD) |
- (u32) dmem_offset);
+ (((u32) etd->dmem_offset + (u32) maxpacket) << DW1_YBUFSRTAD) |
+ (u32) etd->dmem_offset);
urb_priv->active = 1;
/* enable the ETD to kick off transfer */
dev_vdbg(imx21->dev, "Activating etd %d for %d bytes %s\n",
etd_num, count, dir != TD_DIR_IN ? "out" : "in");
- activate_etd(imx21, etd_num, etd->dma_handle, dir);
+ activate_etd(imx21, etd_num, dir);
}
-static void nonisoc_etd_done(struct usb_hcd *hcd, struct urb *urb, int etd_num)
+static void nonisoc_etd_done(struct usb_hcd *hcd, int etd_num)
{
struct imx21 *imx21 = hcd_to_imx21(hcd);
struct etd_priv *etd = &imx21->etd[etd_num];
+ struct urb *urb = etd->urb;
u32 etd_mask = 1 << etd_num;
struct urb_priv *urb_priv = urb->hcpriv;
int dir;
- u16 xbufaddr;
int cc;
u32 bytes_xfrd;
int etd_done;
@@ -894,7 +1040,6 @@ static void nonisoc_etd_done(struct usb_hcd *hcd, struct urb *urb, int etd_num)
disactivate_etd(imx21, etd_num);
dir = (etd_readl(imx21, etd_num, 0) >> DW0_DIRECT) & 0x3;
- xbufaddr = etd_readl(imx21, etd_num, 1) & 0xffff;
cc = (etd_readl(imx21, etd_num, 2) >> DW2_COMPCODE) & 0xf;
bytes_xfrd = etd->len - (etd_readl(imx21, etd_num, 3) & 0x1fffff);
@@ -906,8 +1051,21 @@ static void nonisoc_etd_done(struct usb_hcd *hcd, struct urb *urb, int etd_num)
if (dir == TD_DIR_IN) {
clear_toggle_bit(imx21, USBH_XFILLSTAT, etd_mask);
clear_toggle_bit(imx21, USBH_YFILLSTAT, etd_mask);
+
+ if (etd->bounce_buffer) {
+ memcpy(etd->cpu_buffer, etd->bounce_buffer, bytes_xfrd);
+ dma_unmap_single(imx21->dev,
+ etd->dma_handle, etd->len, DMA_FROM_DEVICE);
+ } else if (!etd->dma_handle && bytes_xfrd) {/* PIO */
+ memcpy_fromio(etd->cpu_buffer,
+ imx21->regs + USBOTG_DMEM + etd->dmem_offset,
+ bytes_xfrd);
+ }
}
- free_dmem(imx21, xbufaddr);
+
+ kfree(etd->bounce_buffer);
+ etd->bounce_buffer = NULL;
+ free_dmem(imx21, etd);
urb->error_count = 0;
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)
break;
}
- if (!etd_done) {
+ if (etd_done)
+ nonisoc_urb_completed_for_etd(imx21, etd, cc_to_error[cc]);
+ else {
dev_vdbg(imx21->dev, "next state=%d\n", urb_priv->state);
schedule_nonisoc_etd(imx21, urb);
- } else {
- struct usb_host_endpoint *ep = urb->ep;
-
- urb_done(hcd, urb, cc_to_error[cc]);
- etd->urb = NULL;
-
- if (!list_empty(&ep->urb_list)) {
- urb = list_first_entry(&ep->urb_list,
- struct urb, urb_list);
- dev_vdbg(imx21->dev, "next URB %p\n", urb);
- schedule_nonisoc_etd(imx21, urb);
- }
}
}
+
static struct ep_priv *alloc_ep(void)
{
int i;
@@ -1007,7 +1156,6 @@ static int imx21_hc_urb_enqueue(struct usb_hcd *hcd,
struct etd_priv *etd;
int ret;
unsigned long flags;
- int new_ep = 0;
dev_vdbg(imx21->dev,
"enqueue urb=%p ep=%p len=%d "
@@ -1035,7 +1183,6 @@ static int imx21_hc_urb_enqueue(struct usb_hcd *hcd,
}
ep->hcpriv = ep_priv;
ep_priv->ep = ep;
- new_ep = 1;
}
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,
} else if (urb_priv->active) {
int etd_num = ep_priv->etd[0];
if (etd_num != -1) {
+ struct etd_priv *etd = &imx21->etd[etd_num];
+
disactivate_etd(imx21, etd_num);
- free_dmem(imx21, etd_readl(imx21, etd_num, 1) & 0xffff);
- imx21->etd[etd_num].urb = NULL;
+ free_dmem(imx21, etd);
+ etd->urb = NULL;
+ kfree(etd->bounce_buffer);
+ etd->bounce_buffer = NULL;
}
}
@@ -1226,9 +1377,9 @@ static void process_etds(struct usb_hcd *hcd, struct imx21 *imx21, int sof)
}
if (usb_pipeisoc(etd->urb->pipe))
- isoc_etd_done(hcd, etd->urb, etd_num);
+ isoc_etd_done(hcd, etd_num);
else
- nonisoc_etd_done(hcd, etd->urb, etd_num);
+ nonisoc_etd_done(hcd, etd_num);
}
/* only enable SOF interrupt if it may be needed for the kludge */
@@ -1696,6 +1847,7 @@ static int imx21_probe(struct platform_device *pdev)
}
imx21 = hcd_to_imx21(hcd);
+ imx21->hcd = hcd;
imx21->dev = &pdev->dev;
imx21->pdata = pdev->dev.platform_data;
if (!imx21->pdata)
@@ -1754,7 +1906,7 @@ failed_clock_set:
failed_clock_get:
iounmap(imx21->regs);
failed_ioremap:
- release_mem_region(res->start, res->end - res->start);
+ release_mem_region(res->start, resource_size(res));
failed_request_mem:
remove_debug_files(imx21);
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 @@
#define USBCTRL_USB_BYP (1 << 2)
#define USBCTRL_HOST1_TXEN_OE (1 << 1)
+#define USBOTG_DMEM 0x1000
/* Values in TD blocks */
#define TD_DIR_SETUP 0
@@ -346,8 +347,8 @@ struct td {
struct list_head list;
struct urb *urb;
struct usb_host_endpoint *ep;
- dma_addr_t data;
- unsigned long buf_addr;
+ dma_addr_t dma_handle;
+ void *cpu_buffer;
int len;
int frame;
int isoc_index;
@@ -360,6 +361,8 @@ struct etd_priv {
struct td *td;
struct list_head queue;
dma_addr_t dma_handle;
+ void *cpu_buffer;
+ void *bounce_buffer;
int alloc;
int len;
int dmem_size;
@@ -412,6 +415,7 @@ struct debug_isoc_trace {
struct imx21 {
spinlock_t lock;
struct device *dev;
+ struct usb_hcd *hcd;
struct mx21_usbh_platform_data *pdata;
struct list_head dmem_list;
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)
return 0;
}
-#define resource_len(r) (((r)->end - (r)->start) + 1)
-
static int __devinit isp116x_probe(struct platform_device *pdev)
{
struct usb_hcd *hcd;
@@ -1597,7 +1595,7 @@ static int __devinit isp116x_probe(struct platform_device *pdev)
ret = -EBUSY;
goto err1;
}
- addr_reg = ioremap(addr->start, resource_len(addr));
+ addr_reg = ioremap(addr->start, resource_size(addr));
if (addr_reg == NULL) {
ret = -ENOMEM;
goto err2;
@@ -1606,7 +1604,7 @@ static int __devinit isp116x_probe(struct platform_device *pdev)
ret = -EBUSY;
goto err3;
}
- data_reg = ioremap(data->start, resource_len(data));
+ data_reg = ioremap(data->start, resource_size(data));
if (data_reg == NULL) {
ret = -ENOMEM;
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,
switch (wValue) {
case USB_PORT_FEAT_SUSPEND:
_DBG(0, "USB_PORT_FEAT_SUSPEND\n");
-#ifdef CONFIG_USB_OTG
- if (ohci->hcd.self.otg_port == (wIndex + 1) &&
- ohci->hcd.self.b_hnp_enable) {
- start_hnp(ohci);
- break;
- }
-#endif
spin_lock_irqsave(&isp1362_hcd->lock, flags);
isp1362_write_reg32(isp1362_hcd, HCRHPORT1 + wIndex, RH_PS_PSS);
isp1362_hcd->rhport[wIndex] =
@@ -2656,8 +2649,6 @@ static struct hc_driver isp1362_hc_driver = {
/*-------------------------------------------------------------------------*/
-#define resource_len(r) (((r)->end - (r)->start) + 1)
-
static int __devexit isp1362_remove(struct platform_device *pdev)
{
struct usb_hcd *hcd = platform_get_drvdata(pdev);
@@ -2679,12 +2670,12 @@ static int __devexit isp1362_remove(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
DBG(0, "%s: release mem_region: %08lx\n", __func__, (long unsigned int)res->start);
if (res)
- release_mem_region(res->start, resource_len(res));
+ release_mem_region(res->start, resource_size(res));
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
DBG(0, "%s: release mem_region: %08lx\n", __func__, (long unsigned int)res->start);
if (res)
- release_mem_region(res->start, resource_len(res));
+ release_mem_region(res->start, resource_size(res));
DBG(0, "%s: put_hcd\n", __func__);
usb_put_hcd(hcd);
@@ -2730,21 +2721,21 @@ static int __init isp1362_probe(struct platform_device *pdev)
goto err1;
}
- if (!request_mem_region(addr->start, resource_len(addr), hcd_name)) {
+ if (!request_mem_region(addr->start, resource_size(addr), hcd_name)) {
retval = -EBUSY;
goto err1;
}
- addr_reg = ioremap(addr->start, resource_len(addr));
+ addr_reg = ioremap(addr->start, resource_size(addr));
if (addr_reg == NULL) {
retval = -ENOMEM;
goto err2;
}
- if (!request_mem_region(data->start, resource_len(data), hcd_name)) {
+ if (!request_mem_region(data->start, resource_size(data), hcd_name)) {
retval = -EBUSY;
goto err3;
}
- data_reg = ioremap(data->start, resource_len(data));
+ data_reg = ioremap(data->start, resource_size(data));
if (data_reg == NULL) {
retval = -ENOMEM;
goto err4;
@@ -2802,13 +2793,13 @@ static int __init isp1362_probe(struct platform_device *pdev)
iounmap(data_reg);
err4:
DBG(0, "%s: Releasing mem region %08lx\n", __func__, (long unsigned int)data->start);
- release_mem_region(data->start, resource_len(data));
+ release_mem_region(data->start, resource_size(data));
err3:
DBG(0, "%s: Unmapping addr_reg @ %p\n", __func__, addr_reg);
iounmap(addr_reg);
err2:
DBG(0, "%s: Releasing mem region %08lx\n", __func__, (long unsigned int)addr->start);
- release_mem_region(addr->start, resource_len(addr));
+ release_mem_region(addr->start, resource_size(addr));
err1:
pr_err("%s: init error, %d\n", __func__, retval);
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)
ohci = hcd_to_ohci (hcd);
ohci_writel (ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable);
- ohci_usb_reset (ohci);
+ ohci->hc_control = ohci_readl(ohci, &ohci->regs->control);
+
+ /* If the SHUTDOWN quirk is set, don't put the controller in RESET */
+ ohci->hc_control &= (ohci->flags & OHCI_QUIRK_SHUTDOWN ?
+ OHCI_CTRL_RWC | OHCI_CTRL_HCFS :
+ OHCI_CTRL_RWC);
+ ohci_writel(ohci, ohci->hc_control, &ohci->regs->control);
+
/* flush the writes */
(void) ohci_readl (ohci, &ohci->regs->control);
}
@@ -1270,6 +1277,9 @@ static void __exit ohci_hcd_mod_exit(void)
#ifdef PLATFORM_DRIVER
platform_driver_unregister(&PLATFORM_DRIVER);
#endif
+#ifdef OMAP3_PLATFORM_DRIVER
+ platform_driver_unregister(&OMAP3_PLATFORM_DRIVER);
+#endif
#ifdef PS3_SYSTEM_BUS_DRIVER
ps3_ohci_driver_unregister(&PS3_SYSTEM_BUS_DRIVER);
#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)
return 0;
}
+/* nVidia controllers continue to drive Reset signalling on the bus
+ * even after system shutdown, wasting power. This flag tells the
+ * shutdown routine to leave the controller OPERATIONAL instead of RESET.
+ */
+static int ohci_quirk_nvidia_shutdown(struct usb_hcd *hcd)
+{
+ struct ohci_hcd *ohci = hcd_to_ohci(hcd);
+
+ ohci->flags |= OHCI_QUIRK_SHUTDOWN;
+ ohci_dbg(ohci, "enabled nVidia shutdown quirk\n");
+
+ return 0;
+}
+
/*
* The hardware normally enables the A-link power management feature, which
* lets the system lower the power consumption in idle states.
@@ -332,6 +346,10 @@ static const struct pci_device_id ohci_pci_quirks[] = {
PCI_DEVICE(PCI_VENDOR_ID_ATI, 0x4399),
.driver_data = (unsigned long)ohci_quirk_amd700,
},
+ {
+ PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID),
+ .driver_data = (unsigned long) ohci_quirk_nvidia_shutdown,
+ },
/* FIXME for some of the early AMD 760 southbridges, OHCI
* 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 = {
/*-------------------------------------------------------------------------*/
-#define resource_len(r) (((r)->end - (r)->start) + 1)
static int ohci_hcd_sh_probe(struct platform_device *pdev)
{
struct resource *res = NULL;
@@ -109,7 +108,7 @@ static int ohci_hcd_sh_probe(struct platform_device *pdev)
hcd->regs = (void __iomem *)res->start;
hcd->rsrc_start = res->start;
- hcd->rsrc_len = resource_len(res);
+ hcd->rsrc_len = resource_size(res);
ret = usb_add_hcd(hcd, irq, IRQF_DISABLED);
if (ret != 0) {
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)
retval = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED);
if (retval)
- goto err4;
+ goto err5;
/* enable power and unmask interrupts */
@@ -176,6 +176,8 @@ static int ohci_hcd_sm501_drv_probe(struct platform_device *pdev)
sm501_modify_reg(dev->parent, SM501_IRQ_MASK, 1 << 6, 0);
return 0;
+err5:
+ iounmap(hcd->regs);
err4:
release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
err3:
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 {
#define OHCI_QUIRK_HUB_POWER 0x100 /* distrust firmware power/oc setup */
#define OHCI_QUIRK_AMD_ISO 0x200 /* ISO transfers*/
#define OHCI_QUIRK_AMD_PREFETCH 0x400 /* pre-fetch for ISO transfer */
+#define OHCI_QUIRK_SHUTDOWN 0x800 /* nVidia power bug */
// there are also chip quirks/bugs in init logic
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)
static int oxu_verify_id(struct platform_device *pdev, void *base)
{
u32 id;
- char *bo[] = {
+ static const char * const bo[] = {
"reserved",
"128-pin LQFP",
"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)
static void __devinit quirk_usb_handoff_ohci(struct pci_dev *pdev)
{
void __iomem *base;
+ u32 control;
if (!mmio_resource_enabled(pdev, 0))
return;
@@ -177,10 +178,14 @@ static void __devinit quirk_usb_handoff_ohci(struct pci_dev *pdev)
if (base == NULL)
return;
+ control = readl(base + OHCI_CONTROL);
+
/* On PA-RISC, PDC can leave IR set incorrectly; ignore it there. */
-#ifndef __hppa__
-{
- u32 control = readl(base + OHCI_CONTROL);
+#ifdef __hppa__
+#define OHCI_CTRL_MASK (OHCI_CTRL_RWC | OHCI_CTRL_IR)
+#else
+#define OHCI_CTRL_MASK OHCI_CTRL_RWC
+
if (control & OHCI_CTRL_IR) {
int wait_time = 500; /* arbitrary; 5 seconds */
writel(OHCI_INTR_OC, base + OHCI_INTRENABLE);
@@ -194,13 +199,12 @@ static void __devinit quirk_usb_handoff_ohci(struct pci_dev *pdev)
dev_warn(&pdev->dev, "OHCI: BIOS handoff failed"
" (BIOS bug?) %08x\n",
readl(base + OHCI_CONTROL));
-
- /* reset controller, preserving RWC */
- writel(control & OHCI_CTRL_RWC, base + OHCI_CONTROL);
}
-}
#endif
+ /* reset controller, preserving RWC (and possibly IR) */
+ writel(control & OHCI_CTRL_MASK, base + OHCI_CONTROL);
+
/*
* disable interrupts
*/
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,
int odd = len & 0x0001;
len = len / 2;
- ioread16_rep(fifoaddr, buf, len);
+ iowrite16_rep(fifoaddr, buf, len);
if (unlikely(odd)) {
buf = &buf[len];
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,
unsigned long destination, status;
int maxsze = le16_to_cpu(qh->hep->desc.wMaxPacketSize);
int len = urb->transfer_buffer_length;
- dma_addr_t data = urb->transfer_dma;
+ int this_sg_len;
+ dma_addr_t data;
__le32 *plink;
struct urb_priv *urbp = urb->hcpriv;
unsigned int toggle;
+ struct scatterlist *sg;
+ int i;
if (len < 0)
return -EINVAL;
@@ -937,12 +940,26 @@ static int uhci_submit_common(struct uhci_hcd *uhci, struct urb *urb,
if (usb_pipein(urb->pipe))
status |= TD_CTRL_SPD;
+ i = urb->num_sgs;
+ if (len > 0 && i > 0) {
+ sg = urb->sg;
+ data = sg_dma_address(sg);
+
+ /* urb->transfer_buffer_length may be smaller than the
+ * size of the scatterlist (or vice versa)
+ */
+ this_sg_len = min_t(int, sg_dma_len(sg), len);
+ } else {
+ sg = NULL;
+ data = urb->transfer_dma;
+ this_sg_len = len;
+ }
/*
* Build the DATA TDs
*/
plink = NULL;
td = qh->dummy_td;
- do { /* Allow zero length packets */
+ for (;;) { /* Allow zero length packets */
int pktsze = maxsze;
if (len <= pktsze) { /* The last packet */
@@ -965,10 +982,18 @@ static int uhci_submit_common(struct uhci_hcd *uhci, struct urb *urb,
plink = &td->link;
status |= TD_CTRL_ACTIVE;
+ toggle ^= 1;
data += pktsze;
+ this_sg_len -= pktsze;
len -= maxsze;
- toggle ^= 1;
- } while (len > 0);
+ if (this_sg_len <= 0) {
+ if (--i <= 0 || len <= 0)
+ break;
+ sg = sg_next(sg);
+ data = sg_dma_address(sg);
+ this_sg_len = min_t(int, sg_dma_len(sg), len);
+ }
+ }
/*
* 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
whci-hcd-y := \
asl.o \
debug.o \
- hcd.o \
+ hcd.o \
hw.o \
init.o \
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 @@
#include "xhci.h"
+#define PORT_WAKE_BITS (PORT_WKOC_E | PORT_WKDISC_E | PORT_WKCONN_E)
+#define PORT_RWC_BITS (PORT_CSC | PORT_PEC | PORT_WRC | PORT_OCC | \
+ PORT_RC | PORT_PLC | PORT_PE)
+
static void xhci_hub_descriptor(struct xhci_hcd *xhci,
struct usb_hub_descriptor *desc)
{
@@ -123,12 +127,105 @@ static unsigned int xhci_port_speed(unsigned int port_status)
* writing a 0 clears the bit and writing a 1 sets the bit (RWS).
* For all other types (RW1S, RW1CS, RW, and RZ), writing a '0' has no effect.
*/
-static u32 xhci_port_state_to_neutral(u32 state)
+u32 xhci_port_state_to_neutral(u32 state)
{
/* Save read-only status and port state */
return (state & XHCI_PORT_RO) | (state & XHCI_PORT_RWS);
}
+/*
+ * find slot id based on port number.
+ */
+int xhci_find_slot_id_by_port(struct xhci_hcd *xhci, u16 port)
+{
+ int slot_id;
+ int i;
+
+ slot_id = 0;
+ for (i = 0; i < MAX_HC_SLOTS; i++) {
+ if (!xhci->devs[i])
+ continue;
+ if (xhci->devs[i]->port == port) {
+ slot_id = i;
+ break;
+ }
+ }
+
+ return slot_id;
+}
+
+/*
+ * Stop device
+ * It issues stop endpoint command for EP 0 to 30. And wait the last command
+ * to complete.
+ * suspend will set to 1, if suspend bit need to set in command.
+ */
+static int xhci_stop_device(struct xhci_hcd *xhci, int slot_id, int suspend)
+{
+ struct xhci_virt_device *virt_dev;
+ struct xhci_command *cmd;
+ unsigned long flags;
+ int timeleft;
+ int ret;
+ int i;
+
+ ret = 0;
+ virt_dev = xhci->devs[slot_id];
+ cmd = xhci_alloc_command(xhci, false, true, GFP_NOIO);
+ if (!cmd) {
+ xhci_dbg(xhci, "Couldn't allocate command structure.\n");
+ return -ENOMEM;
+ }
+
+ spin_lock_irqsave(&xhci->lock, flags);
+ for (i = LAST_EP_INDEX; i > 0; i--) {
+ if (virt_dev->eps[i].ring && virt_dev->eps[i].ring->dequeue)
+ xhci_queue_stop_endpoint(xhci, slot_id, i, suspend);
+ }
+ cmd->command_trb = xhci->cmd_ring->enqueue;
+ list_add_tail(&cmd->cmd_list, &virt_dev->cmd_list);
+ xhci_queue_stop_endpoint(xhci, slot_id, 0, suspend);
+ xhci_ring_cmd_db(xhci);
+ spin_unlock_irqrestore(&xhci->lock, flags);
+
+ /* Wait for last stop endpoint command to finish */
+ timeleft = wait_for_completion_interruptible_timeout(
+ cmd->completion,
+ USB_CTRL_SET_TIMEOUT);
+ if (timeleft <= 0) {
+ xhci_warn(xhci, "%s while waiting for stop endpoint command\n",
+ timeleft == 0 ? "Timeout" : "Signal");
+ spin_lock_irqsave(&xhci->lock, flags);
+ /* The timeout might have raced with the event ring handler, so
+ * only delete from the list if the item isn't poisoned.
+ */
+ if (cmd->cmd_list.next != LIST_POISON1)
+ list_del(&cmd->cmd_list);
+ spin_unlock_irqrestore(&xhci->lock, flags);
+ ret = -ETIME;
+ goto command_cleanup;
+ }
+
+command_cleanup:
+ xhci_free_command(xhci, cmd);
+ return ret;
+}
+
+/*
+ * Ring device, it rings the all doorbells unconditionally.
+ */
+void xhci_ring_device(struct xhci_hcd *xhci, int slot_id)
+{
+ int i;
+
+ for (i = 0; i < LAST_EP_INDEX + 1; i++)
+ if (xhci->devs[slot_id]->eps[i].ring &&
+ xhci->devs[slot_id]->eps[i].ring->dequeue)
+ xhci_ring_ep_doorbell(xhci, slot_id, i, 0);
+
+ return;
+}
+
static void xhci_disable_port(struct xhci_hcd *xhci, u16 wIndex,
u32 __iomem *addr, u32 port_status)
{
@@ -162,6 +259,10 @@ static void xhci_clear_port_change_bit(struct xhci_hcd *xhci, u16 wValue,
status = PORT_PEC;
port_change_bit = "enable/disable";
break;
+ case USB_PORT_FEAT_C_SUSPEND:
+ status = PORT_PLC;
+ port_change_bit = "suspend/resume";
+ break;
default:
/* Should never happen */
return;
@@ -179,9 +280,10 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
int ports;
unsigned long flags;
- u32 temp, status;
+ u32 temp, temp1, status;
int retval = 0;
u32 __iomem *addr;
+ int slot_id;
ports = HCS_MAX_PORTS(xhci->hcs_params1);
@@ -211,9 +313,49 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
if ((temp & PORT_OCC))
status |= USB_PORT_STAT_C_OVERCURRENT << 16;
/*
- * FIXME ignoring suspend, reset, and USB 2.1/3.0 specific
+ * FIXME ignoring reset and USB 2.1/3.0 specific
* changes
*/
+ if ((temp & PORT_PLS_MASK) == XDEV_U3
+ && (temp & PORT_POWER))
+ status |= 1 << USB_PORT_FEAT_SUSPEND;
+ if ((temp & PORT_PLS_MASK) == XDEV_RESUME) {
+ if ((temp & PORT_RESET) || !(temp & PORT_PE))
+ goto error;
+ if (!DEV_SUPERSPEED(temp) && time_after_eq(jiffies,
+ xhci->resume_done[wIndex])) {
+ xhci_dbg(xhci, "Resume USB2 port %d\n",
+ wIndex + 1);
+ xhci->resume_done[wIndex] = 0;
+ temp1 = xhci_port_state_to_neutral(temp);
+ temp1 &= ~PORT_PLS_MASK;
+ temp1 |= PORT_LINK_STROBE | XDEV_U0;
+ xhci_writel(xhci, temp1, addr);
+
+ xhci_dbg(xhci, "set port %d resume\n",
+ wIndex + 1);
+ slot_id = xhci_find_slot_id_by_port(xhci,
+ wIndex + 1);
+ if (!slot_id) {
+ xhci_dbg(xhci, "slot_id is zero\n");
+ goto error;
+ }
+ xhci_ring_device(xhci, slot_id);
+ xhci->port_c_suspend[wIndex >> 5] |=
+ 1 << (wIndex & 31);
+ xhci->suspended_ports[wIndex >> 5] &=
+ ~(1 << (wIndex & 31));
+ }
+ }
+ if ((temp & PORT_PLS_MASK) == XDEV_U0
+ && (temp & PORT_POWER)
+ && (xhci->suspended_ports[wIndex >> 5] &
+ (1 << (wIndex & 31)))) {
+ xhci->suspended_ports[wIndex >> 5] &=
+ ~(1 << (wIndex & 31));
+ xhci->port_c_suspend[wIndex >> 5] |=
+ 1 << (wIndex & 31);
+ }
if (temp & PORT_CONNECT) {
status |= USB_PORT_STAT_CONNECTION;
status |= xhci_port_speed(temp);
@@ -226,6 +368,8 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
status |= USB_PORT_STAT_RESET;
if (temp & PORT_POWER)
status |= USB_PORT_STAT_POWER;
+ if (xhci->port_c_suspend[wIndex >> 5] & (1 << (wIndex & 31)))
+ status |= 1 << USB_PORT_FEAT_C_SUSPEND;
xhci_dbg(xhci, "Get port status returned 0x%x\n", status);
put_unaligned(cpu_to_le32(status), (__le32 *) buf);
break;
@@ -238,6 +382,42 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
temp = xhci_readl(xhci, addr);
temp = xhci_port_state_to_neutral(temp);
switch (wValue) {
+ case USB_PORT_FEAT_SUSPEND:
+ temp = xhci_readl(xhci, addr);
+ /* In spec software should not attempt to suspend
+ * a port unless the port reports that it is in the
+ * enabled (PED = ‘1’,PLS < ‘3’) state.
+ */
+ if ((temp & PORT_PE) == 0 || (temp & PORT_RESET)
+ || (temp & PORT_PLS_MASK) >= XDEV_U3) {
+ xhci_warn(xhci, "USB core suspending device "
+ "not in U0/U1/U2.\n");
+ goto error;
+ }
+
+ slot_id = xhci_find_slot_id_by_port(xhci, wIndex + 1);
+ if (!slot_id) {
+ xhci_warn(xhci, "slot_id is zero\n");
+ goto error;
+ }
+ /* unlock to execute stop endpoint commands */
+ spin_unlock_irqrestore(&xhci->lock, flags);
+ xhci_stop_device(xhci, slot_id, 1);
+ spin_lock_irqsave(&xhci->lock, flags);
+
+ temp = xhci_port_state_to_neutral(temp);
+ temp &= ~PORT_PLS_MASK;
+ temp |= PORT_LINK_STROBE | XDEV_U3;
+ xhci_writel(xhci, temp, addr);
+
+ spin_unlock_irqrestore(&xhci->lock, flags);
+ msleep(10); /* wait device to enter */
+ spin_lock_irqsave(&xhci->lock, flags);
+
+ temp = xhci_readl(xhci, addr);
+ xhci->suspended_ports[wIndex >> 5] |=
+ 1 << (wIndex & (31));
+ break;
case USB_PORT_FEAT_POWER:
/*
* 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,
temp = xhci_readl(xhci, addr);
temp = xhci_port_state_to_neutral(temp);
switch (wValue) {
+ case USB_PORT_FEAT_SUSPEND:
+ temp = xhci_readl(xhci, addr);
+ xhci_dbg(xhci, "clear USB_PORT_FEAT_SUSPEND\n");
+ xhci_dbg(xhci, "PORTSC %04x\n", temp);
+ if (temp & PORT_RESET)
+ goto error;
+ if (temp & XDEV_U3) {
+ if ((temp & PORT_PE) == 0)
+ goto error;
+ if (DEV_SUPERSPEED(temp)) {
+ temp = xhci_port_state_to_neutral(temp);
+ temp &= ~PORT_PLS_MASK;
+ temp |= PORT_LINK_STROBE | XDEV_U0;
+ xhci_writel(xhci, temp, addr);
+ xhci_readl(xhci, addr);
+ } else {
+ temp = xhci_port_state_to_neutral(temp);
+ temp &= ~PORT_PLS_MASK;
+ temp |= PORT_LINK_STROBE | XDEV_RESUME;
+ xhci_writel(xhci, temp, addr);
+
+ spin_unlock_irqrestore(&xhci->lock,
+ flags);
+ msleep(20);
+ spin_lock_irqsave(&xhci->lock, flags);
+
+ temp = xhci_readl(xhci, addr);
+ temp = xhci_port_state_to_neutral(temp);
+ temp &= ~PORT_PLS_MASK;
+ temp |= PORT_LINK_STROBE | XDEV_U0;
+ xhci_writel(xhci, temp, addr);
+ }
+ xhci->port_c_suspend[wIndex >> 5] |=
+ 1 << (wIndex & 31);
+ }
+
+ slot_id = xhci_find_slot_id_by_port(xhci, wIndex + 1);
+ if (!slot_id) {
+ xhci_dbg(xhci, "slot_id is zero\n");
+ goto error;
+ }
+ xhci_ring_device(xhci, slot_id);
+ break;
+ case USB_PORT_FEAT_C_SUSPEND:
+ xhci->port_c_suspend[wIndex >> 5] &=
+ ~(1 << (wIndex & 31));
case USB_PORT_FEAT_C_RESET:
case USB_PORT_FEAT_C_CONNECTION:
case USB_PORT_FEAT_C_OVER_CURRENT:
@@ -306,6 +532,7 @@ int xhci_hub_status_data(struct usb_hcd *hcd, char *buf)
{
unsigned long flags;
u32 temp, status;
+ u32 mask;
int i, retval;
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
int ports;
@@ -318,13 +545,18 @@ int xhci_hub_status_data(struct usb_hcd *hcd, char *buf)
memset(buf, 0, retval);
status = 0;
+ mask = PORT_CSC | PORT_PEC | PORT_OCC;
+
spin_lock_irqsave(&xhci->lock, flags);
/* For each port, did anything change? If so, set that bit in buf. */
for (i = 0; i < ports; i++) {
addr = &xhci->op_regs->port_status_base +
NUM_PORT_REGS*i;
temp = xhci_readl(xhci, addr);
- if (temp & (PORT_CSC | PORT_PEC | PORT_OCC)) {
+ if ((temp & mask) != 0 ||
+ (xhci->port_c_suspend[i >> 5] & 1 << (i & 31)) ||
+ (xhci->resume_done[i] && time_after_eq(
+ jiffies, xhci->resume_done[i]))) {
buf[(i + 1) / 8] |= 1 << (i + 1) % 8;
status = 1;
}
@@ -332,3 +564,182 @@ int xhci_hub_status_data(struct usb_hcd *hcd, char *buf)
spin_unlock_irqrestore(&xhci->lock, flags);
return status ? retval : 0;
}
+
+#ifdef CONFIG_PM
+
+int xhci_bus_suspend(struct usb_hcd *hcd)
+{
+ struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+ int port;
+ unsigned long flags;
+
+ xhci_dbg(xhci, "suspend root hub\n");
+
+ spin_lock_irqsave(&xhci->lock, flags);
+
+ if (hcd->self.root_hub->do_remote_wakeup) {
+ port = HCS_MAX_PORTS(xhci->hcs_params1);
+ while (port--) {
+ if (xhci->resume_done[port] != 0) {
+ spin_unlock_irqrestore(&xhci->lock, flags);
+ xhci_dbg(xhci, "suspend failed because "
+ "port %d is resuming\n",
+ port + 1);
+ return -EBUSY;
+ }
+ }
+ }
+
+ port = HCS_MAX_PORTS(xhci->hcs_params1);
+ xhci->bus_suspended = 0;
+ while (port--) {
+ /* suspend the port if the port is not suspended */
+ u32 __iomem *addr;
+ u32 t1, t2;
+ int slot_id;
+
+ addr = &xhci->op_regs->port_status_base +
+ NUM_PORT_REGS * (port & 0xff);
+ t1 = xhci_readl(xhci, addr);
+ t2 = xhci_port_state_to_neutral(t1);
+
+ if ((t1 & PORT_PE) && !(t1 & PORT_PLS_MASK)) {
+ xhci_dbg(xhci, "port %d not suspended\n", port);
+ slot_id = xhci_find_slot_id_by_port(xhci, port + 1);
+ if (slot_id) {
+ spin_unlock_irqrestore(&xhci->lock, flags);
+ xhci_stop_device(xhci, slot_id, 1);
+ spin_lock_irqsave(&xhci->lock, flags);
+ }
+ t2 &= ~PORT_PLS_MASK;
+ t2 |= PORT_LINK_STROBE | XDEV_U3;
+ set_bit(port, &xhci->bus_suspended);
+ }
+ if (hcd->self.root_hub->do_remote_wakeup) {
+ if (t1 & PORT_CONNECT) {
+ t2 |= PORT_WKOC_E | PORT_WKDISC_E;
+ t2 &= ~PORT_WKCONN_E;
+ } else {
+ t2 |= PORT_WKOC_E | PORT_WKCONN_E;
+ t2 &= ~PORT_WKDISC_E;
+ }
+ } else
+ t2 &= ~PORT_WAKE_BITS;
+
+ t1 = xhci_port_state_to_neutral(t1);
+ if (t1 != t2)
+ xhci_writel(xhci, t2, addr);
+
+ if (DEV_HIGHSPEED(t1)) {
+ /* enable remote wake up for USB 2.0 */
+ u32 __iomem *addr;
+ u32 tmp;
+
+ addr = &xhci->op_regs->port_power_base +
+ NUM_PORT_REGS * (port & 0xff);
+ tmp = xhci_readl(xhci, addr);
+ tmp |= PORT_RWE;
+ xhci_writel(xhci, tmp, addr);
+ }
+ }
+ hcd->state = HC_STATE_SUSPENDED;
+ xhci->next_statechange = jiffies + msecs_to_jiffies(10);
+ spin_unlock_irqrestore(&xhci->lock, flags);
+ return 0;
+}
+
+int xhci_bus_resume(struct usb_hcd *hcd)
+{
+ struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+ int port;
+ u32 temp;
+ unsigned long flags;
+
+ xhci_dbg(xhci, "resume root hub\n");
+
+ if (time_before(jiffies, xhci->next_statechange))
+ msleep(5);
+
+ spin_lock_irqsave(&xhci->lock, flags);
+ if (!HCD_HW_ACCESSIBLE(hcd)) {
+ spin_unlock_irqrestore(&xhci->lock, flags);
+ return -ESHUTDOWN;
+ }
+
+ /* delay the irqs */
+ temp = xhci_readl(xhci, &xhci->op_regs->command);
+ temp &= ~CMD_EIE;
+ xhci_writel(xhci, temp, &xhci->op_regs->command);
+
+ port = HCS_MAX_PORTS(xhci->hcs_params1);
+ while (port--) {
+ /* Check whether need resume ports. If needed
+ resume port and disable remote wakeup */
+ u32 __iomem *addr;
+ u32 temp;
+ int slot_id;
+
+ addr = &xhci->op_regs->port_status_base +
+ NUM_PORT_REGS * (port & 0xff);
+ temp = xhci_readl(xhci, addr);
+ if (DEV_SUPERSPEED(temp))
+ temp &= ~(PORT_RWC_BITS | PORT_CEC | PORT_WAKE_BITS);
+ else
+ temp &= ~(PORT_RWC_BITS | PORT_WAKE_BITS);
+ if (test_bit(port, &xhci->bus_suspended) &&
+ (temp & PORT_PLS_MASK)) {
+ if (DEV_SUPERSPEED(temp)) {
+ temp = xhci_port_state_to_neutral(temp);
+ temp &= ~PORT_PLS_MASK;
+ temp |= PORT_LINK_STROBE | XDEV_U0;
+ xhci_writel(xhci, temp, addr);
+ } else {
+ temp = xhci_port_state_to_neutral(temp);
+ temp &= ~PORT_PLS_MASK;
+ temp |= PORT_LINK_STROBE | XDEV_RESUME;
+ xhci_writel(xhci, temp, addr);
+
+ spin_unlock_irqrestore(&xhci->lock, flags);
+ msleep(20);
+ spin_lock_irqsave(&xhci->lock, flags);
+
+ temp = xhci_readl(xhci, addr);
+ temp = xhci_port_state_to_neutral(temp);
+ temp &= ~PORT_PLS_MASK;
+ temp |= PORT_LINK_STROBE | XDEV_U0;
+ xhci_writel(xhci, temp, addr);
+ }
+ slot_id = xhci_find_slot_id_by_port(xhci, port + 1);
+ if (slot_id)
+ xhci_ring_device(xhci, slot_id);
+ } else
+ xhci_writel(xhci, temp, addr);
+
+ if (DEV_HIGHSPEED(temp)) {
+ /* disable remote wake up for USB 2.0 */
+ u32 __iomem *addr;
+ u32 tmp;
+
+ addr = &xhci->op_regs->port_power_base +
+ NUM_PORT_REGS * (port & 0xff);
+ tmp = xhci_readl(xhci, addr);
+ tmp &= ~PORT_RWE;
+ xhci_writel(xhci, tmp, addr);
+ }
+ }
+
+ (void) xhci_readl(xhci, &xhci->op_regs->command);
+
+ xhci->next_statechange = jiffies + msecs_to_jiffies(5);
+ hcd->state = HC_STATE_RUNNING;
+ /* re-enable irqs */
+ temp = xhci_readl(xhci, &xhci->op_regs->command);
+ temp |= CMD_EIE;
+ xhci_writel(xhci, temp, &xhci->op_regs->command);
+ temp = xhci_readl(xhci, &xhci->op_regs->command);
+
+ spin_unlock_irqrestore(&xhci->lock, flags);
+ return 0;
+}
+
+#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,
init_completion(&dev->cmd_completion);
INIT_LIST_HEAD(&dev->cmd_list);
+ dev->udev = udev;
/* Point to output device context in dcbaa. */
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
top_dev = top_dev->parent)
/* Found device below root hub */;
slot_ctx->dev_info2 |= (u32) ROOT_HUB_PORT(top_dev->portnum);
+ dev->port = top_dev->portnum;
xhci_dbg(xhci, "Set root hub portnum to %d\n", top_dev->portnum);
/* Is this a LS/FS device under a HS hub? */
@@ -1443,6 +1445,7 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
scratchpad_free(xhci);
xhci->page_size = 0;
xhci->page_shift = 0;
+ xhci->bus_suspended = 0;
}
static 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)
init_completion(&xhci->addr_dev);
for (i = 0; i < MAX_HC_SLOTS; ++i)
xhci->devs[i] = NULL;
+ for (i = 0; i < MAX_HC_PORTS; ++i)
+ xhci->resume_done[i] = 0;
if (scratchpad_alloc(xhci, flags))
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)
return xhci_pci_reinit(xhci, pdev);
}
+#ifdef CONFIG_PM
+static int xhci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup)
+{
+ struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+ int retval = 0;
+
+ if (hcd->state != HC_STATE_SUSPENDED)
+ return -EINVAL;
+
+ retval = xhci_suspend(xhci);
+
+ return retval;
+}
+
+static int xhci_pci_resume(struct usb_hcd *hcd, bool hibernated)
+{
+ struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+ int retval = 0;
+
+ retval = xhci_resume(xhci, hibernated);
+ return retval;
+}
+#endif /* CONFIG_PM */
+
static const struct hc_driver xhci_pci_hc_driver = {
.description = hcd_name,
.product_desc = "xHCI Host Controller",
@@ -132,7 +156,10 @@ static const struct hc_driver xhci_pci_hc_driver = {
*/
.reset = xhci_pci_setup,
.start = xhci_run,
- /* suspend and resume implemented later */
+#ifdef CONFIG_PM
+ .pci_suspend = xhci_pci_suspend,
+ .pci_resume = xhci_pci_resume,
+#endif
.stop = xhci_stop,
.shutdown = xhci_shutdown,
@@ -152,7 +179,7 @@ static const struct hc_driver xhci_pci_hc_driver = {
.reset_bandwidth = xhci_reset_bandwidth,
.address_device = xhci_address_device,
.update_hub_device = xhci_update_hub_device,
- .reset_device = xhci_reset_device,
+ .reset_device = xhci_discover_or_reset_device,
/*
* scheduling support
@@ -162,6 +189,8 @@ static const struct hc_driver xhci_pci_hc_driver = {
/* Root hub support */
.hub_control = xhci_hub_control,
.hub_status_data = xhci_hub_status_data,
+ .bus_suspend = xhci_bus_suspend,
+ .bus_resume = xhci_bus_resume,
};
/*-------------------------------------------------------------------------*/
@@ -186,6 +215,11 @@ static struct pci_driver xhci_pci_driver = {
/* suspend and resume implemented later */
.shutdown = usb_hcd_pci_shutdown,
+#ifdef CONFIG_PM_SLEEP
+ .driver = {
+ .pm = &usb_hcd_pci_pm_ops
+ },
+#endif
};
int 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 @@
#include <linux/slab.h>
#include "xhci.h"
+static int handle_cmd_in_cmd_wait_list(struct xhci_hcd *xhci,
+ struct xhci_virt_device *virt_dev,
+ struct xhci_event_cmd *event);
+
/*
* Returns zero if the TRB isn't in this segment, otherwise it returns the DMA
* address of the TRB.
@@ -313,7 +317,7 @@ void xhci_ring_cmd_db(struct xhci_hcd *xhci)
xhci_readl(xhci, &xhci->dba->doorbell[0]);
}
-static void ring_ep_doorbell(struct xhci_hcd *xhci,
+void xhci_ring_ep_doorbell(struct xhci_hcd *xhci,
unsigned int slot_id,
unsigned int ep_index,
unsigned int stream_id)
@@ -353,7 +357,7 @@ static void ring_doorbell_for_active_rings(struct xhci_hcd *xhci,
/* A ring has pending URBs if its TD list is not empty */
if (!(ep->ep_state & EP_HAS_STREAMS)) {
if (!(list_empty(&ep->ring->td_list)))
- ring_ep_doorbell(xhci, slot_id, ep_index, 0);
+ xhci_ring_ep_doorbell(xhci, slot_id, ep_index, 0);
return;
}
@@ -361,7 +365,8 @@ static void ring_doorbell_for_active_rings(struct xhci_hcd *xhci,
stream_id++) {
struct xhci_stream_info *stream_info = ep->stream_info;
if (!list_empty(&stream_info->stream_rings[stream_id]->td_list))
- ring_ep_doorbell(xhci, slot_id, ep_index, stream_id);
+ xhci_ring_ep_doorbell(xhci, slot_id, ep_index,
+ stream_id);
}
}
@@ -626,10 +631,11 @@ static void xhci_giveback_urb_in_irq(struct xhci_hcd *xhci,
* bit cleared) so that the HW will skip over them.
*/
static void handle_stopped_endpoint(struct xhci_hcd *xhci,
- union xhci_trb *trb)
+ union xhci_trb *trb, struct xhci_event_cmd *event)
{
unsigned int slot_id;
unsigned int ep_index;
+ struct xhci_virt_device *virt_dev;
struct xhci_ring *ep_ring;
struct xhci_virt_ep *ep;
struct list_head *entry;
@@ -638,6 +644,21 @@ static void handle_stopped_endpoint(struct xhci_hcd *xhci,
struct xhci_dequeue_state deq_state;
+ if (unlikely(TRB_TO_SUSPEND_PORT(
+ xhci->cmd_ring->dequeue->generic.field[3]))) {
+ slot_id = TRB_TO_SLOT_ID(
+ xhci->cmd_ring->dequeue->generic.field[3]);
+ virt_dev = xhci->devs[slot_id];
+ if (virt_dev)
+ handle_cmd_in_cmd_wait_list(xhci, virt_dev,
+ event);
+ else
+ xhci_warn(xhci, "Stop endpoint command "
+ "completion for disabled slot %u\n",
+ slot_id);
+ return;
+ }
+
memset(&deq_state, 0, sizeof(deq_state));
slot_id = TRB_TO_SLOT_ID(trb->generic.field[3]);
ep_index = TRB_TO_EP_INDEX(trb->generic.field[3]);
@@ -1091,7 +1112,7 @@ bandwidth_change:
complete(&xhci->addr_dev);
break;
case TRB_TYPE(TRB_STOP_RING):
- handle_stopped_endpoint(xhci, xhci->cmd_ring->dequeue);
+ handle_stopped_endpoint(xhci, xhci->cmd_ring->dequeue, event);
break;
case TRB_TYPE(TRB_SET_DEQ):
handle_set_deq_completion(xhci, event, xhci->cmd_ring->dequeue);
@@ -1144,17 +1165,72 @@ static void handle_vendor_event(struct xhci_hcd *xhci,
static void handle_port_status(struct xhci_hcd *xhci,
union xhci_trb *event)
{
+ struct usb_hcd *hcd = xhci_to_hcd(xhci);
u32 port_id;
+ u32 temp, temp1;
+ u32 __iomem *addr;
+ int ports;
+ int slot_id;
/* Port status change events always have a successful completion code */
if (GET_COMP_CODE(event->generic.field[2]) != COMP_SUCCESS) {
xhci_warn(xhci, "WARN: xHC returned failed port status event\n");
xhci->error_bitmask |= 1 << 8;
}
- /* FIXME: core doesn't care about all port link state changes yet */
port_id = GET_PORT_ID(event->generic.field[0]);
xhci_dbg(xhci, "Port Status Change Event for port %d\n", port_id);
+ ports = HCS_MAX_PORTS(xhci->hcs_params1);
+ if ((port_id <= 0) || (port_id > ports)) {
+ xhci_warn(xhci, "Invalid port id %d\n", port_id);
+ goto cleanup;
+ }
+
+ addr = &xhci->op_regs->port_status_base + NUM_PORT_REGS * (port_id - 1);
+ temp = xhci_readl(xhci, addr);
+ if ((temp & PORT_CONNECT) && (hcd->state == HC_STATE_SUSPENDED)) {
+ xhci_dbg(xhci, "resume root hub\n");
+ usb_hcd_resume_root_hub(hcd);
+ }
+
+ if ((temp & PORT_PLC) && (temp & PORT_PLS_MASK) == XDEV_RESUME) {
+ xhci_dbg(xhci, "port resume event for port %d\n", port_id);
+
+ temp1 = xhci_readl(xhci, &xhci->op_regs->command);
+ if (!(temp1 & CMD_RUN)) {
+ xhci_warn(xhci, "xHC is not running.\n");
+ goto cleanup;
+ }
+
+ if (DEV_SUPERSPEED(temp)) {
+ xhci_dbg(xhci, "resume SS port %d\n", port_id);
+ temp = xhci_port_state_to_neutral(temp);
+ temp &= ~PORT_PLS_MASK;
+ temp |= PORT_LINK_STROBE | XDEV_U0;
+ xhci_writel(xhci, temp, addr);
+ slot_id = xhci_find_slot_id_by_port(xhci, port_id);
+ if (!slot_id) {
+ xhci_dbg(xhci, "slot_id is zero\n");
+ goto cleanup;
+ }
+ xhci_ring_device(xhci, slot_id);
+ xhci_dbg(xhci, "resume SS port %d finished\n", port_id);
+ /* Clear PORT_PLC */
+ temp = xhci_readl(xhci, addr);
+ temp = xhci_port_state_to_neutral(temp);
+ temp |= PORT_PLC;
+ xhci_writel(xhci, temp, addr);
+ } else {
+ xhci_dbg(xhci, "resume HS port %d\n", port_id);
+ xhci->resume_done[port_id - 1] = jiffies +
+ msecs_to_jiffies(20);
+ mod_timer(&hcd->rh_timer,
+ xhci->resume_done[port_id - 1]);
+ /* Do the rest in GetPortStatus */
+ }
+ }
+
+cleanup:
/* Update event ring dequeue pointer before dropping the lock */
inc_deq(xhci, xhci->event_ring, true);
@@ -2347,7 +2423,7 @@ static void giveback_first_trb(struct xhci_hcd *xhci, int slot_id,
*/
wmb();
start_trb->field[3] |= start_cycle;
- ring_ep_doorbell(xhci, slot_id, ep_index, stream_id);
+ xhci_ring_ep_doorbell(xhci, slot_id, ep_index, stream_id);
}
/*
@@ -2931,7 +3007,7 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
wmb();
start_trb->field[3] |= start_cycle;
- ring_ep_doorbell(xhci, slot_id, ep_index, urb->stream_id);
+ xhci_ring_ep_doorbell(xhci, slot_id, ep_index, urb->stream_id);
return 0;
}
@@ -3108,15 +3184,20 @@ int xhci_queue_evaluate_context(struct xhci_hcd *xhci, dma_addr_t in_ctx_ptr,
false);
}
+/*
+ * Suspend is set to indicate "Stop Endpoint Command" is being issued to stop
+ * activity on an endpoint that is about to be suspended.
+ */
int xhci_queue_stop_endpoint(struct xhci_hcd *xhci, int slot_id,
- unsigned int ep_index)
+ unsigned int ep_index, int suspend)
{
u32 trb_slot_id = SLOT_ID_FOR_TRB(slot_id);
u32 trb_ep_index = EP_ID_FOR_TRB(ep_index);
u32 type = TRB_TYPE(TRB_STOP_RING);
+ u32 trb_suspend = SUSPEND_PORT_FOR_TRB(suspend);
return queue_command(xhci, 0, 0, 0,
- trb_slot_id | trb_ep_index | type, false);
+ trb_slot_id | trb_ep_index | type | trb_suspend, false);
}
/* 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)
xhci_readl(xhci, &xhci->op_regs->status));
}
+#ifdef CONFIG_PM
+static void xhci_save_registers(struct xhci_hcd *xhci)
+{
+ xhci->s3.command = xhci_readl(xhci, &xhci->op_regs->command);
+ xhci->s3.dev_nt = xhci_readl(xhci, &xhci->op_regs->dev_notification);
+ xhci->s3.dcbaa_ptr = xhci_read_64(xhci, &xhci->op_regs->dcbaa_ptr);
+ xhci->s3.config_reg = xhci_readl(xhci, &xhci->op_regs->config_reg);
+ xhci->s3.irq_pending = xhci_readl(xhci, &xhci->ir_set->irq_pending);
+ xhci->s3.irq_control = xhci_readl(xhci, &xhci->ir_set->irq_control);
+ xhci->s3.erst_size = xhci_readl(xhci, &xhci->ir_set->erst_size);
+ xhci->s3.erst_base = xhci_read_64(xhci, &xhci->ir_set->erst_base);
+ xhci->s3.erst_dequeue = xhci_read_64(xhci, &xhci->ir_set->erst_dequeue);
+}
+
+static void xhci_restore_registers(struct xhci_hcd *xhci)
+{
+ xhci_writel(xhci, xhci->s3.command, &xhci->op_regs->command);
+ xhci_writel(xhci, xhci->s3.dev_nt, &xhci->op_regs->dev_notification);
+ xhci_write_64(xhci, xhci->s3.dcbaa_ptr, &xhci->op_regs->dcbaa_ptr);
+ xhci_writel(xhci, xhci->s3.config_reg, &xhci->op_regs->config_reg);
+ xhci_writel(xhci, xhci->s3.irq_pending, &xhci->ir_set->irq_pending);
+ xhci_writel(xhci, xhci->s3.irq_control, &xhci->ir_set->irq_control);
+ xhci_writel(xhci, xhci->s3.erst_size, &xhci->ir_set->erst_size);
+ xhci_write_64(xhci, xhci->s3.erst_base, &xhci->ir_set->erst_base);
+}
+
+/*
+ * Stop HC (not bus-specific)
+ *
+ * This is called when the machine transition into S3/S4 mode.
+ *
+ */
+int xhci_suspend(struct xhci_hcd *xhci)
+{
+ int rc = 0;
+ struct usb_hcd *hcd = xhci_to_hcd(xhci);
+ u32 command;
+
+ spin_lock_irq(&xhci->lock);
+ clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
+ /* step 1: stop endpoint */
+ /* skipped assuming that port suspend has done */
+
+ /* step 2: clear Run/Stop bit */
+ command = xhci_readl(xhci, &xhci->op_regs->command);
+ command &= ~CMD_RUN;
+ xhci_writel(xhci, command, &xhci->op_regs->command);
+ if (handshake(xhci, &xhci->op_regs->status,
+ STS_HALT, STS_HALT, 100*100)) {
+ xhci_warn(xhci, "WARN: xHC CMD_RUN timeout\n");
+ spin_unlock_irq(&xhci->lock);
+ return -ETIMEDOUT;
+ }
+
+ /* step 3: save registers */
+ xhci_save_registers(xhci);
+
+ /* step 4: set CSS flag */
+ command = xhci_readl(xhci, &xhci->op_regs->command);
+ command |= CMD_CSS;
+ xhci_writel(xhci, command, &xhci->op_regs->command);
+ if (handshake(xhci, &xhci->op_regs->status, STS_SAVE, 0, 10*100)) {
+ xhci_warn(xhci, "WARN: xHC CMD_CSS timeout\n");
+ spin_unlock_irq(&xhci->lock);
+ return -ETIMEDOUT;
+ }
+ /* step 5: remove core well power */
+ xhci_cleanup_msix(xhci);
+ spin_unlock_irq(&xhci->lock);
+
+ return rc;
+}
+
+/*
+ * start xHC (not bus-specific)
+ *
+ * This is called when the machine transition from S3/S4 mode.
+ *
+ */
+int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
+{
+ u32 command, temp = 0;
+ struct usb_hcd *hcd = xhci_to_hcd(xhci);
+ struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
+ u64 val_64;
+ int old_state, retval;
+
+ old_state = hcd->state;
+ if (time_before(jiffies, xhci->next_statechange))
+ msleep(100);
+
+ spin_lock_irq(&xhci->lock);
+
+ if (!hibernated) {
+ /* step 1: restore register */
+ xhci_restore_registers(xhci);
+ /* step 2: initialize command ring buffer */
+ val_64 = xhci_read_64(xhci, &xhci->op_regs->cmd_ring);
+ val_64 = (val_64 & (u64) CMD_RING_RSVD_BITS) |
+ (xhci_trb_virt_to_dma(xhci->cmd_ring->deq_seg,
+ xhci->cmd_ring->dequeue) &
+ (u64) ~CMD_RING_RSVD_BITS) |
+ xhci->cmd_ring->cycle_state;
+ xhci_dbg(xhci, "// Setting command ring address to 0x%llx\n",
+ (long unsigned long) val_64);
+ xhci_write_64(xhci, val_64, &xhci->op_regs->cmd_ring);
+ /* step 3: restore state and start state*/
+ /* step 3: set CRS flag */
+ command = xhci_readl(xhci, &xhci->op_regs->command);
+ command |= CMD_CRS;
+ xhci_writel(xhci, command, &xhci->op_regs->command);
+ if (handshake(xhci, &xhci->op_regs->status,
+ STS_RESTORE, 0, 10*100)) {
+ xhci_dbg(xhci, "WARN: xHC CMD_CSS timeout\n");
+ spin_unlock_irq(&xhci->lock);
+ return -ETIMEDOUT;
+ }
+ temp = xhci_readl(xhci, &xhci->op_regs->status);
+ }
+
+ /* If restore operation fails, re-initialize the HC during resume */
+ if ((temp & STS_SRE) || hibernated) {
+ usb_root_hub_lost_power(hcd->self.root_hub);
+
+ xhci_dbg(xhci, "Stop HCD\n");
+ xhci_halt(xhci);
+ xhci_reset(xhci);
+ if (hibernated)
+ xhci_cleanup_msix(xhci);
+ spin_unlock_irq(&xhci->lock);
+
+#ifdef CONFIG_USB_XHCI_HCD_DEBUGGING
+ /* Tell the event ring poll function not to reschedule */
+ xhci->zombie = 1;
+ del_timer_sync(&xhci->event_ring_timer);
+#endif
+
+ xhci_dbg(xhci, "// Disabling event ring interrupts\n");
+ temp = xhci_readl(xhci, &xhci->op_regs->status);
+ xhci_writel(xhci, temp & ~STS_EINT, &xhci->op_regs->status);
+ temp = xhci_readl(xhci, &xhci->ir_set->irq_pending);
+ xhci_writel(xhci, ER_IRQ_DISABLE(temp),
+ &xhci->ir_set->irq_pending);
+ xhci_print_ir_set(xhci, xhci->ir_set, 0);
+
+ xhci_dbg(xhci, "cleaning up memory\n");
+ xhci_mem_cleanup(xhci);
+ xhci_dbg(xhci, "xhci_stop completed - status = %x\n",
+ xhci_readl(xhci, &xhci->op_regs->status));
+
+ xhci_dbg(xhci, "Initialize the HCD\n");
+ retval = xhci_init(hcd);
+ if (retval)
+ return retval;
+
+ xhci_dbg(xhci, "Start the HCD\n");
+ retval = xhci_run(hcd);
+ if (!retval)
+ set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
+ hcd->state = HC_STATE_SUSPENDED;
+ return retval;
+ }
+
+ /* Re-setup MSI-X */
+ if (hcd->irq)
+ free_irq(hcd->irq, hcd);
+ hcd->irq = -1;
+
+ retval = xhci_setup_msix(xhci);
+ if (retval)
+ /* fall back to msi*/
+ retval = xhci_setup_msi(xhci);
+
+ if (retval) {
+ /* fall back to legacy interrupt*/
+ retval = request_irq(pdev->irq, &usb_hcd_irq, IRQF_SHARED,
+ hcd->irq_descr, hcd);
+ if (retval) {
+ xhci_err(xhci, "request interrupt %d failed\n",
+ pdev->irq);
+ return retval;
+ }
+ hcd->irq = pdev->irq;
+ }
+
+ /* step 4: set Run/Stop bit */
+ command = xhci_readl(xhci, &xhci->op_regs->command);
+ command |= CMD_RUN;
+ xhci_writel(xhci, command, &xhci->op_regs->command);
+ handshake(xhci, &xhci->op_regs->status, STS_HALT,
+ 0, 250 * 1000);
+
+ /* step 5: walk topology and initialize portsc,
+ * portpmsc and portli
+ */
+ /* this is done in bus_resume */
+
+ /* step 6: restart each of the previously
+ * Running endpoints by ringing their doorbells
+ */
+
+ set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
+ if (!hibernated)
+ hcd->state = old_state;
+ else
+ hcd->state = HC_STATE_SUSPENDED;
+
+ spin_unlock_irq(&xhci->lock);
+ return 0;
+}
+#endif /* CONFIG_PM */
+
/*-------------------------------------------------------------------------*/
/**
@@ -607,7 +819,11 @@ unsigned int xhci_last_valid_endpoint(u32 added_ctxs)
* returns 0 this is a root hub; returns -EINVAL for NULL pointers.
*/
int xhci_check_args(struct usb_hcd *hcd, struct usb_device *udev,
- struct usb_host_endpoint *ep, int check_ep, const char *func) {
+ struct usb_host_endpoint *ep, int check_ep, bool check_virt_dev,
+ const char *func) {
+ struct xhci_hcd *xhci;
+ struct xhci_virt_device *virt_dev;
+
if (!hcd || (check_ep && !ep) || !udev) {
printk(KERN_DEBUG "xHCI %s called with invalid args\n",
func);
@@ -618,11 +834,24 @@ int xhci_check_args(struct usb_hcd *hcd, struct usb_device *udev,
func);
return 0;
}
- if (!udev->slot_id) {
- printk(KERN_DEBUG "xHCI %s called with unaddressed device\n",
- func);
- return -EINVAL;
+
+ if (check_virt_dev) {
+ xhci = hcd_to_xhci(hcd);
+ if (!udev->slot_id || !xhci->devs
+ || !xhci->devs[udev->slot_id]) {
+ printk(KERN_DEBUG "xHCI %s called with unaddressed "
+ "device\n", func);
+ return -EINVAL;
+ }
+
+ virt_dev = xhci->devs[udev->slot_id];
+ if (virt_dev->udev != udev) {
+ printk(KERN_DEBUG "xHCI %s called with udev and "
+ "virt_dev does not match\n", func);
+ return -EINVAL;
+ }
}
+
return 1;
}
@@ -704,18 +933,13 @@ int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags)
struct urb_priv *urb_priv;
int size, i;
- if (!urb || xhci_check_args(hcd, urb->dev, urb->ep, true, __func__) <= 0)
+ if (!urb || xhci_check_args(hcd, urb->dev, urb->ep,
+ true, true, __func__) <= 0)
return -EINVAL;
slot_id = urb->dev->slot_id;
ep_index = xhci_get_endpoint_index(&urb->ep->desc);
- if (!xhci->devs || !xhci->devs[slot_id]) {
- if (!in_interrupt())
- dev_warn(&urb->dev->dev, "WARN: urb submitted for dev with no Slot ID\n");
- ret = -EINVAL;
- goto exit;
- }
if (!HCD_HW_ACCESSIBLE(hcd)) {
if (!in_interrupt())
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)
ep->stop_cmd_timer.expires = jiffies +
XHCI_STOP_EP_CMD_TIMEOUT * HZ;
add_timer(&ep->stop_cmd_timer);
- xhci_queue_stop_endpoint(xhci, urb->dev->slot_id, ep_index);
+ xhci_queue_stop_endpoint(xhci, urb->dev->slot_id, ep_index, 0);
xhci_ring_cmd_db(xhci);
}
done:
@@ -991,7 +1215,7 @@ int xhci_drop_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
u32 new_add_flags, new_drop_flags, new_slot_info;
int ret;
- ret = xhci_check_args(hcd, udev, ep, 1, __func__);
+ ret = xhci_check_args(hcd, udev, ep, 1, true, __func__);
if (ret <= 0)
return ret;
xhci = hcd_to_xhci(hcd);
@@ -1004,12 +1228,6 @@ int xhci_drop_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
return 0;
}
- if (!xhci->devs || !xhci->devs[udev->slot_id]) {
- xhci_warn(xhci, "xHCI %s called with unaddressed device\n",
- __func__);
- return -EINVAL;
- }
-
in_ctx = xhci->devs[udev->slot_id]->in_ctx;
out_ctx = xhci->devs[udev->slot_id]->out_ctx;
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,
u32 new_add_flags, new_drop_flags, new_slot_info;
int ret = 0;
- ret = xhci_check_args(hcd, udev, ep, 1, __func__);
+ ret = xhci_check_args(hcd, udev, ep, 1, true, __func__);
if (ret <= 0) {
/* So we won't queue a reset ep command for a root hub */
ep->hcpriv = NULL;
@@ -1098,12 +1316,6 @@ int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
return 0;
}
- if (!xhci->devs || !xhci->devs[udev->slot_id]) {
- xhci_warn(xhci, "xHCI %s called with unaddressed device\n",
- __func__);
- return -EINVAL;
- }
-
in_ctx = xhci->devs[udev->slot_id]->in_ctx;
out_ctx = xhci->devs[udev->slot_id]->out_ctx;
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)
struct xhci_input_control_ctx *ctrl_ctx;
struct xhci_slot_ctx *slot_ctx;
- ret = xhci_check_args(hcd, udev, NULL, 0, __func__);
+ ret = xhci_check_args(hcd, udev, NULL, 0, true, __func__);
if (ret <= 0)
return ret;
xhci = hcd_to_xhci(hcd);
- if (!udev->slot_id || !xhci->devs || !xhci->devs[udev->slot_id]) {
- xhci_warn(xhci, "xHCI %s called with unaddressed device\n",
- __func__);
- return -EINVAL;
- }
xhci_dbg(xhci, "%s called for udev %p\n", __func__, udev);
virt_dev = xhci->devs[udev->slot_id];
@@ -1405,16 +1612,11 @@ void xhci_reset_bandwidth(struct usb_hcd *hcd, struct usb_device *udev)
struct xhci_virt_device *virt_dev;
int i, ret;
- ret = xhci_check_args(hcd, udev, NULL, 0, __func__);
+ ret = xhci_check_args(hcd, udev, NULL, 0, true, __func__);
if (ret <= 0)
return;
xhci = hcd_to_xhci(hcd);
- if (!xhci->devs || !xhci->devs[udev->slot_id]) {
- xhci_warn(xhci, "xHCI %s called with unaddressed device\n",
- __func__);
- return;
- }
xhci_dbg(xhci, "%s called for udev %p\n", __func__, udev);
virt_dev = xhci->devs[udev->slot_id];
/* Free any rings allocated for added endpoints */
@@ -1575,7 +1777,7 @@ static int xhci_check_streams_endpoint(struct xhci_hcd *xhci,
if (!ep)
return -EINVAL;
- ret = xhci_check_args(xhci_to_hcd(xhci), udev, ep, 1, __func__);
+ ret = xhci_check_args(xhci_to_hcd(xhci), udev, ep, 1, true, __func__);
if (ret <= 0)
return -EINVAL;
if (ep->ss_ep_comp.bmAttributes == 0) {
@@ -1953,8 +2155,13 @@ int xhci_free_streams(struct usb_hcd *hcd, struct usb_device *udev,
* Wait for the Reset Device command to finish. Remove all structures
* associated with the endpoints that were disabled. Clear the input device
* structure? Cache the rings? Reset the control endpoint 0 max packet size?
+ *
+ * If the virt_dev to be reset does not exist or does not match the udev,
+ * it means the device is lost, possibly due to the xHC restore error and
+ * re-initialization during S3/S4. In this case, call xhci_alloc_dev() to
+ * re-allocate the device.
*/
-int xhci_reset_device(struct usb_hcd *hcd, struct usb_device *udev)
+int xhci_discover_or_reset_device(struct usb_hcd *hcd, struct usb_device *udev)
{
int ret, i;
unsigned long flags;
@@ -1965,16 +2172,35 @@ int xhci_reset_device(struct usb_hcd *hcd, struct usb_device *udev)
int timeleft;
int last_freed_endpoint;
- ret = xhci_check_args(hcd, udev, NULL, 0, __func__);
+ ret = xhci_check_args(hcd, udev, NULL, 0, false, __func__);
if (ret <= 0)
return ret;
xhci = hcd_to_xhci(hcd);
slot_id = udev->slot_id;
virt_dev = xhci->devs[slot_id];
if (!virt_dev) {
- xhci_dbg(xhci, "%s called with invalid slot ID %u\n",
- __func__, slot_id);
- return -EINVAL;
+ xhci_dbg(xhci, "The device to be reset with slot ID %u does "
+ "not exist. Re-allocate the device\n", slot_id);
+ ret = xhci_alloc_dev(hcd, udev);
+ if (ret == 1)
+ return 0;
+ else
+ return -EINVAL;
+ }
+
+ if (virt_dev->udev != udev) {
+ /* If the virt_dev and the udev does not match, this virt_dev
+ * may belong to another udev.
+ * Re-allocate the device.
+ */
+ xhci_dbg(xhci, "The device to be reset with slot ID %u does "
+ "not match the udev. Re-allocate the device\n",
+ slot_id);
+ ret = xhci_alloc_dev(hcd, udev);
+ if (ret == 1)
+ return 0;
+ else
+ return -EINVAL;
}
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)
struct xhci_virt_device *virt_dev;
unsigned long flags;
u32 state;
- int i;
+ int i, ret;
- if (udev->slot_id == 0)
+ ret = xhci_check_args(hcd, udev, NULL, 0, true, __func__);
+ if (ret <= 0)
return;
+
virt_dev = xhci->devs[udev->slot_id];
- if (!virt_dev)
- return;
/* Stop any wayward timer functions (which may grab the lock) */
for (i = 0; i < 31; ++i) {
@@ -2191,12 +2417,17 @@ int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev)
virt_dev = xhci->devs[udev->slot_id];
- /* If this is a Set Address to an unconfigured device, setup ep 0 */
- if (!udev->config)
+ slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->in_ctx);
+ /*
+ * If this is the first Set Address since device plug-in or
+ * virt_device realloaction after a resume with an xHCI power loss,
+ * then set up the slot context.
+ */
+ if (!slot_ctx->dev_info)
xhci_setup_addressable_virt_dev(xhci, udev);
+ /* Otherwise, update the control endpoint ring enqueue pointer. */
else
xhci_copy_ep0_dequeue_into_input_ctx(xhci, udev);
- /* Otherwise, assume the core has the device configured how it wants */
xhci_dbg(xhci, "Slot ID %d Input Context:\n", udev->slot_id);
xhci_dbg_ctx(xhci, virt_dev->in_ctx, 2);
@@ -2268,15 +2499,15 @@ int xhci_address_device(struct usb_hcd *hcd, struct usb_device *udev)
* address given back to us by the HC.
*/
slot_ctx = xhci_get_slot_ctx(xhci, virt_dev->out_ctx);
- udev->devnum = (slot_ctx->dev_state & DEV_ADDR_MASK) + 1;
+ /* Use kernel assigned address for devices; store xHC assigned
+ * address locally. */
+ virt_dev->address = (slot_ctx->dev_state & DEV_ADDR_MASK) + 1;
/* Zero the input context control for later use */
ctrl_ctx = xhci_get_input_control_ctx(xhci, virt_dev->in_ctx);
ctrl_ctx->add_flags = 0;
ctrl_ctx->drop_flags = 0;
- xhci_dbg(xhci, "Device address = %d\n", udev->devnum);
- /* XXX Meh, not sure if anyone else but choose_address uses this. */
- set_bit(udev->devnum, udev->bus->devmap.devicemap);
+ xhci_dbg(xhci, "Internal device address = %d\n", virt_dev->address);
return 0;
}
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 {
/* bits 4:6 are reserved (and should be preserved on writes). */
/* light reset (port status stays unchanged) - reset completed when this is 0 */
#define CMD_LRESET (1 << 7)
-/* FIXME: ignoring host controller save/restore state for now. */
+/* host controller save/restore state. */
#define CMD_CSS (1 << 8)
#define CMD_CRS (1 << 9)
/* Enable Wrap Event - '1' means xHC generates an event when MFINDEX wraps. */
@@ -269,6 +269,10 @@ struct xhci_op_regs {
* A read gives the current link PM state of the port,
* a write with Link State Write Strobe set sets the link state.
*/
+#define PORT_PLS_MASK (0xf << 5)
+#define XDEV_U0 (0x0 << 5)
+#define XDEV_U3 (0x3 << 5)
+#define XDEV_RESUME (0xf << 5)
/* true: port has power (see HCC_PPC) */
#define PORT_POWER (1 << 9)
/* bits 10:13 indicate device speed:
@@ -353,6 +357,8 @@ struct xhci_op_regs {
#define PORT_U2_TIMEOUT(p) (((p) & 0xff) << 8)
/* Bits 24:31 for port testing */
+/* USB2 Protocol PORTSPMSC */
+#define PORT_RWE (1 << 0x3)
/**
* struct xhci_intr_reg - Interrupt Register Set
@@ -510,6 +516,7 @@ struct xhci_slot_ctx {
#define MAX_EXIT (0xffff)
/* Root hub port number that is needed to access the USB device */
#define ROOT_HUB_PORT(p) (((p) & 0xff) << 16)
+#define DEVINFO_TO_ROOT_HUB_PORT(p) (((p) >> 16) & 0xff)
/* Maximum number of ports under a hub device */
#define XHCI_MAX_PORTS(p) (((p) & 0xff) << 24)
@@ -731,6 +738,7 @@ struct xhci_virt_ep {
};
struct xhci_virt_device {
+ struct usb_device *udev;
/*
* Commands to the hardware are passed an "input context" that
* tells the hardware what to change in its data structures.
@@ -745,12 +753,15 @@ struct xhci_virt_device {
/* Rings saved to ensure old alt settings can be re-instated */
struct xhci_ring **ring_cache;
int num_rings_cached;
+ /* Store xHC assigned device address */
+ int address;
#define XHCI_MAX_RINGS_CACHED 31
struct xhci_virt_ep eps[31];
struct completion cmd_completion;
/* Status of the last command issued for this device */
u32 cmd_status;
struct list_head cmd_list;
+ u8 port;
};
@@ -881,6 +892,10 @@ struct xhci_event_cmd {
#define TRB_TO_EP_INDEX(p) ((((p) & (0x1f << 16)) >> 16) - 1)
#define EP_ID_FOR_TRB(p) ((((p) + 1) & 0x1f) << 16)
+#define SUSPEND_PORT_FOR_TRB(p) (((p) & 1) << 23)
+#define TRB_TO_SUSPEND_PORT(p) (((p) & (1 << 23)) >> 23)
+#define LAST_EP_INDEX 30
+
/* Set TR Dequeue Pointer command TRB fields */
#define TRB_TO_STREAM_ID(p) ((((p) & (0xffff << 16)) >> 16))
#define STREAM_ID_FOR_TRB(p) ((((p)) & 0xffff) << 16)
@@ -1115,6 +1130,17 @@ struct urb_priv {
#define XHCI_STOP_EP_CMD_TIMEOUT 5
/* XXX: Make these module parameters */
+struct s3_save {
+ u32 command;
+ u32 dev_nt;
+ u64 dcbaa_ptr;
+ u32 config_reg;
+ u32 irq_pending;
+ u32 irq_control;
+ u32 erst_size;
+ u64 erst_base;
+ u64 erst_dequeue;
+};
/* There is one ehci_hci structure per controller */
struct xhci_hcd {
@@ -1178,6 +1204,12 @@ struct xhci_hcd {
#endif
/* Host controller watchdog timer structures */
unsigned int xhc_state;
+
+ unsigned long bus_suspended;
+ unsigned long next_statechange;
+
+ u32 command;
+ struct s3_save s3;
/* Host controller is dying - not responding to commands. "I'm not dead yet!"
*
* xHC interrupts have been disabled and a watchdog timer will (or has already)
@@ -1199,6 +1231,10 @@ struct xhci_hcd {
#define XHCI_LINK_TRB_QUIRK (1 << 0)
#define XHCI_RESET_EP_QUIRK (1 << 1)
#define XHCI_NEC_HOST (1 << 2)
+ u32 port_c_suspend[8]; /* port suspend change*/
+ u32 suspended_ports[8]; /* which ports are
+ suspended */
+ unsigned long resume_done[MAX_HC_PORTS];
};
/* For testing purposes */
@@ -1369,6 +1405,15 @@ int xhci_init(struct usb_hcd *hcd);
int xhci_run(struct usb_hcd *hcd);
void xhci_stop(struct usb_hcd *hcd);
void xhci_shutdown(struct usb_hcd *hcd);
+
+#ifdef CONFIG_PM
+int xhci_suspend(struct xhci_hcd *xhci);
+int xhci_resume(struct xhci_hcd *xhci, bool hibernated);
+#else
+#define xhci_suspend NULL
+#define xhci_resume NULL
+#endif
+
int xhci_get_frame(struct usb_hcd *hcd);
irqreturn_t xhci_irq(struct usb_hcd *hcd);
irqreturn_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);
int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev, struct usb_host_endpoint *ep);
int xhci_drop_endpoint(struct usb_hcd *hcd, struct usb_device *udev, struct usb_host_endpoint *ep);
void xhci_endpoint_reset(struct usb_hcd *hcd, struct usb_host_endpoint *ep);
-int xhci_reset_device(struct usb_hcd *hcd, struct usb_device *udev);
+int xhci_discover_or_reset_device(struct usb_hcd *hcd, struct usb_device *udev);
int xhci_check_bandwidth(struct usb_hcd *hcd, struct usb_device *udev);
void xhci_reset_bandwidth(struct usb_hcd *hcd, struct usb_device *udev);
@@ -1406,7 +1451,7 @@ int xhci_queue_address_device(struct xhci_hcd *xhci, dma_addr_t in_ctx_ptr,
int xhci_queue_vendor_command(struct xhci_hcd *xhci,
u32 field1, u32 field2, u32 field3, u32 field4);
int xhci_queue_stop_endpoint(struct xhci_hcd *xhci, int slot_id,
- unsigned int ep_index);
+ unsigned int ep_index, int suspend);
int xhci_queue_ctrl_tx(struct xhci_hcd *xhci, gfp_t mem_flags, struct urb *urb,
int slot_id, unsigned int ep_index);
int 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,
unsigned int slot_id, unsigned int ep_index,
struct xhci_dequeue_state *deq_state);
void xhci_stop_endpoint_command_watchdog(unsigned long arg);
+void xhci_ring_ep_doorbell(struct xhci_hcd *xhci, unsigned int slot_id,
+ unsigned int ep_index, unsigned int stream_id);
/* xHCI roothub code */
int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, u16 wIndex,
char *buf, u16 wLength);
int xhci_hub_status_data(struct usb_hcd *hcd, char *buf);
+#ifdef CONFIG_PM
+int xhci_bus_suspend(struct usb_hcd *hcd);
+int xhci_bus_resume(struct usb_hcd *hcd);
+#else
+#define xhci_bus_suspend NULL
+#define xhci_bus_resume NULL
+#endif /* CONFIG_PM */
+
+u32 xhci_port_state_to_neutral(u32 state);
+int xhci_find_slot_id_by_port(struct xhci_hcd *xhci, u16 port);
+void xhci_ring_device(struct xhci_hcd *xhci, int slot_id);
+
/* xHCI contexts */
struct xhci_input_control_ctx *xhci_get_input_control_ctx(struct xhci_hcd *xhci, struct xhci_container_ctx *ctx);
struct 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
driver beforehand. Tools for doing so are available at
http://bersace03.free.fr
+config USB_YUREX
+ tristate "USB YUREX driver support"
+ depends on USB
+ help
+ Say Y here if you want to connect a YUREX to your computer's
+ USB port. The YUREX is a leg-shakes sensor. See
+ <http://bbu.kayac.com/en/> for further information.
+ This driver supports read/write of leg-shakes counter and
+ fasync for the counter update via a device file /dev/yurex*.
+
+ To compile this driver as a module, choose M here: the
+ module will be called yurex.
+
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 @@
# (the ones that don't fit into any other categories)
#
-obj-$(CONFIG_USB_ADUTUX) += adutux.o
-obj-$(CONFIG_USB_APPLEDISPLAY) += appledisplay.o
-obj-$(CONFIG_USB_CYPRESS_CY7C63)+= cypress_cy7c63.o
-obj-$(CONFIG_USB_CYTHERM) += cytherm.o
-obj-$(CONFIG_USB_EMI26) += emi26.o
-obj-$(CONFIG_USB_EMI62) += emi62.o
-obj-$(CONFIG_USB_FTDI_ELAN) += ftdi-elan.o
-obj-$(CONFIG_USB_IDMOUSE) += idmouse.o
-obj-$(CONFIG_USB_IOWARRIOR) += iowarrior.o
-obj-$(CONFIG_USB_ISIGHTFW) += isight_firmware.o
-obj-$(CONFIG_USB_LCD) += usblcd.o
-obj-$(CONFIG_USB_LD) += ldusb.o
-obj-$(CONFIG_USB_LED) += usbled.o
-obj-$(CONFIG_USB_LEGOTOWER) += legousbtower.o
-obj-$(CONFIG_USB_RIO500) += rio500.o
-obj-$(CONFIG_USB_TEST) += usbtest.o
-obj-$(CONFIG_USB_TRANCEVIBRATOR) += trancevibrator.o
-obj-$(CONFIG_USB_USS720) += uss720.o
-obj-$(CONFIG_USB_SEVSEG) += usbsevseg.o
+ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG
-obj-$(CONFIG_USB_SISUSBVGA) += sisusbvga/
+obj-$(CONFIG_USB_ADUTUX) += adutux.o
+obj-$(CONFIG_USB_APPLEDISPLAY) += appledisplay.o
+obj-$(CONFIG_USB_CYPRESS_CY7C63) += cypress_cy7c63.o
+obj-$(CONFIG_USB_CYTHERM) += cytherm.o
+obj-$(CONFIG_USB_EMI26) += emi26.o
+obj-$(CONFIG_USB_EMI62) += emi62.o
+obj-$(CONFIG_USB_FTDI_ELAN) += ftdi-elan.o
+obj-$(CONFIG_USB_IDMOUSE) += idmouse.o
+obj-$(CONFIG_USB_IOWARRIOR) += iowarrior.o
+obj-$(CONFIG_USB_ISIGHTFW) += isight_firmware.o
+obj-$(CONFIG_USB_LCD) += usblcd.o
+obj-$(CONFIG_USB_LD) += ldusb.o
+obj-$(CONFIG_USB_LED) += usbled.o
+obj-$(CONFIG_USB_LEGOTOWER) += legousbtower.o
+obj-$(CONFIG_USB_RIO500) += rio500.o
+obj-$(CONFIG_USB_TEST) += usbtest.o
+obj-$(CONFIG_USB_TRANCEVIBRATOR) += trancevibrator.o
+obj-$(CONFIG_USB_USS720) += uss720.o
+obj-$(CONFIG_USB_SEVSEG) += usbsevseg.o
+obj-$(CONFIG_USB_YUREX) += yurex.o
-ifeq ($(CONFIG_USB_DEBUG),y)
-EXTRA_CFLAGS += -DDEBUG
-endif
+obj-$(CONFIG_USB_SISUSBVGA) += sisusbvga/
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,
ftdi->sequence_num = ++ftdi_instances;
mutex_unlock(&ftdi_module_lock);
ftdi_elan_init_kref(ftdi);
- init_MUTEX(&ftdi->sw_lock);
+ sema_init(&ftdi->sw_lock, 1);
ftdi->udev = usb_get_dev(interface_to_usbdev(interface));
ftdi->interface = interface;
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,
case USB_DEVICE_ID_CODEMERCS_IOWPV2:
case USB_DEVICE_ID_CODEMERCS_IOW40:
/* IOW24 and IOW40 use a synchronous call */
- buf = kmalloc(8, GFP_KERNEL); /* 8 bytes are enough for both products */
+ buf = kmalloc(count, GFP_KERNEL);
if (!buf) {
retval = -ENOMEM;
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 @@
obj-$(CONFIG_USB_SISUSBVGA) += sisusbvga.o
-sisusbvga-objs := sisusb.o sisusb_init.o sisusb_con.o
-
+sisusbvga-y := sisusb.o sisusb_init.o sisusb_con.o
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 @@
/*-------------------------------------------------------------------------*/
-// FIXME make these public somewhere; usbdevfs.h?
-//
+/* FIXME make these public somewhere; usbdevfs.h? */
struct usbtest_param {
- // inputs
+ /* inputs */
unsigned test_num; /* 0..(TEST_CASES-1) */
unsigned iterations;
unsigned length;
unsigned vary;
unsigned sglen;
- // outputs
+ /* outputs */
struct timeval duration;
};
#define USBTEST_REQUEST _IOWR('U', 100, struct usbtest_param)
@@ -45,9 +44,9 @@ struct usbtest_info {
const char *name;
u8 ep_in; /* bulk/intr source */
u8 ep_out; /* bulk/intr sink */
- unsigned autoconf : 1;
- unsigned ctrl_out : 1;
- unsigned iso : 1; /* try iso in/out */
+ unsigned autoconf:1;
+ unsigned ctrl_out:1;
+ unsigned iso:1; /* try iso in/out */
int alt;
};
@@ -71,9 +70,9 @@ struct usbtest_dev {
u8 *buf;
};
-static struct usb_device *testdev_to_usbdev (struct usbtest_dev *test)
+static struct usb_device *testdev_to_usbdev(struct usbtest_dev *test)
{
- return interface_to_usbdev (test->intf);
+ return interface_to_usbdev(test->intf);
}
/* 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)
/*-------------------------------------------------------------------------*/
static int
-get_endpoints (struct usbtest_dev *dev, struct usb_interface *intf)
+get_endpoints(struct usbtest_dev *dev, struct usb_interface *intf)
{
int tmp;
struct usb_host_interface *alt;
@@ -115,7 +114,7 @@ get_endpoints (struct usbtest_dev *dev, struct usb_interface *intf)
case USB_ENDPOINT_XFER_ISOC:
if (dev->info->iso)
goto try_iso;
- // FALLTHROUGH
+ /* FALLTHROUGH */
default:
continue;
}
@@ -142,9 +141,9 @@ try_iso:
return -EINVAL;
found:
- udev = testdev_to_usbdev (dev);
+ udev = testdev_to_usbdev(dev);
if (alt->desc.bAlternateSetting != 0) {
- tmp = usb_set_interface (udev,
+ tmp = usb_set_interface(udev,
alt->desc.bInterfaceNumber,
alt->desc.bAlternateSetting);
if (tmp < 0)
@@ -152,21 +151,21 @@ found:
}
if (in) {
- dev->in_pipe = usb_rcvbulkpipe (udev,
+ dev->in_pipe = usb_rcvbulkpipe(udev,
in->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
- dev->out_pipe = usb_sndbulkpipe (udev,
+ dev->out_pipe = usb_sndbulkpipe(udev,
out->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
}
if (iso_in) {
dev->iso_in = &iso_in->desc;
- dev->in_iso_pipe = usb_rcvisocpipe (udev,
+ dev->in_iso_pipe = usb_rcvisocpipe(udev,
iso_in->desc.bEndpointAddress
& USB_ENDPOINT_NUMBER_MASK);
}
if (iso_out) {
dev->iso_out = &iso_out->desc;
- dev->out_iso_pipe = usb_sndisocpipe (udev,
+ dev->out_iso_pipe = usb_sndisocpipe(udev,
iso_out->desc.bEndpointAddress
& USB_ENDPOINT_NUMBER_MASK);
}
@@ -182,12 +181,12 @@ found:
* them with non-zero test data (or test for it) when appropriate.
*/
-static void simple_callback (struct urb *urb)
+static void simple_callback(struct urb *urb)
{
complete(urb->context);
}
-static struct urb *simple_alloc_urb (
+static struct urb *simple_alloc_urb(
struct usb_device *udev,
int pipe,
unsigned long bytes
@@ -195,32 +194,32 @@ static struct urb *simple_alloc_urb (
{
struct urb *urb;
- urb = usb_alloc_urb (0, GFP_KERNEL);
+ urb = usb_alloc_urb(0, GFP_KERNEL);
if (!urb)
return urb;
- usb_fill_bulk_urb (urb, udev, pipe, NULL, bytes, simple_callback, NULL);
+ usb_fill_bulk_urb(urb, udev, pipe, NULL, bytes, simple_callback, NULL);
urb->interval = (udev->speed == USB_SPEED_HIGH)
? (INTERRUPT_RATE << 3)
: INTERRUPT_RATE;
urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP;
- if (usb_pipein (pipe))
+ if (usb_pipein(pipe))
urb->transfer_flags |= URB_SHORT_NOT_OK;
- urb->transfer_buffer = usb_alloc_coherent (udev, bytes, GFP_KERNEL,
+ urb->transfer_buffer = usb_alloc_coherent(udev, bytes, GFP_KERNEL,
&urb->transfer_dma);
if (!urb->transfer_buffer) {
- usb_free_urb (urb);
+ usb_free_urb(urb);
urb = NULL;
} else
- memset (urb->transfer_buffer, 0, bytes);
+ memset(urb->transfer_buffer, 0, bytes);
return urb;
}
-static unsigned pattern = 0;
+static unsigned pattern;
static unsigned mod_pattern;
module_param_named(pattern, mod_pattern, uint, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(mod_pattern, "i/o pattern (0 == zeroes)");
-static inline void simple_fill_buf (struct urb *urb)
+static inline void simple_fill_buf(struct urb *urb)
{
unsigned i;
u8 *buf = urb->transfer_buffer;
@@ -228,9 +227,9 @@ static inline void simple_fill_buf (struct urb *urb)
switch (pattern) {
default:
- // FALLTHROUGH
+ /* FALLTHROUGH */
case 0:
- memset (buf, 0, len);
+ memset(buf, 0, len);
break;
case 1: /* mod63 */
for (i = 0; i < len; i++)
@@ -273,14 +272,14 @@ static inline int simple_check_buf(struct usbtest_dev *tdev, struct urb *urb)
return 0;
}
-static void simple_free_urb (struct urb *urb)
+static void simple_free_urb(struct urb *urb)
{
usb_free_coherent(urb->dev, urb->transfer_buffer_length,
urb->transfer_buffer, urb->transfer_dma);
- usb_free_urb (urb);
+ usb_free_urb(urb);
}
-static int simple_io (
+static int simple_io(
struct usbtest_dev *tdev,
struct urb *urb,
int iterations,
@@ -296,17 +295,18 @@ static int simple_io (
urb->context = &completion;
while (retval == 0 && iterations-- > 0) {
- init_completion (&completion);
- if (usb_pipeout (urb->pipe))
- simple_fill_buf (urb);
- if ((retval = usb_submit_urb (urb, GFP_KERNEL)) != 0)
+ init_completion(&completion);
+ if (usb_pipeout(urb->pipe))
+ simple_fill_buf(urb);
+ retval = usb_submit_urb(urb, GFP_KERNEL);
+ if (retval != 0)
break;
/* NOTE: no timeouts; can't be broken out of by interrupt */
- wait_for_completion (&completion);
+ wait_for_completion(&completion);
retval = urb->status;
urb->dev = udev;
- if (retval == 0 && usb_pipein (urb->pipe))
+ if (retval == 0 && usb_pipein(urb->pipe))
retval = simple_check_buf(tdev, urb);
if (vary) {
@@ -337,7 +337,7 @@ static int simple_io (
* Yes, this also tests the scatterlist primitives.
*/
-static void free_sglist (struct scatterlist *sg, int nents)
+static void free_sglist(struct scatterlist *sg, int nents)
{
unsigned i;
@@ -346,19 +346,19 @@ static void free_sglist (struct scatterlist *sg, int nents)
for (i = 0; i < nents; i++) {
if (!sg_page(&sg[i]))
continue;
- kfree (sg_virt(&sg[i]));
+ kfree(sg_virt(&sg[i]));
}
- kfree (sg);
+ kfree(sg);
}
static struct scatterlist *
-alloc_sglist (int nents, int max, int vary)
+alloc_sglist(int nents, int max, int vary)
{
struct scatterlist *sg;
unsigned i;
unsigned size = max;
- sg = kmalloc (nents * sizeof *sg, GFP_KERNEL);
+ sg = kmalloc(nents * sizeof *sg, GFP_KERNEL);
if (!sg)
return NULL;
sg_init_table(sg, nents);
@@ -367,9 +367,9 @@ alloc_sglist (int nents, int max, int vary)
char *buf;
unsigned j;
- buf = kzalloc (size, GFP_KERNEL);
+ buf = kzalloc(size, GFP_KERNEL);
if (!buf) {
- free_sglist (sg, i);
+ free_sglist(sg, i);
return NULL;
}
@@ -397,7 +397,7 @@ alloc_sglist (int nents, int max, int vary)
return sg;
}
-static int perform_sglist (
+static int perform_sglist(
struct usbtest_dev *tdev,
unsigned iterations,
int pipe,
@@ -410,7 +410,7 @@ static int perform_sglist (
int retval = 0;
while (retval == 0 && iterations-- > 0) {
- retval = usb_sg_init (req, udev, pipe,
+ retval = usb_sg_init(req, udev, pipe,
(udev->speed == USB_SPEED_HIGH)
? (INTERRUPT_RATE << 3)
: INTERRUPT_RATE,
@@ -418,7 +418,7 @@ static int perform_sglist (
if (retval)
break;
- usb_sg_wait (req);
+ usb_sg_wait(req);
retval = req->status;
/* FIXME check resulting data pattern */
@@ -426,9 +426,9 @@ static int perform_sglist (
/* FIXME if endpoint halted, clear halt (and log) */
}
- // FIXME for unlink or fault handling tests, don't report
- // failure if retval is as we expected ...
-
+ /* FIXME for unlink or fault handling tests, don't report
+ * failure if retval is as we expected ...
+ */
if (retval)
ERROR(tdev, "perform_sglist failed, "
"iterations left %d, status %d\n",
@@ -452,31 +452,31 @@ static int perform_sglist (
*/
static unsigned realworld = 1;
-module_param (realworld, uint, 0);
-MODULE_PARM_DESC (realworld, "clear to demand stricter spec compliance");
+module_param(realworld, uint, 0);
+MODULE_PARM_DESC(realworld, "clear to demand stricter spec compliance");
-static int get_altsetting (struct usbtest_dev *dev)
+static int get_altsetting(struct usbtest_dev *dev)
{
struct usb_interface *iface = dev->intf;
- struct usb_device *udev = interface_to_usbdev (iface);
+ struct usb_device *udev = interface_to_usbdev(iface);
int retval;
- retval = usb_control_msg (udev, usb_rcvctrlpipe (udev, 0),
+ retval = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
USB_REQ_GET_INTERFACE, USB_DIR_IN|USB_RECIP_INTERFACE,
- 0, iface->altsetting [0].desc.bInterfaceNumber,
+ 0, iface->altsetting[0].desc.bInterfaceNumber,
dev->buf, 1, USB_CTRL_GET_TIMEOUT);
switch (retval) {
case 1:
- return dev->buf [0];
+ return dev->buf[0];
case 0:
retval = -ERANGE;
- // FALLTHROUGH
+ /* FALLTHROUGH */
default:
return retval;
}
}
-static int set_altsetting (struct usbtest_dev *dev, int alternate)
+static int set_altsetting(struct usbtest_dev *dev, int alternate)
{
struct usb_interface *iface = dev->intf;
struct usb_device *udev;
@@ -484,9 +484,9 @@ static int set_altsetting (struct usbtest_dev *dev, int alternate)
if (alternate < 0 || alternate >= 256)
return -EINVAL;
- udev = interface_to_usbdev (iface);
- return usb_set_interface (udev,
- iface->altsetting [0].desc.bInterfaceNumber,
+ udev = interface_to_usbdev(iface);
+ return usb_set_interface(udev,
+ iface->altsetting[0].desc.bInterfaceNumber,
alternate);
}
@@ -519,9 +519,9 @@ static int is_good_config(struct usbtest_dev *tdev, int len)
return 0;
}
- if (le16_to_cpu(config->wTotalLength) == len) /* read it all */
+ if (le16_to_cpu(config->wTotalLength) == len) /* read it all */
return 1;
- if (le16_to_cpu(config->wTotalLength) >= TBUF_SIZE) /* max partial read */
+ if (le16_to_cpu(config->wTotalLength) >= TBUF_SIZE) /* max partial read */
return 1;
ERROR(tdev, "bogus config descriptor read size\n");
return 0;
@@ -542,10 +542,10 @@ static int is_good_config(struct usbtest_dev *tdev, int len)
* to see if usbcore, hcd, and device all behave right. such testing would
* involve varied read sizes and other operation sequences.
*/
-static int ch9_postconfig (struct usbtest_dev *dev)
+static int ch9_postconfig(struct usbtest_dev *dev)
{
struct usb_interface *iface = dev->intf;
- struct usb_device *udev = interface_to_usbdev (iface);
+ struct usb_device *udev = interface_to_usbdev(iface);
int i, alt, retval;
/* [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)
for (i = 0; i < iface->num_altsetting; i++) {
/* 9.2.3 constrains the range here */
- alt = iface->altsetting [i].desc.bAlternateSetting;
+ alt = iface->altsetting[i].desc.bAlternateSetting;
if (alt < 0 || alt >= iface->num_altsetting) {
dev_err(&iface->dev,
"invalid alt [%d].bAltSetting = %d\n",
@@ -566,7 +566,7 @@ static int ch9_postconfig (struct usbtest_dev *dev)
continue;
/* [9.4.10] set_interface */
- retval = set_altsetting (dev, alt);
+ retval = set_altsetting(dev, alt);
if (retval) {
dev_err(&iface->dev, "can't set_interface = %d, %d\n",
alt, retval);
@@ -574,7 +574,7 @@ static int ch9_postconfig (struct usbtest_dev *dev)
}
/* [9.4.4] get_interface always works */
- retval = get_altsetting (dev);
+ retval = get_altsetting(dev);
if (retval != alt) {
dev_err(&iface->dev, "get alt should be %d, was %d\n",
alt, retval);
@@ -591,11 +591,11 @@ static int ch9_postconfig (struct usbtest_dev *dev)
* ... although some cheap devices (like one TI Hub I've got)
* won't return config descriptors except before set_config.
*/
- retval = usb_control_msg (udev, usb_rcvctrlpipe (udev, 0),
+ retval = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
USB_REQ_GET_CONFIGURATION,
USB_DIR_IN | USB_RECIP_DEVICE,
0, 0, dev->buf, 1, USB_CTRL_GET_TIMEOUT);
- if (retval != 1 || dev->buf [0] != expected) {
+ if (retval != 1 || dev->buf[0] != expected) {
dev_err(&iface->dev, "get config --> %d %d (1 %d)\n",
retval, dev->buf[0], expected);
return (retval < 0) ? retval : -EDOM;
@@ -603,7 +603,7 @@ static int ch9_postconfig (struct usbtest_dev *dev)
}
/* there's always [9.4.3] a device descriptor [9.6.1] */
- retval = usb_get_descriptor (udev, USB_DT_DEVICE, 0,
+ retval = usb_get_descriptor(udev, USB_DT_DEVICE, 0,
dev->buf, sizeof udev->descriptor);
if (retval != sizeof udev->descriptor) {
dev_err(&iface->dev, "dev descriptor --> %d\n", retval);
@@ -612,7 +612,7 @@ static int ch9_postconfig (struct usbtest_dev *dev)
/* there's always [9.4.3] at least one config descriptor [9.6.3] */
for (i = 0; i < udev->descriptor.bNumConfigurations; i++) {
- retval = usb_get_descriptor (udev, USB_DT_CONFIG, i,
+ retval = usb_get_descriptor(udev, USB_DT_CONFIG, i,
dev->buf, TBUF_SIZE);
if (!is_good_config(dev, retval)) {
dev_err(&iface->dev,
@@ -621,18 +621,19 @@ static int ch9_postconfig (struct usbtest_dev *dev)
return (retval < 0) ? retval : -EDOM;
}
- // FIXME cross-checking udev->config[i] to make sure usbcore
- // parsed it right (etc) would be good testing paranoia
+ /* FIXME cross-checking udev->config[i] to make sure usbcore
+ * parsed it right (etc) would be good testing paranoia
+ */
}
/* and sometimes [9.2.6.6] speed dependent descriptors */
if (le16_to_cpu(udev->descriptor.bcdUSB) == 0x0200) {
- struct usb_qualifier_descriptor *d = NULL;
+ struct usb_qualifier_descriptor *d = NULL;
/* device qualifier [9.6.2] */
- retval = usb_get_descriptor (udev,
+ retval = usb_get_descriptor(udev,
USB_DT_DEVICE_QUALIFIER, 0, dev->buf,
- sizeof (struct usb_qualifier_descriptor));
+ sizeof(struct usb_qualifier_descriptor));
if (retval == -EPIPE) {
if (udev->speed == USB_SPEED_HIGH) {
dev_err(&iface->dev,
@@ -641,7 +642,7 @@ static int ch9_postconfig (struct usbtest_dev *dev)
return (retval < 0) ? retval : -EDOM;
}
/* usb2.0 but not high-speed capable; fine */
- } else if (retval != sizeof (struct usb_qualifier_descriptor)) {
+ } else if (retval != sizeof(struct usb_qualifier_descriptor)) {
dev_err(&iface->dev, "dev qualifier --> %d\n", retval);
return (retval < 0) ? retval : -EDOM;
} else
@@ -651,7 +652,7 @@ static int ch9_postconfig (struct usbtest_dev *dev)
if (d) {
unsigned max = d->bNumConfigurations;
for (i = 0; i < max; i++) {
- retval = usb_get_descriptor (udev,
+ retval = usb_get_descriptor(udev,
USB_DT_OTHER_SPEED_CONFIG, i,
dev->buf, TBUF_SIZE);
if (!is_good_config(dev, retval)) {
@@ -663,25 +664,26 @@ static int ch9_postconfig (struct usbtest_dev *dev)
}
}
}
- // FIXME fetch strings from at least the device descriptor
+ /* FIXME fetch strings from at least the device descriptor */
/* [9.4.5] get_status always works */
- retval = usb_get_status (udev, USB_RECIP_DEVICE, 0, dev->buf);
+ retval = usb_get_status(udev, USB_RECIP_DEVICE, 0, dev->buf);
if (retval != 2) {
dev_err(&iface->dev, "get dev status --> %d\n", retval);
return (retval < 0) ? retval : -EDOM;
}
- // FIXME configuration.bmAttributes says if we could try to set/clear
- // the device's remote wakeup feature ... if we can, test that here
+ /* FIXME configuration.bmAttributes says if we could try to set/clear
+ * the device's remote wakeup feature ... if we can, test that here
+ */
- retval = usb_get_status (udev, USB_RECIP_INTERFACE,
- iface->altsetting [0].desc.bInterfaceNumber, dev->buf);
+ retval = usb_get_status(udev, USB_RECIP_INTERFACE,
+ iface->altsetting[0].desc.bInterfaceNumber, dev->buf);
if (retval != 2) {
dev_err(&iface->dev, "get interface status --> %d\n", retval);
return (retval < 0) ? retval : -EDOM;
}
- // FIXME get status for each endpoint in the interface
+ /* FIXME get status for each endpoint in the interface */
return 0;
}
@@ -717,7 +719,7 @@ struct subcase {
int expected;
};
-static void ctrl_complete (struct urb *urb)
+static void ctrl_complete(struct urb *urb)
{
struct ctrl_ctx *ctx = urb->context;
struct usb_ctrlrequest *reqp;
@@ -725,9 +727,9 @@ static void ctrl_complete (struct urb *urb)
int status = urb->status;
reqp = (struct usb_ctrlrequest *)urb->setup_packet;
- subcase = container_of (reqp, struct subcase, setup);
+ subcase = container_of(reqp, struct subcase, setup);
- spin_lock (&ctx->lock);
+ spin_lock(&ctx->lock);
ctx->count--;
ctx->pending--;
@@ -787,14 +789,14 @@ error:
/* unlink whatever's still pending */
for (i = 1; i < ctx->param->sglen; i++) {
- struct urb *u = ctx->urb [
- (i + subcase->number)
- % ctx->param->sglen];
+ struct urb *u = ctx->urb[
+ (i + subcase->number)
+ % ctx->param->sglen];
if (u == urb || !u->dev)
continue;
spin_unlock(&ctx->lock);
- status = usb_unlink_urb (u);
+ status = usb_unlink_urb(u);
spin_lock(&ctx->lock);
switch (status) {
case -EINPROGRESS:
@@ -812,7 +814,8 @@ error:
/* resubmit if we need to, else mark this as done */
if ((status == 0) && (ctx->pending < ctx->count)) {
- if ((status = usb_submit_urb (urb, GFP_ATOMIC)) != 0) {
+ status = usb_submit_urb(urb, GFP_ATOMIC);
+ if (status != 0) {
ERROR(ctx->dev,
"can't resubmit ctrl %02x.%02x, err %d\n",
reqp->bRequestType, reqp->bRequest, status);
@@ -824,21 +827,21 @@ error:
/* signal completion when nothing's queued */
if (ctx->pending == 0)
- complete (&ctx->complete);
- spin_unlock (&ctx->lock);
+ complete(&ctx->complete);
+ spin_unlock(&ctx->lock);
}
static int
-test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param)
+test_ctrl_queue(struct usbtest_dev *dev, struct usbtest_param *param)
{
- struct usb_device *udev = testdev_to_usbdev (dev);
+ struct usb_device *udev = testdev_to_usbdev(dev);
struct urb **urb;
struct ctrl_ctx context;
int i;
- spin_lock_init (&context.lock);
+ spin_lock_init(&context.lock);
context.dev = dev;
- init_completion (&context.complete);
+ init_completion(&context.complete);
context.count = param->sglen * param->iterations;
context.pending = 0;
context.status = -ENOMEM;
@@ -853,7 +856,7 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param)
if (!urb)
return -ENOMEM;
for (i = 0; i < param->sglen; i++) {
- int pipe = usb_rcvctrlpipe (udev, 0);
+ int pipe = usb_rcvctrlpipe(udev, 0);
unsigned len;
struct urb *u;
struct usb_ctrlrequest req;
@@ -869,104 +872,108 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param)
* device, but some are chosen to trigger protocol stalls
* or short reads.
*/
- memset (&req, 0, sizeof req);
+ memset(&req, 0, sizeof req);
req.bRequest = USB_REQ_GET_DESCRIPTOR;
req.bRequestType = USB_DIR_IN|USB_RECIP_DEVICE;
switch (i % NUM_SUBCASES) {
- case 0: // get device descriptor
- req.wValue = cpu_to_le16 (USB_DT_DEVICE << 8);
- len = sizeof (struct usb_device_descriptor);
+ case 0: /* get device descriptor */
+ req.wValue = cpu_to_le16(USB_DT_DEVICE << 8);
+ len = sizeof(struct usb_device_descriptor);
break;
- case 1: // get first config descriptor (only)
- req.wValue = cpu_to_le16 ((USB_DT_CONFIG << 8) | 0);
- len = sizeof (struct usb_config_descriptor);
+ case 1: /* get first config descriptor (only) */
+ req.wValue = cpu_to_le16((USB_DT_CONFIG << 8) | 0);
+ len = sizeof(struct usb_config_descriptor);
break;
- case 2: // get altsetting (OFTEN STALLS)
+ case 2: /* get altsetting (OFTEN STALLS) */
req.bRequest = USB_REQ_GET_INTERFACE;
req.bRequestType = USB_DIR_IN|USB_RECIP_INTERFACE;
- // index = 0 means first interface
+ /* index = 0 means first interface */
len = 1;
expected = EPIPE;
break;
- case 3: // get interface status
+ case 3: /* get interface status */
req.bRequest = USB_REQ_GET_STATUS;
req.bRequestType = USB_DIR_IN|USB_RECIP_INTERFACE;
- // interface 0
+ /* interface 0 */
len = 2;
break;
- case 4: // get device status
+ case 4: /* get device status */
req.bRequest = USB_REQ_GET_STATUS;
req.bRequestType = USB_DIR_IN|USB_RECIP_DEVICE;
len = 2;
break;
- case 5: // get device qualifier (MAY STALL)
+ case 5: /* get device qualifier (MAY STALL) */
req.wValue = cpu_to_le16 (USB_DT_DEVICE_QUALIFIER << 8);
- len = sizeof (struct usb_qualifier_descriptor);
+ len = sizeof(struct usb_qualifier_descriptor);
if (udev->speed != USB_SPEED_HIGH)
expected = EPIPE;
break;
- case 6: // get first config descriptor, plus interface
- req.wValue = cpu_to_le16 ((USB_DT_CONFIG << 8) | 0);
- len = sizeof (struct usb_config_descriptor);
- len += sizeof (struct usb_interface_descriptor);
+ case 6: /* get first config descriptor, plus interface */
+ req.wValue = cpu_to_le16((USB_DT_CONFIG << 8) | 0);
+ len = sizeof(struct usb_config_descriptor);
+ len += sizeof(struct usb_interface_descriptor);
break;
- case 7: // get interface descriptor (ALWAYS STALLS)
+ case 7: /* get interface descriptor (ALWAYS STALLS) */
req.wValue = cpu_to_le16 (USB_DT_INTERFACE << 8);
- // interface == 0
- len = sizeof (struct usb_interface_descriptor);
+ /* interface == 0 */
+ len = sizeof(struct usb_interface_descriptor);
expected = -EPIPE;
break;
- // NOTE: two consecutive stalls in the queue here.
- // that tests fault recovery a bit more aggressively.
- case 8: // clear endpoint halt (MAY STALL)
+ /* NOTE: two consecutive stalls in the queue here.
+ * that tests fault recovery a bit more aggressively. */
+ case 8: /* clear endpoint halt (MAY STALL) */
req.bRequest = USB_REQ_CLEAR_FEATURE;
req.bRequestType = USB_RECIP_ENDPOINT;
- // wValue 0 == ep halt
- // wIndex 0 == ep0 (shouldn't halt!)
+ /* wValue 0 == ep halt */
+ /* wIndex 0 == ep0 (shouldn't halt!) */
len = 0;
- pipe = usb_sndctrlpipe (udev, 0);
+ pipe = usb_sndctrlpipe(udev, 0);
expected = EPIPE;
break;
- case 9: // get endpoint status
+ case 9: /* get endpoint status */
req.bRequest = USB_REQ_GET_STATUS;
req.bRequestType = USB_DIR_IN|USB_RECIP_ENDPOINT;
- // endpoint 0
+ /* endpoint 0 */
len = 2;
break;
- case 10: // trigger short read (EREMOTEIO)
- req.wValue = cpu_to_le16 ((USB_DT_CONFIG << 8) | 0);
+ case 10: /* trigger short read (EREMOTEIO) */
+ req.wValue = cpu_to_le16((USB_DT_CONFIG << 8) | 0);
len = 1024;
expected = -EREMOTEIO;
break;
- // NOTE: two consecutive _different_ faults in the queue.
- case 11: // get endpoint descriptor (ALWAYS STALLS)
- req.wValue = cpu_to_le16 (USB_DT_ENDPOINT << 8);
- // endpoint == 0
- len = sizeof (struct usb_interface_descriptor);
+ /* NOTE: two consecutive _different_ faults in the queue. */
+ case 11: /* get endpoint descriptor (ALWAYS STALLS) */
+ req.wValue = cpu_to_le16(USB_DT_ENDPOINT << 8);
+ /* endpoint == 0 */
+ len = sizeof(struct usb_interface_descriptor);
expected = EPIPE;
break;
- // NOTE: sometimes even a third fault in the queue!
- case 12: // get string 0 descriptor (MAY STALL)
- req.wValue = cpu_to_le16 (USB_DT_STRING << 8);
- // string == 0, for language IDs
- len = sizeof (struct usb_interface_descriptor);
- // may succeed when > 4 languages
- expected = EREMOTEIO; // or EPIPE, if no strings
+ /* NOTE: sometimes even a third fault in the queue! */
+ case 12: /* get string 0 descriptor (MAY STALL) */
+ req.wValue = cpu_to_le16(USB_DT_STRING << 8);
+ /* string == 0, for language IDs */
+ len = sizeof(struct usb_interface_descriptor);
+ /* may succeed when > 4 languages */
+ expected = EREMOTEIO; /* or EPIPE, if no strings */
break;
- case 13: // short read, resembling case 10
- req.wValue = cpu_to_le16 ((USB_DT_CONFIG << 8) | 0);
- // last data packet "should" be DATA1, not DATA0
+ case 13: /* short read, resembling case 10 */
+ req.wValue = cpu_to_le16((USB_DT_CONFIG << 8) | 0);
+ /* last data packet "should" be DATA1, not DATA0 */
len = 1024 - udev->descriptor.bMaxPacketSize0;
expected = -EREMOTEIO;
break;
- case 14: // short read; try to fill the last packet
- req.wValue = cpu_to_le16 ((USB_DT_DEVICE << 8) | 0);
+ case 14: /* short read; try to fill the last packet */
+ req.wValue = cpu_to_le16((USB_DT_DEVICE << 8) | 0);
/* device descriptor size == 18 bytes */
len = udev->descriptor.bMaxPacketSize0;
switch (len) {
- case 8: len = 24; break;
- case 16: len = 32; break;
+ case 8:
+ len = 24;
+ break;
+ case 16:
+ len = 32;
+ break;
}
expected = -EREMOTEIO;
break;
@@ -975,8 +982,8 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param)
context.status = -EINVAL;
goto cleanup;
}
- req.wLength = cpu_to_le16 (len);
- urb [i] = u = simple_alloc_urb (udev, pipe, len);
+ req.wLength = cpu_to_le16(len);
+ urb[i] = u = simple_alloc_urb(udev, pipe, len);
if (!u)
goto cleanup;
@@ -994,9 +1001,9 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param)
/* queue the urbs */
context.urb = urb;
- spin_lock_irq (&context.lock);
+ spin_lock_irq(&context.lock);
for (i = 0; i < param->sglen; i++) {
- context.status = usb_submit_urb (urb [i], GFP_ATOMIC);
+ context.status = usb_submit_urb(urb[i], GFP_ATOMIC);
if (context.status != 0) {
ERROR(dev, "can't submit urb[%d], status %d\n",
i, context.status);
@@ -1005,23 +1012,23 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param)
}
context.pending++;
}
- spin_unlock_irq (&context.lock);
+ spin_unlock_irq(&context.lock);
/* FIXME set timer and time out; provide a disconnect hook */
/* wait for the last one to complete */
if (context.pending > 0)
- wait_for_completion (&context.complete);
+ wait_for_completion(&context.complete);
cleanup:
for (i = 0; i < param->sglen; i++) {
- if (!urb [i])
+ if (!urb[i])
continue;
- urb [i]->dev = udev;
+ urb[i]->dev = udev;
kfree(urb[i]->setup_packet);
- simple_free_urb (urb [i]);
+ simple_free_urb(urb[i]);
}
- kfree (urb);
+ kfree(urb);
return context.status;
}
#undef NUM_SUBCASES
@@ -1029,27 +1036,27 @@ cleanup:
/*-------------------------------------------------------------------------*/
-static void unlink1_callback (struct urb *urb)
+static void unlink1_callback(struct urb *urb)
{
int status = urb->status;
- // we "know" -EPIPE (stall) never happens
+ /* we "know" -EPIPE (stall) never happens */
if (!status)
- status = usb_submit_urb (urb, GFP_ATOMIC);
+ status = usb_submit_urb(urb, GFP_ATOMIC);
if (status) {
urb->status = status;
complete(urb->context);
}
}
-static int unlink1 (struct usbtest_dev *dev, int pipe, int size, int async)
+static int unlink1(struct usbtest_dev *dev, int pipe, int size, int async)
{
struct urb *urb;
struct completion completion;
int retval = 0;
- init_completion (&completion);
- urb = simple_alloc_urb (testdev_to_usbdev (dev), pipe, size);
+ init_completion(&completion);
+ urb = simple_alloc_urb(testdev_to_usbdev(dev), pipe, size);
if (!urb)
return -ENOMEM;
urb->context = &completion;
@@ -1061,7 +1068,8 @@ static int unlink1 (struct usbtest_dev *dev, int pipe, int size, int async)
* FIXME want additional tests for when endpoint is STALLing
* due to errors, or is just NAKing requests.
*/
- if ((retval = usb_submit_urb (urb, GFP_KERNEL)) != 0) {
+ retval = usb_submit_urb(urb, GFP_KERNEL);
+ if (retval != 0) {
dev_err(&dev->intf->dev, "submit fail %d\n", retval);
return retval;
}
@@ -1069,7 +1077,7 @@ static int unlink1 (struct usbtest_dev *dev, int pipe, int size, int async)
/* unlinking that should always work. variable delay tests more
* hcd states and code paths, even with little other system load.
*/
- msleep (jiffies % (2 * INTERRUPT_RATE));
+ msleep(jiffies % (2 * INTERRUPT_RATE));
if (async) {
while (!completion_done(&completion)) {
retval = usb_unlink_urb(urb);
@@ -1098,11 +1106,11 @@ static int unlink1 (struct usbtest_dev *dev, int pipe, int size, int async)
break;
}
} else
- usb_kill_urb (urb);
+ usb_kill_urb(urb);
- wait_for_completion (&completion);
+ wait_for_completion(&completion);
retval = urb->status;
- simple_free_urb (urb);
+ simple_free_urb(urb);
if (async)
return (retval == -ECONNRESET) ? 0 : retval - 1000;
@@ -1111,14 +1119,14 @@ static int unlink1 (struct usbtest_dev *dev, int pipe, int size, int async)
0 : retval - 2000;
}
-static int unlink_simple (struct usbtest_dev *dev, int pipe, int len)
+static int unlink_simple(struct usbtest_dev *dev, int pipe, int len)
{
int retval = 0;
/* test sync and async paths */
- retval = unlink1 (dev, pipe, len, 1);
+ retval = unlink1(dev, pipe, len, 1);
if (!retval)
- retval = unlink1 (dev, pipe, len, 0);
+ retval = unlink1(dev, pipe, len, 0);
return retval;
}
@@ -1130,7 +1138,7 @@ static int verify_not_halted(struct usbtest_dev *tdev, int ep, struct urb *urb)
u16 status;
/* shouldn't look or act halted */
- retval = usb_get_status (urb->dev, USB_RECIP_ENDPOINT, ep, &status);
+ retval = usb_get_status(urb->dev, USB_RECIP_ENDPOINT, ep, &status);
if (retval < 0) {
ERROR(tdev, "ep %02x couldn't get no-halt status, %d\n",
ep, retval);
@@ -1152,7 +1160,7 @@ static int verify_halted(struct usbtest_dev *tdev, int ep, struct urb *urb)
u16 status;
/* should look and act halted */
- retval = usb_get_status (urb->dev, USB_RECIP_ENDPOINT, ep, &status);
+ retval = usb_get_status(urb->dev, USB_RECIP_ENDPOINT, ep, &status);
if (retval < 0) {
ERROR(tdev, "ep %02x couldn't get halt status, %d\n",
ep, retval);
@@ -1182,7 +1190,7 @@ static int test_halt(struct usbtest_dev *tdev, int ep, struct urb *urb)
return retval;
/* set halt (protocol test only), verify it worked */
- retval = usb_control_msg (urb->dev, usb_sndctrlpipe (urb->dev, 0),
+ retval = usb_control_msg(urb->dev, usb_sndctrlpipe(urb->dev, 0),
USB_REQ_SET_FEATURE, USB_RECIP_ENDPOINT,
USB_ENDPOINT_HALT, ep,
NULL, 0, USB_CTRL_SET_TIMEOUT);
@@ -1195,7 +1203,7 @@ static int test_halt(struct usbtest_dev *tdev, int ep, struct urb *urb)
return retval;
/* clear halt (tests API + protocol), verify it worked */
- retval = usb_clear_halt (urb->dev, urb->pipe);
+ retval = usb_clear_halt(urb->dev, urb->pipe);
if (retval < 0) {
ERROR(tdev, "ep %02x couldn't clear halt, %d\n", ep, retval);
return retval;
@@ -1209,18 +1217,18 @@ static int test_halt(struct usbtest_dev *tdev, int ep, struct urb *urb)
return 0;
}
-static int halt_simple (struct usbtest_dev *dev)
+static int halt_simple(struct usbtest_dev *dev)
{
int ep;
int retval = 0;
struct urb *urb;
- urb = simple_alloc_urb (testdev_to_usbdev (dev), 0, 512);
+ urb = simple_alloc_urb(testdev_to_usbdev(dev), 0, 512);
if (urb == NULL)
return -ENOMEM;
if (dev->in_pipe) {
- ep = usb_pipeendpoint (dev->in_pipe) | USB_DIR_IN;
+ ep = usb_pipeendpoint(dev->in_pipe) | USB_DIR_IN;
urb->pipe = dev->in_pipe;
retval = test_halt(dev, ep, urb);
if (retval < 0)
@@ -1228,12 +1236,12 @@ static int halt_simple (struct usbtest_dev *dev)
}
if (dev->out_pipe) {
- ep = usb_pipeendpoint (dev->out_pipe);
+ ep = usb_pipeendpoint(dev->out_pipe);
urb->pipe = dev->out_pipe;
retval = test_halt(dev, ep, urb);
}
done:
- simple_free_urb (urb);
+ simple_free_urb(urb);
return retval;
}
@@ -1247,7 +1255,7 @@ done:
* need to be able to handle more than one OUT data packet. We'll
* try whatever we're told to try.
*/
-static int ctrl_out (struct usbtest_dev *dev,
+static int ctrl_out(struct usbtest_dev *dev,
unsigned count, unsigned length, unsigned vary)
{
unsigned i, j, len;
@@ -1263,7 +1271,7 @@ static int ctrl_out (struct usbtest_dev *dev,
if (!buf)
return -ENOMEM;
- udev = testdev_to_usbdev (dev);
+ udev = testdev_to_usbdev(dev);
len = length;
retval = 0;
@@ -1273,8 +1281,8 @@ static int ctrl_out (struct usbtest_dev *dev,
for (i = 0; i < count; i++) {
/* write patterned data */
for (j = 0; j < len; j++)
- buf [j] = i + j;
- retval = usb_control_msg (udev, usb_sndctrlpipe (udev,0),
+ buf[j] = i + j;
+ retval = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
0x5b, USB_DIR_OUT|USB_TYPE_VENDOR,
0, 0, buf, len, USB_CTRL_SET_TIMEOUT);
if (retval != len) {
@@ -1288,7 +1296,7 @@ static int ctrl_out (struct usbtest_dev *dev,
}
/* read it back -- assuming nothing intervened!! */
- retval = usb_control_msg (udev, usb_rcvctrlpipe (udev,0),
+ retval = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
0x5c, USB_DIR_IN|USB_TYPE_VENDOR,
0, 0, buf, len, USB_CTRL_GET_TIMEOUT);
if (retval != len) {
@@ -1303,9 +1311,9 @@ static int ctrl_out (struct usbtest_dev *dev,
/* fail if we can't verify */
for (j = 0; j < len; j++) {
- if (buf [j] != (u8) (i + j)) {
+ if (buf[j] != (u8) (i + j)) {
ERROR(dev, "ctrl_out, byte %d is %d not %d\n",
- j, buf [j], (u8) i + j);
+ j, buf[j], (u8) i + j);
retval = -EBADMSG;
break;
}
@@ -1326,10 +1334,10 @@ static int ctrl_out (struct usbtest_dev *dev,
}
if (retval < 0)
- ERROR (dev, "ctrl_out %s failed, code %d, count %d\n",
+ ERROR(dev, "ctrl_out %s failed, code %d, count %d\n",
what, retval, i);
- kfree (buf);
+ kfree(buf);
return retval;
}
@@ -1351,7 +1359,7 @@ struct iso_context {
struct usbtest_dev *dev;
};
-static void iso_callback (struct urb *urb)
+static void iso_callback(struct urb *urb)
{
struct iso_context *ctx = urb->context;
@@ -1363,10 +1371,12 @@ static void iso_callback (struct urb *urb)
ctx->errors += urb->error_count;
else if (urb->status != 0)
ctx->errors += urb->number_of_packets;
+ else if (urb->actual_length != urb->transfer_buffer_length)
+ ctx->errors++;
if (urb->status == 0 && ctx->count > (ctx->pending - 1)
&& !ctx->submit_error) {
- int status = usb_submit_urb (urb, GFP_ATOMIC);
+ int status = usb_submit_urb(urb, GFP_ATOMIC);
switch (status) {
case 0:
goto done;
@@ -1388,13 +1398,13 @@ static void iso_callback (struct urb *urb)
dev_err(&ctx->dev->intf->dev,
"iso test, %lu errors out of %lu\n",
ctx->errors, ctx->packet_count);
- complete (&ctx->done);
+ complete(&ctx->done);
}
done:
spin_unlock(&ctx->lock);
}
-static struct urb *iso_alloc_urb (
+static struct urb *iso_alloc_urb(
struct usb_device *udev,
int pipe,
struct usb_endpoint_descriptor *desc,
@@ -1410,7 +1420,7 @@ static struct urb *iso_alloc_urb (
maxp *= 1 + (0x3 & (le16_to_cpu(desc->wMaxPacketSize) >> 11));
packets = DIV_ROUND_UP(bytes, maxp);
- urb = usb_alloc_urb (packets, GFP_KERNEL);
+ urb = usb_alloc_urb(packets, GFP_KERNEL);
if (!urb)
return urb;
urb->dev = udev;
@@ -1418,30 +1428,30 @@ static struct urb *iso_alloc_urb (
urb->number_of_packets = packets;
urb->transfer_buffer_length = bytes;
- urb->transfer_buffer = usb_alloc_coherent (udev, bytes, GFP_KERNEL,
+ urb->transfer_buffer = usb_alloc_coherent(udev, bytes, GFP_KERNEL,
&urb->transfer_dma);
if (!urb->transfer_buffer) {
- usb_free_urb (urb);
+ usb_free_urb(urb);
return NULL;
}
- memset (urb->transfer_buffer, 0, bytes);
+ memset(urb->transfer_buffer, 0, bytes);
for (i = 0; i < packets; i++) {
/* here, only the last packet will be short */
- urb->iso_frame_desc[i].length = min ((unsigned) bytes, maxp);
+ urb->iso_frame_desc[i].length = min((unsigned) bytes, maxp);
bytes -= urb->iso_frame_desc[i].length;
urb->iso_frame_desc[i].offset = maxp * i;
}
urb->complete = iso_callback;
- // urb->context = SET BY CALLER
+ /* urb->context = SET BY CALLER */
urb->interval = 1 << (desc->bInterval - 1);
urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP;
return urb;
}
static int
-test_iso_queue (struct usbtest_dev *dev, struct usbtest_param *param,
+test_iso_queue(struct usbtest_dev *dev, struct usbtest_param *param,
int pipe, struct usb_endpoint_descriptor *desc)
{
struct iso_context context;
@@ -1457,11 +1467,11 @@ test_iso_queue (struct usbtest_dev *dev, struct usbtest_param *param,
memset(&context, 0, sizeof context);
context.count = param->iterations * param->sglen;
context.dev = dev;
- init_completion (&context.done);
- spin_lock_init (&context.lock);
+ init_completion(&context.done);
+ spin_lock_init(&context.lock);
- memset (urbs, 0, sizeof urbs);
- udev = testdev_to_usbdev (dev);
+ memset(urbs, 0, sizeof urbs);
+ udev = testdev_to_usbdev(dev);
dev_info(&dev->intf->dev,
"... iso period %d %sframes, wMaxPacket %04x\n",
1 << (desc->bInterval - 1),
@@ -1469,14 +1479,14 @@ test_iso_queue (struct usbtest_dev *dev, struct usbtest_param *param,
le16_to_cpu(desc->wMaxPacketSize));
for (i = 0; i < param->sglen; i++) {
- urbs [i] = iso_alloc_urb (udev, pipe, desc,
+ urbs[i] = iso_alloc_urb(udev, pipe, desc,
param->length);
- if (!urbs [i]) {
+ if (!urbs[i]) {
status = -ENOMEM;
goto fail;
}
packets += urbs[i]->number_of_packets;
- urbs [i]->context = &context;
+ urbs[i]->context = &context;
}
packets *= param->iterations;
dev_info(&dev->intf->dev,
@@ -1485,27 +1495,27 @@ test_iso_queue (struct usbtest_dev *dev, struct usbtest_param *param,
/ ((udev->speed == USB_SPEED_HIGH) ? 8 : 1),
packets);
- spin_lock_irq (&context.lock);
+ spin_lock_irq(&context.lock);
for (i = 0; i < param->sglen; i++) {
++context.pending;
- status = usb_submit_urb (urbs [i], GFP_ATOMIC);
+ status = usb_submit_urb(urbs[i], GFP_ATOMIC);
if (status < 0) {
- ERROR (dev, "submit iso[%d], error %d\n", i, status);
+ ERROR(dev, "submit iso[%d], error %d\n", i, status);
if (i == 0) {
- spin_unlock_irq (&context.lock);
+ spin_unlock_irq(&context.lock);
goto fail;
}
- simple_free_urb (urbs [i]);
+ simple_free_urb(urbs[i]);
urbs[i] = NULL;
context.pending--;
context.submit_error = 1;
break;
}
}
- spin_unlock_irq (&context.lock);
+ spin_unlock_irq(&context.lock);
- wait_for_completion (&context.done);
+ wait_for_completion(&context.done);
for (i = 0; i < param->sglen; i++) {
if (urbs[i])
@@ -1526,8 +1536,8 @@ test_iso_queue (struct usbtest_dev *dev, struct usbtest_param *param,
fail:
for (i = 0; i < param->sglen; i++) {
- if (urbs [i])
- simple_free_urb (urbs [i]);
+ if (urbs[i])
+ simple_free_urb(urbs[i]);
}
return status;
}
@@ -1557,10 +1567,10 @@ fail:
/* No BKL needed */
static int
-usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
+usbtest_ioctl(struct usb_interface *intf, unsigned int code, void *buf)
{
- struct usbtest_dev *dev = usb_get_intfdata (intf);
- struct usb_device *udev = testdev_to_usbdev (dev);
+ struct usbtest_dev *dev = usb_get_intfdata(intf);
+ struct usb_device *udev = testdev_to_usbdev(dev);
struct usbtest_param *param = buf;
int retval = -EOPNOTSUPP;
struct urb *urb;
@@ -1569,7 +1579,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
struct timeval start;
unsigned i;
- // FIXME USBDEVFS_CONNECTINFO doesn't say how fast the device is.
+ /* FIXME USBDEVFS_CONNECTINFO doesn't say how fast the device is. */
pattern = mod_pattern;
@@ -1595,9 +1605,9 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
mutex_unlock(&dev->lock);
return -ENODEV;
}
- res = set_altsetting (dev, dev->info->alt);
+ res = set_altsetting(dev, dev->info->alt);
if (res) {
- dev_err (&intf->dev,
+ dev_err(&intf->dev,
"set altsetting to %d failed, %d\n",
dev->info->alt, res);
mutex_unlock(&dev->lock);
@@ -1614,7 +1624,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
* FIXME add more tests! cancel requests, verify the data, control
* queueing, concurrent read+write threads, and so on.
*/
- do_gettimeofday (&start);
+ do_gettimeofday(&start);
switch (param->test_num) {
case 0:
@@ -1629,14 +1639,14 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
dev_info(&intf->dev,
"TEST 1: write %d bytes %u times\n",
param->length, param->iterations);
- urb = simple_alloc_urb (udev, dev->out_pipe, param->length);
+ urb = simple_alloc_urb(udev, dev->out_pipe, param->length);
if (!urb) {
retval = -ENOMEM;
break;
}
- // FIRMWARE: bulk sink (maybe accepts short writes)
+ /* FIRMWARE: bulk sink (maybe accepts short writes) */
retval = simple_io(dev, urb, param->iterations, 0, 0, "test1");
- simple_free_urb (urb);
+ simple_free_urb(urb);
break;
case 2:
if (dev->in_pipe == 0)
@@ -1644,14 +1654,14 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
dev_info(&intf->dev,
"TEST 2: read %d bytes %u times\n",
param->length, param->iterations);
- urb = simple_alloc_urb (udev, dev->in_pipe, param->length);
+ urb = simple_alloc_urb(udev, dev->in_pipe, param->length);
if (!urb) {
retval = -ENOMEM;
break;
}
- // FIRMWARE: bulk source (maybe generates short writes)
+ /* FIRMWARE: bulk source (maybe generates short writes) */
retval = simple_io(dev, urb, param->iterations, 0, 0, "test2");
- simple_free_urb (urb);
+ simple_free_urb(urb);
break;
case 3:
if (dev->out_pipe == 0 || param->vary == 0)
@@ -1659,15 +1669,15 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
dev_info(&intf->dev,
"TEST 3: write/%d 0..%d bytes %u times\n",
param->vary, param->length, param->iterations);
- urb = simple_alloc_urb (udev, dev->out_pipe, param->length);
+ urb = simple_alloc_urb(udev, dev->out_pipe, param->length);
if (!urb) {
retval = -ENOMEM;
break;
}
- // FIRMWARE: bulk sink (maybe accepts short writes)
+ /* FIRMWARE: bulk sink (maybe accepts short writes) */
retval = simple_io(dev, urb, param->iterations, param->vary,
0, "test3");
- simple_free_urb (urb);
+ simple_free_urb(urb);
break;
case 4:
if (dev->in_pipe == 0 || param->vary == 0)
@@ -1675,15 +1685,15 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
dev_info(&intf->dev,
"TEST 4: read/%d 0..%d bytes %u times\n",
param->vary, param->length, param->iterations);
- urb = simple_alloc_urb (udev, dev->in_pipe, param->length);
+ urb = simple_alloc_urb(udev, dev->in_pipe, param->length);
if (!urb) {
retval = -ENOMEM;
break;
}
- // FIRMWARE: bulk source (maybe generates short writes)
+ /* FIRMWARE: bulk source (maybe generates short writes) */
retval = simple_io(dev, urb, param->iterations, param->vary,
0, "test4");
- simple_free_urb (urb);
+ simple_free_urb(urb);
break;
/* Queued bulk I/O tests */
@@ -1694,15 +1704,15 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
"TEST 5: write %d sglists %d entries of %d bytes\n",
param->iterations,
param->sglen, param->length);
- sg = alloc_sglist (param->sglen, param->length, 0);
+ sg = alloc_sglist(param->sglen, param->length, 0);
if (!sg) {
retval = -ENOMEM;
break;
}
- // FIRMWARE: bulk sink (maybe accepts short writes)
+ /* FIRMWARE: bulk sink (maybe accepts short writes) */
retval = perform_sglist(dev, param->iterations, dev->out_pipe,
&req, sg, param->sglen);
- free_sglist (sg, param->sglen);
+ free_sglist(sg, param->sglen);
break;
case 6:
@@ -1712,15 +1722,15 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
"TEST 6: read %d sglists %d entries of %d bytes\n",
param->iterations,
param->sglen, param->length);
- sg = alloc_sglist (param->sglen, param->length, 0);
+ sg = alloc_sglist(param->sglen, param->length, 0);
if (!sg) {
retval = -ENOMEM;
break;
}
- // FIRMWARE: bulk source (maybe generates short writes)
+ /* FIRMWARE: bulk source (maybe generates short writes) */
retval = perform_sglist(dev, param->iterations, dev->in_pipe,
&req, sg, param->sglen);
- free_sglist (sg, param->sglen);
+ free_sglist(sg, param->sglen);
break;
case 7:
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)
"TEST 7: write/%d %d sglists %d entries 0..%d bytes\n",
param->vary, param->iterations,
param->sglen, param->length);
- sg = alloc_sglist (param->sglen, param->length, param->vary);
+ sg = alloc_sglist(param->sglen, param->length, param->vary);
if (!sg) {
retval = -ENOMEM;
break;
}
- // FIRMWARE: bulk sink (maybe accepts short writes)
+ /* FIRMWARE: bulk sink (maybe accepts short writes) */
retval = perform_sglist(dev, param->iterations, dev->out_pipe,
&req, sg, param->sglen);
- free_sglist (sg, param->sglen);
+ free_sglist(sg, param->sglen);
break;
case 8:
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)
"TEST 8: read/%d %d sglists %d entries 0..%d bytes\n",
param->vary, param->iterations,
param->sglen, param->length);
- sg = alloc_sglist (param->sglen, param->length, param->vary);
+ sg = alloc_sglist(param->sglen, param->length, param->vary);
if (!sg) {
retval = -ENOMEM;
break;
}
- // FIRMWARE: bulk source (maybe generates short writes)
+ /* FIRMWARE: bulk source (maybe generates short writes) */
retval = perform_sglist(dev, param->iterations, dev->in_pipe,
&req, sg, param->sglen);
- free_sglist (sg, param->sglen);
+ free_sglist(sg, param->sglen);
break;
/* non-queued sanity tests for control (chapter 9 subset) */
@@ -1764,7 +1774,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
"TEST 9: ch9 (subset) control tests, %d times\n",
param->iterations);
for (i = param->iterations; retval == 0 && i--; /* NOP */)
- retval = ch9_postconfig (dev);
+ retval = ch9_postconfig(dev);
if (retval)
dev_err(&intf->dev, "ch9 subset failed, "
"iterations left %d\n", i);
@@ -1779,7 +1789,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
"TEST 10: queue %d control calls, %d times\n",
param->sglen,
param->iterations);
- retval = test_ctrl_queue (dev, param);
+ retval = test_ctrl_queue(dev, param);
break;
/* simple non-queued unlinks (ring with one urb) */
@@ -1790,7 +1800,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
dev_info(&intf->dev, "TEST 11: unlink %d reads of %d\n",
param->iterations, param->length);
for (i = param->iterations; retval == 0 && i--; /* NOP */)
- retval = unlink_simple (dev, dev->in_pipe,
+ retval = unlink_simple(dev, dev->in_pipe,
param->length);
if (retval)
dev_err(&intf->dev, "unlink reads failed %d, "
@@ -1803,7 +1813,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
dev_info(&intf->dev, "TEST 12: unlink %d writes of %d\n",
param->iterations, param->length);
for (i = param->iterations; retval == 0 && i--; /* NOP */)
- retval = unlink_simple (dev, dev->out_pipe,
+ retval = unlink_simple(dev, dev->out_pipe,
param->length);
if (retval)
dev_err(&intf->dev, "unlink writes failed %d, "
@@ -1818,7 +1828,7 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
dev_info(&intf->dev, "TEST 13: set/clear %d halts\n",
param->iterations);
for (i = param->iterations; retval == 0 && i--; /* NOP */)
- retval = halt_simple (dev);
+ retval = halt_simple(dev);
if (retval)
ERROR(dev, "halts failed, iterations left %d\n", i);
@@ -1844,8 +1854,8 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
"TEST 15: write %d iso, %d entries of %d bytes\n",
param->iterations,
param->sglen, param->length);
- // FIRMWARE: iso sink
- retval = test_iso_queue (dev, param,
+ /* FIRMWARE: iso sink */
+ retval = test_iso_queue(dev, param,
dev->out_iso_pipe, dev->iso_out);
break;
@@ -1857,17 +1867,17 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
"TEST 16: read %d iso, %d entries of %d bytes\n",
param->iterations,
param->sglen, param->length);
- // FIRMWARE: iso source
- retval = test_iso_queue (dev, param,
+ /* FIRMWARE: iso source */
+ retval = test_iso_queue(dev, param,
dev->in_iso_pipe, dev->iso_in);
break;
- // FIXME unlink from queue (ring with N urbs)
+ /* FIXME unlink from queue (ring with N urbs) */
- // FIXME scatterlist cancel (needs helper thread)
+ /* FIXME scatterlist cancel (needs helper thread) */
}
- do_gettimeofday (&param->duration);
+ do_gettimeofday(&param->duration);
param->duration.tv_sec -= start.tv_sec;
param->duration.tv_usec -= start.tv_usec;
if (param->duration.tv_usec < 0) {
@@ -1880,22 +1890,22 @@ usbtest_ioctl (struct usb_interface *intf, unsigned int code, void *buf)
/*-------------------------------------------------------------------------*/
-static unsigned force_interrupt = 0;
-module_param (force_interrupt, uint, 0);
-MODULE_PARM_DESC (force_interrupt, "0 = test default; else interrupt");
+static unsigned force_interrupt;
+module_param(force_interrupt, uint, 0);
+MODULE_PARM_DESC(force_interrupt, "0 = test default; else interrupt");
#ifdef GENERIC
static unsigned short vendor;
module_param(vendor, ushort, 0);
-MODULE_PARM_DESC (vendor, "vendor code (from usb-if)");
+MODULE_PARM_DESC(vendor, "vendor code (from usb-if)");
static unsigned short product;
module_param(product, ushort, 0);
-MODULE_PARM_DESC (product, "product code (from vendor)");
+MODULE_PARM_DESC(product, "product code (from vendor)");
#endif
static int
-usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id)
+usbtest_probe(struct usb_interface *intf, const struct usb_device_id *id)
{
struct usb_device *udev;
struct usbtest_dev *dev;
@@ -1903,7 +1913,7 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id)
char *rtest, *wtest;
char *irtest, *iwtest;
- udev = interface_to_usbdev (intf);
+ udev = interface_to_usbdev(intf);
#ifdef GENERIC
/* specify devices by module parameters? */
@@ -1930,8 +1940,9 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id)
dev->intf = intf;
/* cacheline-aligned scratch for i/o */
- if ((dev->buf = kmalloc (TBUF_SIZE, GFP_KERNEL)) == NULL) {
- kfree (dev);
+ dev->buf = kmalloc(TBUF_SIZE, GFP_KERNEL);
+ if (dev->buf == NULL) {
+ kfree(dev);
return -ENOMEM;
}
@@ -1943,18 +1954,18 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id)
irtest = iwtest = "";
if (force_interrupt || udev->speed == USB_SPEED_LOW) {
if (info->ep_in) {
- dev->in_pipe = usb_rcvintpipe (udev, info->ep_in);
+ dev->in_pipe = usb_rcvintpipe(udev, info->ep_in);
rtest = " intr-in";
}
if (info->ep_out) {
- dev->out_pipe = usb_sndintpipe (udev, info->ep_out);
+ dev->out_pipe = usb_sndintpipe(udev, info->ep_out);
wtest = " intr-out";
}
} else {
if (info->autoconf) {
int status;
- status = get_endpoints (dev, intf);
+ status = get_endpoints(dev, intf);
if (status < 0) {
WARNING(dev, "couldn't get endpoints, %d\n",
status);
@@ -1963,10 +1974,10 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id)
/* may find bulk or ISO pipes */
} else {
if (info->ep_in)
- dev->in_pipe = usb_rcvbulkpipe (udev,
+ dev->in_pipe = usb_rcvbulkpipe(udev,
info->ep_in);
if (info->ep_out)
- dev->out_pipe = usb_sndbulkpipe (udev,
+ dev->out_pipe = usb_sndbulkpipe(udev,
info->ep_out);
}
if (dev->in_pipe)
@@ -1979,15 +1990,23 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id)
iwtest = " iso-out";
}
- usb_set_intfdata (intf, dev);
- dev_info (&intf->dev, "%s\n", info->name);
- dev_info (&intf->dev, "%s speed {control%s%s%s%s%s} tests%s\n",
+ usb_set_intfdata(intf, dev);
+ dev_info(&intf->dev, "%s\n", info->name);
+ dev_info(&intf->dev, "%s speed {control%s%s%s%s%s} tests%s\n",
({ char *tmp;
switch (udev->speed) {
- case USB_SPEED_LOW: tmp = "low"; break;
- case USB_SPEED_FULL: tmp = "full"; break;
- case USB_SPEED_HIGH: tmp = "high"; break;
- default: tmp = "unknown"; break;
+ case USB_SPEED_LOW:
+ tmp = "low";
+ break;
+ case USB_SPEED_FULL:
+ tmp = "full";
+ break;
+ case USB_SPEED_HIGH:
+ tmp = "high";
+ break;
+ default:
+ tmp = "unknown";
+ break;
}; tmp; }),
info->ctrl_out ? " in/out" : "",
rtest, wtest,
@@ -1996,24 +2015,24 @@ usbtest_probe (struct usb_interface *intf, const struct usb_device_id *id)
return 0;
}
-static int usbtest_suspend (struct usb_interface *intf, pm_message_t message)
+static int usbtest_suspend(struct usb_interface *intf, pm_message_t message)
{
return 0;
}
-static int usbtest_resume (struct usb_interface *intf)
+static int usbtest_resume(struct usb_interface *intf)
{
return 0;
}
-static void usbtest_disconnect (struct usb_interface *intf)
+static void usbtest_disconnect(struct usb_interface *intf)
{
- struct usbtest_dev *dev = usb_get_intfdata (intf);
+ struct usbtest_dev *dev = usb_get_intfdata(intf);
- usb_set_intfdata (intf, NULL);
- dev_dbg (&intf->dev, "disconnect\n");
- kfree (dev);
+ usb_set_intfdata(intf, NULL);
+ dev_dbg(&intf->dev, "disconnect\n");
+ kfree(dev);
}
/* Basic testing only needs a device that can source or sink bulk traffic.
@@ -2050,9 +2069,9 @@ static struct usbtest_info fw_info = {
.ep_in = 2,
.ep_out = 2,
.alt = 1,
- .autoconf = 1, // iso and ctrl_out need autoconf
+ .autoconf = 1, /* iso and ctrl_out need autoconf */
.ctrl_out = 1,
- .iso = 1, // iso_ep's are #8 in/out
+ .iso = 1, /* iso_ep's are #8 in/out */
};
/* peripheral running Linux and 'zero.c' test firmware, or
@@ -2109,56 +2128,56 @@ static const struct usb_device_id id_table[] = {
*/
/* generic EZ-USB FX controller */
- { USB_DEVICE (0x0547, 0x2235),
+ { USB_DEVICE(0x0547, 0x2235),
.driver_info = (unsigned long) &ez1_info,
- },
+ },
/* CY3671 development board with EZ-USB FX */
- { USB_DEVICE (0x0547, 0x0080),
+ { USB_DEVICE(0x0547, 0x0080),
.driver_info = (unsigned long) &ez1_info,
- },
+ },
/* generic EZ-USB FX2 controller (or development board) */
- { USB_DEVICE (0x04b4, 0x8613),
+ { USB_DEVICE(0x04b4, 0x8613),
.driver_info = (unsigned long) &ez2_info,
- },
+ },
/* re-enumerated usb test device firmware */
- { USB_DEVICE (0xfff0, 0xfff0),
+ { USB_DEVICE(0xfff0, 0xfff0),
.driver_info = (unsigned long) &fw_info,
- },
+ },
/* "Gadget Zero" firmware runs under Linux */
- { USB_DEVICE (0x0525, 0xa4a0),
+ { USB_DEVICE(0x0525, 0xa4a0),
.driver_info = (unsigned long) &gz_info,
- },
+ },
/* so does a user-mode variant */
- { USB_DEVICE (0x0525, 0xa4a4),
+ { USB_DEVICE(0x0525, 0xa4a4),
.driver_info = (unsigned long) &um_info,
- },
+ },
/* ... and a user-mode variant that talks iso */
- { USB_DEVICE (0x0525, 0xa4a3),
+ { USB_DEVICE(0x0525, 0xa4a3),
.driver_info = (unsigned long) &um2_info,
- },
+ },
#ifdef KEYSPAN_19Qi
/* Keyspan 19qi uses an21xx (original EZ-USB) */
- // this does not coexist with the real Keyspan 19qi driver!
- { USB_DEVICE (0x06cd, 0x010b),
+ /* this does not coexist with the real Keyspan 19qi driver! */
+ { USB_DEVICE(0x06cd, 0x010b),
.driver_info = (unsigned long) &ez1_info,
- },
+ },
#endif
/*-------------------------------------------------------------*/
#ifdef IBOT2
/* iBOT2 makes a nice source of high speed bulk-in data */
- // this does not coexist with a real iBOT2 driver!
- { USB_DEVICE (0x0b62, 0x0059),
+ /* this does not coexist with a real iBOT2 driver! */
+ { USB_DEVICE(0x0b62, 0x0059),
.driver_info = (unsigned long) &ibot2_info,
- },
+ },
#endif
/*-------------------------------------------------------------*/
@@ -2172,7 +2191,7 @@ static const struct usb_device_id id_table[] = {
{ }
};
-MODULE_DEVICE_TABLE (usb, id_table);
+MODULE_DEVICE_TABLE(usb, id_table);
static struct usb_driver usbtest_driver = {
.name = "usbtest",
@@ -2186,22 +2205,22 @@ static struct usb_driver usbtest_driver = {
/*-------------------------------------------------------------------------*/
-static int __init usbtest_init (void)
+static int __init usbtest_init(void)
{
#ifdef GENERIC
if (vendor)
pr_debug("params: vend=0x%04x prod=0x%04x\n", vendor, product);
#endif
- return usb_register (&usbtest_driver);
+ return usb_register(&usbtest_driver);
}
-module_init (usbtest_init);
+module_init(usbtest_init);
-static void __exit usbtest_exit (void)
+static void __exit usbtest_exit(void)
{
- usb_deregister (&usbtest_driver);
+ usb_deregister(&usbtest_driver);
}
-module_exit (usbtest_exit);
+module_exit(usbtest_exit);
-MODULE_DESCRIPTION ("USB Core/HCD Testing Driver");
-MODULE_LICENSE ("GPL");
+MODULE_DESCRIPTION("USB Core/HCD Testing Driver");
+MODULE_LICENSE("GPL");
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 @@
+/*
+ * Driver for Meywa-Denki & KAYAC YUREX
+ *
+ * Copyright (C) 2010 Tomoki Sekiyama (tomoki.sekiyama@gmail.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, version 2.
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/module.h>
+#include <linux/kref.h>
+#include <linux/mutex.h>
+#include <linux/uaccess.h>
+#include <linux/usb.h>
+#include <linux/hid.h>
+
+#define DRIVER_AUTHOR "Tomoki Sekiyama"
+#define DRIVER_DESC "Driver for Meywa-Denki & KAYAC YUREX"
+
+#define YUREX_VENDOR_ID 0x0c45
+#define YUREX_PRODUCT_ID 0x1010
+
+#define CMD_ACK '!'
+#define CMD_ANIMATE 'A'
+#define CMD_COUNT 'C'
+#define CMD_LED 'L'
+#define CMD_READ 'R'
+#define CMD_SET 'S'
+#define CMD_VERSION 'V'
+#define CMD_EOF 0x0d
+#define CMD_PADDING 0xff
+
+#define YUREX_BUF_SIZE 8
+#define YUREX_WRITE_TIMEOUT (HZ*2)
+
+/* table of devices that work with this driver */
+static struct usb_device_id yurex_table[] = {
+ { USB_DEVICE(YUREX_VENDOR_ID, YUREX_PRODUCT_ID) },
+ { } /* Terminating entry */
+};
+MODULE_DEVICE_TABLE(usb, yurex_table);
+
+#ifdef CONFIG_USB_DYNAMIC_MINORS
+#define YUREX_MINOR_BASE 0
+#else
+#define YUREX_MINOR_BASE 192
+#endif
+
+/* Structure to hold all of our device specific stuff */
+struct usb_yurex {
+ struct usb_device *udev;
+ struct usb_interface *interface;
+ __u8 int_in_endpointAddr;
+ struct urb *urb; /* URB for interrupt in */
+ unsigned char *int_buffer; /* buffer for intterupt in */
+ struct urb *cntl_urb; /* URB for control msg */
+ struct usb_ctrlrequest *cntl_req; /* req for control msg */
+ unsigned char *cntl_buffer; /* buffer for control msg */
+
+ struct kref kref;
+ struct mutex io_mutex;
+ struct fasync_struct *async_queue;
+ wait_queue_head_t waitq;
+
+ spinlock_t lock;
+ __s64 bbu; /* BBU from device */
+};
+#define to_yurex_dev(d) container_of(d, struct usb_yurex, kref)
+
+static struct usb_driver yurex_driver;
+static const struct file_operations yurex_fops;
+
+
+static void yurex_control_callback(struct urb *urb)
+{
+ struct usb_yurex *dev = urb->context;
+ int status = urb->status;
+
+ if (status) {
+ err("%s - control failed: %d\n", __func__, status);
+ wake_up_interruptible(&dev->waitq);
+ return;
+ }
+ /* on success, sender woken up by CMD_ACK int in, or timeout */
+}
+
+static void yurex_delete(struct kref *kref)
+{
+ struct usb_yurex *dev = to_yurex_dev(kref);
+
+ dbg("yurex_delete");
+
+ usb_put_dev(dev->udev);
+ if (dev->cntl_urb) {
+ usb_kill_urb(dev->cntl_urb);
+ if (dev->cntl_req)
+ usb_free_coherent(dev->udev, YUREX_BUF_SIZE,
+ dev->cntl_req, dev->cntl_urb->setup_dma);
+ if (dev->cntl_buffer)
+ usb_free_coherent(dev->udev, YUREX_BUF_SIZE,
+ dev->cntl_buffer, dev->cntl_urb->transfer_dma);
+ usb_free_urb(dev->cntl_urb);
+ }
+ if (dev->urb) {
+ usb_kill_urb(dev->urb);
+ if (dev->int_buffer)
+ usb_free_coherent(dev->udev, YUREX_BUF_SIZE,
+ dev->int_buffer, dev->urb->transfer_dma);
+ usb_free_urb(dev->urb);
+ }
+ kfree(dev);
+}
+
+/*
+ * usb class driver info in order to get a minor number from the usb core,
+ * and to have the device registered with the driver core
+ */
+static struct usb_class_driver yurex_class = {
+ .name = "yurex%d",
+ .fops = &yurex_fops,
+ .minor_base = YUREX_MINOR_BASE,
+};
+
+static void yurex_interrupt(struct urb *urb)
+{
+ struct usb_yurex *dev = urb->context;
+ unsigned char *buf = dev->int_buffer;
+ int status = urb->status;
+ unsigned long flags;
+ int retval, i;
+
+ switch (status) {
+ case 0: /*success*/
+ break;
+ case -EOVERFLOW:
+ err("%s - overflow with length %d, actual length is %d",
+ __func__, YUREX_BUF_SIZE, dev->urb->actual_length);
+ case -ECONNRESET:
+ case -ENOENT:
+ case -ESHUTDOWN:
+ case -EILSEQ:
+ /* The device is terminated, clean up */
+ return;
+ default:
+ err("%s - unknown status received: %d", __func__, status);
+ goto exit;
+ }
+
+ /* handle received message */
+ switch (buf[0]) {
+ case CMD_COUNT:
+ case CMD_READ:
+ if (buf[6] == CMD_EOF) {
+ spin_lock_irqsave(&dev->lock, flags);
+ dev->bbu = 0;
+ for (i = 1; i < 6; i++) {
+ dev->bbu += buf[i];
+ if (i != 5)
+ dev->bbu <<= 8;
+ }
+ dbg("%s count: %lld", __func__, dev->bbu);
+ spin_unlock_irqrestore(&dev->lock, flags);
+
+ kill_fasync(&dev->async_queue, SIGIO, POLL_IN);
+ }
+ else
+ dbg("data format error - no EOF");
+ break;
+ case CMD_ACK:
+ dbg("%s ack: %c", __func__, buf[1]);
+ wake_up_interruptible(&dev->waitq);
+ break;
+ }
+
+exit:
+ retval = usb_submit_urb(dev->urb, GFP_ATOMIC);
+ if (retval) {
+ err("%s - usb_submit_urb failed: %d",
+ __func__, retval);
+ }
+}
+
+static int yurex_probe(struct usb_interface *interface, const struct usb_device_id *id)
+{
+ struct usb_yurex *dev;
+ struct usb_host_interface *iface_desc;
+ struct usb_endpoint_descriptor *endpoint;
+ int retval = -ENOMEM;
+ int i;
+ DEFINE_WAIT(wait);
+
+ /* allocate memory for our device state and initialize it */
+ dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+ if (!dev) {
+ err("Out of memory");
+ goto error;
+ }
+ kref_init(&dev->kref);
+ mutex_init(&dev->io_mutex);
+ spin_lock_init(&dev->lock);
+ init_waitqueue_head(&dev->waitq);
+
+ dev->udev = usb_get_dev(interface_to_usbdev(interface));
+ dev->interface = interface;
+
+ /* set up the endpoint information */
+ iface_desc = interface->cur_altsetting;
+ for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) {
+ endpoint = &iface_desc->endpoint[i].desc;
+
+ if (usb_endpoint_is_int_in(endpoint)) {
+ dev->int_in_endpointAddr = endpoint->bEndpointAddress;
+ break;
+ }
+ }
+ if (!dev->int_in_endpointAddr) {
+ retval = -ENODEV;
+ err("Could not find endpoints");
+ goto error;
+ }
+
+
+ /* allocate control URB */
+ dev->cntl_urb = usb_alloc_urb(0, GFP_KERNEL);
+ if (!dev->cntl_urb) {
+ err("Could not allocate control URB");
+ goto error;
+ }
+
+ /* allocate buffer for control req */
+ dev->cntl_req = usb_alloc_coherent(dev->udev, YUREX_BUF_SIZE,
+ GFP_KERNEL,
+ &dev->cntl_urb->setup_dma);
+ if (!dev->cntl_req) {
+ err("Could not allocate cntl_req");
+ goto error;
+ }
+
+ /* allocate buffer for control msg */
+ dev->cntl_buffer = usb_alloc_coherent(dev->udev, YUREX_BUF_SIZE,
+ GFP_KERNEL,
+ &dev->cntl_urb->transfer_dma);
+ if (!dev->cntl_buffer) {
+ err("Could not allocate cntl_buffer");
+ goto error;
+ }
+
+ /* configure control URB */
+ dev->cntl_req->bRequestType = USB_DIR_OUT | USB_TYPE_CLASS |
+ USB_RECIP_INTERFACE;
+ dev->cntl_req->bRequest = HID_REQ_SET_REPORT;
+ dev->cntl_req->wValue = cpu_to_le16((HID_OUTPUT_REPORT + 1) << 8);
+ dev->cntl_req->wIndex = cpu_to_le16(iface_desc->desc.bInterfaceNumber);
+ dev->cntl_req->wLength = cpu_to_le16(YUREX_BUF_SIZE);
+
+ usb_fill_control_urb(dev->cntl_urb, dev->udev,
+ usb_sndctrlpipe(dev->udev, 0),
+ (void *)dev->cntl_req, dev->cntl_buffer,
+ YUREX_BUF_SIZE, yurex_control_callback, dev);
+ dev->cntl_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
+
+
+ /* allocate interrupt URB */
+ dev->urb = usb_alloc_urb(0, GFP_KERNEL);
+ if (!dev->urb) {
+ err("Could not allocate URB");
+ goto error;
+ }
+
+ /* allocate buffer for interrupt in */
+ dev->int_buffer = usb_alloc_coherent(dev->udev, YUREX_BUF_SIZE,
+ GFP_KERNEL, &dev->urb->transfer_dma);
+ if (!dev->int_buffer) {
+ err("Could not allocate int_buffer");
+ goto error;
+ }
+
+ /* configure interrupt URB */
+ usb_fill_int_urb(dev->urb, dev->udev,
+ usb_rcvintpipe(dev->udev, dev->int_in_endpointAddr),
+ dev->int_buffer, YUREX_BUF_SIZE, yurex_interrupt,
+ dev, 1);
+ dev->cntl_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
+ if (usb_submit_urb(dev->urb, GFP_KERNEL)) {
+ retval = -EIO;
+ err("Could not submitting URB");
+ goto error;
+ }
+
+ /* save our data pointer in this interface device */
+ usb_set_intfdata(interface, dev);
+
+ /* we can register the device now, as it is ready */
+ retval = usb_register_dev(interface, &yurex_class);
+ if (retval) {
+ err("Not able to get a minor for this device.");
+ usb_set_intfdata(interface, NULL);
+ goto error;
+ }
+
+ dev->bbu = -1;
+
+ dev_info(&interface->dev,
+ "USB YUREX device now attached to Yurex #%d\n",
+ interface->minor);
+
+ return 0;
+
+error:
+ if (dev)
+ /* this frees allocated memory */
+ kref_put(&dev->kref, yurex_delete);
+ return retval;
+}
+
+static void yurex_disconnect(struct usb_interface *interface)
+{
+ struct usb_yurex *dev;
+ int minor = interface->minor;
+
+ dev = usb_get_intfdata(interface);
+ usb_set_intfdata(interface, NULL);
+
+ /* give back our minor */
+ usb_deregister_dev(interface, &yurex_class);
+
+ /* prevent more I/O from starting */
+ mutex_lock(&dev->io_mutex);
+ dev->interface = NULL;
+ mutex_unlock(&dev->io_mutex);
+
+ /* wakeup waiters */
+ kill_fasync(&dev->async_queue, SIGIO, POLL_IN);
+ wake_up_interruptible(&dev->waitq);
+
+ /* decrement our usage count */
+ kref_put(&dev->kref, yurex_delete);
+
+ dev_info(&interface->dev, "USB YUREX #%d now disconnected\n", minor);
+}
+
+static struct usb_driver yurex_driver = {
+ .name = "yurex",
+ .probe = yurex_probe,
+ .disconnect = yurex_disconnect,
+ .id_table = yurex_table,
+};
+
+
+static int yurex_fasync(int fd, struct file *file, int on)
+{
+ struct usb_yurex *dev;
+
+ dev = (struct usb_yurex *)file->private_data;
+ return fasync_helper(fd, file, on, &dev->async_queue);
+}
+
+static int yurex_open(struct inode *inode, struct file *file)
+{
+ struct usb_yurex *dev;
+ struct usb_interface *interface;
+ int subminor;
+ int retval = 0;
+
+ subminor = iminor(inode);
+
+ interface = usb_find_interface(&yurex_driver, subminor);
+ if (!interface) {
+ err("%s - error, can't find device for minor %d",
+ __func__, subminor);
+ retval = -ENODEV;
+ goto exit;
+ }
+
+ dev = usb_get_intfdata(interface);
+ if (!dev) {
+ retval = -ENODEV;
+ goto exit;
+ }
+
+ /* increment our usage count for the device */
+ kref_get(&dev->kref);
+
+ /* save our object in the file's private structure */
+ mutex_lock(&dev->io_mutex);
+ file->private_data = dev;
+ mutex_unlock(&dev->io_mutex);
+
+exit:
+ return retval;
+}
+
+static int yurex_release(struct inode *inode, struct file *file)
+{
+ struct usb_yurex *dev;
+
+ dev = (struct usb_yurex *)file->private_data;
+ if (dev == NULL)
+ return -ENODEV;
+
+ yurex_fasync(-1, file, 0);
+
+ /* decrement the count on our device */
+ kref_put(&dev->kref, yurex_delete);
+ return 0;
+}
+
+static ssize_t yurex_read(struct file *file, char *buffer, size_t count, loff_t *ppos)
+{
+ struct usb_yurex *dev;
+ int retval = 0;
+ int bytes_read = 0;
+ char in_buffer[20];
+ unsigned long flags;
+
+ dev = (struct usb_yurex *)file->private_data;
+
+ mutex_lock(&dev->io_mutex);
+ if (!dev->interface) { /* already disconnected */
+ retval = -ENODEV;
+ goto exit;
+ }
+
+ spin_lock_irqsave(&dev->lock, flags);
+ bytes_read = snprintf(in_buffer, 20, "%lld\n", dev->bbu);
+ spin_unlock_irqrestore(&dev->lock, flags);
+
+ if (*ppos < bytes_read) {
+ if (copy_to_user(buffer, in_buffer + *ppos, bytes_read - *ppos))
+ retval = -EFAULT;
+ else {
+ retval = bytes_read - *ppos;
+ *ppos += bytes_read;
+ }
+ }
+
+exit:
+ mutex_unlock(&dev->io_mutex);
+ return retval;
+}
+
+static ssize_t yurex_write(struct file *file, const char *user_buffer, size_t count, loff_t *ppos)
+{
+ struct usb_yurex *dev;
+ int i, set = 0, retval = 0;
+ char buffer[16];
+ char *data = buffer;
+ unsigned long long c, c2 = 0;
+ signed long timeout = 0;
+ DEFINE_WAIT(wait);
+
+ count = min(sizeof(buffer), count);
+ dev = (struct usb_yurex *)file->private_data;
+
+ /* verify that we actually have some data to write */
+ if (count == 0)
+ goto error;
+
+ mutex_lock(&dev->io_mutex);
+ if (!dev->interface) { /* alreaday disconnected */
+ mutex_unlock(&dev->io_mutex);
+ retval = -ENODEV;
+ goto error;
+ }
+
+ if (copy_from_user(buffer, user_buffer, count)) {
+ mutex_unlock(&dev->io_mutex);
+ retval = -EFAULT;
+ goto error;
+ }
+ memset(dev->cntl_buffer, CMD_PADDING, YUREX_BUF_SIZE);
+
+ switch (buffer[0]) {
+ case CMD_ANIMATE:
+ case CMD_LED:
+ dev->cntl_buffer[0] = buffer[0];
+ dev->cntl_buffer[1] = buffer[1];
+ dev->cntl_buffer[2] = CMD_EOF;
+ break;
+ case CMD_READ:
+ case CMD_VERSION:
+ dev->cntl_buffer[0] = buffer[0];
+ dev->cntl_buffer[1] = 0x00;
+ dev->cntl_buffer[2] = CMD_EOF;
+ break;
+ case CMD_SET:
+ data++;
+ /* FALL THROUGH */
+ case '0' ... '9':
+ set = 1;
+ c = c2 = simple_strtoull(data, NULL, 0);
+ dev->cntl_buffer[0] = CMD_SET;
+ for (i = 1; i < 6; i++) {
+ dev->cntl_buffer[i] = (c>>32) & 0xff;
+ c <<= 8;
+ }
+ buffer[6] = CMD_EOF;
+ break;
+ default:
+ mutex_unlock(&dev->io_mutex);
+ return -EINVAL;
+ }
+
+ /* send the data as the control msg */
+ prepare_to_wait(&dev->waitq, &wait, TASK_INTERRUPTIBLE);
+ dbg("%s - submit %c", __func__, dev->cntl_buffer[0]);
+ retval = usb_submit_urb(dev->cntl_urb, GFP_KERNEL);
+ if (retval >= 0)
+ timeout = schedule_timeout(YUREX_WRITE_TIMEOUT);
+ finish_wait(&dev->waitq, &wait);
+
+ mutex_unlock(&dev->io_mutex);
+
+ if (retval < 0) {
+ err("%s - failed to send bulk msg, error %d", __func__, retval);
+ goto error;
+ }
+ if (set && timeout)
+ dev->bbu = c2;
+ return timeout ? count : -EIO;
+
+error:
+ return retval;
+}
+
+static const struct file_operations yurex_fops = {
+ .owner = THIS_MODULE,
+ .read = yurex_read,
+ .write = yurex_write,
+ .open = yurex_open,
+ .release = yurex_release,
+ .fasync = yurex_fasync,
+};
+
+
+static int __init usb_yurex_init(void)
+{
+ int result;
+
+ /* register this driver with the USB subsystem */
+ result = usb_register(&yurex_driver);
+ if (result)
+ err("usb_register failed. Error number %d", result);
+
+ return result;
+}
+
+static void __exit usb_yurex_exit(void)
+{
+ /* deregister this driver with the USB subsystem */
+ usb_deregister(&yurex_driver);
+}
+
+module_init(usb_yurex_init);
+module_exit(usb_yurex_exit);
+
+MODULE_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 @@
# Makefile for USB monitor
#
-usbmon-objs := mon_main.o mon_stat.o mon_text.o mon_bin.o
+usbmon-y := mon_main.o mon_stat.o mon_text.o mon_bin.o
obj-$(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
comment "DaVinci 35x and 644x USB support"
depends on USB_MUSB_HDRC && ARCH_DAVINCI_DMx
+comment "DA8xx/OMAP-L1x USB support"
+ depends on USB_MUSB_HDRC && ARCH_DAVINCI_DA8XX
+
comment "OMAP 243x high speed USB support"
depends on USB_MUSB_HDRC && ARCH_OMAP2430
@@ -57,6 +60,17 @@ comment "OMAP 44xx high speed USB support"
comment "Blackfin high speed USB Support"
depends on USB_MUSB_HDRC && ((BF54x && !BF544) || (BF52x && !BF522 && !BF523))
+config USB_MUSB_AM35X
+ bool
+ depends on USB_MUSB_HDRC && !ARCH_OMAP2430 && !ARCH_OMAP4
+ select NOP_USB_XCEIV
+ default MACH_OMAP3517EVM
+ help
+ Select this option if your platform is based on AM35x. As
+ AM35x has an updated MUSB with CPPI4.1 DMA so this config
+ is introduced to differentiate musb ip between OMAP3x and
+ AM35x platforms.
+
config USB_TUSB6010
boolean "TUSB 6010 support"
depends on USB_MUSB_HDRC && !USB_MUSB_SOC
@@ -144,7 +158,7 @@ config USB_MUSB_HDRC_HCD
config MUSB_PIO_ONLY
bool 'Disable DMA (always use PIO)'
depends on USB_MUSB_HDRC
- default y if USB_TUSB6010
+ default USB_TUSB6010 || ARCH_DAVINCI_DA8XX || USB_MUSB_AM35X
help
All data is copied between memory and FIFO by the CPU.
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 @@
# for USB OTG silicon based on Mentor Graphics INVENTRA designs
#
-musb_hdrc-objs := musb_core.o
+ccflags-$(CONFIG_USB_MUSB_DEBUG) := -DDEBUG
-obj-$(CONFIG_USB_MUSB_HDRC) += musb_hdrc.o
+obj-$(CONFIG_USB_MUSB_HDRC) += musb_hdrc.o
-ifeq ($(CONFIG_ARCH_DAVINCI_DMx),y)
- musb_hdrc-objs += davinci.o
-endif
-
-ifeq ($(CONFIG_USB_TUSB6010),y)
- musb_hdrc-objs += tusb6010.o
-endif
-
-ifeq ($(CONFIG_ARCH_OMAP2430),y)
- musb_hdrc-objs += omap2430.o
-endif
-
-ifeq ($(CONFIG_ARCH_OMAP3430),y)
- musb_hdrc-objs += omap2430.o
-endif
-
-ifeq ($(CONFIG_ARCH_OMAP4),y)
- musb_hdrc-objs += omap2430.o
-endif
-
-ifeq ($(CONFIG_BF54x),y)
- musb_hdrc-objs += blackfin.o
-endif
+musb_hdrc-y := musb_core.o
-ifeq ($(CONFIG_BF52x),y)
- musb_hdrc-objs += blackfin.o
-endif
-
-ifeq ($(CONFIG_USB_GADGET_MUSB_HDRC),y)
- musb_hdrc-objs += musb_gadget_ep0.o musb_gadget.o
-endif
-
-ifeq ($(CONFIG_USB_MUSB_HDRC_HCD),y)
- musb_hdrc-objs += musb_virthub.o musb_host.o
-endif
-
-ifeq ($(CONFIG_DEBUG_FS),y)
- musb_hdrc-objs += musb_debugfs.o
+musb_hdrc-$(CONFIG_ARCH_DAVINCI_DMx) += davinci.o
+musb_hdrc-$(CONFIG_ARCH_DAVINCI_DA8XX) += da8xx.o
+musb_hdrc-$(CONFIG_USB_TUSB6010) += tusb6010.o
+musb_hdrc-$(CONFIG_ARCH_OMAP2430) += omap2430.o
+ifeq ($(CONFIG_USB_MUSB_AM35X),y)
+ musb_hdrc-$(CONFIG_ARCH_OMAP3430) += am35x.o
+else
+ musb_hdrc-$(CONFIG_ARCH_OMAP3430) += omap2430.o
endif
+musb_hdrc-$(CONFIG_ARCH_OMAP4) += omap2430.o
+musb_hdrc-$(CONFIG_BF54x) += blackfin.o
+musb_hdrc-$(CONFIG_BF52x) += blackfin.o
+musb_hdrc-$(CONFIG_USB_GADGET_MUSB_HDRC) += musb_gadget_ep0.o musb_gadget.o
+musb_hdrc-$(CONFIG_USB_MUSB_HDRC_HCD) += musb_virthub.o musb_host.o
+musb_hdrc-$(CONFIG_DEBUG_FS) += musb_debugfs.o
# the kconfig must guarantee that only one of the
# possible I/O schemes will be enabled at a time ...
@@ -54,26 +32,17 @@ endif
ifneq ($(CONFIG_MUSB_PIO_ONLY),y)
ifeq ($(CONFIG_USB_INVENTRA_DMA),y)
- musb_hdrc-objs += musbhsdma.o
+ musb_hdrc-y += musbhsdma.o
else
ifeq ($(CONFIG_USB_TI_CPPI_DMA),y)
- musb_hdrc-objs += cppi_dma.o
+ musb_hdrc-y += cppi_dma.o
else
ifeq ($(CONFIG_USB_TUSB_OMAP_DMA),y)
- musb_hdrc-objs += tusb6010_omap.o
+ musb_hdrc-y += tusb6010_omap.o
endif
endif
endif
endif
-
-
-################################################################################
-
-# Debugging
-
-ifeq ($(CONFIG_USB_MUSB_DEBUG),y)
- EXTRA_CFLAGS += -DDEBUG
-endif
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 @@
+/*
+ * Texas Instruments AM35x "glue layer"
+ *
+ * Copyright (c) 2010, by Texas Instruments
+ *
+ * Based on the DA8xx "glue layer" code.
+ * Copyright (c) 2008-2009, MontaVista Software, Inc. <source@mvista.com>
+ *
+ * This file is part of the Inventra Controller Driver for Linux.
+ *
+ * The Inventra Controller Driver for Linux is free software; you
+ * can redistribute it and/or modify it under the terms of the GNU
+ * General Public License version 2 as published by the Free Software
+ * Foundation.
+ *
+ * The Inventra Controller Driver for Linux is distributed in
+ * the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with The Inventra Controller Driver for Linux ; if not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include <linux/init.h>
+#include <linux/clk.h>
+#include <linux/io.h>
+
+#include <plat/control.h>
+#include <plat/usb.h>
+
+#include "musb_core.h"
+
+/*
+ * AM35x specific definitions
+ */
+/* USB 2.0 OTG module registers */
+#define USB_REVISION_REG 0x00
+#define USB_CTRL_REG 0x04
+#define USB_STAT_REG 0x08
+#define USB_EMULATION_REG 0x0c
+/* 0x10 Reserved */
+#define USB_AUTOREQ_REG 0x14
+#define USB_SRP_FIX_TIME_REG 0x18
+#define USB_TEARDOWN_REG 0x1c
+#define EP_INTR_SRC_REG 0x20
+#define EP_INTR_SRC_SET_REG 0x24
+#define EP_INTR_SRC_CLEAR_REG 0x28
+#define EP_INTR_MASK_REG 0x2c
+#define EP_INTR_MASK_SET_REG 0x30
+#define EP_INTR_MASK_CLEAR_REG 0x34
+#define EP_INTR_SRC_MASKED_REG 0x38
+#define CORE_INTR_SRC_REG 0x40
+#define CORE_INTR_SRC_SET_REG 0x44
+#define CORE_INTR_SRC_CLEAR_REG 0x48
+#define CORE_INTR_MASK_REG 0x4c
+#define CORE_INTR_MASK_SET_REG 0x50
+#define CORE_INTR_MASK_CLEAR_REG 0x54
+#define CORE_INTR_SRC_MASKED_REG 0x58
+/* 0x5c Reserved */
+#define USB_END_OF_INTR_REG 0x60
+
+/* Control register bits */
+#define AM35X_SOFT_RESET_MASK 1
+
+/* USB interrupt register bits */
+#define AM35X_INTR_USB_SHIFT 16
+#define AM35X_INTR_USB_MASK (0x1ff << AM35X_INTR_USB_SHIFT)
+#define AM35X_INTR_DRVVBUS 0x100
+#define AM35X_INTR_RX_SHIFT 16
+#define AM35X_INTR_TX_SHIFT 0
+#define AM35X_TX_EP_MASK 0xffff /* EP0 + 15 Tx EPs */
+#define AM35X_RX_EP_MASK 0xfffe /* 15 Rx EPs */
+#define AM35X_TX_INTR_MASK (AM35X_TX_EP_MASK << AM35X_INTR_TX_SHIFT)
+#define AM35X_RX_INTR_MASK (AM35X_RX_EP_MASK << AM35X_INTR_RX_SHIFT)
+
+#define USB_MENTOR_CORE_OFFSET 0x400
+
+static inline void phy_on(void)
+{
+ unsigned long timeout = jiffies + msecs_to_jiffies(100);
+ u32 devconf2;
+
+ /*
+ * Start the on-chip PHY and its PLL.
+ */
+ devconf2 = omap_ctrl_readl(AM35XX_CONTROL_DEVCONF2);
+
+ devconf2 &= ~(CONF2_RESET | CONF2_PHYPWRDN | CONF2_OTGPWRDN);
+ devconf2 |= CONF2_PHY_PLLON;
+
+ omap_ctrl_writel(devconf2, AM35XX_CONTROL_DEVCONF2);
+
+ DBG(1, "Waiting for PHY clock good...\n");
+ while (!(omap_ctrl_readl(AM35XX_CONTROL_DEVCONF2)
+ & CONF2_PHYCLKGD)) {
+ cpu_relax();
+
+ if (time_after(jiffies, timeout)) {
+ DBG(1, "musb PHY clock good timed out\n");
+ break;
+ }
+ }
+}
+
+static inline void phy_off(void)
+{
+ u32 devconf2;
+
+ /*
+ * Power down the on-chip PHY.
+ */
+ devconf2 = omap_ctrl_readl(AM35XX_CONTROL_DEVCONF2);
+
+ devconf2 &= ~CONF2_PHY_PLLON;
+ devconf2 |= CONF2_PHYPWRDN | CONF2_OTGPWRDN;
+ omap_ctrl_writel(devconf2, AM35XX_CONTROL_DEVCONF2);
+}
+
+/*
+ * musb_platform_enable - enable interrupts
+ */
+void musb_platform_enable(struct musb *musb)
+{
+ void __iomem *reg_base = musb->ctrl_base;
+ u32 epmask;
+
+ /* Workaround: setup IRQs through both register sets. */
+ epmask = ((musb->epmask & AM35X_TX_EP_MASK) << AM35X_INTR_TX_SHIFT) |
+ ((musb->epmask & AM35X_RX_EP_MASK) << AM35X_INTR_RX_SHIFT);
+
+ musb_writel(reg_base, EP_INTR_MASK_SET_REG, epmask);
+ musb_writel(reg_base, CORE_INTR_MASK_SET_REG, AM35X_INTR_USB_MASK);
+
+ /* Force the DRVVBUS IRQ so we can start polling for ID change. */
+ if (is_otg_enabled(musb))
+ musb_writel(reg_base, CORE_INTR_SRC_SET_REG,
+ AM35X_INTR_DRVVBUS << AM35X_INTR_USB_SHIFT);
+}
+
+/*
+ * musb_platform_disable - disable HDRC and flush interrupts
+ */
+void musb_platform_disable(struct musb *musb)
+{
+ void __iomem *reg_base = musb->ctrl_base;
+
+ musb_writel(reg_base, CORE_INTR_MASK_CLEAR_REG, AM35X_INTR_USB_MASK);
+ musb_writel(reg_base, EP_INTR_MASK_CLEAR_REG,
+ AM35X_TX_INTR_MASK | AM35X_RX_INTR_MASK);
+ musb_writeb(musb->mregs, MUSB_DEVCTL, 0);
+ musb_writel(reg_base, USB_END_OF_INTR_REG, 0);
+}
+
+#ifdef CONFIG_USB_MUSB_HDRC_HCD
+#define portstate(stmt) stmt
+#else
+#define portstate(stmt)
+#endif
+
+static void am35x_set_vbus(struct musb *musb, int is_on)
+{
+ WARN_ON(is_on && is_peripheral_active(musb));
+}
+
+#define POLL_SECONDS 2
+
+static struct timer_list otg_workaround;
+
+static void otg_timer(unsigned long _musb)
+{
+ struct musb *musb = (void *)_musb;
+ void __iomem *mregs = musb->mregs;
+ u8 devctl;
+ unsigned long flags;
+
+ /*
+ * We poll because AM35x's won't expose several OTG-critical
+ * status change events (from the transceiver) otherwise.
+ */
+ devctl = musb_readb(mregs, MUSB_DEVCTL);
+ DBG(7, "Poll devctl %02x (%s)\n", devctl, otg_state_string(musb));
+
+ spin_lock_irqsave(&musb->lock, flags);
+ switch (musb->xceiv->state) {
+ case OTG_STATE_A_WAIT_BCON:
+ devctl &= ~MUSB_DEVCTL_SESSION;
+ musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
+
+ devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
+ if (devctl & MUSB_DEVCTL_BDEVICE) {
+ musb->xceiv->state = OTG_STATE_B_IDLE;
+ MUSB_DEV_MODE(musb);
+ } else {
+ musb->xceiv->state = OTG_STATE_A_IDLE;
+ MUSB_HST_MODE(musb);
+ }
+ break;
+ case OTG_STATE_A_WAIT_VFALL:
+ musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ musb_writel(musb->ctrl_base, CORE_INTR_SRC_SET_REG,
+ MUSB_INTR_VBUSERROR << AM35X_INTR_USB_SHIFT);
+ break;
+ case OTG_STATE_B_IDLE:
+ if (!is_peripheral_enabled(musb))
+ break;
+
+ devctl = musb_readb(mregs, MUSB_DEVCTL);
+ if (devctl & MUSB_DEVCTL_BDEVICE)
+ mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
+ else
+ musb->xceiv->state = OTG_STATE_A_IDLE;
+ break;
+ default:
+ break;
+ }
+ spin_unlock_irqrestore(&musb->lock, flags);
+}
+
+void musb_platform_try_idle(struct musb *musb, unsigned long timeout)
+{
+ static unsigned long last_timer;
+
+ if (!is_otg_enabled(musb))
+ return;
+
+ if (timeout == 0)
+ timeout = jiffies + msecs_to_jiffies(3);
+
+ /* Never idle if active, or when VBUS timeout is not set as host */
+ if (musb->is_active || (musb->a_wait_bcon == 0 &&
+ musb->xceiv->state == OTG_STATE_A_WAIT_BCON)) {
+ DBG(4, "%s active, deleting timer\n", otg_state_string(musb));
+ del_timer(&otg_workaround);
+ last_timer = jiffies;
+ return;
+ }
+
+ if (time_after(last_timer, timeout) && timer_pending(&otg_workaround)) {
+ DBG(4, "Longer idle timer already pending, ignoring...\n");
+ return;
+ }
+ last_timer = timeout;
+
+ DBG(4, "%s inactive, starting idle timer for %u ms\n",
+ otg_state_string(musb), jiffies_to_msecs(timeout - jiffies));
+ mod_timer(&otg_workaround, timeout);
+}
+
+static irqreturn_t am35x_interrupt(int irq, void *hci)
+{
+ struct musb *musb = hci;
+ void __iomem *reg_base = musb->ctrl_base;
+ unsigned long flags;
+ irqreturn_t ret = IRQ_NONE;
+ u32 epintr, usbintr, lvl_intr;
+
+ spin_lock_irqsave(&musb->lock, flags);
+
+ /* Get endpoint interrupts */
+ epintr = musb_readl(reg_base, EP_INTR_SRC_MASKED_REG);
+
+ if (epintr) {
+ musb_writel(reg_base, EP_INTR_SRC_CLEAR_REG, epintr);
+
+ musb->int_rx =
+ (epintr & AM35X_RX_INTR_MASK) >> AM35X_INTR_RX_SHIFT;
+ musb->int_tx =
+ (epintr & AM35X_TX_INTR_MASK) >> AM35X_INTR_TX_SHIFT;
+ }
+
+ /* Get usb core interrupts */
+ usbintr = musb_readl(reg_base, CORE_INTR_SRC_MASKED_REG);
+ if (!usbintr && !epintr)
+ goto eoi;
+
+ if (usbintr) {
+ musb_writel(reg_base, CORE_INTR_SRC_CLEAR_REG, usbintr);
+
+ musb->int_usb =
+ (usbintr & AM35X_INTR_USB_MASK) >> AM35X_INTR_USB_SHIFT;
+ }
+ /*
+ * DRVVBUS IRQs are the only proxy we have (a very poor one!) for
+ * AM35x's missing ID change IRQ. We need an ID change IRQ to
+ * switch appropriately between halves of the OTG state machine.
+ * Managing DEVCTL.SESSION per Mentor docs requires that we know its
+ * value but DEVCTL.BDEVICE is invalid without DEVCTL.SESSION set.
+ * Also, DRVVBUS pulses for SRP (but not at 5V) ...
+ */
+ if (usbintr & (AM35X_INTR_DRVVBUS << AM35X_INTR_USB_SHIFT)) {
+ int drvvbus = musb_readl(reg_base, USB_STAT_REG);
+ void __iomem *mregs = musb->mregs;
+ u8 devctl = musb_readb(mregs, MUSB_DEVCTL);
+ int err;
+
+ err = is_host_enabled(musb) && (musb->int_usb &
+ MUSB_INTR_VBUSERROR);
+ if (err) {
+ /*
+ * The Mentor core doesn't debounce VBUS as needed
+ * to cope with device connect current spikes. This
+ * means it's not uncommon for bus-powered devices
+ * to get VBUS errors during enumeration.
+ *
+ * This is a workaround, but newer RTL from Mentor
+ * seems to allow a better one: "re"-starting sessions
+ * without waiting for VBUS to stop registering in
+ * devctl.
+ */
+ musb->int_usb &= ~MUSB_INTR_VBUSERROR;
+ musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
+ mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
+ WARNING("VBUS error workaround (delay coming)\n");
+ } else if (is_host_enabled(musb) && drvvbus) {
+ MUSB_HST_MODE(musb);
+ musb->xceiv->default_a = 1;
+ musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ portstate(musb->port1_status |= USB_PORT_STAT_POWER);
+ del_timer(&otg_workaround);
+ } else {
+ musb->is_active = 0;
+ MUSB_DEV_MODE(musb);
+ musb->xceiv->default_a = 0;
+ musb->xceiv->state = OTG_STATE_B_IDLE;
+ portstate(musb->port1_status &= ~USB_PORT_STAT_POWER);
+ }
+
+ /* NOTE: this must complete power-on within 100 ms. */
+ DBG(2, "VBUS %s (%s)%s, devctl %02x\n",
+ drvvbus ? "on" : "off",
+ otg_state_string(musb),
+ err ? " ERROR" : "",
+ devctl);
+ ret = IRQ_HANDLED;
+ }
+
+ if (musb->int_tx || musb->int_rx || musb->int_usb)
+ ret |= musb_interrupt(musb);
+
+eoi:
+ /* EOI needs to be written for the IRQ to be re-asserted. */
+ if (ret == IRQ_HANDLED || epintr || usbintr) {
+ /* clear level interrupt */
+ lvl_intr = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
+ lvl_intr |= AM35XX_USBOTGSS_INT_CLR;
+ omap_ctrl_writel(lvl_intr, AM35XX_CONTROL_LVL_INTR_CLEAR);
+ /* write EOI */
+ musb_writel(reg_base, USB_END_OF_INTR_REG, 0);
+ }
+
+ /* Poll for ID change */
+ if (is_otg_enabled(musb) && musb->xceiv->state == OTG_STATE_B_IDLE)
+ mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
+
+ spin_unlock_irqrestore(&musb->lock, flags);
+
+ return ret;
+}
+
+int musb_platform_set_mode(struct musb *musb, u8 musb_mode)
+{
+ u32 devconf2 = omap_ctrl_readl(AM35XX_CONTROL_DEVCONF2);
+
+ devconf2 &= ~CONF2_OTGMODE;
+ switch (musb_mode) {
+#ifdef CONFIG_USB_MUSB_HDRC_HCD
+ case MUSB_HOST: /* Force VBUS valid, ID = 0 */
+ devconf2 |= CONF2_FORCE_HOST;
+ break;
+#endif
+#ifdef CONFIG_USB_GADGET_MUSB_HDRC
+ case MUSB_PERIPHERAL: /* Force VBUS valid, ID = 1 */
+ devconf2 |= CONF2_FORCE_DEVICE;
+ break;
+#endif
+#ifdef CONFIG_USB_MUSB_OTG
+ case MUSB_OTG: /* Don't override the VBUS/ID comparators */
+ devconf2 |= CONF2_NO_OVERRIDE;
+ break;
+#endif
+ default:
+ DBG(2, "Trying to set unsupported mode %u\n", musb_mode);
+ }
+
+ omap_ctrl_writel(devconf2, AM35XX_CONTROL_DEVCONF2);
+ return 0;
+}
+
+int __init musb_platform_init(struct musb *musb, void *board_data)
+{
+ void __iomem *reg_base = musb->ctrl_base;
+ u32 rev, lvl_intr, sw_reset;
+ int status;
+
+ musb->mregs += USB_MENTOR_CORE_OFFSET;
+
+ clk_enable(musb->clock);
+ DBG(2, "musb->clock=%lud\n", clk_get_rate(musb->clock));
+
+ musb->phy_clock = clk_get(musb->controller, "fck");
+ if (IS_ERR(musb->phy_clock)) {
+ status = PTR_ERR(musb->phy_clock);
+ goto exit0;
+ }
+ clk_enable(musb->phy_clock);
+ DBG(2, "musb->phy_clock=%lud\n", clk_get_rate(musb->phy_clock));
+
+ /* Returns zero if e.g. not clocked */
+ rev = musb_readl(reg_base, USB_REVISION_REG);
+ if (!rev) {
+ status = -ENODEV;
+ goto exit1;
+ }
+
+ usb_nop_xceiv_register();
+ musb->xceiv = otg_get_transceiver();
+ if (!musb->xceiv) {
+ status = -ENODEV;
+ goto exit1;
+ }
+
+ if (is_host_enabled(musb))
+ setup_timer(&otg_workaround, otg_timer, (unsigned long) musb);
+
+ musb->board_set_vbus = am35x_set_vbus;
+
+ /* Global reset */
+ sw_reset = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET);
+
+ sw_reset |= AM35XX_USBOTGSS_SW_RST;
+ omap_ctrl_writel(sw_reset, AM35XX_CONTROL_IP_SW_RESET);
+
+ sw_reset &= ~AM35XX_USBOTGSS_SW_RST;
+ omap_ctrl_writel(sw_reset, AM35XX_CONTROL_IP_SW_RESET);
+
+ /* Reset the controller */
+ musb_writel(reg_base, USB_CTRL_REG, AM35X_SOFT_RESET_MASK);
+
+ /* Start the on-chip PHY and its PLL. */
+ phy_on();
+
+ msleep(5);
+
+ musb->isr = am35x_interrupt;
+
+ /* clear level interrupt */
+ lvl_intr = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
+ lvl_intr |= AM35XX_USBOTGSS_INT_CLR;
+ omap_ctrl_writel(lvl_intr, AM35XX_CONTROL_LVL_INTR_CLEAR);
+ return 0;
+exit1:
+ clk_disable(musb->phy_clock);
+ clk_put(musb->phy_clock);
+exit0:
+ clk_disable(musb->clock);
+ return status;
+}
+
+int musb_platform_exit(struct musb *musb)
+{
+ if (is_host_enabled(musb))
+ del_timer_sync(&otg_workaround);
+
+ phy_off();
+
+ otg_put_transceiver(musb->xceiv);
+ usb_nop_xceiv_unregister();
+
+ clk_disable(musb->clock);
+
+ clk_disable(musb->phy_clock);
+ clk_put(musb->phy_clock);
+
+ return 0;
+}
+
+#ifdef CONFIG_PM
+void musb_platform_save_context(struct musb *musb,
+ struct musb_context_registers *musb_context)
+{
+ phy_off();
+}
+
+void musb_platform_restore_context(struct musb *musb,
+ struct musb_context_registers *musb_context)
+{
+ phy_on();
+}
+#endif
+
+/* AM35x supports only 32bit read operation */
+void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *dst)
+{
+ void __iomem *fifo = hw_ep->fifo;
+ u32 val;
+ int i;
+
+ /* Read for 32bit-aligned destination address */
+ if (likely((0x03 & (unsigned long) dst) == 0) && len >= 4) {
+ readsl(fifo, dst, len >> 2);
+ dst += len & ~0x03;
+ len &= 0x03;
+ }
+ /*
+ * Now read the remaining 1 to 3 byte or complete length if
+ * unaligned address.
+ */
+ if (len > 4) {
+ for (i = 0; i < (len >> 2); i++) {
+ *(u32 *) dst = musb_readl(fifo, 0);
+ dst += 4;
+ }
+ len &= 0x03;
+ }
+ if (len > 0) {
+ val = musb_readl(fifo, 0);
+ memcpy(dst, &val, len);
+ }
+}
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)
usb_nop_xceiv_register();
musb->xceiv = otg_get_transceiver();
- if (!musb->xceiv)
+ if (!musb->xceiv) {
+ gpio_free(musb->config->gpio_vrsel);
return -ENODEV;
+ }
if (ANOMALY_05000346) {
bfin_write_USB_APHY_CALIB(ANOMALY_05000346_value);
@@ -394,8 +396,9 @@ int __init musb_platform_init(struct musb *musb, void *board_data)
int musb_platform_exit(struct musb *musb)
{
-
gpio_free(musb->config->gpio_vrsel);
+ otg_put_transceiver(musb->xceiv);
+ usb_nop_xceiv_unregister();
return 0;
}
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)
struct musb_hw_ep *hw_ep = NULL;
u32 rx, tx;
int i, index;
- unsigned long flags;
+ unsigned long uninitialized_var(flags);
cppi = container_of(musb->dma_controller, struct cppi, controller);
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 @@
+/*
+ * Texas Instruments DA8xx/OMAP-L1x "glue layer"
+ *
+ * Copyright (c) 2008-2009 MontaVista Software, Inc. <source@mvista.com>
+ *
+ * Based on the DaVinci "glue layer" code.
+ * Copyright (C) 2005-2006 by Texas Instruments
+ *
+ * This file is part of the Inventra Controller Driver for Linux.
+ *
+ * The Inventra Controller Driver for Linux is free software; you
+ * can redistribute it and/or modify it under the terms of the GNU
+ * General Public License version 2 as published by the Free Software
+ * Foundation.
+ *
+ * The Inventra Controller Driver for Linux is distributed in
+ * the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with The Inventra Controller Driver for Linux ; if not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include <linux/init.h>
+#include <linux/clk.h>
+#include <linux/io.h>
+
+#include <mach/da8xx.h>
+#include <mach/usb.h>
+
+#include "musb_core.h"
+
+/*
+ * DA8XX specific definitions
+ */
+
+/* USB 2.0 OTG module registers */
+#define DA8XX_USB_REVISION_REG 0x00
+#define DA8XX_USB_CTRL_REG 0x04
+#define DA8XX_USB_STAT_REG 0x08
+#define DA8XX_USB_EMULATION_REG 0x0c
+#define DA8XX_USB_MODE_REG 0x10 /* Transparent, CDC, [Generic] RNDIS */
+#define DA8XX_USB_AUTOREQ_REG 0x14
+#define DA8XX_USB_SRP_FIX_TIME_REG 0x18
+#define DA8XX_USB_TEARDOWN_REG 0x1c
+#define DA8XX_USB_INTR_SRC_REG 0x20
+#define DA8XX_USB_INTR_SRC_SET_REG 0x24
+#define DA8XX_USB_INTR_SRC_CLEAR_REG 0x28
+#define DA8XX_USB_INTR_MASK_REG 0x2c
+#define DA8XX_USB_INTR_MASK_SET_REG 0x30
+#define DA8XX_USB_INTR_MASK_CLEAR_REG 0x34
+#define DA8XX_USB_INTR_SRC_MASKED_REG 0x38
+#define DA8XX_USB_END_OF_INTR_REG 0x3c
+#define DA8XX_USB_GENERIC_RNDIS_EP_SIZE_REG(n) (0x50 + (((n) - 1) << 2))
+
+/* Control register bits */
+#define DA8XX_SOFT_RESET_MASK 1
+
+#define DA8XX_USB_TX_EP_MASK 0x1f /* EP0 + 4 Tx EPs */
+#define DA8XX_USB_RX_EP_MASK 0x1e /* 4 Rx EPs */
+
+/* USB interrupt register bits */
+#define DA8XX_INTR_USB_SHIFT 16
+#define DA8XX_INTR_USB_MASK (0x1ff << DA8XX_INTR_USB_SHIFT) /* 8 Mentor */
+ /* interrupts and DRVVBUS interrupt */
+#define DA8XX_INTR_DRVVBUS 0x100
+#define DA8XX_INTR_RX_SHIFT 8
+#define DA8XX_INTR_RX_MASK (DA8XX_USB_RX_EP_MASK << DA8XX_INTR_RX_SHIFT)
+#define DA8XX_INTR_TX_SHIFT 0
+#define DA8XX_INTR_TX_MASK (DA8XX_USB_TX_EP_MASK << DA8XX_INTR_TX_SHIFT)
+
+#define DA8XX_MENTOR_CORE_OFFSET 0x400
+
+#define CFGCHIP2 IO_ADDRESS(DA8XX_SYSCFG0_BASE + DA8XX_CFGCHIP2_REG)
+
+/*
+ * REVISIT (PM): we should be able to keep the PHY in low power mode most
+ * of the time (24 MHz oscillator and PLL off, etc.) by setting POWER.D0
+ * and, when in host mode, autosuspending idle root ports... PHY_PLLON
+ * (overriding SUSPENDM?) then likely needs to stay off.
+ */
+
+static inline void phy_on(void)
+{
+ u32 cfgchip2 = __raw_readl(CFGCHIP2);
+
+ /*
+ * Start the on-chip PHY and its PLL.
+ */
+ cfgchip2 &= ~(CFGCHIP2_RESET | CFGCHIP2_PHYPWRDN | CFGCHIP2_OTGPWRDN);
+ cfgchip2 |= CFGCHIP2_PHY_PLLON;
+ __raw_writel(cfgchip2, CFGCHIP2);
+
+ pr_info("Waiting for USB PHY clock good...\n");
+ while (!(__raw_readl(CFGCHIP2) & CFGCHIP2_PHYCLKGD))
+ cpu_relax();
+}
+
+static inline void phy_off(void)
+{
+ u32 cfgchip2 = __raw_readl(CFGCHIP2);
+
+ /*
+ * Ensure that USB 1.1 reference clock is not being sourced from
+ * USB 2.0 PHY. Otherwise do not power down the PHY.
+ */
+ if (!(cfgchip2 & CFGCHIP2_USB1PHYCLKMUX) &&
+ (cfgchip2 & CFGCHIP2_USB1SUSPENDM)) {
+ pr_warning("USB 1.1 clocked from USB 2.0 PHY -- "
+ "can't power it down\n");
+ return;
+ }
+
+ /*
+ * Power down the on-chip PHY.
+ */
+ cfgchip2 |= CFGCHIP2_PHYPWRDN | CFGCHIP2_OTGPWRDN;
+ __raw_writel(cfgchip2, CFGCHIP2);
+}
+
+/*
+ * Because we don't set CTRL.UINT, it's "important" to:
+ * - not read/write INTRUSB/INTRUSBE (except during
+ * initial setup, as a workaround);
+ * - use INTSET/INTCLR instead.
+ */
+
+/**
+ * musb_platform_enable - enable interrupts
+ */
+void musb_platform_enable(struct musb *musb)
+{
+ void __iomem *reg_base = musb->ctrl_base;
+ u32 mask;
+
+ /* Workaround: setup IRQs through both register sets. */
+ mask = ((musb->epmask & DA8XX_USB_TX_EP_MASK) << DA8XX_INTR_TX_SHIFT) |
+ ((musb->epmask & DA8XX_USB_RX_EP_MASK) << DA8XX_INTR_RX_SHIFT) |
+ DA8XX_INTR_USB_MASK;
+ musb_writel(reg_base, DA8XX_USB_INTR_MASK_SET_REG, mask);
+
+ /* Force the DRVVBUS IRQ so we can start polling for ID change. */
+ if (is_otg_enabled(musb))
+ musb_writel(reg_base, DA8XX_USB_INTR_SRC_SET_REG,
+ DA8XX_INTR_DRVVBUS << DA8XX_INTR_USB_SHIFT);
+}
+
+/**
+ * musb_platform_disable - disable HDRC and flush interrupts
+ */
+void musb_platform_disable(struct musb *musb)
+{
+ void __iomem *reg_base = musb->ctrl_base;
+
+ musb_writel(reg_base, DA8XX_USB_INTR_MASK_CLEAR_REG,
+ DA8XX_INTR_USB_MASK |
+ DA8XX_INTR_TX_MASK | DA8XX_INTR_RX_MASK);
+ musb_writeb(musb->mregs, MUSB_DEVCTL, 0);
+ musb_writel(reg_base, DA8XX_USB_END_OF_INTR_REG, 0);
+}
+
+#ifdef CONFIG_USB_MUSB_HDRC_HCD
+#define portstate(stmt) stmt
+#else
+#define portstate(stmt)
+#endif
+
+static void da8xx_set_vbus(struct musb *musb, int is_on)
+{
+ WARN_ON(is_on && is_peripheral_active(musb));
+}
+
+#define POLL_SECONDS 2
+
+static struct timer_list otg_workaround;
+
+static void otg_timer(unsigned long _musb)
+{
+ struct musb *musb = (void *)_musb;
+ void __iomem *mregs = musb->mregs;
+ u8 devctl;
+ unsigned long flags;
+
+ /*
+ * We poll because DaVinci's won't expose several OTG-critical
+ * status change events (from the transceiver) otherwise.
+ */
+ devctl = musb_readb(mregs, MUSB_DEVCTL);
+ DBG(7, "Poll devctl %02x (%s)\n", devctl, otg_state_string(musb));
+
+ spin_lock_irqsave(&musb->lock, flags);
+ switch (musb->xceiv->state) {
+ case OTG_STATE_A_WAIT_BCON:
+ devctl &= ~MUSB_DEVCTL_SESSION;
+ musb_writeb(musb->mregs, MUSB_DEVCTL, devctl);
+
+ devctl = musb_readb(musb->mregs, MUSB_DEVCTL);
+ if (devctl & MUSB_DEVCTL_BDEVICE) {
+ musb->xceiv->state = OTG_STATE_B_IDLE;
+ MUSB_DEV_MODE(musb);
+ } else {
+ musb->xceiv->state = OTG_STATE_A_IDLE;
+ MUSB_HST_MODE(musb);
+ }
+ break;
+ case OTG_STATE_A_WAIT_VFALL:
+ /*
+ * Wait till VBUS falls below SessionEnd (~0.2 V); the 1.3
+ * RTL seems to mis-handle session "start" otherwise (or in
+ * our case "recover"), in routine "VBUS was valid by the time
+ * VBUSERR got reported during enumeration" cases.
+ */
+ if (devctl & MUSB_DEVCTL_VBUS) {
+ mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
+ break;
+ }
+ musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ musb_writel(musb->ctrl_base, DA8XX_USB_INTR_SRC_SET_REG,
+ MUSB_INTR_VBUSERROR << DA8XX_INTR_USB_SHIFT);
+ break;
+ case OTG_STATE_B_IDLE:
+ if (!is_peripheral_enabled(musb))
+ break;
+
+ /*
+ * There's no ID-changed IRQ, so we have no good way to tell
+ * when to switch to the A-Default state machine (by setting
+ * the DEVCTL.Session bit).
+ *
+ * Workaround: whenever we're in B_IDLE, try setting the
+ * session flag every few seconds. If it works, ID was
+ * grounded and we're now in the A-Default state machine.
+ *
+ * NOTE: setting the session flag is _supposed_ to trigger
+ * SRP but clearly it doesn't.
+ */
+ musb_writeb(mregs, MUSB_DEVCTL, devctl | MUSB_DEVCTL_SESSION);
+ devctl = musb_readb(mregs, MUSB_DEVCTL);
+ if (devctl & MUSB_DEVCTL_BDEVICE)
+ mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
+ else
+ musb->xceiv->state = OTG_STATE_A_IDLE;
+ break;
+ default:
+ break;
+ }
+ spin_unlock_irqrestore(&musb->lock, flags);
+}
+
+void musb_platform_try_idle(struct musb *musb, unsigned long timeout)
+{
+ static unsigned long last_timer;
+
+ if (!is_otg_enabled(musb))
+ return;
+
+ if (timeout == 0)
+ timeout = jiffies + msecs_to_jiffies(3);
+
+ /* Never idle if active, or when VBUS timeout is not set as host */
+ if (musb->is_active || (musb->a_wait_bcon == 0 &&
+ musb->xceiv->state == OTG_STATE_A_WAIT_BCON)) {
+ DBG(4, "%s active, deleting timer\n", otg_state_string(musb));
+ del_timer(&otg_workaround);
+ last_timer = jiffies;
+ return;
+ }
+
+ if (time_after(last_timer, timeout) && timer_pending(&otg_workaround)) {
+ DBG(4, "Longer idle timer already pending, ignoring...\n");
+ return;
+ }
+ last_timer = timeout;
+
+ DBG(4, "%s inactive, starting idle timer for %u ms\n",
+ otg_state_string(musb), jiffies_to_msecs(timeout - jiffies));
+ mod_timer(&otg_workaround, timeout);
+}
+
+static irqreturn_t da8xx_interrupt(int irq, void *hci)
+{
+ struct musb *musb = hci;
+ void __iomem *reg_base = musb->ctrl_base;
+ unsigned long flags;
+ irqreturn_t ret = IRQ_NONE;
+ u32 status;
+
+ spin_lock_irqsave(&musb->lock, flags);
+
+ /*
+ * NOTE: DA8XX shadows the Mentor IRQs. Don't manage them through
+ * the Mentor registers (except for setup), use the TI ones and EOI.
+ */
+
+ /* Acknowledge and handle non-CPPI interrupts */
+ status = musb_readl(reg_base, DA8XX_USB_INTR_SRC_MASKED_REG);
+ if (!status)
+ goto eoi;
+
+ musb_writel(reg_base, DA8XX_USB_INTR_SRC_CLEAR_REG, status);
+ DBG(4, "USB IRQ %08x\n", status);
+
+ musb->int_rx = (status & DA8XX_INTR_RX_MASK) >> DA8XX_INTR_RX_SHIFT;
+ musb->int_tx = (status & DA8XX_INTR_TX_MASK) >> DA8XX_INTR_TX_SHIFT;
+ musb->int_usb = (status & DA8XX_INTR_USB_MASK) >> DA8XX_INTR_USB_SHIFT;
+
+ /*
+ * DRVVBUS IRQs are the only proxy we have (a very poor one!) for
+ * DA8xx's missing ID change IRQ. We need an ID change IRQ to
+ * switch appropriately between halves of the OTG state machine.
+ * Managing DEVCTL.Session per Mentor docs requires that we know its
+ * value but DEVCTL.BDevice is invalid without DEVCTL.Session set.
+ * Also, DRVVBUS pulses for SRP (but not at 5 V)...
+ */
+ if (status & (DA8XX_INTR_DRVVBUS << DA8XX_INTR_USB_SHIFT)) {
+ int drvvbus = musb_readl(reg_base, DA8XX_USB_STAT_REG);
+ void __iomem *mregs = musb->mregs;
+ u8 devctl = musb_readb(mregs, MUSB_DEVCTL);
+ int err;
+
+ err = is_host_enabled(musb) && (musb->int_usb &
+ MUSB_INTR_VBUSERROR);
+ if (err) {
+ /*
+ * The Mentor core doesn't debounce VBUS as needed
+ * to cope with device connect current spikes. This
+ * means it's not uncommon for bus-powered devices
+ * to get VBUS errors during enumeration.
+ *
+ * This is a workaround, but newer RTL from Mentor
+ * seems to allow a better one: "re"-starting sessions
+ * without waiting for VBUS to stop registering in
+ * devctl.
+ */
+ musb->int_usb &= ~MUSB_INTR_VBUSERROR;
+ musb->xceiv->state = OTG_STATE_A_WAIT_VFALL;
+ mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
+ WARNING("VBUS error workaround (delay coming)\n");
+ } else if (is_host_enabled(musb) && drvvbus) {
+ MUSB_HST_MODE(musb);
+ musb->xceiv->default_a = 1;
+ musb->xceiv->state = OTG_STATE_A_WAIT_VRISE;
+ portstate(musb->port1_status |= USB_PORT_STAT_POWER);
+ del_timer(&otg_workaround);
+ } else {
+ musb->is_active = 0;
+ MUSB_DEV_MODE(musb);
+ musb->xceiv->default_a = 0;
+ musb->xceiv->state = OTG_STATE_B_IDLE;
+ portstate(musb->port1_status &= ~USB_PORT_STAT_POWER);
+ }
+
+ DBG(2, "VBUS %s (%s)%s, devctl %02x\n",
+ drvvbus ? "on" : "off",
+ otg_state_string(musb),
+ err ? " ERROR" : "",
+ devctl);
+ ret = IRQ_HANDLED;
+ }
+
+ if (musb->int_tx || musb->int_rx || musb->int_usb)
+ ret |= musb_interrupt(musb);
+
+ eoi:
+ /* EOI needs to be written for the IRQ to be re-asserted. */
+ if (ret == IRQ_HANDLED || status)
+ musb_writel(reg_base, DA8XX_USB_END_OF_INTR_REG, 0);
+
+ /* Poll for ID change */
+ if (is_otg_enabled(musb) && musb->xceiv->state == OTG_STATE_B_IDLE)
+ mod_timer(&otg_workaround, jiffies + POLL_SECONDS * HZ);
+
+ spin_unlock_irqrestore(&musb->lock, flags);
+
+ return ret;
+}
+
+int musb_platform_set_mode(struct musb *musb, u8 musb_mode)
+{
+ u32 cfgchip2 = __raw_readl(CFGCHIP2);
+
+ cfgchip2 &= ~CFGCHIP2_OTGMODE;
+ switch (musb_mode) {
+#ifdef CONFIG_USB_MUSB_HDRC_HCD
+ case MUSB_HOST: /* Force VBUS valid, ID = 0 */
+ cfgchip2 |= CFGCHIP2_FORCE_HOST;
+ break;
+#endif
+#ifdef CONFIG_USB_GADGET_MUSB_HDRC
+ case MUSB_PERIPHERAL: /* Force VBUS valid, ID = 1 */
+ cfgchip2 |= CFGCHIP2_FORCE_DEVICE;
+ break;
+#endif
+#ifdef CONFIG_USB_MUSB_OTG
+ case MUSB_OTG: /* Don't override the VBUS/ID comparators */
+ cfgchip2 |= CFGCHIP2_NO_OVERRIDE;
+ break;
+#endif
+ default:
+ DBG(2, "Trying to set unsupported mode %u\n", musb_mode);
+ }
+
+ __raw_writel(cfgchip2, CFGCHIP2);
+ return 0;
+}
+
+int __init musb_platform_init(struct musb *musb, void *board_data)
+{
+ void __iomem *reg_base = musb->ctrl_base;
+ u32 rev;
+
+ musb->mregs += DA8XX_MENTOR_CORE_OFFSET;
+
+ clk_enable(musb->clock);
+
+ /* Returns zero if e.g. not clocked */
+ rev = musb_readl(reg_base, DA8XX_USB_REVISION_REG);
+ if (!rev)
+ goto fail;
+
+ usb_nop_xceiv_register();
+ musb->xceiv = otg_get_transceiver();
+ if (!musb->xceiv)
+ goto fail;
+
+ if (is_host_enabled(musb))
+ setup_timer(&otg_workaround, otg_timer, (unsigned long)musb);
+
+ musb->board_set_vbus = da8xx_set_vbus;
+
+ /* Reset the controller */
+ musb_writel(reg_base, DA8XX_USB_CTRL_REG, DA8XX_SOFT_RESET_MASK);
+
+ /* Start the on-chip PHY and its PLL. */
+ phy_on();
+
+ msleep(5);
+
+ /* NOTE: IRQs are in mixed mode, not bypass to pure MUSB */
+ pr_debug("DA8xx OTG revision %08x, PHY %03x, control %02x\n",
+ rev, __raw_readl(CFGCHIP2),
+ musb_readb(reg_base, DA8XX_USB_CTRL_REG));
+
+ musb->isr = da8xx_interrupt;
+ return 0;
+fail:
+ clk_disable(musb->clock);
+ return -ENODEV;
+}
+
+int musb_platform_exit(struct musb *musb)
+{
+ if (is_host_enabled(musb))
+ del_timer_sync(&otg_workaround);
+
+ phy_off();
+
+ otg_put_transceiver(musb->xceiv);
+ usb_nop_xceiv_unregister();
+
+ clk_disable(musb->clock);
+
+ return 0;
+}
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)
fail:
clk_disable(musb->clock);
+ otg_put_transceiver(musb->xceiv);
usb_nop_xceiv_unregister();
return -ENODEV;
}
@@ -496,6 +497,7 @@ int musb_platform_exit(struct musb *musb)
clk_disable(musb->clock);
+ otg_put_transceiver(musb->xceiv);
usb_nop_xceiv_unregister();
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)
}
}
+#if !defined(CONFIG_USB_MUSB_AM35X)
/*
* Unload an endpoint's FIFO
*/
@@ -309,6 +310,7 @@ void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *dst)
readsb(fifo, dst, len);
}
}
+#endif
#endif /* normal PIO */
@@ -550,6 +552,11 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb,
if (int_usb & MUSB_INTR_SESSREQ) {
void __iomem *mbase = musb->mregs;
+ if (devctl & MUSB_DEVCTL_BDEVICE) {
+ DBG(3, "SessReq while on B state\n");
+ return IRQ_HANDLED;
+ }
+
DBG(1, "SESSION_REQUEST (%s)\n", otg_state_string(musb));
/* IRQ arrives from ID pin sense or (later, if VBUS power
@@ -1921,10 +1928,6 @@ static void musb_free(struct musb *musb)
dma_controller_destroy(c);
}
-#ifdef CONFIG_USB_MUSB_OTG
- put_device(musb->xceiv->dev);
-#endif
-
#ifdef CONFIG_USB_MUSB_HDRC_HCD
usb_put_hcd(musb_to_hcd(musb));
#else
@@ -2266,6 +2269,7 @@ void musb_save_context(struct musb *musb)
{
int i;
void __iomem *musb_base = musb->mregs;
+ void __iomem *epio;
if (is_host_enabled(musb)) {
musb_context.frame = musb_readw(musb_base, MUSB_FRAME);
@@ -2279,16 +2283,16 @@ void musb_save_context(struct musb *musb)
musb_context.index = musb_readb(musb_base, MUSB_INDEX);
musb_context.devctl = musb_readb(musb_base, MUSB_DEVCTL);
- for (i = 0; i < MUSB_C_NUM_EPS; ++i) {
- musb_writeb(musb_base, MUSB_INDEX, i);
+ for (i = 0; i < musb->config->num_eps; ++i) {
+ epio = musb->endpoints[i].regs;
musb_context.index_regs[i].txmaxp =
- musb_readw(musb_base, 0x10 + MUSB_TXMAXP);
+ musb_readw(epio, MUSB_TXMAXP);
musb_context.index_regs[i].txcsr =
- musb_readw(musb_base, 0x10 + MUSB_TXCSR);
+ musb_readw(epio, MUSB_TXCSR);
musb_context.index_regs[i].rxmaxp =
- musb_readw(musb_base, 0x10 + MUSB_RXMAXP);
+ musb_readw(epio, MUSB_RXMAXP);
musb_context.index_regs[i].rxcsr =
- musb_readw(musb_base, 0x10 + MUSB_RXCSR);
+ musb_readw(epio, MUSB_RXCSR);
if (musb->dyn_fifo) {
musb_context.index_regs[i].txfifoadd =
@@ -2302,13 +2306,13 @@ void musb_save_context(struct musb *musb)
}
if (is_host_enabled(musb)) {
musb_context.index_regs[i].txtype =
- musb_readb(musb_base, 0x10 + MUSB_TXTYPE);
+ musb_readb(epio, MUSB_TXTYPE);
musb_context.index_regs[i].txinterval =
- musb_readb(musb_base, 0x10 + MUSB_TXINTERVAL);
+ musb_readb(epio, MUSB_TXINTERVAL);
musb_context.index_regs[i].rxtype =
- musb_readb(musb_base, 0x10 + MUSB_RXTYPE);
+ musb_readb(epio, MUSB_RXTYPE);
musb_context.index_regs[i].rxinterval =
- musb_readb(musb_base, 0x10 + MUSB_RXINTERVAL);
+ musb_readb(epio, MUSB_RXINTERVAL);
musb_context.index_regs[i].txfunaddr =
musb_read_txfunaddr(musb_base, i);
@@ -2326,8 +2330,6 @@ void musb_save_context(struct musb *musb)
}
}
- musb_writeb(musb_base, MUSB_INDEX, musb_context.index);
-
musb_platform_save_context(musb, &musb_context);
}
@@ -2336,6 +2338,7 @@ void musb_restore_context(struct musb *musb)
int i;
void __iomem *musb_base = musb->mregs;
void __iomem *ep_target_regs;
+ void __iomem *epio;
musb_platform_restore_context(musb, &musb_context);
@@ -2350,15 +2353,15 @@ void musb_restore_context(struct musb *musb)
musb_writeb(musb_base, MUSB_INTRUSBE, musb_context.intrusbe);
musb_writeb(musb_base, MUSB_DEVCTL, musb_context.devctl);
- for (i = 0; i < MUSB_C_NUM_EPS; ++i) {
- musb_writeb(musb_base, MUSB_INDEX, i);
- musb_writew(musb_base, 0x10 + MUSB_TXMAXP,
+ for (i = 0; i < musb->config->num_eps; ++i) {
+ epio = musb->endpoints[i].regs;
+ musb_writew(epio, MUSB_TXMAXP,
musb_context.index_regs[i].txmaxp);
- musb_writew(musb_base, 0x10 + MUSB_TXCSR,
+ musb_writew(epio, MUSB_TXCSR,
musb_context.index_regs[i].txcsr);
- musb_writew(musb_base, 0x10 + MUSB_RXMAXP,
+ musb_writew(epio, MUSB_RXMAXP,
musb_context.index_regs[i].rxmaxp);
- musb_writew(musb_base, 0x10 + MUSB_RXCSR,
+ musb_writew(epio, MUSB_RXCSR,
musb_context.index_regs[i].rxcsr);
if (musb->dyn_fifo) {
@@ -2373,13 +2376,13 @@ void musb_restore_context(struct musb *musb)
}
if (is_host_enabled(musb)) {
- musb_writeb(musb_base, 0x10 + MUSB_TXTYPE,
+ musb_writeb(epio, MUSB_TXTYPE,
musb_context.index_regs[i].txtype);
- musb_writeb(musb_base, 0x10 + MUSB_TXINTERVAL,
+ musb_writeb(epio, MUSB_TXINTERVAL,
musb_context.index_regs[i].txinterval);
- musb_writeb(musb_base, 0x10 + MUSB_RXTYPE,
+ musb_writeb(epio, MUSB_RXTYPE,
musb_context.index_regs[i].rxtype);
- musb_writeb(musb_base, 0x10 + MUSB_RXINTERVAL,
+ musb_writeb(epio, MUSB_RXINTERVAL,
musb_context.index_regs[i].rxinterval);
musb_write_txfunaddr(musb_base, i,
@@ -2400,8 +2403,6 @@ void musb_restore_context(struct musb *musb)
musb_context.index_regs[i].rxhubport);
}
}
-
- musb_writeb(musb_base, MUSB_INDEX, musb_context.index);
}
static 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 {
/* device lock */
spinlock_t lock;
struct clk *clock;
+ struct clk *phy_clock;
irqreturn_t (*isr)(int, void *);
struct work_struct irq_work;
u16 hwvers;
@@ -599,6 +600,7 @@ extern void musb_hnp_stop(struct musb *musb);
extern int musb_platform_set_mode(struct musb *musb, u8 musb_mode);
#if defined(CONFIG_USB_TUSB6010) || defined(CONFIG_BLACKFIN) || \
+ defined(CONFIG_ARCH_DAVINCI_DA8XX) || \
defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP3) || \
defined(CONFIG_ARCH_OMAP4)
extern 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 @@
#define INFO(fmt, args...) yprintk(KERN_INFO, fmt, ## args)
#define ERR(fmt, args...) yprintk(KERN_ERR, fmt, ## args)
-#define xprintk(level, facility, format, args...) do { \
- if (_dbg_level(level)) { \
- printk(facility "%s %d: " format , \
- __func__, __LINE__ , ## args); \
- } } while (0)
+#define DBG(level, format, args...) do { \
+ if (_dbg_level(level)) \
+ pr_debug("%s %d: " format, __func__, __LINE__, ## args); \
+ } while (0)
extern unsigned musb_debug;
@@ -55,8 +54,6 @@ static inline int _dbg_level(unsigned l)
return musb_debug >= l;
}
-#define DBG(level, fmt, args...) xprintk(level, KERN_DEBUG, fmt, ## args)
-
extern const char *otg_state_string(struct musb *);
#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)
csr |= (MUSB_TXCSR_DMAENAB |
MUSB_TXCSR_MODE);
/* against programming guide */
- } else
- csr |= (MUSB_TXCSR_AUTOSET
- | MUSB_TXCSR_DMAENAB
+ } else {
+ csr |= (MUSB_TXCSR_DMAENAB
| MUSB_TXCSR_DMAMODE
| MUSB_TXCSR_MODE);
-
+ if (!musb_ep->hb_mult)
+ csr |= MUSB_TXCSR_AUTOSET;
+ }
csr &= ~MUSB_TXCSR_P_UNDERRUN;
+
musb_writew(epio, MUSB_TXCSR, csr);
}
}
@@ -475,40 +477,39 @@ void musb_g_tx(struct musb *musb, u8 epnum)
epnum, csr, musb_ep->dma->actual_len, request);
}
- if (is_dma || request->actual == request->length) {
- /*
- * First, maybe a terminating short packet. Some DMA
- * engines might handle this by themselves.
- */
- if ((request->zero && request->length
- && request->length % musb_ep->packet_sz == 0)
+ /*
+ * First, maybe a terminating short packet. Some DMA
+ * engines might handle this by themselves.
+ */
+ if ((request->zero && request->length
+ && (request->length % musb_ep->packet_sz == 0)
+ && (request->actual == request->length))
#ifdef CONFIG_USB_INVENTRA_DMA
- || (is_dma && (!dma->desired_mode ||
- (request->actual &
- (musb_ep->packet_sz - 1))))
+ || (is_dma && (!dma->desired_mode ||
+ (request->actual &
+ (musb_ep->packet_sz - 1))))
#endif
- ) {
- /*
- * On DMA completion, FIFO may not be
- * available yet...
- */
- if (csr & MUSB_TXCSR_TXPKTRDY)
- return;
+ ) {
+ /*
+ * On DMA completion, FIFO may not be
+ * available yet...
+ */
+ if (csr & MUSB_TXCSR_TXPKTRDY)
+ return;
- DBG(4, "sending zero pkt\n");
- musb_writew(epio, MUSB_TXCSR, MUSB_TXCSR_MODE
- | MUSB_TXCSR_TXPKTRDY);
- request->zero = 0;
- }
+ DBG(4, "sending zero pkt\n");
+ musb_writew(epio, MUSB_TXCSR, MUSB_TXCSR_MODE
+ | MUSB_TXCSR_TXPKTRDY);
+ request->zero = 0;
+ }
- if (request->actual == request->length) {
- musb_g_giveback(musb_ep, request, 0);
- request = musb_ep->desc ? next_request(musb_ep) : NULL;
- if (!request) {
- DBG(4, "%s idle now\n",
- musb_ep->end_point.name);
- return;
- }
+ if (request->actual == request->length) {
+ musb_g_giveback(musb_ep, request, 0);
+ request = musb_ep->desc ? next_request(musb_ep) : NULL;
+ if (!request) {
+ DBG(4, "%s idle now\n",
+ musb_ep->end_point.name);
+ return;
}
}
@@ -643,7 +644,9 @@ static void rxstate(struct musb *musb, struct musb_request *req)
*/
csr |= MUSB_RXCSR_DMAENAB;
- csr |= MUSB_RXCSR_AUTOCLEAR;
+ if (!musb_ep->hb_mult &&
+ musb_ep->hw_ep->rx_double_buffered)
+ csr |= MUSB_RXCSR_AUTOCLEAR;
#ifdef USE_MODE1
/* csr |= MUSB_RXCSR_DMAMODE; */
@@ -772,7 +775,7 @@ void musb_g_rx(struct musb *musb, u8 epnum)
musb_writew(epio, MUSB_RXCSR, csr);
DBG(3, "%s iso overrun on %p\n", musb_ep->name, request);
- if (request && request->status == -EINPROGRESS)
+ if (request->status == -EINPROGRESS)
request->status = -EOVERFLOW;
}
if (csr & MUSB_RXCSR_INCOMPRX) {
@@ -825,14 +828,8 @@ void musb_g_rx(struct musb *musb, u8 epnum)
return;
}
- /* analyze request if the ep is hot */
- if (request)
- rxstate(musb, to_musb_request(request));
- else
- DBG(3, "packet waiting for %s%s request\n",
- musb_ep->desc ? "" : "inactive ",
- musb_ep->end_point.name);
- return;
+ /* Analyze request */
+ rxstate(musb, to_musb_request(request));
}
/* ------------------------------------------------------------ */
@@ -875,9 +872,25 @@ static int musb_gadget_enable(struct usb_ep *ep,
/* REVISIT this rules out high bandwidth periodic transfers */
tmp = le16_to_cpu(desc->wMaxPacketSize);
- if (tmp & ~0x07ff)
- goto fail;
- musb_ep->packet_sz = tmp;
+ if (tmp & ~0x07ff) {
+ int ok;
+
+ if (usb_endpoint_dir_in(desc))
+ ok = musb->hb_iso_tx;
+ else
+ ok = musb->hb_iso_rx;
+
+ if (!ok) {
+ DBG(4, "%s: not support ISO high bandwidth\n", __func__);
+ goto fail;
+ }
+ musb_ep->hb_mult = (tmp >> 11) & 3;
+ } else {
+ musb_ep->hb_mult = 0;
+ }
+
+ musb_ep->packet_sz = tmp & 0x7ff;
+ tmp = musb_ep->packet_sz * (musb_ep->hb_mult + 1);
/* enable the interrupts for the endpoint, set the endpoint
* packet size (or fail), set the mode, clear the fifo
@@ -890,8 +903,11 @@ static int musb_gadget_enable(struct usb_ep *ep,
musb_ep->is_in = 1;
if (!musb_ep->is_in)
goto fail;
- if (tmp > hw_ep->max_packet_sz_tx)
+
+ if (tmp > hw_ep->max_packet_sz_tx) {
+ DBG(4, "%s: packet size beyond hw fifo size\n", __func__);
goto fail;
+ }
int_txe |= (1 << epnum);
musb_writew(mbase, MUSB_INTRTXE, int_txe);
@@ -906,7 +922,7 @@ static int musb_gadget_enable(struct usb_ep *ep,
if (musb->hwvers < MUSB_HWVERS_2000)
musb_writew(regs, MUSB_TXMAXP, hw_ep->max_packet_sz_tx);
else
- musb_writew(regs, MUSB_TXMAXP, tmp);
+ musb_writew(regs, MUSB_TXMAXP, musb_ep->packet_sz | (musb_ep->hb_mult << 11));
csr = MUSB_TXCSR_MODE | MUSB_TXCSR_CLRDATATOG;
if (musb_readw(regs, MUSB_TXCSR)
@@ -927,8 +943,11 @@ static int musb_gadget_enable(struct usb_ep *ep,
musb_ep->is_in = 0;
if (musb_ep->is_in)
goto fail;
- if (tmp > hw_ep->max_packet_sz_rx)
+
+ if (tmp > hw_ep->max_packet_sz_rx) {
+ DBG(4, "%s: packet size beyond hw fifo size\n", __func__);
goto fail;
+ }
int_rxe |= (1 << epnum);
musb_writew(mbase, MUSB_INTRRXE, int_rxe);
@@ -942,7 +961,7 @@ static int musb_gadget_enable(struct usb_ep *ep,
if (musb->hwvers < MUSB_HWVERS_2000)
musb_writew(regs, MUSB_RXMAXP, hw_ep->max_packet_sz_rx);
else
- musb_writew(regs, MUSB_RXMAXP, tmp);
+ musb_writew(regs, MUSB_RXMAXP, musb_ep->packet_sz | (musb_ep->hb_mult << 11));
/* force shared fifo to OUT-only mode */
if (hw_ep->is_shared_fifo) {
@@ -1699,9 +1718,11 @@ void musb_gadget_cleanup(struct musb *musb)
* -ENOMEM no memeory to perform the operation
*
* @param driver the gadget driver
+ * @param bind the driver's bind function
* @return <0 if error, 0 if everything is fine
*/
-int usb_gadget_register_driver(struct usb_gadget_driver *driver)
+int usb_gadget_probe_driver(struct usb_gadget_driver *driver,
+ int (*bind)(struct usb_gadget *))
{
int retval;
unsigned long flags;
@@ -1709,8 +1730,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
if (!driver
|| driver->speed != USB_SPEED_HIGH
- || !driver->bind
- || !driver->setup)
+ || !bind || !driver->setup)
return -EINVAL;
/* driver must be initialized to support peripheral mode */
@@ -1738,7 +1758,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
spin_unlock_irqrestore(&musb->lock, flags);
if (retval == 0) {
- retval = driver->bind(&musb->g);
+ retval = bind(&musb->g);
if (retval != 0) {
DBG(3, "bind to driver %s failed --> %d\n",
driver->driver.name, retval);
@@ -1786,7 +1806,7 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
return retval;
}
-EXPORT_SYMBOL(usb_gadget_register_driver);
+EXPORT_SYMBOL(usb_gadget_probe_driver);
static void stop_activity(struct musb *musb, struct usb_gadget_driver *driver)
{
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 {
/* true if lock must be dropped but req_list may not be advanced */
u8 busy;
+
+ u8 hb_mult;
};
static 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 @@
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/list.h>
+#include <linux/dma-mapping.h>
#include "musb_core.h"
#include "musb_host.h"
@@ -1119,6 +1120,7 @@ void musb_host_tx(struct musb *musb, u8 epnum)
u32 status = 0;
void __iomem *mbase = musb->mregs;
struct dma_channel *dma;
+ bool transfer_pending = false;
musb_ep_select(mbase, epnum);
tx_csr = musb_readw(epio, MUSB_TXCSR);
@@ -1279,7 +1281,7 @@ void musb_host_tx(struct musb *musb, u8 epnum)
offset = d->offset;
length = d->length;
}
- } else if (dma) {
+ } else if (dma && urb->transfer_buffer_length == qh->offset) {
done = true;
} else {
/* see if we need to send more data, or ZLP */
@@ -1292,6 +1294,7 @@ void musb_host_tx(struct musb *musb, u8 epnum)
if (!done) {
offset = qh->offset;
length = urb->transfer_buffer_length - offset;
+ transfer_pending = true;
}
}
}
@@ -1311,7 +1314,7 @@ void musb_host_tx(struct musb *musb, u8 epnum)
urb->actual_length = qh->offset;
musb_advance_schedule(musb, urb, hw_ep, USB_DIR_OUT);
return;
- } else if (usb_pipeisoc(pipe) && dma) {
+ } else if ((usb_pipeisoc(pipe) || transfer_pending) && dma) {
if (musb_tx_dma_program(musb->dma_controller, hw_ep, qh, urb,
offset, length)) {
if (is_cppi_enabled() || tusb_dma_omap())
@@ -1332,6 +1335,8 @@ void musb_host_tx(struct musb *musb, u8 epnum)
*/
if (length > qh->maxpacket)
length = qh->maxpacket;
+ /* Unmap the buffer so that CPU can use it */
+ unmap_urb_for_dma(musb_to_hcd(musb), urb);
musb_write_fifo(hw_ep, length, urb->transfer_buffer + offset);
qh->segsize = length;
@@ -1752,6 +1757,8 @@ void musb_host_rx(struct musb *musb, u8 epnum)
#endif /* Mentor DMA */
if (!dma) {
+ /* Unmap the buffer so that CPU can use it */
+ unmap_urb_for_dma(musb_to_hcd(musb), urb);
done = musb_host_packet_rx(musb, urb,
epnum, iso_err);
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,
channel = &(musb_channel->channel);
channel->private_data = musb_channel;
channel->status = MUSB_DMA_STATUS_FREE;
- channel->max_len = 0x10000;
+ channel->max_len = 0x100000;
/* Tx => mode 1; Rx => mode 0 */
channel->desired_mode = transmit;
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)
musb_platform_suspend(musb);
+ otg_put_transceiver(musb->xceiv);
return 0;
}
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:
if (ret < 0) {
if (sync)
iounmap(sync);
+
+ otg_put_transceiver(musb->xceiv);
usb_nop_xceiv_unregister();
}
return ret;
@@ -1166,6 +1168,8 @@ int musb_platform_exit(struct musb *musb)
musb->board_set_power(0);
iounmap(musb->sync_va);
+
+ otg_put_transceiver(musb->xceiv);
usb_nop_xceiv_unregister();
return 0;
}
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
built-in with usb ip or which are autonomous and doesn't require any
phy programming such as ISP1x04 etc.
+config USB_LANGWELL_OTG
+ tristate "Intel Langwell USB OTG dual-role support"
+ depends on USB && PCI && INTEL_SCU_IPC
+ select USB_OTG
+ select USB_OTG_UTILS
+ help
+ Say Y here if you want to build Intel Langwell USB OTG
+ transciever driver in kernel. This driver implements role
+ switch between EHCI host driver and Langwell USB OTG
+ client driver.
+
+ To compile this driver as a module, choose M here: the
+ module will be called langwell_otg.
+
endif # 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 @@
# OTG infrastructure and transceiver drivers
#
+ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG
+ccflags-$(CONFIG_USB_GADGET_DEBUG) += -DDEBUG
+
# infrastructure
obj-$(CONFIG_USB_OTG_UTILS) += otg.o
@@ -9,9 +12,6 @@ obj-$(CONFIG_USB_OTG_UTILS) += otg.o
obj-$(CONFIG_USB_GPIO_VBUS) += gpio_vbus.o
obj-$(CONFIG_ISP1301_OMAP) += isp1301_omap.o
obj-$(CONFIG_TWL4030_USB) += twl4030-usb.o
+obj-$(CONFIG_USB_LANGWELL_OTG) += langwell_otg.o
obj-$(CONFIG_NOP_USB_XCEIV) += nop-usb-xceiv.o
obj-$(CONFIG_USB_ULPI) += ulpi.o
-
-ccflags-$(CONFIG_USB_DEBUG) += -DDEBUG
-ccflags-$(CONFIG_USB_GADGET_DEBUG) += -DDEBUG
-
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 @@
+/*
+ * Intel Langwell USB OTG transceiver driver
+ * Copyright (C) 2008 - 2010, Intel Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+/* This driver helps to switch Langwell OTG controller function between host
+ * and peripheral. It works with EHCI driver and Langwell client controller
+ * driver together.
+ */
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/pci.h>
+#include <linux/errno.h>
+#include <linux/interrupt.h>
+#include <linux/kernel.h>
+#include <linux/device.h>
+#include <linux/moduleparam.h>
+#include <linux/usb/ch9.h>
+#include <linux/usb/gadget.h>
+#include <linux/usb.h>
+#include <linux/usb/otg.h>
+#include <linux/usb/hcd.h>
+#include <linux/notifier.h>
+#include <linux/delay.h>
+#include <asm/intel_scu_ipc.h>
+
+#include <linux/usb/langwell_otg.h>
+
+#define DRIVER_DESC "Intel Langwell USB OTG transceiver driver"
+#define DRIVER_VERSION "July 10, 2010"
+
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_AUTHOR("Henry Yuan <hang.yuan@intel.com>, Hao Wu <hao.wu@intel.com>");
+MODULE_VERSION(DRIVER_VERSION);
+MODULE_LICENSE("GPL");
+
+static const char driver_name[] = "langwell_otg";
+
+static int langwell_otg_probe(struct pci_dev *pdev,
+ const struct pci_device_id *id);
+static void langwell_otg_remove(struct pci_dev *pdev);
+static int langwell_otg_suspend(struct pci_dev *pdev, pm_message_t message);
+static int langwell_otg_resume(struct pci_dev *pdev);
+
+static int langwell_otg_set_host(struct otg_transceiver *otg,
+ struct usb_bus *host);
+static int langwell_otg_set_peripheral(struct otg_transceiver *otg,
+ struct usb_gadget *gadget);
+static int langwell_otg_start_srp(struct otg_transceiver *otg);
+
+static const struct pci_device_id pci_ids[] = {{
+ .class = ((PCI_CLASS_SERIAL_USB << 8) | 0xfe),
+ .class_mask = ~0,
+ .vendor = 0x8086,
+ .device = 0x0811,
+ .subvendor = PCI_ANY_ID,
+ .subdevice = PCI_ANY_ID,
+}, { /* end: all zeroes */ }
+};
+
+static struct pci_driver otg_pci_driver = {
+ .name = (char *) driver_name,
+ .id_table = pci_ids,
+
+ .probe = langwell_otg_probe,
+ .remove = langwell_otg_remove,
+
+ .suspend = langwell_otg_suspend,
+ .resume = langwell_otg_resume,
+};
+
+static const char *state_string(enum usb_otg_state state)
+{
+ switch (state) {
+ case OTG_STATE_A_IDLE:
+ return "a_idle";
+ case OTG_STATE_A_WAIT_VRISE:
+ return "a_wait_vrise";
+ case OTG_STATE_A_WAIT_BCON:
+ return "a_wait_bcon";
+ case OTG_STATE_A_HOST:
+ return "a_host";
+ case OTG_STATE_A_SUSPEND:
+ return "a_suspend";
+ case OTG_STATE_A_PERIPHERAL:
+ return "a_peripheral";
+ case OTG_STATE_A_WAIT_VFALL:
+ return "a_wait_vfall";
+ case OTG_STATE_A_VBUS_ERR:
+ return "a_vbus_err";
+ case OTG_STATE_B_IDLE:
+ return "b_idle";
+ case OTG_STATE_B_SRP_INIT:
+ return "b_srp_init";
+ case OTG_STATE_B_PERIPHERAL:
+ return "b_peripheral";
+ case OTG_STATE_B_WAIT_ACON:
+ return "b_wait_acon";
+ case OTG_STATE_B_HOST:
+ return "b_host";
+ default:
+ return "UNDEFINED";
+ }
+}
+
+/* HSM timers */
+static inline struct langwell_otg_timer *otg_timer_initializer
+(void (*function)(unsigned long), unsigned long expires, unsigned long data)
+{
+ struct langwell_otg_timer *timer;
+ timer = kmalloc(sizeof(struct langwell_otg_timer), GFP_KERNEL);
+ if (timer == NULL)
+ return timer;
+
+ timer->function = function;
+ timer->expires = expires;
+ timer->data = data;
+ return timer;
+}
+
+static struct langwell_otg_timer *a_wait_vrise_tmr, *a_aidl_bdis_tmr,
+ *b_se0_srp_tmr, *b_srp_init_tmr;
+
+static struct list_head active_timers;
+
+static struct langwell_otg *the_transceiver;
+
+/* host/client notify transceiver when event affects HNP state */
+void langwell_update_transceiver(void)
+{
+ struct langwell_otg *lnw = the_transceiver;
+
+ dev_dbg(lnw->dev, "transceiver is updated\n");
+
+ if (!lnw->qwork)
+ return ;
+
+ queue_work(lnw->qwork, &lnw->work);
+}
+EXPORT_SYMBOL(langwell_update_transceiver);
+
+static int langwell_otg_set_host(struct otg_transceiver *otg,
+ struct usb_bus *host)
+{
+ otg->host = host;
+
+ return 0;
+}
+
+static int langwell_otg_set_peripheral(struct otg_transceiver *otg,
+ struct usb_gadget *gadget)
+{
+ otg->gadget = gadget;
+
+ return 0;
+}
+
+static int langwell_otg_set_power(struct otg_transceiver *otg,
+ unsigned mA)
+{
+ return 0;
+}
+
+/* A-device drives vbus, controlled through PMIC CHRGCNTL register*/
+static int langwell_otg_set_vbus(struct otg_transceiver *otg, bool enabled)
+{
+ struct langwell_otg *lnw = the_transceiver;
+ u8 r;
+
+ dev_dbg(lnw->dev, "%s <--- %s\n", __func__, enabled ? "on" : "off");
+
+ /* FIXME: surely we should cache this on the first read. If not use
+ readv to avoid two transactions */
+ if (intel_scu_ipc_ioread8(0x00, &r) < 0) {
+ dev_dbg(lnw->dev, "Failed to read PMIC register 0xD2");
+ return -EBUSY;
+ }
+ if ((r & 0x03) != 0x02) {
+ dev_dbg(lnw->dev, "not NEC PMIC attached\n");
+ return -EBUSY;
+ }
+
+ if (intel_scu_ipc_ioread8(0x20, &r) < 0) {
+ dev_dbg(lnw->dev, "Failed to read PMIC register 0xD2");
+ return -EBUSY;
+ }
+
+ if ((r & 0x20) == 0) {
+ dev_dbg(lnw->dev, "no battery attached\n");
+ return -EBUSY;
+ }
+
+ /* Workaround for battery attachment issue */
+ if (r == 0x34) {
+ dev_dbg(lnw->dev, "no battery attached on SH\n");
+ return -EBUSY;
+ }
+
+ dev_dbg(lnw->dev, "battery attached. 2 reg = %x\n", r);
+
+ /* workaround: FW detect writing 0x20/0xc0 to d4 event.
+ * this is only for NEC PMIC.
+ */
+
+ if (intel_scu_ipc_iowrite8(0xD4, enabled ? 0x20 : 0xC0))
+ dev_dbg(lnw->dev, "Failed to write PMIC.\n");
+
+ dev_dbg(lnw->dev, "%s --->\n", __func__);
+
+ return 0;
+}
+
+/* charge vbus or discharge vbus through a resistor to ground */
+static void langwell_otg_chrg_vbus(int on)
+{
+ struct langwell_otg *lnw = the_transceiver;
+ u32 val;
+
+ val = readl(lnw->iotg.base + CI_OTGSC);
+
+ if (on)
+ writel((val & ~OTGSC_INTSTS_MASK) | OTGSC_VC,
+ lnw->iotg.base + CI_OTGSC);
+ else
+ writel((val & ~OTGSC_INTSTS_MASK) | OTGSC_VD,
+ lnw->iotg.base + CI_OTGSC);
+}
+
+/* Start SRP */
+static int langwell_otg_start_srp(struct otg_transceiver *otg)
+{
+ struct langwell_otg *lnw = the_transceiver;
+ struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
+ u32 val;
+
+ dev_dbg(lnw->dev, "%s --->\n", __func__);
+
+ val = readl(iotg->base + CI_OTGSC);
+
+ writel((val & ~OTGSC_INTSTS_MASK) | OTGSC_HADP,
+ iotg->base + CI_OTGSC);
+
+ /* Check if the data plus is finished or not */
+ msleep(8);
+ val = readl(iotg->base + CI_OTGSC);
+ if (val & (OTGSC_HADP | OTGSC_DP))
+ dev_dbg(lnw->dev, "DataLine SRP Error\n");
+
+ /* Disable interrupt - b_sess_vld */
+ val = readl(iotg->base + CI_OTGSC);
+ val &= (~(OTGSC_BSVIE | OTGSC_BSEIE));
+ writel(val, iotg->base + CI_OTGSC);
+
+ /* Start VBus SRP, drive vbus to generate VBus pulse */
+ iotg->otg.set_vbus(&iotg->otg, true);
+ msleep(15);
+ iotg->otg.set_vbus(&iotg->otg, false);
+
+ /* Enable interrupt - b_sess_vld*/
+ val = readl(iotg->base + CI_OTGSC);
+ dev_dbg(lnw->dev, "after VBUS pulse otgsc = %x\n", val);
+
+ val |= (OTGSC_BSVIE | OTGSC_BSEIE);
+ writel(val, iotg->base + CI_OTGSC);
+
+ /* If Vbus is valid, then update the hsm */
+ if (val & OTGSC_BSV) {
+ dev_dbg(lnw->dev, "no b_sess_vld interrupt\n");
+
+ lnw->iotg.hsm.b_sess_vld = 1;
+ langwell_update_transceiver();
+ }
+
+ dev_dbg(lnw->dev, "%s <---\n", __func__);
+ return 0;
+}
+
+/* stop SOF via bus_suspend */
+static void langwell_otg_loc_sof(int on)
+{
+ struct langwell_otg *lnw = the_transceiver;
+ struct usb_hcd *hcd;
+ int err;
+
+ dev_dbg(lnw->dev, "%s ---> %s\n", __func__, on ? "suspend" : "resume");
+
+ hcd = bus_to_hcd(lnw->iotg.otg.host);
+ if (on)
+ err = hcd->driver->bus_resume(hcd);
+ else
+ err = hcd->driver->bus_suspend(hcd);
+
+ if (err)
+ dev_dbg(lnw->dev, "Fail to resume/suspend USB bus - %d\n", err);
+
+ dev_dbg(lnw->dev, "%s <---\n", __func__);
+}
+
+static int langwell_otg_check_otgsc(void)
+{
+ struct langwell_otg *lnw = the_transceiver;
+ u32 otgsc, usbcfg;
+
+ dev_dbg(lnw->dev, "check sync OTGSC and USBCFG registers\n");
+
+ otgsc = readl(lnw->iotg.base + CI_OTGSC);
+ usbcfg = readl(lnw->usbcfg);
+
+ dev_dbg(lnw->dev, "OTGSC = %08x, USBCFG = %08x\n",
+ otgsc, usbcfg);
+ dev_dbg(lnw->dev, "OTGSC_AVV = %d\n", !!(otgsc & OTGSC_AVV));
+ dev_dbg(lnw->dev, "USBCFG.VBUSVAL = %d\n",
+ !!(usbcfg & USBCFG_VBUSVAL));
+ dev_dbg(lnw->dev, "OTGSC_ASV = %d\n", !!(otgsc & OTGSC_ASV));
+ dev_dbg(lnw->dev, "USBCFG.AVALID = %d\n",
+ !!(usbcfg & USBCFG_AVALID));
+ dev_dbg(lnw->dev, "OTGSC_BSV = %d\n", !!(otgsc & OTGSC_BSV));
+ dev_dbg(lnw->dev, "USBCFG.BVALID = %d\n",
+ !!(usbcfg & USBCFG_BVALID));
+ dev_dbg(lnw->dev, "OTGSC_BSE = %d\n", !!(otgsc & OTGSC_BSE));
+ dev_dbg(lnw->dev, "USBCFG.SESEND = %d\n",
+ !!(usbcfg & USBCFG_SESEND));
+
+ /* Check USBCFG VBusValid/AValid/BValid/SessEnd */
+ if (!!(otgsc & OTGSC_AVV) ^ !!(usbcfg & USBCFG_VBUSVAL)) {
+ dev_dbg(lnw->dev, "OTGSC.AVV != USBCFG.VBUSVAL\n");
+ goto err;
+ }
+ if (!!(otgsc & OTGSC_ASV) ^ !!(usbcfg & USBCFG_AVALID)) {
+ dev_dbg(lnw->dev, "OTGSC.ASV != USBCFG.AVALID\n");
+ goto err;
+ }
+ if (!!(otgsc & OTGSC_BSV) ^ !!(usbcfg & USBCFG_BVALID)) {
+ dev_dbg(lnw->dev, "OTGSC.BSV != USBCFG.BVALID\n");
+ goto err;
+ }
+ if (!!(otgsc & OTGSC_BSE) ^ !!(usbcfg & USBCFG_SESEND)) {
+ dev_dbg(lnw->dev, "OTGSC.BSE != USBCFG.SESSEN\n");
+ goto err;
+ }
+
+ dev_dbg(lnw->dev, "OTGSC and USBCFG are synced\n");
+
+ return 0;
+
+err:
+ dev_warn(lnw->dev, "OTGSC isn't equal to USBCFG\n");
+ return -EPIPE;
+}
+
+
+static void langwell_otg_phy_low_power(int on)
+{
+ struct langwell_otg *lnw = the_transceiver;
+ struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
+ u8 val, phcd;
+ int retval;
+
+ dev_dbg(lnw->dev, "%s ---> %s mode\n",
+ __func__, on ? "Low power" : "Normal");
+
+ phcd = 0x40;
+
+ val = readb(iotg->base + CI_HOSTPC1 + 2);
+
+ if (on) {
+ /* Due to hardware issue, after set PHCD, sync will failed
+ * between USBCFG and OTGSC, so before set PHCD, check if
+ * sync is in process now. If the answer is "yes", then do
+ * not touch PHCD bit */
+ retval = langwell_otg_check_otgsc();
+ if (retval) {
+ dev_dbg(lnw->dev, "Skip PHCD programming..\n");
+ return ;
+ }
+
+ writeb(val | phcd, iotg->base + CI_HOSTPC1 + 2);
+ } else
+ writeb(val & ~phcd, iotg->base + CI_HOSTPC1 + 2);
+
+ dev_dbg(lnw->dev, "%s <--- done\n", __func__);
+}
+
+/* After drv vbus, add 2 ms delay to set PHCD */
+static void langwell_otg_phy_low_power_wait(int on)
+{
+ struct langwell_otg *lnw = the_transceiver;
+
+ dev_dbg(lnw->dev, "add 2ms delay before programing PHCD\n");
+
+ mdelay(2);
+ langwell_otg_phy_low_power(on);
+}
+
+/* Enable/Disable OTG interrupt */
+static void langwell_otg_intr(int on)
+{
+ struct langwell_otg *lnw = the_transceiver;
+ struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
+ u32 val;
+
+ dev_dbg(lnw->dev, "%s ---> %s\n", __func__, on ? "on" : "off");
+
+ val = readl(iotg->base + CI_OTGSC);
+
+ /* OTGSC_INT_MASK doesn't contains 1msInt */
+ if (on) {
+ val = val | (OTGSC_INT_MASK);
+ writel(val, iotg->base + CI_OTGSC);
+ } else {
+ val = val & ~(OTGSC_INT_MASK);
+ writel(val, iotg->base + CI_OTGSC);
+ }
+
+ dev_dbg(lnw->dev, "%s <---\n", __func__);
+}
+
+/* set HAAR: Hardware Assist Auto-Reset */
+static void langwell_otg_HAAR(int on)
+{
+ struct langwell_otg *lnw = the_transceiver;
+ struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
+ u32 val;
+
+ dev_dbg(lnw->dev, "%s ---> %s\n", __func__, on ? "on" : "off");
+
+ val = readl(iotg->base + CI_OTGSC);
+ if (on)
+ writel((val & ~OTGSC_INTSTS_MASK) | OTGSC_HAAR,
+ iotg->base + CI_OTGSC);
+ else
+ writel((val & ~OTGSC_INTSTS_MASK) & ~OTGSC_HAAR,
+ iotg->base + CI_OTGSC);
+
+ dev_dbg(lnw->dev, "%s <---\n", __func__);
+}
+
+/* set HABA: Hardware Assist B-Disconnect to A-Connect */
+static void langwell_otg_HABA(int on)
+{
+ struct langwell_otg *lnw = the_transceiver;
+ struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
+ u32 val;
+
+ dev_dbg(lnw->dev, "%s ---> %s\n", __func__, on ? "on" : "off");
+
+ val = readl(iotg->base + CI_OTGSC);
+ if (on)
+ writel((val & ~OTGSC_INTSTS_MASK) | OTGSC_HABA,
+ iotg->base + CI_OTGSC);
+ else
+ writel((val & ~OTGSC_INTSTS_MASK) & ~OTGSC_HABA,
+ iotg->base + CI_OTGSC);
+
+ dev_dbg(lnw->dev, "%s <---\n", __func__);
+}
+
+static int langwell_otg_check_se0_srp(int on)
+{
+ struct langwell_otg *lnw = the_transceiver;
+ int delay_time = TB_SE0_SRP * 10;
+ u32 val;
+
+ dev_dbg(lnw->dev, "%s --->\n", __func__);
+
+ do {
+ udelay(100);
+ if (!delay_time--)
+ break;
+ val = readl(lnw->iotg.base + CI_PORTSC1);
+ val &= PORTSC_LS;
+ } while (!val);
+
+ dev_dbg(lnw->dev, "%s <---\n", __func__);
+ return val;
+}
+
+/* The timeout callback function to set time out bit */
+static void set_tmout(unsigned long indicator)
+{
+ *(int *)indicator = 1;
+}
+
+void langwell_otg_nsf_msg(unsigned long indicator)
+{
+ struct langwell_otg *lnw = the_transceiver;
+
+ switch (indicator) {
+ case 2:
+ case 4:
+ case 6:
+ case 7:
+ dev_warn(lnw->dev,
+ "OTG:NSF-%lu - deivce not responding\n", indicator);
+ break;
+ case 3:
+ dev_warn(lnw->dev,
+ "OTG:NSF-%lu - deivce not supported\n", indicator);
+ break;
+ default:
+ dev_warn(lnw->dev, "Do not have this kind of NSF\n");
+ break;
+ }
+}
+
+/* Initialize timers */
+static int langwell_otg_init_timers(struct otg_hsm *hsm)
+{
+ /* HSM used timers */
+ a_wait_vrise_tmr = otg_timer_initializer(&set_tmout, TA_WAIT_VRISE,
+ (unsigned long)&hsm->a_wait_vrise_tmout);
+ if (a_wait_vrise_tmr == NULL)
+ return -ENOMEM;
+ a_aidl_bdis_tmr = otg_timer_initializer(&set_tmout, TA_AIDL_BDIS,
+ (unsigned long)&hsm->a_aidl_bdis_tmout);
+ if (a_aidl_bdis_tmr == NULL)
+ return -ENOMEM;
+ b_se0_srp_tmr = otg_timer_initializer(&set_tmout, TB_SE0_SRP,
+ (unsigned long)&hsm->b_se0_srp);
+ if (b_se0_srp_tmr == NULL)
+ return -ENOMEM;
+ b_srp_init_tmr = otg_timer_initializer(&set_tmout, TB_SRP_INIT,
+ (unsigned long)&hsm->b_srp_init_tmout);
+ if (b_srp_init_tmr == NULL)
+ return -ENOMEM;
+
+ return 0;
+}
+
+/* Free timers */
+static void langwell_otg_free_timers(void)
+{
+ kfree(a_wait_vrise_tmr);
+ kfree(a_aidl_bdis_tmr);
+ kfree(b_se0_srp_tmr);
+ kfree(b_srp_init_tmr);
+}
+
+/* The timeout callback function to set time out bit */
+static void langwell_otg_timer_fn(unsigned long indicator)
+{
+ struct langwell_otg *lnw = the_transceiver;
+
+ *(int *)indicator = 1;
+
+ dev_dbg(lnw->dev, "kernel timer - timeout\n");
+
+ langwell_update_transceiver();
+}
+
+/* kernel timer used instead of HW based interrupt */
+static void langwell_otg_add_ktimer(enum langwell_otg_timer_type timers)
+{
+ struct langwell_otg *lnw = the_transceiver;
+ struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
+ unsigned long j = jiffies;
+ unsigned long data, time;
+
+ switch (timers) {
+ case TA_WAIT_VRISE_TMR:
+ iotg->hsm.a_wait_vrise_tmout = 0;
+ data = (unsigned long)&iotg->hsm.a_wait_vrise_tmout;
+ time = TA_WAIT_VRISE;
+ break;
+ case TA_WAIT_BCON_TMR:
+ iotg->hsm.a_wait_bcon_tmout = 0;
+ data = (unsigned long)&iotg->hsm.a_wait_bcon_tmout;
+ time = TA_WAIT_BCON;
+ break;
+ case TA_AIDL_BDIS_TMR:
+ iotg->hsm.a_aidl_bdis_tmout = 0;
+ data = (unsigned long)&iotg->hsm.a_aidl_bdis_tmout;
+ time = TA_AIDL_BDIS;
+ break;
+ case TB_ASE0_BRST_TMR:
+ iotg->hsm.b_ase0_brst_tmout = 0;
+ data = (unsigned long)&iotg->hsm.b_ase0_brst_tmout;
+ time = TB_ASE0_BRST;
+ break;
+ case TB_SRP_INIT_TMR:
+ iotg->hsm.b_srp_init_tmout = 0;
+ data = (unsigned long)&iotg->hsm.b_srp_init_tmout;
+ time = TB_SRP_INIT;
+ break;
+ case TB_SRP_FAIL_TMR:
+ iotg->hsm.b_srp_fail_tmout = 0;
+ data = (unsigned long)&iotg->hsm.b_srp_fail_tmout;
+ time = TB_SRP_FAIL;
+ break;
+ case TB_BUS_SUSPEND_TMR:
+ iotg->hsm.b_bus_suspend_tmout = 0;
+ data = (unsigned long)&iotg->hsm.b_bus_suspend_tmout;
+ time = TB_BUS_SUSPEND;
+ break;
+ default:
+ dev_dbg(lnw->dev, "unkown timer, cannot enable it\n");
+ return;
+ }
+
+ lnw->hsm_timer.data = data;
+ lnw->hsm_timer.function = langwell_otg_timer_fn;
+ lnw->hsm_timer.expires = j + time * HZ / 1000; /* milliseconds */
+
+ add_timer(&lnw->hsm_timer);
+
+ dev_dbg(lnw->dev, "add timer successfully\n");
+}
+
+/* Add timer to timer list */
+static void langwell_otg_add_timer(void *gtimer)
+{
+ struct langwell_otg_timer *timer = (struct langwell_otg_timer *)gtimer;
+ struct langwell_otg_timer *tmp_timer;
+ struct intel_mid_otg_xceiv *iotg = &the_transceiver->iotg;
+ u32 val32;
+
+ /* Check if the timer is already in the active list,
+ * if so update timer count
+ */
+ list_for_each_entry(tmp_timer, &active_timers, list)
+ if (tmp_timer == timer) {
+ timer->count = timer->expires;
+ return;
+ }
+ timer->count = timer->expires;
+
+ if (list_empty(&active_timers)) {
+ val32 = readl(iotg->base + CI_OTGSC);
+ writel(val32 | OTGSC_1MSE, iotg->base + CI_OTGSC);
+ }
+
+ list_add_tail(&timer->list, &active_timers);
+}
+
+/* Remove timer from the timer list; clear timeout status */
+static void langwell_otg_del_timer(void *gtimer)
+{
+ struct langwell_otg *lnw = the_transceiver;
+ struct langwell_otg_timer *timer = (struct langwell_otg_timer *)gtimer;
+ struct langwell_otg_timer *tmp_timer, *del_tmp;
+ u32 val32;
+
+ list_for_each_entry_safe(tmp_timer, del_tmp, &active_timers, list)
+ if (tmp_timer == timer)
+ list_del(&timer->list);
+
+ if (list_empty(&active_timers)) {
+ val32 = readl(lnw->iotg.base + CI_OTGSC);
+ writel(val32 & ~OTGSC_1MSE, lnw->iotg.base + CI_OTGSC);
+ }
+}
+
+/* Reduce timer count by 1, and find timeout conditions.*/
+static int langwell_otg_tick_timer(u32 *int_sts)
+{
+ struct langwell_otg *lnw = the_transceiver;
+ struct langwell_otg_timer *tmp_timer, *del_tmp;
+ int expired = 0;
+
+ list_for_each_entry_safe(tmp_timer, del_tmp, &active_timers, list) {
+ tmp_timer->count--;
+ /* check if timer expires */
+ if (!tmp_timer->count) {
+ list_del(&tmp_timer->list);
+ tmp_timer->function(tmp_timer->data);
+ expired = 1;
+ }
+ }
+
+ if (list_empty(&active_timers)) {
+ dev_dbg(lnw->dev, "tick timer: disable 1ms int\n");
+ *int_sts = *int_sts & ~OTGSC_1MSE;
+ }
+ return expired;
+}
+
+static void reset_otg(void)
+{
+ struct langwell_otg *lnw = the_transceiver;
+ int delay_time = 1000;
+ u32 val;
+
+ dev_dbg(lnw->dev, "reseting OTG controller ...\n");
+ val = readl(lnw->iotg.base + CI_USBCMD);
+ writel(val | USBCMD_RST, lnw->iotg.base + CI_USBCMD);
+ do {
+ udelay(100);
+ if (!delay_time--)
+ dev_dbg(lnw->dev, "reset timeout\n");
+ val = readl(lnw->iotg.base + CI_USBCMD);
+ val &= USBCMD_RST;
+ } while (val != 0);
+ dev_dbg(lnw->dev, "reset done.\n");
+}
+
+static void set_host_mode(void)
+{
+ struct langwell_otg *lnw = the_transceiver;
+ u32 val;
+
+ reset_otg();
+ val = readl(lnw->iotg.base + CI_USBMODE);
+ val = (val & (~USBMODE_CM)) | USBMODE_HOST;
+ writel(val, lnw->iotg.base + CI_USBMODE);
+}
+
+static void set_client_mode(void)
+{
+ struct langwell_otg *lnw = the_transceiver;
+ u32 val;
+
+ reset_otg();
+ val = readl(lnw->iotg.base + CI_USBMODE);
+ val = (val & (~USBMODE_CM)) | USBMODE_DEVICE;
+ writel(val, lnw->iotg.base + CI_USBMODE);
+}
+
+static void init_hsm(void)
+{
+ struct langwell_otg *lnw = the_transceiver;
+ struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
+ u32 val32;
+
+ /* read OTGSC after reset */
+ val32 = readl(lnw->iotg.base + CI_OTGSC);
+ dev_dbg(lnw->dev, "%s: OTGSC init value = 0x%x\n", __func__, val32);
+
+ /* set init state */
+ if (val32 & OTGSC_ID) {
+ iotg->hsm.id = 1;
+ iotg->otg.default_a = 0;
+ set_client_mode();
+ iotg->otg.state = OTG_STATE_B_IDLE;
+ } else {
+ iotg->hsm.id = 0;
+ iotg->otg.default_a = 1;
+ set_host_mode();
+ iotg->otg.state = OTG_STATE_A_IDLE;
+ }
+
+ /* set session indicator */
+ if (val32 & OTGSC_BSE)
+ iotg->hsm.b_sess_end = 1;
+ if (val32 & OTGSC_BSV)
+ iotg->hsm.b_sess_vld = 1;
+ if (val32 & OTGSC_ASV)
+ iotg->hsm.a_sess_vld = 1;
+ if (val32 & OTGSC_AVV)
+ iotg->hsm.a_vbus_vld = 1;
+
+ /* defautly power the bus */
+ iotg->hsm.a_bus_req = 1;
+ iotg->hsm.a_bus_drop = 0;
+ /* defautly don't request bus as B device */
+ iotg->hsm.b_bus_req = 0;
+ /* no system error */
+ iotg->hsm.a_clr_err = 0;
+
+ langwell_otg_phy_low_power_wait(1);
+}
+
+static void update_hsm(void)
+{
+ struct langwell_otg *lnw = the_transceiver;
+ struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
+ u32 val32;
+
+ /* read OTGSC */
+ val32 = readl(lnw->iotg.base + CI_OTGSC);
+ dev_dbg(lnw->dev, "%s: OTGSC value = 0x%x\n", __func__, val32);
+
+ iotg->hsm.id = !!(val32 & OTGSC_ID);
+ iotg->hsm.b_sess_end = !!(val32 & OTGSC_BSE);
+ iotg->hsm.b_sess_vld = !!(val32 & OTGSC_BSV);
+ iotg->hsm.a_sess_vld = !!(val32 & OTGSC_ASV);
+ iotg->hsm.a_vbus_vld = !!(val32 & OTGSC_AVV);
+}
+
+static irqreturn_t otg_dummy_irq(int irq, void *_dev)
+{
+ struct langwell_otg *lnw = the_transceiver;
+ void __iomem *reg_base = _dev;
+ u32 val;
+ u32 int_mask = 0;
+
+ val = readl(reg_base + CI_USBMODE);
+ if ((val & USBMODE_CM) != USBMODE_DEVICE)
+ return IRQ_NONE;
+
+ val = readl(reg_base + CI_USBSTS);
+ int_mask = val & INTR_DUMMY_MASK;
+
+ if (int_mask == 0)
+ return IRQ_NONE;
+
+ /* clear hsm.b_conn here since host driver can't detect it
+ * otg_dummy_irq called means B-disconnect happened.
+ */
+ if (lnw->iotg.hsm.b_conn) {
+ lnw->iotg.hsm.b_conn = 0;
+ if (spin_trylock(&lnw->wq_lock)) {
+ langwell_update_transceiver();
+ spin_unlock(&lnw->wq_lock);
+ }
+ }
+
+ /* Clear interrupts */
+ writel(int_mask, reg_base + CI_USBSTS);
+ return IRQ_HANDLED;
+}
+
+static irqreturn_t otg_irq(int irq, void *_dev)
+{
+ struct langwell_otg *lnw = _dev;
+ struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
+ u32 int_sts, int_en;
+ u32 int_mask = 0;
+ int flag = 0;
+
+ int_sts = readl(lnw->iotg.base + CI_OTGSC);
+ int_en = (int_sts & OTGSC_INTEN_MASK) >> 8;
+ int_mask = int_sts & int_en;
+ if (int_mask == 0)
+ return IRQ_NONE;
+
+ if (int_mask & OTGSC_IDIS) {
+ dev_dbg(lnw->dev, "%s: id change int\n", __func__);
+ iotg->hsm.id = (int_sts & OTGSC_ID) ? 1 : 0;
+ dev_dbg(lnw->dev, "id = %d\n", iotg->hsm.id);
+ flag = 1;
+ }
+ if (int_mask & OTGSC_DPIS) {
+ dev_dbg(lnw->dev, "%s: data pulse int\n", __func__);
+ iotg->hsm.a_srp_det = (int_sts & OTGSC_DPS) ? 1 : 0;
+ dev_dbg(lnw->dev, "data pulse = %d\n", iotg->hsm.a_srp_det);
+ flag = 1;
+ }
+ if (int_mask & OTGSC_BSEIS) {
+ dev_dbg(lnw->dev, "%s: b session end int\n", __func__);
+ iotg->hsm.b_sess_end = (int_sts & OTGSC_BSE) ? 1 : 0;
+ dev_dbg(lnw->dev, "b_sess_end = %d\n", iotg->hsm.b_sess_end);
+ flag = 1;
+ }
+ if (int_mask & OTGSC_BSVIS) {
+ dev_dbg(lnw->dev, "%s: b session valid int\n", __func__);
+ iotg->hsm.b_sess_vld = (int_sts & OTGSC_BSV) ? 1 : 0;
+ dev_dbg(lnw->dev, "b_sess_vld = %d\n", iotg->hsm.b_sess_end);
+ flag = 1;
+ }
+ if (int_mask & OTGSC_ASVIS) {
+ dev_dbg(lnw->dev, "%s: a session valid int\n", __func__);
+ iotg->hsm.a_sess_vld = (int_sts & OTGSC_ASV) ? 1 : 0;
+ dev_dbg(lnw->dev, "a_sess_vld = %d\n", iotg->hsm.a_sess_vld);
+ flag = 1;
+ }
+ if (int_mask & OTGSC_AVVIS) {
+ dev_dbg(lnw->dev, "%s: a vbus valid int\n", __func__);
+ iotg->hsm.a_vbus_vld = (int_sts & OTGSC_AVV) ? 1 : 0;
+ dev_dbg(lnw->dev, "a_vbus_vld = %d\n", iotg->hsm.a_vbus_vld);
+ flag = 1;
+ }
+
+ if (int_mask & OTGSC_1MSS) {
+ /* need to schedule otg_work if any timer is expired */
+ if (langwell_otg_tick_timer(&int_sts))
+ flag = 1;
+ }
+
+ writel((int_sts & ~OTGSC_INTSTS_MASK) | int_mask,
+ lnw->iotg.base + CI_OTGSC);
+ if (flag)
+ langwell_update_transceiver();
+
+ return IRQ_HANDLED;
+}
+
+static int langwell_otg_iotg_notify(struct notifier_block *nb,
+ unsigned long action, void *data)
+{
+ struct langwell_otg *lnw = the_transceiver;
+ struct intel_mid_otg_xceiv *iotg = data;
+ int flag = 0;
+
+ if (iotg == NULL)
+ return NOTIFY_BAD;
+
+ if (lnw == NULL)
+ return NOTIFY_BAD;
+
+ switch (action) {
+ case MID_OTG_NOTIFY_CONNECT:
+ dev_dbg(lnw->dev, "Lnw OTG Notify Connect Event\n");
+ if (iotg->otg.default_a == 1)
+ iotg->hsm.b_conn = 1;
+ else
+ iotg->hsm.a_conn = 1;
+ flag = 1;
+ break;
+ case MID_OTG_NOTIFY_DISCONN:
+ dev_dbg(lnw->dev, "Lnw OTG Notify Disconnect Event\n");
+ if (iotg->otg.default_a == 1)
+ iotg->hsm.b_conn = 0;
+ else
+ iotg->hsm.a_conn = 0;
+ flag = 1;
+ break;
+ case MID_OTG_NOTIFY_HSUSPEND:
+ dev_dbg(lnw->dev, "Lnw OTG Notify Host Bus suspend Event\n");
+ if (iotg->otg.default_a == 1)
+ iotg->hsm.a_suspend_req = 1;
+ else
+ iotg->hsm.b_bus_req = 0;
+ flag = 1;
+ break;
+ case MID_OTG_NOTIFY_HRESUME:
+ dev_dbg(lnw->dev, "Lnw OTG Notify Host Bus resume Event\n");
+ if (iotg->otg.default_a == 1)
+ iotg->hsm.b_bus_resume = 1;
+ flag = 1;
+ break;
+ case MID_OTG_NOTIFY_CSUSPEND:
+ dev_dbg(lnw->dev, "Lnw OTG Notify Client Bus suspend Event\n");
+ if (iotg->otg.default_a == 1) {
+ if (iotg->hsm.b_bus_suspend_vld == 2) {
+ iotg->hsm.b_bus_suspend = 1;
+ iotg->hsm.b_bus_suspend_vld = 0;
+ flag = 1;
+ } else {
+ iotg->hsm.b_bus_suspend_vld++;
+ flag = 0;
+ }
+ } else {
+ if (iotg->hsm.a_bus_suspend == 0) {
+ iotg->hsm.a_bus_suspend = 1;
+ flag = 1;
+ }
+ }
+ break;
+ case MID_OTG_NOTIFY_CRESUME:
+ dev_dbg(lnw->dev, "Lnw OTG Notify Client Bus resume Event\n");
+ if (iotg->otg.default_a == 0)
+ iotg->hsm.a_bus_suspend = 0;
+ flag = 0;
+ break;
+ case MID_OTG_NOTIFY_HOSTADD:
+ dev_dbg(lnw->dev, "Lnw OTG Nofity Host Driver Add\n");
+ flag = 1;
+ break;
+ case MID_OTG_NOTIFY_HOSTREMOVE:
+ dev_dbg(lnw->dev, "Lnw OTG Nofity Host Driver remove\n");
+ flag = 1;
+ break;
+ case MID_OTG_NOTIFY_CLIENTADD:
+ dev_dbg(lnw->dev, "Lnw OTG Nofity Client Driver Add\n");
+ flag = 1;
+ break;
+ case MID_OTG_NOTIFY_CLIENTREMOVE:
+ dev_dbg(lnw->dev, "Lnw OTG Nofity Client Driver remove\n");
+ flag = 1;
+ break;
+ default:
+ dev_dbg(lnw->dev, "Lnw OTG Nofity unknown notify message\n");
+ return NOTIFY_DONE;
+ }
+
+ if (flag)
+ langwell_update_transceiver();
+
+ return NOTIFY_OK;
+}
+
+static void langwell_otg_work(struct work_struct *work)
+{
+ struct langwell_otg *lnw;
+ struct intel_mid_otg_xceiv *iotg;
+ int retval;
+ struct pci_dev *pdev;
+
+ lnw = container_of(work, struct langwell_otg, work);
+ iotg = &lnw->iotg;
+ pdev = to_pci_dev(lnw->dev);
+
+ dev_dbg(lnw->dev, "%s: old state = %s\n", __func__,
+ state_string(iotg->otg.state));
+
+ switch (iotg->otg.state) {
+ case OTG_STATE_UNDEFINED:
+ case OTG_STATE_B_IDLE:
+ if (!iotg->hsm.id) {
+ langwell_otg_del_timer(b_srp_init_tmr);
+ del_timer_sync(&lnw->hsm_timer);
+
+ iotg->otg.default_a = 1;
+ iotg->hsm.a_srp_det = 0;
+
+ langwell_otg_chrg_vbus(0);
+ set_host_mode();
+ langwell_otg_phy_low_power(1);
+
+ iotg->otg.state = OTG_STATE_A_IDLE;
+ langwell_update_transceiver();
+ } else if (iotg->hsm.b_sess_vld) {
+ langwell_otg_del_timer(b_srp_init_tmr);
+ del_timer_sync(&lnw->hsm_timer);
+ iotg->hsm.b_sess_end = 0;
+ iotg->hsm.a_bus_suspend = 0;
+ langwell_otg_chrg_vbus(0);
+
+ if (lnw->iotg.start_peripheral) {
+ lnw->iotg.start_peripheral(&lnw->iotg);
+ iotg->otg.state = OTG_STATE_B_PERIPHERAL;
+ } else
+ dev_dbg(lnw->dev, "client driver not loaded\n");
+
+ } else if (iotg->hsm.b_srp_init_tmout) {
+ iotg->hsm.b_srp_init_tmout = 0;
+ dev_warn(lnw->dev, "SRP init timeout\n");
+ } else if (iotg->hsm.b_srp_fail_tmout) {
+ iotg->hsm.b_srp_fail_tmout = 0;
+ iotg->hsm.b_bus_req = 0;
+
+ /* No silence failure */
+ langwell_otg_nsf_msg(6);
+ } else if (iotg->hsm.b_bus_req && iotg->hsm.b_sess_end) {
+ del_timer_sync(&lnw->hsm_timer);
+ /* workaround for b_se0_srp detection */
+ retval = langwell_otg_check_se0_srp(0);
+ if (retval) {
+ iotg->hsm.b_bus_req = 0;
+ dev_dbg(lnw->dev, "LS isn't SE0, try later\n");
+ } else {
+ /* clear the PHCD before start srp */
+ langwell_otg_phy_low_power(0);
+
+ /* Start SRP */
+ langwell_otg_add_timer(b_srp_init_tmr);
+ iotg->otg.start_srp(&iotg->otg);
+ langwell_otg_del_timer(b_srp_init_tmr);
+ langwell_otg_add_ktimer(TB_SRP_FAIL_TMR);
+
+ /* reset PHY low power mode here */
+ langwell_otg_phy_low_power_wait(1);
+ }
+ }
+ break;
+ case OTG_STATE_B_SRP_INIT:
+ if (!iotg->hsm.id) {
+ iotg->otg.default_a = 1;
+ iotg->hsm.a_srp_det = 0;
+
+ /* Turn off VBus */
+ iotg->otg.set_vbus(&iotg->otg, false);
+ langwell_otg_chrg_vbus(0);
+ set_host_mode();
+ langwell_otg_phy_low_power(1);
+ iotg->otg.state = OTG_STATE_A_IDLE;
+ langwell_update_transceiver();
+ } else if (iotg->hsm.b_sess_vld) {
+ langwell_otg_chrg_vbus(0);
+ if (lnw->iotg.start_peripheral) {
+ lnw->iotg.start_peripheral(&lnw->iotg);
+ iotg->otg.state = OTG_STATE_B_PERIPHERAL;
+ } else
+ dev_dbg(lnw->dev, "client driver not loaded\n");
+ }
+ break;
+ case OTG_STATE_B_PERIPHERAL:
+ if (!iotg->hsm.id) {
+ iotg->otg.default_a = 1;
+ iotg->hsm.a_srp_det = 0;
+
+ langwell_otg_chrg_vbus(0);
+
+ if (lnw->iotg.stop_peripheral)
+ lnw->iotg.stop_peripheral(&lnw->iotg);
+ else
+ dev_dbg(lnw->dev,
+ "client driver has been removed.\n");
+
+ set_host_mode();
+ langwell_otg_phy_low_power(1);
+ iotg->otg.state = OTG_STATE_A_IDLE;
+ langwell_update_transceiver();
+ } else if (!iotg->hsm.b_sess_vld) {
+ iotg->hsm.b_hnp_enable = 0;
+
+ if (lnw->iotg.stop_peripheral)
+ lnw->iotg.stop_peripheral(&lnw->iotg);
+ else
+ dev_dbg(lnw->dev,
+ "client driver has been removed.\n");
+
+ iotg->otg.state = OTG_STATE_B_IDLE;
+ } else if (iotg->hsm.b_bus_req && iotg->otg.gadget &&
+ iotg->otg.gadget->b_hnp_enable &&
+ iotg->hsm.a_bus_suspend) {
+
+ if (lnw->iotg.stop_peripheral)
+ lnw->iotg.stop_peripheral(&lnw->iotg);
+ else
+ dev_dbg(lnw->dev,
+ "client driver has been removed.\n");
+
+ langwell_otg_HAAR(1);
+ iotg->hsm.a_conn = 0;
+
+ if (lnw->iotg.start_host) {
+ lnw->iotg.start_host(&lnw->iotg);
+ iotg->otg.state = OTG_STATE_B_WAIT_ACON;
+ } else
+ dev_dbg(lnw->dev,
+ "host driver not loaded.\n");
+
+ iotg->hsm.a_bus_resume = 0;
+ langwell_otg_add_ktimer(TB_ASE0_BRST_TMR);
+ }
+ break;
+
+ case OTG_STATE_B_WAIT_ACON:
+ if (!iotg->hsm.id) {
+ /* delete hsm timer for b_ase0_brst_tmr */
+ del_timer_sync(&lnw->hsm_timer);
+
+ iotg->otg.default_a = 1;
+ iotg->hsm.a_srp_det = 0;
+
+ langwell_otg_chrg_vbus(0);
+
+ langwell_otg_HAAR(0);
+ if (lnw->iotg.stop_host)
+ lnw->iotg.stop_host(&lnw->iotg);
+ else
+ dev_dbg(lnw->dev,
+ "host driver has been removed.\n");
+
+ set_host_mode();
+ langwell_otg_phy_low_power(1);
+ iotg->otg.state = OTG_STATE_A_IDLE;
+ langwell_update_transceiver();
+ } else if (!iotg->hsm.b_sess_vld) {
+ /* delete hsm timer for b_ase0_brst_tmr */
+ del_timer_sync(&lnw->hsm_timer);
+
+ iotg->hsm.b_hnp_enable = 0;
+ iotg->hsm.b_bus_req = 0;
+
+ langwell_otg_chrg_vbus(0);
+ langwell_otg_HAAR(0);
+
+ if (lnw->iotg.stop_host)
+ lnw->iotg.stop_host(&lnw->iotg);
+ else
+ dev_dbg(lnw->dev,
+ "host driver has been removed.\n");
+
+ set_client_mode();
+ langwell_otg_phy_low_power(1);
+ iotg->otg.state = OTG_STATE_B_IDLE;
+ } else if (iotg->hsm.a_conn) {
+ /* delete hsm timer for b_ase0_brst_tmr */
+ del_timer_sync(&lnw->hsm_timer);
+
+ langwell_otg_HAAR(0);
+ iotg->otg.state = OTG_STATE_B_HOST;
+ langwell_update_transceiver();
+ } else if (iotg->hsm.a_bus_resume ||
+ iotg->hsm.b_ase0_brst_tmout) {
+ /* delete hsm timer for b_ase0_brst_tmr */
+ del_timer_sync(&lnw->hsm_timer);
+
+ langwell_otg_HAAR(0);
+ langwell_otg_nsf_msg(7);
+
+ if (lnw->iotg.stop_host)
+ lnw->iotg.stop_host(&lnw->iotg);
+ else
+ dev_dbg(lnw->dev,
+ "host driver has been removed.\n");
+
+ iotg->hsm.a_bus_suspend = 0;
+ iotg->hsm.b_bus_req = 0;
+
+ if (lnw->iotg.start_peripheral)
+ lnw->iotg.start_peripheral(&lnw->iotg);
+ else
+ dev_dbg(lnw->dev,
+ "client driver not loaded.\n");
+
+ iotg->otg.state = OTG_STATE_B_PERIPHERAL;
+ }
+ break;
+
+ case OTG_STATE_B_HOST:
+ if (!iotg->hsm.id) {
+ iotg->otg.default_a = 1;
+ iotg->hsm.a_srp_det = 0;
+
+ langwell_otg_chrg_vbus(0);
+
+ if (lnw->iotg.stop_host)
+ lnw->iotg.stop_host(&lnw->iotg);
+ else
+ dev_dbg(lnw->dev,
+ "host driver has been removed.\n");
+
+ set_host_mode();
+ langwell_otg_phy_low_power(1);
+ iotg->otg.state = OTG_STATE_A_IDLE;
+ langwell_update_transceiver();
+ } else if (!iotg->hsm.b_sess_vld) {
+ iotg->hsm.b_hnp_enable = 0;
+ iotg->hsm.b_bus_req = 0;
+
+ langwell_otg_chrg_vbus(0);
+ if (lnw->iotg.stop_host)
+ lnw->iotg.stop_host(&lnw->iotg);
+ else
+ dev_dbg(lnw->dev,
+ "host driver has been removed.\n");
+
+ set_client_mode();
+ langwell_otg_phy_low_power(1);
+ iotg->otg.state = OTG_STATE_B_IDLE;
+ } else if ((!iotg->hsm.b_bus_req) ||
+ (!iotg->hsm.a_conn)) {
+ iotg->hsm.b_bus_req = 0;
+ langwell_otg_loc_sof(0);
+
+ if (lnw->iotg.stop_host)
+ lnw->iotg.stop_host(&lnw->iotg);
+ else
+ dev_dbg(lnw->dev,
+ "host driver has been removed.\n");
+
+ iotg->hsm.a_bus_suspend = 0;
+
+ if (lnw->iotg.start_peripheral)
+ lnw->iotg.start_peripheral(&lnw->iotg);
+ else
+ dev_dbg(lnw->dev,
+ "client driver not loaded.\n");
+
+ iotg->otg.state = OTG_STATE_B_PERIPHERAL;
+ }
+ break;
+
+ case OTG_STATE_A_IDLE:
+ iotg->otg.default_a = 1;
+ if (iotg->hsm.id) {
+ iotg->otg.default_a = 0;
+ iotg->hsm.b_bus_req = 0;
+ iotg->hsm.vbus_srp_up = 0;
+
+ langwell_otg_chrg_vbus(0);
+ set_client_mode();
+ langwell_otg_phy_low_power(1);
+ iotg->otg.state = OTG_STATE_B_IDLE;
+ langwell_update_transceiver();
+ } else if (!iotg->hsm.a_bus_drop &&
+ (iotg->hsm.a_srp_det || iotg->hsm.a_bus_req)) {
+ langwell_otg_phy_low_power(0);
+
+ /* Turn on VBus */
+ iotg->otg.set_vbus(&iotg->otg, true);
+
+ iotg->hsm.vbus_srp_up = 0;
+ iotg->hsm.a_wait_vrise_tmout = 0;
+ langwell_otg_add_timer(a_wait_vrise_tmr);
+ iotg->otg.state = OTG_STATE_A_WAIT_VRISE;
+ langwell_update_transceiver();
+ } else if (!iotg->hsm.a_bus_drop && iotg->hsm.a_sess_vld) {
+ iotg->hsm.vbus_srp_up = 1;
+ } else if (!iotg->hsm.a_sess_vld && iotg->hsm.vbus_srp_up) {
+ msleep(10);
+ langwell_otg_phy_low_power(0);
+
+ /* Turn on VBus */
+ iotg->otg.set_vbus(&iotg->otg, true);
+ iotg->hsm.a_srp_det = 1;
+ iotg->hsm.vbus_srp_up = 0;
+ iotg->hsm.a_wait_vrise_tmout = 0;
+ langwell_otg_add_timer(a_wait_vrise_tmr);
+ iotg->otg.state = OTG_STATE_A_WAIT_VRISE;
+ langwell_update_transceiver();
+ } else if (!iotg->hsm.a_sess_vld &&
+ !iotg->hsm.vbus_srp_up) {
+ langwell_otg_phy_low_power(1);
+ }
+ break;
+ case OTG_STATE_A_WAIT_VRISE:
+ if (iotg->hsm.id) {
+ langwell_otg_del_timer(a_wait_vrise_tmr);
+ iotg->hsm.b_bus_req = 0;
+ iotg->otg.default_a = 0;
+
+ /* Turn off VBus */
+ iotg->otg.set_vbus(&iotg->otg, false);
+ set_client_mode();
+ langwell_otg_phy_low_power_wait(1);
+ iotg->otg.state = OTG_STATE_B_IDLE;
+ } else if (iotg->hsm.a_vbus_vld) {
+ langwell_otg_del_timer(a_wait_vrise_tmr);
+ iotg->hsm.b_conn = 0;
+ if (lnw->iotg.start_host)
+ lnw->iotg.start_host(&lnw->iotg);
+ else {
+ dev_dbg(lnw->dev, "host driver not loaded.\n");
+ break;
+ }
+
+ langwell_otg_add_ktimer(TA_WAIT_BCON_TMR);
+ iotg->otg.state = OTG_STATE_A_WAIT_BCON;
+ } else if (iotg->hsm.a_wait_vrise_tmout) {
+ iotg->hsm.b_conn = 0;
+ if (iotg->hsm.a_vbus_vld) {
+ if (lnw->iotg.start_host)
+ lnw->iotg.start_host(&lnw->iotg);
+ else {
+ dev_dbg(lnw->dev,
+ "host driver not loaded.\n");
+ break;
+ }
+ langwell_otg_add_ktimer(TA_WAIT_BCON_TMR);
+ iotg->otg.state = OTG_STATE_A_WAIT_BCON;
+ } else {
+
+ /* Turn off VBus */
+ iotg->otg.set_vbus(&iotg->otg, false);
+ langwell_otg_phy_low_power_wait(1);
+ iotg->otg.state = OTG_STATE_A_VBUS_ERR;
+ }
+ }
+ break;
+ case OTG_STATE_A_WAIT_BCON:
+ if (iotg->hsm.id) {
+ /* delete hsm timer for a_wait_bcon_tmr */
+ del_timer_sync(&lnw->hsm_timer);
+
+ iotg->otg.default_a = 0;
+ iotg->hsm.b_bus_req = 0;
+
+ if (lnw->iotg.stop_host)
+ lnw->iotg.stop_host(&lnw->iotg);
+ else
+ dev_dbg(lnw->dev,
+ "host driver has been removed.\n");
+
+ /* Turn off VBus */
+ iotg->otg.set_vbus(&iotg->otg, false);
+ set_client_mode();
+ langwell_otg_phy_low_power_wait(1);
+ iotg->otg.state = OTG_STATE_B_IDLE;
+ langwell_update_transceiver();
+ } else if (!iotg->hsm.a_vbus_vld) {
+ /* delete hsm timer for a_wait_bcon_tmr */
+ del_timer_sync(&lnw->hsm_timer);
+
+ if (lnw->iotg.stop_host)
+ lnw->iotg.stop_host(&lnw->iotg);
+ else
+ dev_dbg(lnw->dev,
+ "host driver has been removed.\n");
+
+ /* Turn off VBus */
+ iotg->otg.set_vbus(&iotg->otg, false);
+ langwell_otg_phy_low_power_wait(1);
+ iotg->otg.state = OTG_STATE_A_VBUS_ERR;
+ } else if (iotg->hsm.a_bus_drop ||
+ (iotg->hsm.a_wait_bcon_tmout &&
+ !iotg->hsm.a_bus_req)) {
+ /* delete hsm timer for a_wait_bcon_tmr */
+ del_timer_sync(&lnw->hsm_timer);
+
+ if (lnw->iotg.stop_host)
+ lnw->iotg.stop_host(&lnw->iotg);
+ else
+ dev_dbg(lnw->dev,
+ "host driver has been removed.\n");
+
+ /* Turn off VBus */
+ iotg->otg.set_vbus(&iotg->otg, false);
+ iotg->otg.state = OTG_STATE_A_WAIT_VFALL;
+ } else if (iotg->hsm.b_conn) {
+ /* delete hsm timer for a_wait_bcon_tmr */
+ del_timer_sync(&lnw->hsm_timer);
+
+ iotg->hsm.a_suspend_req = 0;
+ iotg->otg.state = OTG_STATE_A_HOST;
+ if (iotg->hsm.a_srp_det && iotg->otg.host &&
+ !iotg->otg.host->b_hnp_enable) {
+ /* SRP capable peripheral-only device */
+ iotg->hsm.a_bus_req = 1;
+ iotg->hsm.a_srp_det = 0;
+ } else if (!iotg->hsm.a_bus_req && iotg->otg.host &&
+ iotg->otg.host->b_hnp_enable) {
+ /* It is not safe enough to do a fast
+ * transistion from A_WAIT_BCON to
+ * A_SUSPEND */
+ msleep(10000);
+ if (iotg->hsm.a_bus_req)
+ break;
+
+ if (request_irq(pdev->irq,
+ otg_dummy_irq, IRQF_SHARED,
+ driver_name, iotg->base) != 0) {
+ dev_dbg(lnw->dev,
+ "request interrupt %d fail\n",
+ pdev->irq);
+ }
+
+ langwell_otg_HABA(1);
+ iotg->hsm.b_bus_resume = 0;
+ iotg->hsm.a_aidl_bdis_tmout = 0;
+
+ langwell_otg_loc_sof(0);
+ /* clear PHCD to enable HW timer */
+ langwell_otg_phy_low_power(0);
+ langwell_otg_add_timer(a_aidl_bdis_tmr);
+ iotg->otg.state = OTG_STATE_A_SUSPEND;
+ } else if (!iotg->hsm.a_bus_req && iotg->otg.host &&
+ !iotg->otg.host->b_hnp_enable) {
+ if (lnw->iotg.stop_host)
+ lnw->iotg.stop_host(&lnw->iotg);
+ else
+ dev_dbg(lnw->dev,
+ "host driver removed.\n");
+
+ /* Turn off VBus */
+ iotg->otg.set_vbus(&iotg->otg, false);
+ iotg->otg.state = OTG_STATE_A_WAIT_VFALL;
+ }
+ }
+ break;
+ case OTG_STATE_A_HOST:
+ if (iotg->hsm.id) {
+ iotg->otg.default_a = 0;
+ iotg->hsm.b_bus_req = 0;
+
+ if (lnw->iotg.stop_host)
+ lnw->iotg.stop_host(&lnw->iotg);
+ else
+ dev_dbg(lnw->dev,
+ "host driver has been removed.\n");
+
+ /* Turn off VBus */
+ iotg->otg.set_vbus(&iotg->otg, false);
+ set_client_mode();
+ langwell_otg_phy_low_power_wait(1);
+ iotg->otg.state = OTG_STATE_B_IDLE;
+ langwell_update_transceiver();
+ } else if (iotg->hsm.a_bus_drop ||
+ (iotg->otg.host &&
+ !iotg->otg.host->b_hnp_enable &&
+ !iotg->hsm.a_bus_req)) {
+ if (lnw->iotg.stop_host)
+ lnw->iotg.stop_host(&lnw->iotg);
+ else
+ dev_dbg(lnw->dev,
+ "host driver has been removed.\n");
+
+ /* Turn off VBus */
+ iotg->otg.set_vbus(&iotg->otg, false);
+ iotg->otg.state = OTG_STATE_A_WAIT_VFALL;
+ } else if (!iotg->hsm.a_vbus_vld) {
+ if (lnw->iotg.stop_host)
+ lnw->iotg.stop_host(&lnw->iotg);
+ else
+ dev_dbg(lnw->dev,
+ "host driver has been removed.\n");
+
+ /* Turn off VBus */
+ iotg->otg.set_vbus(&iotg->otg, false);
+ langwell_otg_phy_low_power_wait(1);
+ iotg->otg.state = OTG_STATE_A_VBUS_ERR;
+ } else if (iotg->otg.host &&
+ iotg->otg.host->b_hnp_enable &&
+ !iotg->hsm.a_bus_req) {
+ /* Set HABA to enable hardware assistance to signal
+ * A-connect after receiver B-disconnect. Hardware
+ * will then set client mode and enable URE, SLE and
+ * PCE after the assistance. otg_dummy_irq is used to
+ * clean these ints when client driver is not resumed.
+ */
+ if (request_irq(pdev->irq, otg_dummy_irq, IRQF_SHARED,
+ driver_name, iotg->base) != 0) {
+ dev_dbg(lnw->dev,
+ "request interrupt %d failed\n",
+ pdev->irq);
+ }
+
+ /* set HABA */
+ langwell_otg_HABA(1);
+ iotg->hsm.b_bus_resume = 0;
+ iotg->hsm.a_aidl_bdis_tmout = 0;
+ langwell_otg_loc_sof(0);
+ /* clear PHCD to enable HW timer */
+ langwell_otg_phy_low_power(0);
+ langwell_otg_add_timer(a_aidl_bdis_tmr);
+ iotg->otg.state = OTG_STATE_A_SUSPEND;
+ } else if (!iotg->hsm.b_conn || !iotg->hsm.a_bus_req) {
+ langwell_otg_add_ktimer(TA_WAIT_BCON_TMR);
+ iotg->otg.state = OTG_STATE_A_WAIT_BCON;
+ }
+ break;
+ case OTG_STATE_A_SUSPEND:
+ if (iotg->hsm.id) {
+ langwell_otg_del_timer(a_aidl_bdis_tmr);
+ langwell_otg_HABA(0);
+ free_irq(pdev->irq, iotg->base);
+ iotg->otg.default_a = 0;
+ iotg->hsm.b_bus_req = 0;
+
+ if (lnw->iotg.stop_host)
+ lnw->iotg.stop_host(&lnw->iotg);
+ else
+ dev_dbg(lnw->dev,
+ "host driver has been removed.\n");
+
+ /* Turn off VBus */
+ iotg->otg.set_vbus(&iotg->otg, false);
+ set_client_mode();
+ langwell_otg_phy_low_power(1);
+ iotg->otg.state = OTG_STATE_B_IDLE;
+ langwell_update_transceiver();
+ } else if (iotg->hsm.a_bus_req ||
+ iotg->hsm.b_bus_resume) {
+ langwell_otg_del_timer(a_aidl_bdis_tmr);
+ langwell_otg_HABA(0);
+ free_irq(pdev->irq, iotg->base);
+ iotg->hsm.a_suspend_req = 0;
+ langwell_otg_loc_sof(1);
+ iotg->otg.state = OTG_STATE_A_HOST;
+ } else if (iotg->hsm.a_aidl_bdis_tmout ||
+ iotg->hsm.a_bus_drop) {
+ langwell_otg_del_timer(a_aidl_bdis_tmr);
+ langwell_otg_HABA(0);
+ free_irq(pdev->irq, iotg->base);
+ if (lnw->iotg.stop_host)
+ lnw->iotg.stop_host(&lnw->iotg);
+ else
+ dev_dbg(lnw->dev,
+ "host driver has been removed.\n");
+
+ /* Turn off VBus */
+ iotg->otg.set_vbus(&iotg->otg, false);
+ iotg->otg.state = OTG_STATE_A_WAIT_VFALL;
+ } else if (!iotg->hsm.b_conn && iotg->otg.host &&
+ iotg->otg.host->b_hnp_enable) {
+ langwell_otg_del_timer(a_aidl_bdis_tmr);
+ langwell_otg_HABA(0);
+ free_irq(pdev->irq, iotg->base);
+
+ if (lnw->iotg.stop_host)
+ lnw->iotg.stop_host(&lnw->iotg);
+ else
+ dev_dbg(lnw->dev,
+ "host driver has been removed.\n");
+
+ iotg->hsm.b_bus_suspend = 0;
+ iotg->hsm.b_bus_suspend_vld = 0;
+
+ /* msleep(200); */
+ if (lnw->iotg.start_peripheral)
+ lnw->iotg.start_peripheral(&lnw->iotg);
+ else
+ dev_dbg(lnw->dev,
+ "client driver not loaded.\n");
+
+ langwell_otg_add_ktimer(TB_BUS_SUSPEND_TMR);
+ iotg->otg.state = OTG_STATE_A_PERIPHERAL;
+ break;
+ } else if (!iotg->hsm.a_vbus_vld) {
+ langwell_otg_del_timer(a_aidl_bdis_tmr);
+ langwell_otg_HABA(0);
+ free_irq(pdev->irq, iotg->base);
+ if (lnw->iotg.stop_host)
+ lnw->iotg.stop_host(&lnw->iotg);
+ else
+ dev_dbg(lnw->dev,
+ "host driver has been removed.\n");
+
+ /* Turn off VBus */
+ iotg->otg.set_vbus(&iotg->otg, false);
+ langwell_otg_phy_low_power_wait(1);
+ iotg->otg.state = OTG_STATE_A_VBUS_ERR;
+ }
+ break;
+ case OTG_STATE_A_PERIPHERAL:
+ if (iotg->hsm.id) {
+ /* delete hsm timer for b_bus_suspend_tmr */
+ del_timer_sync(&lnw->hsm_timer);
+ iotg->otg.default_a = 0;
+ iotg->hsm.b_bus_req = 0;
+ if (lnw->iotg.stop_peripheral)
+ lnw->iotg.stop_peripheral(&lnw->iotg);
+ else
+ dev_dbg(lnw->dev,
+ "client driver has been removed.\n");
+
+ /* Turn off VBus */
+ iotg->otg.set_vbus(&iotg->otg, false);
+ set_client_mode();
+ langwell_otg_phy_low_power_wait(1);
+ iotg->otg.state = OTG_STATE_B_IDLE;
+ langwell_update_transceiver();
+ } else if (!iotg->hsm.a_vbus_vld) {
+ /* delete hsm timer for b_bus_suspend_tmr */
+ del_timer_sync(&lnw->hsm_timer);
+
+ if (lnw->iotg.stop_peripheral)
+ lnw->iotg.stop_peripheral(&lnw->iotg);
+ else
+ dev_dbg(lnw->dev,
+ "client driver has been removed.\n");
+
+ /* Turn off VBus */
+ iotg->otg.set_vbus(&iotg->otg, false);
+ langwell_otg_phy_low_power_wait(1);
+ iotg->otg.state = OTG_STATE_A_VBUS_ERR;
+ } else if (iotg->hsm.a_bus_drop) {
+ /* delete hsm timer for b_bus_suspend_tmr */
+ del_timer_sync(&lnw->hsm_timer);
+
+ if (lnw->iotg.stop_peripheral)
+ lnw->iotg.stop_peripheral(&lnw->iotg);
+ else
+ dev_dbg(lnw->dev,
+ "client driver has been removed.\n");
+
+ /* Turn off VBus */
+ iotg->otg.set_vbus(&iotg->otg, false);
+ iotg->otg.state = OTG_STATE_A_WAIT_VFALL;
+ } else if (iotg->hsm.b_bus_suspend) {
+ /* delete hsm timer for b_bus_suspend_tmr */
+ del_timer_sync(&lnw->hsm_timer);
+
+ if (lnw->iotg.stop_peripheral)
+ lnw->iotg.stop_peripheral(&lnw->iotg);
+ else
+ dev_dbg(lnw->dev,
+ "client driver has been removed.\n");
+
+ if (lnw->iotg.start_host)
+ lnw->iotg.start_host(&lnw->iotg);
+ else
+ dev_dbg(lnw->dev,
+ "host driver not loaded.\n");
+ langwell_otg_add_ktimer(TA_WAIT_BCON_TMR);
+ iotg->otg.state = OTG_STATE_A_WAIT_BCON;
+ } else if (iotg->hsm.b_bus_suspend_tmout) {
+ u32 val;
+ val = readl(lnw->iotg.base + CI_PORTSC1);
+ if (!(val & PORTSC_SUSP))
+ break;
+
+ if (lnw->iotg.stop_peripheral)
+ lnw->iotg.stop_peripheral(&lnw->iotg);
+ else
+ dev_dbg(lnw->dev,
+ "client driver has been removed.\n");
+
+ if (lnw->iotg.start_host)
+ lnw->iotg.start_host(&lnw->iotg);
+ else
+ dev_dbg(lnw->dev,
+ "host driver not loaded.\n");
+ langwell_otg_add_ktimer(TA_WAIT_BCON_TMR);
+ iotg->otg.state = OTG_STATE_A_WAIT_BCON;
+ }
+ break;
+ case OTG_STATE_A_VBUS_ERR:
+ if (iotg->hsm.id) {
+ iotg->otg.default_a = 0;
+ iotg->hsm.a_clr_err = 0;
+ iotg->hsm.a_srp_det = 0;
+ set_client_mode();
+ langwell_otg_phy_low_power(1);
+ iotg->otg.state = OTG_STATE_B_IDLE;
+ langwell_update_transceiver();
+ } else if (iotg->hsm.a_clr_err) {
+ iotg->hsm.a_clr_err = 0;
+ iotg->hsm.a_srp_det = 0;
+ reset_otg();
+ init_hsm();
+ if (iotg->otg.state == OTG_STATE_A_IDLE)
+ langwell_update_transceiver();
+ } else {
+ /* FW will clear PHCD bit when any VBus
+ * event detected. Reset PHCD to 1 again */
+ langwell_otg_phy_low_power(1);
+ }
+ break;
+ case OTG_STATE_A_WAIT_VFALL:
+ if (iotg->hsm.id) {
+ iotg->otg.default_a = 0;
+ set_client_mode();
+ langwell_otg_phy_low_power(1);
+ iotg->otg.state = OTG_STATE_B_IDLE;
+ langwell_update_transceiver();
+ } else if (iotg->hsm.a_bus_req) {
+
+ /* Turn on VBus */
+ iotg->otg.set_vbus(&iotg->otg, true);
+ iotg->hsm.a_wait_vrise_tmout = 0;
+ langwell_otg_add_timer(a_wait_vrise_tmr);
+ iotg->otg.state = OTG_STATE_A_WAIT_VRISE;
+ } else if (!iotg->hsm.a_sess_vld) {
+ iotg->hsm.a_srp_det = 0;
+ set_host_mode();
+ langwell_otg_phy_low_power(1);
+ iotg->otg.state = OTG_STATE_A_IDLE;
+ }
+ break;
+ default:
+ ;
+ }
+
+ dev_dbg(lnw->dev, "%s: new state = %s\n", __func__,
+ state_string(iotg->otg.state));
+}
+
+static ssize_t
+show_registers(struct device *_dev, struct device_attribute *attr, char *buf)
+{
+ struct langwell_otg *lnw = the_transceiver;
+ char *next;
+ unsigned size, t;
+
+ next = buf;
+ size = PAGE_SIZE;
+
+ t = scnprintf(next, size,
+ "\n"
+ "USBCMD = 0x%08x\n"
+ "USBSTS = 0x%08x\n"
+ "USBINTR = 0x%08x\n"
+ "ASYNCLISTADDR = 0x%08x\n"
+ "PORTSC1 = 0x%08x\n"
+ "HOSTPC1 = 0x%08x\n"
+ "OTGSC = 0x%08x\n"
+ "USBMODE = 0x%08x\n",
+ readl(lnw->iotg.base + 0x30),
+ readl(lnw->iotg.base + 0x34),
+ readl(lnw->iotg.base + 0x38),
+ readl(lnw->iotg.base + 0x48),
+ readl(lnw->iotg.base + 0x74),
+ readl(lnw->iotg.base + 0xb4),
+ readl(lnw->iotg.base + 0xf4),
+ readl(lnw->iotg.base + 0xf8)
+ );
+ size -= t;
+ next += t;
+
+ return PAGE_SIZE - size;
+}
+static DEVICE_ATTR(registers, S_IRUGO, show_registers, NULL);
+
+static ssize_t
+show_hsm(struct device *_dev, struct device_attribute *attr, char *buf)
+{
+ struct langwell_otg *lnw = the_transceiver;
+ struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
+ char *next;
+ unsigned size, t;
+
+ next = buf;
+ size = PAGE_SIZE;
+
+ if (iotg->otg.host)
+ iotg->hsm.a_set_b_hnp_en = iotg->otg.host->b_hnp_enable;
+
+ if (iotg->otg.gadget)
+ iotg->hsm.b_hnp_enable = iotg->otg.gadget->b_hnp_enable;
+
+ t = scnprintf(next, size,
+ "\n"
+ "current state = %s\n"
+ "a_bus_resume = \t%d\n"
+ "a_bus_suspend = \t%d\n"
+ "a_conn = \t%d\n"
+ "a_sess_vld = \t%d\n"
+ "a_srp_det = \t%d\n"
+ "a_vbus_vld = \t%d\n"
+ "b_bus_resume = \t%d\n"
+ "b_bus_suspend = \t%d\n"
+ "b_conn = \t%d\n"
+ "b_se0_srp = \t%d\n"
+ "b_sess_end = \t%d\n"
+ "b_sess_vld = \t%d\n"
+ "id = \t%d\n"
+ "a_set_b_hnp_en = \t%d\n"
+ "b_srp_done = \t%d\n"
+ "b_hnp_enable = \t%d\n"
+ "a_wait_vrise_tmout = \t%d\n"
+ "a_wait_bcon_tmout = \t%d\n"
+ "a_aidl_bdis_tmout = \t%d\n"
+ "b_ase0_brst_tmout = \t%d\n"
+ "a_bus_drop = \t%d\n"
+ "a_bus_req = \t%d\n"
+ "a_clr_err = \t%d\n"
+ "a_suspend_req = \t%d\n"
+ "b_bus_req = \t%d\n"
+ "b_bus_suspend_tmout = \t%d\n"
+ "b_bus_suspend_vld = \t%d\n",
+ state_string(iotg->otg.state),
+ iotg->hsm.a_bus_resume,
+ iotg->hsm.a_bus_suspend,
+ iotg->hsm.a_conn,
+ iotg->hsm.a_sess_vld,
+ iotg->hsm.a_srp_det,
+ iotg->hsm.a_vbus_vld,
+ iotg->hsm.b_bus_resume,
+ iotg->hsm.b_bus_suspend,
+ iotg->hsm.b_conn,
+ iotg->hsm.b_se0_srp,
+ iotg->hsm.b_sess_end,
+ iotg->hsm.b_sess_vld,
+ iotg->hsm.id,
+ iotg->hsm.a_set_b_hnp_en,
+ iotg->hsm.b_srp_done,
+ iotg->hsm.b_hnp_enable,
+ iotg->hsm.a_wait_vrise_tmout,
+ iotg->hsm.a_wait_bcon_tmout,
+ iotg->hsm.a_aidl_bdis_tmout,
+ iotg->hsm.b_ase0_brst_tmout,
+ iotg->hsm.a_bus_drop,
+ iotg->hsm.a_bus_req,
+ iotg->hsm.a_clr_err,
+ iotg->hsm.a_suspend_req,
+ iotg->hsm.b_bus_req,
+ iotg->hsm.b_bus_suspend_tmout,
+ iotg->hsm.b_bus_suspend_vld
+ );
+ size -= t;
+ next += t;
+
+ return PAGE_SIZE - size;
+}
+static DEVICE_ATTR(hsm, S_IRUGO, show_hsm, NULL);
+
+static ssize_t
+get_a_bus_req(struct device *dev, struct device_attribute *attr, char *buf)
+{
+ struct langwell_otg *lnw = the_transceiver;
+ char *next;
+ unsigned size, t;
+
+ next = buf;
+ size = PAGE_SIZE;
+
+ t = scnprintf(next, size, "%d", lnw->iotg.hsm.a_bus_req);
+ size -= t;
+ next += t;
+
+ return PAGE_SIZE - size;
+}
+
+static ssize_t
+set_a_bus_req(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct langwell_otg *lnw = the_transceiver;
+ struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
+
+ if (!iotg->otg.default_a)
+ return -1;
+ if (count > 2)
+ return -1;
+
+ if (buf[0] == '0') {
+ iotg->hsm.a_bus_req = 0;
+ dev_dbg(lnw->dev, "User request: a_bus_req = 0\n");
+ } else if (buf[0] == '1') {
+ /* If a_bus_drop is TRUE, a_bus_req can't be set */
+ if (iotg->hsm.a_bus_drop)
+ return -1;
+ iotg->hsm.a_bus_req = 1;
+ dev_dbg(lnw->dev, "User request: a_bus_req = 1\n");
+ }
+ if (spin_trylock(&lnw->wq_lock)) {
+ langwell_update_transceiver();
+ spin_unlock(&lnw->wq_lock);
+ }
+ return count;
+}
+static DEVICE_ATTR(a_bus_req, S_IRUGO | S_IWUGO, get_a_bus_req, set_a_bus_req);
+
+static ssize_t
+get_a_bus_drop(struct device *dev, struct device_attribute *attr, char *buf)
+{
+ struct langwell_otg *lnw = the_transceiver;
+ char *next;
+ unsigned size, t;
+
+ next = buf;
+ size = PAGE_SIZE;
+
+ t = scnprintf(next, size, "%d", lnw->iotg.hsm.a_bus_drop);
+ size -= t;
+ next += t;
+
+ return PAGE_SIZE - size;
+}
+
+static ssize_t
+set_a_bus_drop(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct langwell_otg *lnw = the_transceiver;
+ struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
+
+ if (!iotg->otg.default_a)
+ return -1;
+ if (count > 2)
+ return -1;
+
+ if (buf[0] == '0') {
+ iotg->hsm.a_bus_drop = 0;
+ dev_dbg(lnw->dev, "User request: a_bus_drop = 0\n");
+ } else if (buf[0] == '1') {
+ iotg->hsm.a_bus_drop = 1;
+ iotg->hsm.a_bus_req = 0;
+ dev_dbg(lnw->dev, "User request: a_bus_drop = 1\n");
+ dev_dbg(lnw->dev, "User request: and a_bus_req = 0\n");
+ }
+ if (spin_trylock(&lnw->wq_lock)) {
+ langwell_update_transceiver();
+ spin_unlock(&lnw->wq_lock);
+ }
+ return count;
+}
+static DEVICE_ATTR(a_bus_drop, S_IRUGO | S_IWUGO,
+ get_a_bus_drop, set_a_bus_drop);
+
+static ssize_t
+get_b_bus_req(struct device *dev, struct device_attribute *attr, char *buf)
+{
+ struct langwell_otg *lnw = the_transceiver;
+ char *next;
+ unsigned size, t;
+
+ next = buf;
+ size = PAGE_SIZE;
+
+ t = scnprintf(next, size, "%d", lnw->iotg.hsm.b_bus_req);
+ size -= t;
+ next += t;
+
+ return PAGE_SIZE - size;
+}
+
+static ssize_t
+set_b_bus_req(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct langwell_otg *lnw = the_transceiver;
+ struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
+
+ if (iotg->otg.default_a)
+ return -1;
+
+ if (count > 2)
+ return -1;
+
+ if (buf[0] == '0') {
+ iotg->hsm.b_bus_req = 0;
+ dev_dbg(lnw->dev, "User request: b_bus_req = 0\n");
+ } else if (buf[0] == '1') {
+ iotg->hsm.b_bus_req = 1;
+ dev_dbg(lnw->dev, "User request: b_bus_req = 1\n");
+ }
+ if (spin_trylock(&lnw->wq_lock)) {
+ langwell_update_transceiver();
+ spin_unlock(&lnw->wq_lock);
+ }
+ return count;
+}
+static DEVICE_ATTR(b_bus_req, S_IRUGO | S_IWUGO, get_b_bus_req, set_b_bus_req);
+
+static ssize_t
+set_a_clr_err(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct langwell_otg *lnw = the_transceiver;
+ struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
+
+ if (!iotg->otg.default_a)
+ return -1;
+ if (count > 2)
+ return -1;
+
+ if (buf[0] == '1') {
+ iotg->hsm.a_clr_err = 1;
+ dev_dbg(lnw->dev, "User request: a_clr_err = 1\n");
+ }
+ if (spin_trylock(&lnw->wq_lock)) {
+ langwell_update_transceiver();
+ spin_unlock(&lnw->wq_lock);
+ }
+ return count;
+}
+static DEVICE_ATTR(a_clr_err, S_IWUGO, NULL, set_a_clr_err);
+
+static struct attribute *inputs_attrs[] = {
+ &dev_attr_a_bus_req.attr,
+ &dev_attr_a_bus_drop.attr,
+ &dev_attr_b_bus_req.attr,
+ &dev_attr_a_clr_err.attr,
+ NULL,
+};
+
+static struct attribute_group debug_dev_attr_group = {
+ .name = "inputs",
+ .attrs = inputs_attrs,
+};
+
+static int langwell_otg_probe(struct pci_dev *pdev,
+ const struct pci_device_id *id)
+{
+ unsigned long resource, len;
+ void __iomem *base = NULL;
+ int retval;
+ u32 val32;
+ struct langwell_otg *lnw;
+ char qname[] = "langwell_otg_queue";
+
+ retval = 0;
+ dev_dbg(&pdev->dev, "\notg controller is detected.\n");
+ if (pci_enable_device(pdev) < 0) {
+ retval = -ENODEV;
+ goto done;
+ }
+
+ lnw = kzalloc(sizeof *lnw, GFP_KERNEL);
+ if (lnw == NULL) {
+ retval = -ENOMEM;
+ goto done;
+ }
+ the_transceiver = lnw;
+
+ /* control register: BAR 0 */
+ resource = pci_resource_start(pdev, 0);
+ len = pci_resource_len(pdev, 0);
+ if (!request_mem_region(resource, len, driver_name)) {
+ retval = -EBUSY;
+ goto err;
+ }
+ lnw->region = 1;
+
+ base = ioremap_nocache(resource, len);
+ if (base == NULL) {
+ retval = -EFAULT;
+ goto err;
+ }
+ lnw->iotg.base = base;
+
+ if (!request_mem_region(USBCFG_ADDR, USBCFG_LEN, driver_name)) {
+ retval = -EBUSY;
+ goto err;
+ }
+ lnw->cfg_region = 1;
+
+ /* For the SCCB.USBCFG register */
+ base = ioremap_nocache(USBCFG_ADDR, USBCFG_LEN);
+ if (base == NULL) {
+ retval = -EFAULT;
+ goto err;
+ }
+ lnw->usbcfg = base;
+
+ if (!pdev->irq) {
+ dev_dbg(&pdev->dev, "No IRQ.\n");
+ retval = -ENODEV;
+ goto err;
+ }
+
+ lnw->qwork = create_singlethread_workqueue(qname);
+ if (!lnw->qwork) {
+ dev_dbg(&pdev->dev, "cannot create workqueue %s\n", qname);
+ retval = -ENOMEM;
+ goto err;
+ }
+ INIT_WORK(&lnw->work, langwell_otg_work);
+
+ /* OTG common part */
+ lnw->dev = &pdev->dev;
+ lnw->iotg.otg.dev = lnw->dev;
+ lnw->iotg.otg.label = driver_name;
+ lnw->iotg.otg.set_host = langwell_otg_set_host;
+ lnw->iotg.otg.set_peripheral = langwell_otg_set_peripheral;
+ lnw->iotg.otg.set_power = langwell_otg_set_power;
+ lnw->iotg.otg.set_vbus = langwell_otg_set_vbus;
+ lnw->iotg.otg.start_srp = langwell_otg_start_srp;
+ lnw->iotg.otg.state = OTG_STATE_UNDEFINED;
+
+ if (otg_set_transceiver(&lnw->iotg.otg)) {
+ dev_dbg(lnw->dev, "can't set transceiver\n");
+ retval = -EBUSY;
+ goto err;
+ }
+
+ reset_otg();
+ init_hsm();
+
+ spin_lock_init(&lnw->lock);
+ spin_lock_init(&lnw->wq_lock);
+ INIT_LIST_HEAD(&active_timers);
+ retval = langwell_otg_init_timers(&lnw->iotg.hsm);
+ if (retval) {
+ dev_dbg(&pdev->dev, "Failed to init timers\n");
+ goto err;
+ }
+
+ init_timer(&lnw->hsm_timer);
+ ATOMIC_INIT_NOTIFIER_HEAD(&lnw->iotg.iotg_notifier);
+
+ lnw->iotg_notifier.notifier_call = langwell_otg_iotg_notify;
+
+ retval = intel_mid_otg_register_notifier(&lnw->iotg,
+ &lnw->iotg_notifier);
+ if (retval) {
+ dev_dbg(lnw->dev, "Failed to register notifier\n");
+ goto err;
+ }
+
+ if (request_irq(pdev->irq, otg_irq, IRQF_SHARED,
+ driver_name, lnw) != 0) {
+ dev_dbg(lnw->dev, "request interrupt %d failed\n", pdev->irq);
+ retval = -EBUSY;
+ goto err;
+ }
+
+ /* enable OTGSC int */
+ val32 = OTGSC_DPIE | OTGSC_BSEIE | OTGSC_BSVIE |
+ OTGSC_ASVIE | OTGSC_AVVIE | OTGSC_IDIE | OTGSC_IDPU;
+ writel(val32, lnw->iotg.base + CI_OTGSC);
+
+ retval = device_create_file(&pdev->dev, &dev_attr_registers);
+ if (retval < 0) {
+ dev_dbg(lnw->dev,
+ "Can't register sysfs attribute: %d\n", retval);
+ goto err;
+ }
+
+ retval = device_create_file(&pdev->dev, &dev_attr_hsm);
+ if (retval < 0) {
+ dev_dbg(lnw->dev, "Can't hsm sysfs attribute: %d\n", retval);
+ goto err;
+ }
+
+ retval = sysfs_create_group(&pdev->dev.kobj, &debug_dev_attr_group);
+ if (retval < 0) {
+ dev_dbg(lnw->dev,
+ "Can't register sysfs attr group: %d\n", retval);
+ goto err;
+ }
+
+ if (lnw->iotg.otg.state == OTG_STATE_A_IDLE)
+ langwell_update_transceiver();
+
+ return 0;
+
+err:
+ if (the_transceiver)
+ langwell_otg_remove(pdev);
+done:
+ return retval;
+}
+
+static void langwell_otg_remove(struct pci_dev *pdev)
+{
+ struct langwell_otg *lnw = the_transceiver;
+
+ if (lnw->qwork) {
+ flush_workqueue(lnw->qwork);
+ destroy_workqueue(lnw->qwork);
+ }
+ intel_mid_otg_unregister_notifier(&lnw->iotg, &lnw->iotg_notifier);
+ langwell_otg_free_timers();
+
+ /* disable OTGSC interrupt as OTGSC doesn't change in reset */
+ writel(0, lnw->iotg.base + CI_OTGSC);
+
+ if (pdev->irq)
+ free_irq(pdev->irq, lnw);
+ if (lnw->usbcfg)
+ iounmap(lnw->usbcfg);
+ if (lnw->cfg_region)
+ release_mem_region(USBCFG_ADDR, USBCFG_LEN);
+ if (lnw->iotg.base)
+ iounmap(lnw->iotg.base);
+ if (lnw->region)
+ release_mem_region(pci_resource_start(pdev, 0),
+ pci_resource_len(pdev, 0));
+
+ otg_set_transceiver(NULL);
+ pci_disable_device(pdev);
+ sysfs_remove_group(&pdev->dev.kobj, &debug_dev_attr_group);
+ device_remove_file(&pdev->dev, &dev_attr_hsm);
+ device_remove_file(&pdev->dev, &dev_attr_registers);
+ kfree(lnw);
+ lnw = NULL;
+}
+
+static void transceiver_suspend(struct pci_dev *pdev)
+{
+ pci_save_state(pdev);
+ pci_set_power_state(pdev, PCI_D3hot);
+ langwell_otg_phy_low_power(1);
+}
+
+static int langwell_otg_suspend(struct pci_dev *pdev, pm_message_t message)
+{
+ struct langwell_otg *lnw = the_transceiver;
+ struct intel_mid_otg_xceiv *iotg = &lnw->iotg;
+ int ret = 0;
+
+ /* Disbale OTG interrupts */
+ langwell_otg_intr(0);
+
+ if (pdev->irq)
+ free_irq(pdev->irq, lnw);
+
+ /* Prevent more otg_work */
+ flush_workqueue(lnw->qwork);
+ destroy_workqueue(lnw->qwork);
+ lnw->qwork = NULL;
+
+ /* start actions */
+ switch (iotg->otg.state) {
+ case OTG_STATE_A_WAIT_VFALL:
+ iotg->otg.state = OTG_STATE_A_IDLE;
+ case OTG_STATE_A_IDLE:
+ case OTG_STATE_B_IDLE:
+ case OTG_STATE_A_VBUS_ERR:
+ transceiver_suspend(pdev);
+ break;
+ case OTG_STATE_A_WAIT_VRISE:
+ langwell_otg_del_timer(a_wait_vrise_tmr);
+ iotg->hsm.a_srp_det = 0;
+
+ /* Turn off VBus */
+ iotg->otg.set_vbus(&iotg->otg, false);
+ iotg->otg.state = OTG_STATE_A_IDLE;
+ transceiver_suspend(pdev);
+ break;
+ case OTG_STATE_A_WAIT_BCON:
+ del_timer_sync(&lnw->hsm_timer);
+ if (lnw->iotg.stop_host)
+ lnw->iotg.stop_host(&lnw->iotg);
+ else
+ dev_dbg(&pdev->dev, "host driver has been removed.\n");
+
+ iotg->hsm.a_srp_det = 0;
+
+ /* Turn off VBus */
+ iotg->otg.set_vbus(&iotg->otg, false);
+ iotg->otg.state = OTG_STATE_A_IDLE;
+ transceiver_suspend(pdev);
+ break;
+ case OTG_STATE_A_HOST:
+ if (lnw->iotg.stop_host)
+ lnw->iotg.stop_host(&lnw->iotg);
+ else
+ dev_dbg(&pdev->dev, "host driver has been removed.\n");
+
+ iotg->hsm.a_srp_det = 0;
+
+ /* Turn off VBus */
+ iotg->otg.set_vbus(&iotg->otg, false);
+
+ iotg->otg.state = OTG_STATE_A_IDLE;
+ transceiver_suspend(pdev);
+ break;
+ case OTG_STATE_A_SUSPEND:
+ langwell_otg_del_timer(a_aidl_bdis_tmr);
+ langwell_otg_HABA(0);
+ if (lnw->iotg.stop_host)
+ lnw->iotg.stop_host(&lnw->iotg);
+ else
+ dev_dbg(lnw->dev, "host driver has been removed.\n");
+ iotg->hsm.a_srp_det = 0;
+
+ /* Turn off VBus */
+ iotg->otg.set_vbus(&iotg->otg, false);
+ iotg->otg.state = OTG_STATE_A_IDLE;
+ transceiver_suspend(pdev);
+ break;
+ case OTG_STATE_A_PERIPHERAL:
+ del_timer_sync(&lnw->hsm_timer);
+
+ if (lnw->iotg.stop_peripheral)
+ lnw->iotg.stop_peripheral(&lnw->iotg);
+ else
+ dev_dbg(&pdev->dev,
+ "client driver has been removed.\n");
+ iotg->hsm.a_srp_det = 0;
+
+ /* Turn off VBus */
+ iotg->otg.set_vbus(&iotg->otg, false);
+ iotg->otg.state = OTG_STATE_A_IDLE;
+ transceiver_suspend(pdev);
+ break;
+ case OTG_STATE_B_HOST:
+ if (lnw->iotg.stop_host)
+ lnw->iotg.stop_host(&lnw->iotg);
+ else
+ dev_dbg(&pdev->dev, "host driver has been removed.\n");
+ iotg->hsm.b_bus_req = 0;
+ iotg->otg.state = OTG_STATE_B_IDLE;
+ transceiver_suspend(pdev);
+ break;
+ case OTG_STATE_B_PERIPHERAL:
+ if (lnw->iotg.stop_peripheral)
+ lnw->iotg.stop_peripheral(&lnw->iotg);
+ else
+ dev_dbg(&pdev->dev,
+ "client driver has been removed.\n");
+ iotg->otg.state = OTG_STATE_B_IDLE;
+ transceiver_suspend(pdev);
+ break;
+ case OTG_STATE_B_WAIT_ACON:
+ /* delete hsm timer for b_ase0_brst_tmr */
+ del_timer_sync(&lnw->hsm_timer);
+
+ langwell_otg_HAAR(0);
+
+ if (lnw->iotg.stop_host)
+ lnw->iotg.stop_host(&lnw->iotg);
+ else
+ dev_dbg(&pdev->dev, "host driver has been removed.\n");
+ iotg->hsm.b_bus_req = 0;
+ iotg->otg.state = OTG_STATE_B_IDLE;
+ transceiver_suspend(pdev);
+ break;
+ default:
+ dev_dbg(lnw->dev, "error state before suspend\n");
+ break;
+ }
+
+ return ret;
+}
+
+static void transceiver_resume(struct pci_dev *pdev)
+{
+ pci_restore_state(pdev);
+ pci_set_power_state(pdev, PCI_D0);
+}
+
+static int langwell_otg_resume(struct pci_dev *pdev)
+{
+ struct langwell_otg *lnw = the_transceiver;
+ int ret = 0;
+
+ transceiver_resume(pdev);
+
+ lnw->qwork = create_singlethread_workqueue("langwell_otg_queue");
+ if (!lnw->qwork) {
+ dev_dbg(&pdev->dev, "cannot create langwell otg workqueuen");
+ ret = -ENOMEM;
+ goto error;
+ }
+
+ if (request_irq(pdev->irq, otg_irq, IRQF_SHARED,
+ driver_name, lnw) != 0) {
+ dev_dbg(&pdev->dev, "request interrupt %d failed\n", pdev->irq);
+ ret = -EBUSY;
+ goto error;
+ }
+
+ /* enable OTG interrupts */
+ langwell_otg_intr(1);
+
+ update_hsm();
+
+ langwell_update_transceiver();
+
+ return ret;
+error:
+ langwell_otg_intr(0);
+ transceiver_suspend(pdev);
+ return ret;
+}
+
+static int __init langwell_otg_init(void)
+{
+ return pci_register_driver(&otg_pci_driver);
+}
+module_init(langwell_otg_init);
+
+static void __exit langwell_otg_cleanup(void)
+{
+ pci_unregister_driver(&otg_pci_driver);
+}
+module_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 @@
#include <linux/usb/otg.h>
#include <linux/usb/ulpi.h>
+
+struct ulpi_info {
+ unsigned int id;
+ char *name;
+};
+
#define ULPI_ID(vendor, product) (((vendor) << 16) | (product))
+#define ULPI_INFO(_id, _name) \
+ { \
+ .id = (_id), \
+ .name = (_name), \
+ }
/* ULPI hardcoded IDs, used for probing */
-static unsigned int ulpi_ids[] = {
- ULPI_ID(0x04cc, 0x1504), /* NXP ISP1504 */
- ULPI_ID(0x0424, 0x0006), /* SMSC USB3319 */
+static struct ulpi_info ulpi_ids[] = {
+ ULPI_INFO(ULPI_ID(0x04cc, 0x1504), "NXP ISP1504"),
+ ULPI_INFO(ULPI_ID(0x0424, 0x0006), "SMSC USB3319"),
};
static int ulpi_set_otg_flags(struct otg_transceiver *otg)
@@ -137,6 +148,32 @@ static int ulpi_set_flags(struct otg_transceiver *otg)
return ulpi_set_fc_flags(otg);
}
+static int ulpi_check_integrity(struct otg_transceiver *otg)
+{
+ int ret, i;
+ unsigned int val = 0x55;
+
+ for (i = 0; i < 2; i++) {
+ ret = otg_io_write(otg, val, ULPI_SCRATCH);
+ if (ret < 0)
+ return ret;
+
+ ret = otg_io_read(otg, ULPI_SCRATCH);
+ if (ret < 0)
+ return ret;
+
+ if (ret != val) {
+ pr_err("ULPI integrity check: failed!");
+ return -ENODEV;
+ }
+ val = val << 1;
+ }
+
+ pr_info("ULPI integrity check: passed.\n");
+
+ return 0;
+}
+
static int ulpi_init(struct otg_transceiver *otg)
{
int i, vid, pid, ret;
@@ -153,12 +190,19 @@ static int ulpi_init(struct otg_transceiver *otg)
pr_info("ULPI transceiver vendor/product ID 0x%04x/0x%04x\n", vid, pid);
- for (i = 0; i < ARRAY_SIZE(ulpi_ids); i++)
- if (ulpi_ids[i] == ULPI_ID(vid, pid))
- return ulpi_set_flags(otg);
+ for (i = 0; i < ARRAY_SIZE(ulpi_ids); i++) {
+ if (ulpi_ids[i].id == ULPI_ID(vid, pid)) {
+ pr_info("Found %s ULPI transceiver.\n",
+ ulpi_ids[i].name);
+ break;
+ }
+ }
+
+ ret = ulpi_check_integrity(otg);
+ if (ret)
+ return ret;
- pr_err("ULPI ID does not match any known transceiver.\n");
- return -ENODEV;
+ return ulpi_set_flags(otg);
}
static 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
bool "USB Secure Encapsulated Driver - Padded"
depends on USB_SERIAL_SAFE
+config USB_SERIAL_SAMBA
+ tristate "USB Atmel SAM Boot Assistant (SAM-BA) driver"
+ help
+ Say Y here if you want to access the SAM-BA boot application of an
+ Atmel AT91SAM device.
+
+ To compile this driver as a module, choose M here: the
+ module will be called sam-ba.
+
config USB_SERIAL_SIEMENS_MPI
tristate "USB Siemens MPI driver"
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 @@
obj-$(CONFIG_USB_SERIAL) += usbserial.o
-usbserial-obj-$(CONFIG_USB_SERIAL_CONSOLE) += console.o
-usbserial-obj-$(CONFIG_USB_EZUSB) += ezusb.o
+usbserial-y := usb-serial.o generic.o bus.o
-usbserial-objs := usb-serial.o generic.o bus.o $(usbserial-obj-y)
+usbserial-$(CONFIG_USB_SERIAL_CONSOLE) += console.o
+usbserial-$(CONFIG_USB_EZUSB) += ezusb.o
obj-$(CONFIG_USB_SERIAL_AIRCABLE) += aircable.o
obj-$(CONFIG_USB_SERIAL_ARK3116) += ark3116.o
@@ -48,6 +48,7 @@ obj-$(CONFIG_USB_SERIAL_PL2303) += pl2303.o
obj-$(CONFIG_USB_SERIAL_QCAUX) += qcaux.o
obj-$(CONFIG_USB_SERIAL_QUALCOMM) += qcserial.o
obj-$(CONFIG_USB_SERIAL_SAFE) += safe_serial.o
+obj-$(CONFIG_USB_SERIAL_SAMBA) += sam-ba.o
obj-$(CONFIG_USB_SERIAL_SIEMENS_MPI) += siemens_mpi.o
obj-$(CONFIG_USB_SERIAL_SIERRAWIRELESS) += sierra.o
obj-$(CONFIG_USB_SERIAL_SPCP8X5) += spcp8x5.o
@@ -58,6 +59,5 @@ obj-$(CONFIG_USB_SERIAL_TI) += ti_usb_3410_5052.o
obj-$(CONFIG_USB_SERIAL_VISOR) += visor.o
obj-$(CONFIG_USB_SERIAL_WHITEHEAT) += whiteheat.o
obj-$(CONFIG_USB_SERIAL_XIRCOM) += keyspan_pda.o
-obj-$(CONFIG_USB_SERIAL_VIVOPAY_SERIAL) += vivopay-serial.o
+obj-$(CONFIG_USB_SERIAL_VIVOPAY_SERIAL) += vivopay-serial.o
obj-$(CONFIG_USB_SERIAL_ZIO) += zio.o
-
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);
static int debug;
static const struct usb_device_id id_table[] = {
+ { USB_DEVICE(0x045B, 0x0053) }, /* Renesas RX610 RX-Stick */
{ USB_DEVICE(0x0471, 0x066A) }, /* AKTAKOM ACE-1001 cable */
{ USB_DEVICE(0x0489, 0xE000) }, /* Pirelli Broadband S.p.A, DP-L10 SIP/GSM Mobile */
{ 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[] = {
{ USB_DEVICE(0x17F4, 0xAAAA) }, /* Wavesense Jazz blood glucose meter */
{ USB_DEVICE(0x1843, 0x0200) }, /* Vaisala USB Instrument Cable */
{ USB_DEVICE(0x18EF, 0xE00F) }, /* ELV USB-I2C-Interface */
+ { USB_DEVICE(0x1BE3, 0x07A6) }, /* WAGO 750-923 USB Service Cable */
{ USB_DEVICE(0x413C, 0x9500) }, /* DW700 GPS USB interface */
{ } /* Terminating Entry */
};
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 [] = {
{ USB_DEVICE(FTDI_VID, FTDI_OPENDCC_SNIFFER_PID) },
{ USB_DEVICE(FTDI_VID, FTDI_OPENDCC_THROTTLE_PID) },
{ USB_DEVICE(FTDI_VID, FTDI_OPENDCC_GATEWAY_PID) },
+ { USB_DEVICE(FTDI_VID, FTDI_OPENDCC_GBM_PID) },
{ USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_IOBOARD_PID) },
{ USB_DEVICE(INTERBIOMETRICS_VID, INTERBIOMETRICS_MINI_IOBOARD_PID) },
{ USB_DEVICE(FTDI_VID, FTDI_SPROG_II) },
@@ -674,7 +675,6 @@ static struct usb_device_id id_table_combined [] = {
{ USB_DEVICE(FTDI_VID, FTDI_RRCIRKITS_LOCOBUFFER_PID) },
{ USB_DEVICE(FTDI_VID, FTDI_ASK_RDR400_PID) },
{ USB_DEVICE(ICOM_ID1_VID, ICOM_ID1_PID) },
- { USB_DEVICE(PAPOUCH_VID, PAPOUCH_TMU_PID) },
{ USB_DEVICE(FTDI_VID, FTDI_ACG_HFDUAL_PID) },
{ USB_DEVICE(FTDI_VID, FTDI_YEI_SERVOCENTER31_PID) },
{ USB_DEVICE(FTDI_VID, FTDI_THORLABS_PID) },
@@ -715,8 +715,37 @@ static struct usb_device_id id_table_combined [] = {
.driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
{ USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID_USB60F) },
{ USB_DEVICE(FTDI_VID, FTDI_REU_TINY_PID) },
+
+ /* Papouch devices based on FTDI chip */
+ { USB_DEVICE(PAPOUCH_VID, PAPOUCH_SB485_PID) },
+ { USB_DEVICE(PAPOUCH_VID, PAPOUCH_AP485_PID) },
+ { USB_DEVICE(PAPOUCH_VID, PAPOUCH_SB422_PID) },
+ { USB_DEVICE(PAPOUCH_VID, PAPOUCH_SB485_2_PID) },
+ { USB_DEVICE(PAPOUCH_VID, PAPOUCH_AP485_2_PID) },
+ { USB_DEVICE(PAPOUCH_VID, PAPOUCH_SB422_2_PID) },
+ { USB_DEVICE(PAPOUCH_VID, PAPOUCH_SB485S_PID) },
+ { USB_DEVICE(PAPOUCH_VID, PAPOUCH_SB485C_PID) },
+ { USB_DEVICE(PAPOUCH_VID, PAPOUCH_LEC_PID) },
+ { USB_DEVICE(PAPOUCH_VID, PAPOUCH_SB232_PID) },
+ { USB_DEVICE(PAPOUCH_VID, PAPOUCH_TMU_PID) },
+ { USB_DEVICE(PAPOUCH_VID, PAPOUCH_IRAMP_PID) },
+ { USB_DEVICE(PAPOUCH_VID, PAPOUCH_DRAK5_PID) },
+ { USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO8x8_PID) },
{ USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO4x4_PID) },
+ { USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO2x2_PID) },
+ { USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO10x1_PID) },
+ { USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO30x3_PID) },
+ { USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO60x3_PID) },
+ { USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO2x16_PID) },
+ { USB_DEVICE(PAPOUCH_VID, PAPOUCH_QUIDO3x32_PID) },
+ { USB_DEVICE(PAPOUCH_VID, PAPOUCH_DRAK6_PID) },
+ { USB_DEVICE(PAPOUCH_VID, PAPOUCH_UPSUSB_PID) },
+ { USB_DEVICE(PAPOUCH_VID, PAPOUCH_MU_PID) },
+ { USB_DEVICE(PAPOUCH_VID, PAPOUCH_SIMUKEY_PID) },
{ USB_DEVICE(PAPOUCH_VID, PAPOUCH_AD4USB_PID) },
+ { USB_DEVICE(PAPOUCH_VID, PAPOUCH_GMUX_PID) },
+ { USB_DEVICE(PAPOUCH_VID, PAPOUCH_GMSR_PID) },
+
{ USB_DEVICE(FTDI_VID, FTDI_DOMINTELL_DGQG_PID) },
{ USB_DEVICE(FTDI_VID, FTDI_DOMINTELL_DUSB_PID) },
{ USB_DEVICE(ALTI2_VID, ALTI2_N3_PID) },
@@ -751,6 +780,7 @@ static struct usb_device_id id_table_combined [] = {
{ USB_DEVICE(FTDI_VID, XVERVE_SIGNALYZER_SH4_PID),
.driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
{ USB_DEVICE(FTDI_VID, SEGWAY_RMP200_PID) },
+ { USB_DEVICE(FTDI_VID, ACCESIO_COM4SM_PID) },
{ USB_DEVICE(IONICS_VID, IONICS_PLUGCOMPUTER_PID),
.driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
{ USB_DEVICE(FTDI_VID, FTDI_CHAMSYS_24_MASTER_WING_PID) },
@@ -761,6 +791,9 @@ static struct usb_device_id id_table_combined [] = {
{ USB_DEVICE(FTDI_VID, FTDI_CHAMSYS_MAXI_WING_PID) },
{ USB_DEVICE(FTDI_VID, FTDI_CHAMSYS_MEDIA_WING_PID) },
{ USB_DEVICE(FTDI_VID, FTDI_CHAMSYS_WING_PID) },
+ { USB_DEVICE(FTDI_VID, FTDI_SCIENCESCOPE_LOGBOOKML_PID) },
+ { USB_DEVICE(FTDI_VID, FTDI_SCIENCESCOPE_LS_LOGBOOK_PID) },
+ { USB_DEVICE(FTDI_VID, FTDI_SCIENCESCOPE_HS_LOGBOOK_PID) },
{ }, /* Optional parameter entry */
{ } /* Terminating entry */
};
@@ -1559,6 +1592,7 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)
ftdi_set_max_packet_size(port);
if (read_latency_timer(port) < 0)
priv->latency = 16;
+ write_latency_timer(port);
create_sysfs_attrs(port);
return 0;
}
@@ -1687,8 +1721,6 @@ static int ftdi_open(struct tty_struct *tty, struct usb_serial_port *port)
dbg("%s", __func__);
- write_latency_timer(port);
-
/* No error checking for this (will get errors later anyway) */
/* See ftdi_sio.h for description of what is reset */
usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
@@ -2028,8 +2060,6 @@ static void ftdi_set_termios(struct tty_struct *tty,
"urb failed to set to rts/cts flow control\n");
}
- /* raise DTR/RTS */
- set_mctrl(port, TIOCM_DTR | TIOCM_RTS);
} else {
/*
* Xon/Xoff code
@@ -2077,8 +2107,6 @@ static void ftdi_set_termios(struct tty_struct *tty,
}
}
- /* lower DTR/RTS */
- clear_mctrl(port, TIOCM_DTR | TIOCM_RTS);
}
return;
}
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 @@
#define FTDI_OPENDCC_SNIFFER_PID 0xBFD9
#define FTDI_OPENDCC_THROTTLE_PID 0xBFDA
#define FTDI_OPENDCC_GATEWAY_PID 0xBFDB
+#define FTDI_OPENDCC_GBM_PID 0xBFDC
/*
* RR-CirKits LocoBuffer USB (http://www.rr-cirkits.com)
@@ -1022,9 +1023,34 @@
*/
#define PAPOUCH_VID 0x5050 /* Vendor ID */
+#define PAPOUCH_SB485_PID 0x0100 /* Papouch SB485 USB-485/422 Converter */
+#define PAPOUCH_AP485_PID 0x0101 /* AP485 USB-RS485 Converter */
+#define PAPOUCH_SB422_PID 0x0102 /* Papouch SB422 USB-RS422 Converter */
+#define PAPOUCH_SB485_2_PID 0x0103 /* Papouch SB485 USB-485/422 Converter */
+#define PAPOUCH_AP485_2_PID 0x0104 /* AP485 USB-RS485 Converter */
+#define PAPOUCH_SB422_2_PID 0x0105 /* Papouch SB422 USB-RS422 Converter */
+#define PAPOUCH_SB485S_PID 0x0106 /* Papouch SB485S USB-485/422 Converter */
+#define PAPOUCH_SB485C_PID 0x0107 /* Papouch SB485C USB-485/422 Converter */
+#define PAPOUCH_LEC_PID 0x0300 /* LEC USB Converter */
+#define PAPOUCH_SB232_PID 0x0301 /* Papouch SB232 USB-RS232 Converter */
#define PAPOUCH_TMU_PID 0x0400 /* TMU USB Thermometer */
-#define PAPOUCH_QUIDO4x4_PID 0x0900 /* Quido 4/4 Module */
+#define PAPOUCH_IRAMP_PID 0x0500 /* Papouch IRAmp Duplex */
+#define PAPOUCH_DRAK5_PID 0x0700 /* Papouch DRAK5 */
+#define PAPOUCH_QUIDO8x8_PID 0x0800 /* Papouch Quido 8/8 Module */
+#define PAPOUCH_QUIDO4x4_PID 0x0900 /* Papouch Quido 4/4 Module */
+#define PAPOUCH_QUIDO2x2_PID 0x0a00 /* Papouch Quido 2/2 Module */
+#define PAPOUCH_QUIDO10x1_PID 0x0b00 /* Papouch Quido 10/1 Module */
+#define PAPOUCH_QUIDO30x3_PID 0x0c00 /* Papouch Quido 30/3 Module */
+#define PAPOUCH_QUIDO60x3_PID 0x0d00 /* Papouch Quido 60(100)/3 Module */
+#define PAPOUCH_QUIDO2x16_PID 0x0e00 /* Papouch Quido 2/16 Module */
+#define PAPOUCH_QUIDO3x32_PID 0x0f00 /* Papouch Quido 3/32 Module */
+#define PAPOUCH_DRAK6_PID 0x1000 /* Papouch DRAK6 */
+#define PAPOUCH_UPSUSB_PID 0x8000 /* Papouch UPS-USB adapter */
+#define PAPOUCH_MU_PID 0x8001 /* MU controller */
+#define PAPOUCH_SIMUKEY_PID 0x8002 /* Papouch SimuKey */
#define PAPOUCH_AD4USB_PID 0x8003 /* AD4USB Measurement Module */
+#define PAPOUCH_GMUX_PID 0x8004 /* Papouch GOLIATH MUX */
+#define PAPOUCH_GMSR_PID 0x8005 /* Papouch GOLIATH MSR */
/*
* Marvell SheevaPlug
@@ -1063,3 +1089,14 @@
* Submitted by John G. Rogers
*/
#define SEGWAY_RMP200_PID 0xe729
+
+
+/*
+ * Accesio USB Data Acquisition products (http://www.accesio.com/)
+ */
+#define ACCESIO_COM4SM_PID 0xD578
+
+/* www.sciencescope.co.uk educational dataloggers */
+#define FTDI_SCIENCESCOPE_LOGBOOKML_PID 0xFF18
+#define FTDI_SCIENCESCOPE_LS_LOGBOOK_PID 0xFF1C
+#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)
{
dbg("%s port %d", __func__, port->number);
- usb_serial_generic_close(port);
- if (port->serial->dev)
+ if (port->serial->dev) {
+ /* shutdown our urbs */
+ usb_kill_urb(port->write_urb);
+ usb_kill_urb(port->read_urb);
usb_kill_urb(port->interrupt_in_urb);
+ }
} /* mct_u232_close */
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)
/* real data, send it to the tty layer */
tty = tty_port_tty_get(&port->port);
if (tty) {
- tty_insert_flip_string(tty, data,
- data_length);
+ tty_insert_flip_string(tty, data + 2,
+ data_length);
tty_flip_buffer_push(tty);
tty_kref_put(tty);
}
@@ -108,10 +108,10 @@ static void opticon_bulk_callback(struct urb *urb)
else
priv->rts = true;
} else {
- dev_dbg(&priv->udev->dev,
- "Unknown data packet received from the device:"
- " %2x %2x\n",
- data[0], data[1]);
+ dev_dbg(&priv->udev->dev,
+ "Unknown data packet received from the device:"
+ " %2x %2x\n",
+ data[0], data[1]);
}
}
} else {
@@ -130,7 +130,7 @@ exit:
priv->bulk_address),
priv->bulk_in_buffer, priv->buffer_size,
opticon_bulk_callback, priv);
- result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
+ result = usb_submit_urb(priv->bulk_read_urb, GFP_ATOMIC);
if (result)
dev_err(&port->dev,
"%s - failed resubmitting read urb, error %d\n",
@@ -187,6 +187,9 @@ static void opticon_write_bulk_callback(struct urb *urb)
/* free up the transfer buffer, as usb_free_urb() does not do this */
kfree(urb->transfer_buffer);
+ /* setup packet may be set if we're using it for writing */
+ kfree(urb->setup_packet);
+
if (status)
dbg("%s - nonzero write bulk status received: %d",
__func__, status);
@@ -237,10 +240,29 @@ static int opticon_write(struct tty_struct *tty, struct usb_serial_port *port,
usb_serial_debug_data(debug, &port->dev, __func__, count, buffer);
- usb_fill_bulk_urb(urb, serial->dev,
- usb_sndbulkpipe(serial->dev,
- port->bulk_out_endpointAddress),
- buffer, count, opticon_write_bulk_callback, priv);
+ if (port->bulk_out_endpointAddress) {
+ usb_fill_bulk_urb(urb, serial->dev,
+ usb_sndbulkpipe(serial->dev,
+ port->bulk_out_endpointAddress),
+ buffer, count, opticon_write_bulk_callback, priv);
+ } else {
+ struct usb_ctrlrequest *dr;
+
+ dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_NOIO);
+ if (!dr)
+ return -ENOMEM;
+
+ dr->bRequestType = USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT;
+ dr->bRequest = 0x01;
+ dr->wValue = 0;
+ dr->wIndex = 0;
+ dr->wLength = cpu_to_le16(count);
+
+ usb_fill_control_urb(urb, serial->dev,
+ usb_sndctrlpipe(serial->dev, 0),
+ (unsigned char *)dr, buffer, count,
+ opticon_write_bulk_callback, priv);
+ }
/* send it down the pipe */
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);
#define CELOT_VENDOR_ID 0x211f
#define CELOT_PRODUCT_CT680M 0x6801
+/* ONDA Communication vendor id */
+#define ONDA_VENDOR_ID 0x1ee8
+
+/* ONDA MT825UP HSDPA 14.2 modem */
+#define ONDA_MT825UP 0x000b
+
/* some devices interfaces need special handling due to a number of reasons */
enum option_blacklist_reason {
OPTION_BLACKLIST_NONE = 0,
@@ -622,6 +628,7 @@ static const struct usb_device_id option_ids[] = {
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0011, 0xff, 0xff, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0012, 0xff, 0xff, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0013, 0xff, 0xff, 0xff) },
+ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0014, 0xff, 0xff, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MF628, 0xff, 0xff, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0016, 0xff, 0xff, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0017, 0xff, 0xff, 0xff) },
@@ -633,38 +640,52 @@ static const struct usb_device_id option_ids[] = {
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0023, 0xff, 0xff, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0024, 0xff, 0xff, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0025, 0xff, 0xff, 0xff) },
- { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0026, 0xff, 0xff, 0xff) },
+ /* { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0026, 0xff, 0xff, 0xff) }, */
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0028, 0xff, 0xff, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0029, 0xff, 0xff, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0030, 0xff, 0xff, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MF626, 0xff, 0xff, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0032, 0xff, 0xff, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0033, 0xff, 0xff, 0xff) },
+ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0034, 0xff, 0xff, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0037, 0xff, 0xff, 0xff) },
+ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0038, 0xff, 0xff, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0039, 0xff, 0xff, 0xff) },
+ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0040, 0xff, 0xff, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0042, 0xff, 0xff, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0043, 0xff, 0xff, 0xff) },
+ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0044, 0xff, 0xff, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0048, 0xff, 0xff, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0049, 0xff, 0xff, 0xff) },
+ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0050, 0xff, 0xff, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0051, 0xff, 0xff, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0052, 0xff, 0xff, 0xff) },
+ /* { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0053, 0xff, 0xff, 0xff) }, */
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0054, 0xff, 0xff, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0055, 0xff, 0xff, 0xff) },
+ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0056, 0xff, 0xff, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0057, 0xff, 0xff, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0058, 0xff, 0xff, 0xff) },
+ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0059, 0xff, 0xff, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0061, 0xff, 0xff, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0062, 0xff, 0xff, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0063, 0xff, 0xff, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0064, 0xff, 0xff, 0xff) },
+ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0065, 0xff, 0xff, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0066, 0xff, 0xff, 0xff) },
+ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0067, 0xff, 0xff, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0069, 0xff, 0xff, 0xff) },
+ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0070, 0xff, 0xff, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0076, 0xff, 0xff, 0xff) },
+ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0077, 0xff, 0xff, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0078, 0xff, 0xff, 0xff) },
+ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0079, 0xff, 0xff, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0082, 0xff, 0xff, 0xff) },
+ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0083, 0xff, 0xff, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0086, 0xff, 0xff, 0xff) },
- { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x2002, 0xff, 0xff, 0xff) },
- { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x2003, 0xff, 0xff, 0xff) },
+ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0087, 0xff, 0xff, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0104, 0xff, 0xff, 0xff) },
+ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0105, 0xff, 0xff, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0106, 0xff, 0xff, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0108, 0xff, 0xff, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0113, 0xff, 0xff, 0xff) },
@@ -880,6 +901,8 @@ static const struct usb_device_id option_ids[] = {
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0073, 0xff, 0xff, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0130, 0xff, 0xff, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0141, 0xff, 0xff, 0xff) },
+ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x2002, 0xff, 0xff, 0xff) },
+ { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x2003, 0xff, 0xff, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_CDMA_TECH, 0xff, 0xff, 0xff) },
{ USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC8710, 0xff, 0xff, 0xff) },
{ 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[] = {
{ USB_DEVICE(CINTERION_VENDOR_ID, 0x0047) },
{ USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD100) },
{ USB_DEVICE(CELOT_VENDOR_ID, CELOT_PRODUCT_CT680M) }, /* CT-650 CDMA 450 1xEVDO modem */
+ { USB_DEVICE(ONDA_VENDOR_ID, ONDA_MT825UP) }, /* ONDA MT825UP modem */
{ } /* Terminating entry */
};
MODULE_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)
spin_lock_init(&data->susp_lock);
+ usb_enable_autosuspend(serial->dev);
+
switch (nintf) {
case 1:
/* QDL mode */
@@ -150,7 +152,22 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)
case 3:
case 4:
/* Composite mode */
- if (ifnum == 2) {
+ /* ifnum == 0 is a broadband network adapter */
+ if (ifnum == 1) {
+ /*
+ * Diagnostics Monitor (serial line 9600 8N1)
+ * Qualcomm DM protocol
+ * use "libqcdm" (ModemManager) for communication
+ */
+ dbg("Diagnostics Monitor found");
+ retval = usb_set_interface(serial->dev, ifnum, 0);
+ if (retval < 0) {
+ dev_err(&serial->dev->dev,
+ "Could not set interface, error %d\n",
+ retval);
+ retval = -ENODEV;
+ }
+ } else if (ifnum == 2) {
dbg("Modem port found");
retval = usb_set_interface(serial->dev, ifnum, 0);
if (retval < 0) {
@@ -161,6 +178,20 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)
kfree(data);
}
return retval;
+ } else if (ifnum==3) {
+ /*
+ * NMEA (serial line 9600 8N1)
+ * # echo "\$GPS_START" > /dev/ttyUSBx
+ * # echo "\$GPS_STOP" > /dev/ttyUSBx
+ */
+ dbg("NMEA GPS interface found");
+ retval = usb_set_interface(serial->dev, ifnum, 0);
+ if (retval < 0) {
+ dev_err(&serial->dev->dev,
+ "Could not set interface, error %d\n",
+ retval);
+ retval = -ENODEV;
+ }
}
break;
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 @@
+/*
+ * Atmel SAM Boot Assistant (SAM-BA) driver
+ *
+ * Copyright (C) 2010 Johan Hovold <jhovold@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version
+ * 2 as published by the Free Software Foundation.
+ */
+
+#include <linux/kernel.h>
+#include <linux/tty.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/usb.h>
+#include <linux/usb/serial.h>
+
+
+#define DRIVER_VERSION "v1.0"
+#define DRIVER_AUTHOR "Johan Hovold <jhovold@gmail.com>"
+#define DRIVER_DESC "Atmel SAM Boot Assistant (SAM-BA) driver"
+
+#define SAMBA_VENDOR_ID 0x3eb
+#define SAMBA_PRODUCT_ID 0x6124
+
+
+static int debug;
+
+static const struct usb_device_id id_table[] = {
+ /*
+ * NOTE: Only match the CDC Data interface.
+ */
+ { USB_DEVICE_AND_INTERFACE_INFO(SAMBA_VENDOR_ID, SAMBA_PRODUCT_ID,
+ USB_CLASS_CDC_DATA, 0, 0) },
+ { }
+};
+MODULE_DEVICE_TABLE(usb, id_table);
+
+static struct usb_driver samba_driver = {
+ .name = "sam-ba",
+ .probe = usb_serial_probe,
+ .disconnect = usb_serial_disconnect,
+ .id_table = id_table,
+ .no_dynamic_id = 1,
+};
+
+
+/*
+ * NOTE: The SAM-BA firmware cannot handle merged write requests so we cannot
+ * use the generic write implementation (which uses the port write fifo).
+ */
+static int samba_write(struct tty_struct *tty, struct usb_serial_port *port,
+ const unsigned char *buf, int count)
+{
+ struct urb *urb;
+ unsigned long flags;
+ int result;
+ int i;
+
+ if (!count)
+ return 0;
+
+ count = min_t(int, count, port->bulk_out_size);
+
+ spin_lock_irqsave(&port->lock, flags);
+ if (!port->write_urbs_free) {
+ spin_unlock_irqrestore(&port->lock, flags);
+ return 0;
+ }
+ i = find_first_bit(&port->write_urbs_free,
+ ARRAY_SIZE(port->write_urbs));
+ __clear_bit(i, &port->write_urbs_free);
+ port->tx_bytes += count;
+ spin_unlock_irqrestore(&port->lock, flags);
+
+ urb = port->write_urbs[i];
+ memcpy(urb->transfer_buffer, buf, count);
+ urb->transfer_buffer_length = count;
+ usb_serial_debug_data(debug, &port->dev, __func__, count,
+ urb->transfer_buffer);
+ result = usb_submit_urb(urb, GFP_ATOMIC);
+ if (result) {
+ dev_err(&port->dev, "%s - error submitting urb: %d\n",
+ __func__, result);
+ spin_lock_irqsave(&port->lock, flags);
+ __set_bit(i, &port->write_urbs_free);
+ port->tx_bytes -= count;
+ spin_unlock_irqrestore(&port->lock, flags);
+
+ return result;
+ }
+
+ return count;
+}
+
+static int samba_write_room(struct tty_struct *tty)
+{
+ struct usb_serial_port *port = tty->driver_data;
+ unsigned long flags;
+ unsigned long free;
+ int count;
+ int room;
+
+ spin_lock_irqsave(&port->lock, flags);
+ free = port->write_urbs_free;
+ spin_unlock_irqrestore(&port->lock, flags);
+
+ count = hweight_long(free);
+ room = count * port->bulk_out_size;
+
+ dbg("%s - returns %d", __func__, room);
+
+ return room;
+}
+
+static int samba_chars_in_buffer(struct tty_struct *tty)
+{
+ struct usb_serial_port *port = tty->driver_data;
+ unsigned long flags;
+ int chars;
+
+ spin_lock_irqsave(&port->lock, flags);
+ chars = port->tx_bytes;
+ spin_unlock_irqrestore(&port->lock, flags);
+
+ dbg("%s - returns %d", __func__, chars);
+
+ return chars;
+}
+
+static void samba_write_bulk_callback(struct urb *urb)
+{
+ struct usb_serial_port *port = urb->context;
+ unsigned long flags;
+ int i;
+
+ dbg("%s - port %d", __func__, port->number);
+
+ for (i = 0; i < ARRAY_SIZE(port->write_urbs); ++i) {
+ if (port->write_urbs[i] == urb)
+ break;
+ }
+ spin_lock_irqsave(&port->lock, flags);
+ __set_bit(i, &port->write_urbs_free);
+ port->tx_bytes -= urb->transfer_buffer_length;
+ spin_unlock_irqrestore(&port->lock, flags);
+
+ if (urb->status)
+ dbg("%s - non-zero urb status: %d", __func__, urb->status);
+
+ usb_serial_port_softint(port);
+}
+
+static struct usb_serial_driver samba_device = {
+ .driver = {
+ .owner = THIS_MODULE,
+ .name = "sam-ba",
+ },
+ .usb_driver = &samba_driver,
+ .id_table = id_table,
+ .num_ports = 1,
+ .bulk_in_size = 512,
+ .bulk_out_size = 2048,
+ .write = samba_write,
+ .write_room = samba_write_room,
+ .chars_in_buffer = samba_chars_in_buffer,
+ .write_bulk_callback = samba_write_bulk_callback,
+ .throttle = usb_serial_generic_throttle,
+ .unthrottle = usb_serial_generic_unthrottle,
+};
+
+static int __init samba_init(void)
+{
+ int retval;
+
+ retval = usb_serial_register(&samba_device);
+ if (retval)
+ return retval;
+
+ retval = usb_register(&samba_driver);
+ if (retval) {
+ usb_serial_deregister(&samba_device);
+ return retval;
+ }
+
+ printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ": "
+ DRIVER_DESC "\n");
+ return 0;
+}
+
+static void __exit samba_exit(void)
+{
+ usb_deregister(&samba_driver);
+ usb_serial_deregister(&samba_device);
+}
+
+module_init(samba_init);
+module_exit(samba_exit);
+
+MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_DESCRIPTION(DRIVER_DESC);
+MODULE_VERSION(DRIVER_VERSION);
+MODULE_LICENSE("GPL");
+
+module_param(debug, bool, S_IRUGO | S_IWUSR);
+MODULE_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)
static int clie_5_attach(struct usb_serial *serial)
{
+ struct usb_serial_port *port;
+ unsigned int pipe;
+ int j;
+
dbg("%s", __func__);
/* TH55 registers 2 ports.
@@ -621,9 +625,14 @@ static int clie_5_attach(struct usb_serial *serial)
return -1;
/* port 0 now uses the modified endpoint Address */
- serial->port[0]->bulk_out_endpointAddress =
+ port = serial->port[0];
+ port->bulk_out_endpointAddress =
serial->port[1]->bulk_out_endpointAddress;
+ pipe = usb_sndbulkpipe(serial->dev, port->bulk_out_endpointAddress);
+ for (j = 0; j < ARRAY_SIZE(port->write_urbs); ++j)
+ port->write_urbs[j]->pipe = pipe;
+
return 0;
}
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
If this driver is compiled as a module, it will be named ums-cypress.
+config USB_UAS
+ tristate "USB Attached SCSI"
+ depends on USB && SCSI
+ help
+ The USB Attached SCSI protocol is supported by some USB
+ storage devices. It permits higher performance by supporting
+ multiple outstanding commands.
+
+ If you don't know whether you have a UAS device, it is safe to
+ say 'Y' or 'M' here and the kernel will use the right driver.
+
+ If you compile this driver as a module, it will be named uas.
+
config USB_LIBUSUAL
bool "The shared table of common (or usual) storage devices"
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 @@
# Rewritten to use lists instead of if-statements.
#
-EXTRA_CFLAGS := -Idrivers/scsi
+ccflags-y := -Idrivers/scsi
+obj-$(CONFIG_USB_UAS) += uas.o
obj-$(CONFIG_USB_STORAGE) += usb-storage.o
-usb-storage-obj-$(CONFIG_USB_STORAGE_DEBUG) += debug.o
+usb-storage-y := scsiglue.o protocol.o transport.o usb.o
+usb-storage-y += initializers.o sierra_ms.o option_ms.o
-usb-storage-objs := scsiglue.o protocol.o transport.o usb.o \
- initializers.o sierra_ms.o option_ms.o $(usb-storage-obj-y)
+usb-storage-$(CONFIG_USB_STORAGE_DEBUG) += debug.o
ifeq ($(CONFIG_USB_LIBUSUAL),)
- usb-storage-objs += usual-tables.o
+ usb-storage-y += usual-tables.o
else
obj-$(CONFIG_USB) += usb-libusual.o
- usb-libusual-objs := libusual.o usual-tables.o
+ usb-libusual-y := libusual.o usual-tables.o
endif
obj-$(CONFIG_USB_STORAGE_ALAUDA) += ums-alauda.o
@@ -33,14 +34,14 @@ obj-$(CONFIG_USB_STORAGE_SDDR09) += ums-sddr09.o
obj-$(CONFIG_USB_STORAGE_SDDR55) += ums-sddr55.o
obj-$(CONFIG_USB_STORAGE_USBAT) += ums-usbat.o
-ums-alauda-objs := alauda.o
-ums-cypress-objs := cypress_atacb.o
-ums-datafab-objs := datafab.o
-ums-freecom-objs := freecom.o
-ums-isd200-objs := isd200.o
-ums-jumpshot-objs := jumpshot.o
-ums-karma-objs := karma.o
-ums-onetouch-objs := onetouch.o
-ums-sddr09-objs := sddr09.o
-ums-sddr55-objs := sddr55.o
-ums-usbat-objs := shuttle_usbat.o
+ums-alauda-y := alauda.o
+ums-cypress-y := cypress_atacb.o
+ums-datafab-y := datafab.o
+ums-freecom-y := freecom.o
+ums-isd200-y := isd200.o
+ums-jumpshot-y := jumpshot.o
+ums-karma-y := karma.o
+ums-onetouch-y := onetouch.o
+ums-sddr09-y := sddr09.o
+ums-sddr55-y := sddr55.o
+ums-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)
* Let the scanning code know if this target merely sets
* Peripheral Device Type to 0x1f to indicate no LUN.
*/
- if (us->subclass == US_SC_UFI)
+ if (us->subclass == USB_SC_UFI)
sdev->sdev_target->pdt_1f_for_no_lun = 1;
return 0;
@@ -176,7 +176,7 @@ static int slave_configure(struct scsi_device *sdev)
/* Disk-type devices use MODE SENSE(6) if the protocol
* (SubClass) is Transparent SCSI, otherwise they use
* MODE SENSE(10). */
- if (us->subclass != US_SC_SCSI && us->subclass != US_SC_CYP_ATACB)
+ if (us->subclass != USB_SC_SCSI && us->subclass != USB_SC_CYP_ATACB)
sdev->use_10_for_ms = 1;
/* Many disks only accept MODE SENSE transfer lengths of
@@ -209,6 +209,10 @@ static int slave_configure(struct scsi_device *sdev)
if (us->fflags & US_FL_CAPACITY_HEURISTICS)
sdev->guess_capacity = 1;
+ /* Some devices cannot handle READ_CAPACITY_16 */
+ if (us->fflags & US_FL_NO_READ_CAPACITY_16)
+ sdev->no_read_capacity_16 = 1;
+
/* assume SPC3 or latter devices support sense size > 18 */
if (sdev->scsi_level > SCSI_SPC_2)
us->fflags |= US_FL_SANE_SENSE;
@@ -245,7 +249,7 @@ static int slave_configure(struct scsi_device *sdev)
* capacity will be decremented or is correct. */
if (!(us->fflags & (US_FL_FIX_CAPACITY | US_FL_CAPACITY_OK |
US_FL_SCM_MULT_TARG)) &&
- us->protocol == US_PR_BULK)
+ us->protocol == USB_PR_BULK)
us->use_last_sector_hacks = 1;
} else {
@@ -253,6 +257,10 @@ static int slave_configure(struct scsi_device *sdev)
* or to force 192-byte transfer lengths for MODE SENSE.
* But they do need to use MODE SENSE(10). */
sdev->use_10_for_ms = 1;
+
+ /* Some (fake) usb cdrom devices don't like READ_DISC_INFO */
+ if (us->fflags & US_FL_NO_READ_DISC_INFO)
+ sdev->no_read_disc_info = 1;
}
/* The CB and CBI transports have no way to pass LUN values
@@ -261,7 +269,7 @@ static int slave_configure(struct scsi_device *sdev)
* scsi_level == 0 (UNKNOWN). Hence such devices must necessarily
* be single-LUN.
*/
- if ((us->protocol == US_PR_CB || us->protocol == US_PR_CBI) &&
+ if ((us->protocol == USB_PR_CB || us->protocol == USB_PR_CBI) &&
sdev->scsi_level == SCSI_UNKNOWN)
us->max_lun = 0;
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,
if (result)
return result;
- if (us->protocol == US_PR_DPCM_USB) {
+ if (us->protocol == USB_PR_DPCM_USB) {
us->transport_name = "Control/Bulk-EUSB/SDDR09";
us->transport = dpcm_transport;
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)
* unless the operation involved a data-in transfer. Devices
* can signal most data-in errors by stalling the bulk-in pipe.
*/
- if ((us->protocol == US_PR_CB || us->protocol == US_PR_DPCM_USB) &&
+ if ((us->protocol == USB_PR_CB || us->protocol == USB_PR_DPCM_USB) &&
srb->sc_data_direction != DMA_FROM_DEVICE) {
US_DEBUGP("-- CB transport device requiring auto-sense\n");
need_auto_sense = 1;
@@ -701,8 +701,8 @@ Retry_Sense:
scsi_eh_prep_cmnd(srb, &ses, NULL, 0, sense_size);
/* FIXME: we must do the protocol translation here */
- if (us->subclass == US_SC_RBC || us->subclass == US_SC_SCSI ||
- us->subclass == US_SC_CYP_ATACB)
+ if (us->subclass == USB_SC_RBC || us->subclass == USB_SC_SCSI ||
+ us->subclass == USB_SC_CYP_ATACB)
srb->cmd_len = 6;
else
srb->cmd_len = 12;
@@ -926,7 +926,7 @@ int usb_stor_CB_transport(struct scsi_cmnd *srb, struct us_data *us)
/* NOTE: CB does not have a status stage. Silly, I know. So
* we have to catch this at a higher level.
*/
- if (us->protocol != US_PR_CBI)
+ if (us->protocol != USB_PR_CBI)
return USB_STOR_TRANSPORT_GOOD;
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)
* that this means we could be ignoring a real error on these
* commands, but that can't be helped.
*/
- if (us->subclass == US_SC_UFI) {
+ if (us->subclass == USB_SC_UFI) {
if (srb->cmnd[0] == REQUEST_SENSE ||
srb->cmnd[0] == INQUIRY)
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 @@
+/*
+ * USB Attached SCSI
+ * Note that this is not the same as the USB Mass Storage driver
+ *
+ * Copyright Matthew Wilcox for Intel Corp, 2010
+ * Copyright Sarah Sharp for Intel Corp, 2010
+ *
+ * Distributed under the terms of the GNU GPL, version two.
+ */
+
+#include <linux/blkdev.h>
+#include <linux/slab.h>
+#include <linux/types.h>
+#include <linux/usb.h>
+#include <linux/usb/storage.h>
+
+#include <scsi/scsi.h>
+#include <scsi/scsi_dbg.h>
+#include <scsi/scsi_cmnd.h>
+#include <scsi/scsi_device.h>
+#include <scsi/scsi_host.h>
+#include <scsi/scsi_tcq.h>
+
+/* Common header for all IUs */
+struct iu {
+ __u8 iu_id;
+ __u8 rsvd1;
+ __be16 tag;
+};
+
+enum {
+ IU_ID_COMMAND = 0x01,
+ IU_ID_STATUS = 0x03,
+ IU_ID_RESPONSE = 0x04,
+ IU_ID_TASK_MGMT = 0x05,
+ IU_ID_READ_READY = 0x06,
+ IU_ID_WRITE_READY = 0x07,
+};
+
+struct command_iu {
+ __u8 iu_id;
+ __u8 rsvd1;
+ __be16 tag;
+ __u8 prio_attr;
+ __u8 rsvd5;
+ __u8 len;
+ __u8 rsvd7;
+ struct scsi_lun lun;
+ __u8 cdb[16]; /* XXX: Overflow-checking tools may misunderstand */
+};
+
+struct sense_iu {
+ __u8 iu_id;
+ __u8 rsvd1;
+ __be16 tag;
+ __be16 status_qual;
+ __u8 status;
+ __u8 service_response;
+ __u8 rsvd8[6];
+ __be16 len;
+ __u8 sense[SCSI_SENSE_BUFFERSIZE];
+};
+
+/*
+ * The r00-r01c specs define this version of the SENSE IU data structure.
+ * It's still in use by several different firmware releases.
+ */
+struct sense_iu_old {
+ __u8 iu_id;
+ __u8 rsvd1;
+ __be16 tag;
+ __be16 len;
+ __u8 status;
+ __u8 service_response;
+ __u8 sense[SCSI_SENSE_BUFFERSIZE];
+};
+
+enum {
+ CMD_PIPE_ID = 1,
+ STATUS_PIPE_ID = 2,
+ DATA_IN_PIPE_ID = 3,
+ DATA_OUT_PIPE_ID = 4,
+
+ UAS_SIMPLE_TAG = 0,
+ UAS_HEAD_TAG = 1,
+ UAS_ORDERED_TAG = 2,
+ UAS_ACA = 4,
+};
+
+struct uas_dev_info {
+ struct usb_interface *intf;
+ struct usb_device *udev;
+ int qdepth;
+ unsigned cmd_pipe, status_pipe, data_in_pipe, data_out_pipe;
+ unsigned use_streams:1;
+ unsigned uas_sense_old:1;
+};
+
+enum {
+ ALLOC_SENSE_URB = (1 << 0),
+ SUBMIT_SENSE_URB = (1 << 1),
+ ALLOC_DATA_IN_URB = (1 << 2),
+ SUBMIT_DATA_IN_URB = (1 << 3),
+ ALLOC_DATA_OUT_URB = (1 << 4),
+ SUBMIT_DATA_OUT_URB = (1 << 5),
+ ALLOC_CMD_URB = (1 << 6),
+ SUBMIT_CMD_URB = (1 << 7),
+};
+
+/* Overrides scsi_pointer */
+struct uas_cmd_info {
+ unsigned int state;
+ unsigned int stream;
+ struct urb *cmd_urb;
+ struct urb *sense_urb;
+ struct urb *data_in_urb;
+ struct urb *data_out_urb;
+ struct list_head list;
+};
+
+/* I hate forward declarations, but I actually have a loop */
+static int uas_submit_urbs(struct scsi_cmnd *cmnd,
+ struct uas_dev_info *devinfo, gfp_t gfp);
+
+static DEFINE_SPINLOCK(uas_work_lock);
+static LIST_HEAD(uas_work_list);
+
+static void uas_do_work(struct work_struct *work)
+{
+ struct uas_cmd_info *cmdinfo;
+ struct list_head list;
+
+ spin_lock_irq(&uas_work_lock);
+ list_replace_init(&uas_work_list, &list);
+ spin_unlock_irq(&uas_work_lock);
+
+ list_for_each_entry(cmdinfo, &list, list) {
+ struct scsi_pointer *scp = (void *)cmdinfo;
+ struct scsi_cmnd *cmnd = container_of(scp,
+ struct scsi_cmnd, SCp);
+ uas_submit_urbs(cmnd, cmnd->device->hostdata, GFP_KERNEL);
+ }
+}
+
+static DECLARE_WORK(uas_work, uas_do_work);
+
+static void uas_sense(struct urb *urb, struct scsi_cmnd *cmnd)
+{
+ struct sense_iu *sense_iu = urb->transfer_buffer;
+ struct scsi_device *sdev = cmnd->device;
+
+ if (urb->actual_length > 16) {
+ unsigned len = be16_to_cpup(&sense_iu->len);
+ if (len + 16 != urb->actual_length) {
+ int newlen = min(len + 16, urb->actual_length) - 16;
+ if (newlen < 0)
+ newlen = 0;
+ sdev_printk(KERN_INFO, sdev, "%s: urb length %d "
+ "disagrees with IU sense data length %d, "
+ "using %d bytes of sense data\n", __func__,
+ urb->actual_length, len, newlen);
+ len = newlen;
+ }
+ memcpy(cmnd->sense_buffer, sense_iu->sense, len);
+ }
+
+ cmnd->result = sense_iu->status;
+ if (sdev->current_cmnd)
+ sdev->current_cmnd = NULL;
+ cmnd->scsi_done(cmnd);
+ usb_free_urb(urb);
+}
+
+static void uas_sense_old(struct urb *urb, struct scsi_cmnd *cmnd)
+{
+ struct sense_iu_old *sense_iu = urb->transfer_buffer;
+ struct scsi_device *sdev = cmnd->device;
+
+ if (urb->actual_length > 8) {
+ unsigned len = be16_to_cpup(&sense_iu->len) - 2;
+ if (len + 8 != urb->actual_length) {
+ int newlen = min(len + 8, urb->actual_length) - 8;
+ if (newlen < 0)
+ newlen = 0;
+ sdev_printk(KERN_INFO, sdev, "%s: urb length %d "
+ "disagrees with IU sense data length %d, "
+ "using %d bytes of sense data\n", __func__,
+ urb->actual_length, len, newlen);
+ len = newlen;
+ }
+ memcpy(cmnd->sense_buffer, sense_iu->sense, len);
+ }
+
+ cmnd->result = sense_iu->status;
+ if (sdev->current_cmnd)
+ sdev->current_cmnd = NULL;
+ cmnd->scsi_done(cmnd);
+ usb_free_urb(urb);
+}
+
+static void uas_xfer_data(struct urb *urb, struct scsi_cmnd *cmnd,
+ unsigned direction)
+{
+ struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp;
+ int err;
+
+ cmdinfo->state = direction | SUBMIT_SENSE_URB;
+ err = uas_submit_urbs(cmnd, cmnd->device->hostdata, GFP_ATOMIC);
+ if (err) {
+ spin_lock(&uas_work_lock);
+ list_add_tail(&cmdinfo->list, &uas_work_list);
+ spin_unlock(&uas_work_lock);
+ schedule_work(&uas_work);
+ }
+}
+
+static void uas_stat_cmplt(struct urb *urb)
+{
+ struct iu *iu = urb->transfer_buffer;
+ struct scsi_device *sdev = urb->context;
+ struct uas_dev_info *devinfo = sdev->hostdata;
+ struct scsi_cmnd *cmnd;
+ u16 tag;
+
+ if (urb->status) {
+ dev_err(&urb->dev->dev, "URB BAD STATUS %d\n", urb->status);
+ usb_free_urb(urb);
+ return;
+ }
+
+ tag = be16_to_cpup(&iu->tag) - 1;
+ if (sdev->current_cmnd)
+ cmnd = sdev->current_cmnd;
+ else
+ cmnd = scsi_find_tag(sdev, tag);
+ if (!cmnd)
+ return;
+
+ switch (iu->iu_id) {
+ case IU_ID_STATUS:
+ if (urb->actual_length < 16)
+ devinfo->uas_sense_old = 1;
+ if (devinfo->uas_sense_old)
+ uas_sense_old(urb, cmnd);
+ else
+ uas_sense(urb, cmnd);
+ break;
+ case IU_ID_READ_READY:
+ uas_xfer_data(urb, cmnd, SUBMIT_DATA_IN_URB);
+ break;
+ case IU_ID_WRITE_READY:
+ uas_xfer_data(urb, cmnd, SUBMIT_DATA_OUT_URB);
+ break;
+ default:
+ scmd_printk(KERN_ERR, cmnd,
+ "Bogus IU (%d) received on status pipe\n", iu->iu_id);
+ }
+}
+
+static void uas_data_cmplt(struct urb *urb)
+{
+ struct scsi_data_buffer *sdb = urb->context;
+ sdb->resid = sdb->length - urb->actual_length;
+ usb_free_urb(urb);
+}
+
+static struct urb *uas_alloc_data_urb(struct uas_dev_info *devinfo, gfp_t gfp,
+ unsigned int pipe, u16 stream_id,
+ struct scsi_data_buffer *sdb,
+ enum dma_data_direction dir)
+{
+ struct usb_device *udev = devinfo->udev;
+ struct urb *urb = usb_alloc_urb(0, gfp);
+
+ if (!urb)
+ goto out;
+ usb_fill_bulk_urb(urb, udev, pipe, NULL, sdb->length, uas_data_cmplt,
+ sdb);
+ if (devinfo->use_streams)
+ urb->stream_id = stream_id;
+ urb->num_sgs = udev->bus->sg_tablesize ? sdb->table.nents : 0;
+ urb->sg = sdb->table.sgl;
+ out:
+ return urb;
+}
+
+static struct urb *uas_alloc_sense_urb(struct uas_dev_info *devinfo, gfp_t gfp,
+ struct scsi_cmnd *cmnd, u16 stream_id)
+{
+ struct usb_device *udev = devinfo->udev;
+ struct urb *urb = usb_alloc_urb(0, gfp);
+ struct sense_iu *iu;
+
+ if (!urb)
+ goto out;
+
+ iu = kmalloc(sizeof(*iu), gfp);
+ if (!iu)
+ goto free;
+
+ usb_fill_bulk_urb(urb, udev, devinfo->status_pipe, iu, sizeof(*iu),
+ uas_stat_cmplt, cmnd->device);
+ urb->stream_id = stream_id;
+ urb->transfer_flags |= URB_FREE_BUFFER;
+ out:
+ return urb;
+ free:
+ usb_free_urb(urb);
+ return NULL;
+}
+
+static struct urb *uas_alloc_cmd_urb(struct uas_dev_info *devinfo, gfp_t gfp,
+ struct scsi_cmnd *cmnd, u16 stream_id)
+{
+ struct usb_device *udev = devinfo->udev;
+ struct scsi_device *sdev = cmnd->device;
+ struct urb *urb = usb_alloc_urb(0, gfp);
+ struct command_iu *iu;
+ int len;
+
+ if (!urb)
+ goto out;
+
+ len = cmnd->cmd_len - 16;
+ if (len < 0)
+ len = 0;
+ len = ALIGN(len, 4);
+ iu = kmalloc(sizeof(*iu) + len, gfp);
+ if (!iu)
+ goto free;
+
+ iu->iu_id = IU_ID_COMMAND;
+ iu->tag = cpu_to_be16(stream_id);
+ if (sdev->ordered_tags && (cmnd->request->cmd_flags & REQ_HARDBARRIER))
+ iu->prio_attr = UAS_ORDERED_TAG;
+ else
+ iu->prio_attr = UAS_SIMPLE_TAG;
+ iu->len = len;
+ int_to_scsilun(sdev->lun, &iu->lun);
+ memcpy(iu->cdb, cmnd->cmnd, cmnd->cmd_len);
+
+ usb_fill_bulk_urb(urb, udev, devinfo->cmd_pipe, iu, sizeof(*iu) + len,
+ usb_free_urb, NULL);
+ urb->transfer_flags |= URB_FREE_BUFFER;
+ out:
+ return urb;
+ free:
+ usb_free_urb(urb);
+ return NULL;
+}
+
+/*
+ * Why should I request the Status IU before sending the Command IU? Spec
+ * says to, but also says the device may receive them in any order. Seems
+ * daft to me.
+ */
+
+static int uas_submit_urbs(struct scsi_cmnd *cmnd,
+ struct uas_dev_info *devinfo, gfp_t gfp)
+{
+ struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp;
+
+ if (cmdinfo->state & ALLOC_SENSE_URB) {
+ cmdinfo->sense_urb = uas_alloc_sense_urb(devinfo, gfp, cmnd,
+ cmdinfo->stream);
+ if (!cmdinfo->sense_urb)
+ return SCSI_MLQUEUE_DEVICE_BUSY;
+ cmdinfo->state &= ~ALLOC_SENSE_URB;
+ }
+
+ if (cmdinfo->state & SUBMIT_SENSE_URB) {
+ if (usb_submit_urb(cmdinfo->sense_urb, gfp)) {
+ scmd_printk(KERN_INFO, cmnd,
+ "sense urb submission failure\n");
+ return SCSI_MLQUEUE_DEVICE_BUSY;
+ }
+ cmdinfo->state &= ~SUBMIT_SENSE_URB;
+ }
+
+ if (cmdinfo->state & ALLOC_DATA_IN_URB) {
+ cmdinfo->data_in_urb = uas_alloc_data_urb(devinfo, gfp,
+ devinfo->data_in_pipe, cmdinfo->stream,
+ scsi_in(cmnd), DMA_FROM_DEVICE);
+ if (!cmdinfo->data_in_urb)
+ return SCSI_MLQUEUE_DEVICE_BUSY;
+ cmdinfo->state &= ~ALLOC_DATA_IN_URB;
+ }
+
+ if (cmdinfo->state & SUBMIT_DATA_IN_URB) {
+ if (usb_submit_urb(cmdinfo->data_in_urb, gfp)) {
+ scmd_printk(KERN_INFO, cmnd,
+ "data in urb submission failure\n");
+ return SCSI_MLQUEUE_DEVICE_BUSY;
+ }
+ cmdinfo->state &= ~SUBMIT_DATA_IN_URB;
+ }
+
+ if (cmdinfo->state & ALLOC_DATA_OUT_URB) {
+ cmdinfo->data_out_urb = uas_alloc_data_urb(devinfo, gfp,
+ devinfo->data_out_pipe, cmdinfo->stream,
+ scsi_out(cmnd), DMA_TO_DEVICE);
+ if (!cmdinfo->data_out_urb)
+ return SCSI_MLQUEUE_DEVICE_BUSY;
+ cmdinfo->state &= ~ALLOC_DATA_OUT_URB;
+ }
+
+ if (cmdinfo->state & SUBMIT_DATA_OUT_URB) {
+ if (usb_submit_urb(cmdinfo->data_out_urb, gfp)) {
+ scmd_printk(KERN_INFO, cmnd,
+ "data out urb submission failure\n");
+ return SCSI_MLQUEUE_DEVICE_BUSY;
+ }
+ cmdinfo->state &= ~SUBMIT_DATA_OUT_URB;
+ }
+
+ if (cmdinfo->state & ALLOC_CMD_URB) {
+ cmdinfo->cmd_urb = uas_alloc_cmd_urb(devinfo, gfp, cmnd,
+ cmdinfo->stream);
+ if (!cmdinfo->cmd_urb)
+ return SCSI_MLQUEUE_DEVICE_BUSY;
+ cmdinfo->state &= ~ALLOC_CMD_URB;
+ }
+
+ if (cmdinfo->state & SUBMIT_CMD_URB) {
+ if (usb_submit_urb(cmdinfo->cmd_urb, gfp)) {
+ scmd_printk(KERN_INFO, cmnd,
+ "cmd urb submission failure\n");
+ return SCSI_MLQUEUE_DEVICE_BUSY;
+ }
+ cmdinfo->state &= ~SUBMIT_CMD_URB;
+ }
+
+ return 0;
+}
+
+static int uas_queuecommand(struct scsi_cmnd *cmnd,
+ void (*done)(struct scsi_cmnd *))
+{
+ struct scsi_device *sdev = cmnd->device;
+ struct uas_dev_info *devinfo = sdev->hostdata;
+ struct uas_cmd_info *cmdinfo = (void *)&cmnd->SCp;
+ int err;
+
+ BUILD_BUG_ON(sizeof(struct uas_cmd_info) > sizeof(struct scsi_pointer));
+
+ if (!cmdinfo->sense_urb && sdev->current_cmnd)
+ return SCSI_MLQUEUE_DEVICE_BUSY;
+
+ if (blk_rq_tagged(cmnd->request)) {
+ cmdinfo->stream = cmnd->request->tag + 1;
+ } else {
+ sdev->current_cmnd = cmnd;
+ cmdinfo->stream = 1;
+ }
+
+ cmnd->scsi_done = done;
+
+ cmdinfo->state = ALLOC_SENSE_URB | SUBMIT_SENSE_URB |
+ ALLOC_CMD_URB | SUBMIT_CMD_URB;
+
+ switch (cmnd->sc_data_direction) {
+ case DMA_FROM_DEVICE:
+ cmdinfo->state |= ALLOC_DATA_IN_URB | SUBMIT_DATA_IN_URB;
+ break;
+ case DMA_BIDIRECTIONAL:
+ cmdinfo->state |= ALLOC_DATA_IN_URB | SUBMIT_DATA_IN_URB;
+ case DMA_TO_DEVICE:
+ cmdinfo->state |= ALLOC_DATA_OUT_URB | SUBMIT_DATA_OUT_URB;
+ case DMA_NONE:
+ break;
+ }
+
+ if (!devinfo->use_streams) {
+ cmdinfo->state &= ~(SUBMIT_DATA_IN_URB | SUBMIT_DATA_OUT_URB);
+ cmdinfo->stream = 0;
+ }
+
+ err = uas_submit_urbs(cmnd, devinfo, GFP_ATOMIC);
+ if (err) {
+ /* If we did nothing, give up now */
+ if (cmdinfo->state & SUBMIT_SENSE_URB) {
+ usb_free_urb(cmdinfo->sense_urb);
+ return SCSI_MLQUEUE_DEVICE_BUSY;
+ }
+ spin_lock(&uas_work_lock);
+ list_add_tail(&cmdinfo->list, &uas_work_list);
+ spin_unlock(&uas_work_lock);
+ schedule_work(&uas_work);
+ }
+
+ return 0;
+}
+
+static int uas_eh_abort_handler(struct scsi_cmnd *cmnd)
+{
+ struct scsi_device *sdev = cmnd->device;
+ sdev_printk(KERN_INFO, sdev, "%s tag %d\n", __func__,
+ cmnd->request->tag);
+
+/* XXX: Send ABORT TASK Task Management command */
+ return FAILED;
+}
+
+static int uas_eh_device_reset_handler(struct scsi_cmnd *cmnd)
+{
+ struct scsi_device *sdev = cmnd->device;
+ sdev_printk(KERN_INFO, sdev, "%s tag %d\n", __func__,
+ cmnd->request->tag);
+
+/* XXX: Send LOGICAL UNIT RESET Task Management command */
+ return FAILED;
+}
+
+static int uas_eh_target_reset_handler(struct scsi_cmnd *cmnd)
+{
+ struct scsi_device *sdev = cmnd->device;
+ sdev_printk(KERN_INFO, sdev, "%s tag %d\n", __func__,
+ cmnd->request->tag);
+
+/* XXX: Can we reset just the one USB interface?
+ * Would calling usb_set_interface() have the right effect?
+ */
+ return FAILED;
+}
+
+static int uas_eh_bus_reset_handler(struct scsi_cmnd *cmnd)
+{
+ struct scsi_device *sdev = cmnd->device;
+ struct uas_dev_info *devinfo = sdev->hostdata;
+ struct usb_device *udev = devinfo->udev;
+
+ sdev_printk(KERN_INFO, sdev, "%s tag %d\n", __func__,
+ cmnd->request->tag);
+
+ if (usb_reset_device(udev))
+ return SUCCESS;
+
+ return FAILED;
+}
+
+static int uas_slave_alloc(struct scsi_device *sdev)
+{
+ sdev->hostdata = (void *)sdev->host->hostdata[0];
+ return 0;
+}
+
+static int uas_slave_configure(struct scsi_device *sdev)
+{
+ struct uas_dev_info *devinfo = sdev->hostdata;
+ scsi_set_tag_type(sdev, MSG_ORDERED_TAG);
+ scsi_activate_tcq(sdev, devinfo->qdepth - 1);
+ return 0;
+}
+
+static struct scsi_host_template uas_host_template = {
+ .module = THIS_MODULE,
+ .name = "uas",
+ .queuecommand = uas_queuecommand,
+ .slave_alloc = uas_slave_alloc,
+ .slave_configure = uas_slave_configure,
+ .eh_abort_handler = uas_eh_abort_handler,
+ .eh_device_reset_handler = uas_eh_device_reset_handler,
+ .eh_target_reset_handler = uas_eh_target_reset_handler,
+ .eh_bus_reset_handler = uas_eh_bus_reset_handler,
+ .can_queue = 65536, /* Is there a limit on the _host_ ? */
+ .this_id = -1,
+ .sg_tablesize = SG_NONE,
+ .cmd_per_lun = 1, /* until we override it */
+ .skip_settle_delay = 1,
+ .ordered_tag = 1,
+};
+
+static struct usb_device_id uas_usb_ids[] = {
+ { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, USB_SC_SCSI, USB_PR_BULK) },
+ { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, USB_SC_SCSI, USB_PR_UAS) },
+ /* 0xaa is a prototype device I happen to have access to */
+ { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, USB_SC_SCSI, 0xaa) },
+ { }
+};
+MODULE_DEVICE_TABLE(usb, uas_usb_ids);
+
+static void uas_configure_endpoints(struct uas_dev_info *devinfo)
+{
+ struct usb_host_endpoint *eps[4] = { };
+ struct usb_interface *intf = devinfo->intf;
+ struct usb_device *udev = devinfo->udev;
+ struct usb_host_endpoint *endpoint = intf->cur_altsetting->endpoint;
+ unsigned i, n_endpoints = intf->cur_altsetting->desc.bNumEndpoints;
+
+ devinfo->uas_sense_old = 0;
+
+ for (i = 0; i < n_endpoints; i++) {
+ unsigned char *extra = endpoint[i].extra;
+ int len = endpoint[i].extralen;
+ while (len > 1) {
+ if (extra[1] == USB_DT_PIPE_USAGE) {
+ unsigned pipe_id = extra[2];
+ if (pipe_id > 0 && pipe_id < 5)
+ eps[pipe_id - 1] = &endpoint[i];
+ break;
+ }
+ len -= extra[0];
+ extra += extra[0];
+ }
+ }
+
+ /*
+ * Assume that if we didn't find a control pipe descriptor, we're
+ * using a device with old firmware that happens to be set up like
+ * this.
+ */
+ if (!eps[0]) {
+ devinfo->cmd_pipe = usb_sndbulkpipe(udev, 1);
+ devinfo->status_pipe = usb_rcvbulkpipe(udev, 1);
+ devinfo->data_in_pipe = usb_rcvbulkpipe(udev, 2);
+ devinfo->data_out_pipe = usb_sndbulkpipe(udev, 2);
+
+ eps[1] = usb_pipe_endpoint(udev, devinfo->status_pipe);
+ eps[2] = usb_pipe_endpoint(udev, devinfo->data_in_pipe);
+ eps[3] = usb_pipe_endpoint(udev, devinfo->data_out_pipe);
+ } else {
+ devinfo->cmd_pipe = usb_sndbulkpipe(udev,
+ eps[0]->desc.bEndpointAddress);
+ devinfo->status_pipe = usb_rcvbulkpipe(udev,
+ eps[1]->desc.bEndpointAddress);
+ devinfo->data_in_pipe = usb_rcvbulkpipe(udev,
+ eps[2]->desc.bEndpointAddress);
+ devinfo->data_out_pipe = usb_sndbulkpipe(udev,
+ eps[3]->desc.bEndpointAddress);
+ }
+
+ devinfo->qdepth = usb_alloc_streams(devinfo->intf, eps + 1, 3, 256,
+ GFP_KERNEL);
+ if (devinfo->qdepth < 0) {
+ devinfo->qdepth = 256;
+ devinfo->use_streams = 0;
+ } else {
+ devinfo->use_streams = 1;
+ }
+}
+
+/*
+ * XXX: What I'd like to do here is register a SCSI host for each USB host in
+ * the system. Follow usb-storage's design of registering a SCSI host for
+ * each USB device for the moment. Can implement this by walking up the
+ * USB hierarchy until we find a USB host.
+ */
+static int uas_probe(struct usb_interface *intf, const struct usb_device_id *id)
+{
+ int result;
+ struct Scsi_Host *shost;
+ struct uas_dev_info *devinfo;
+ struct usb_device *udev = interface_to_usbdev(intf);
+
+ if (id->bInterfaceProtocol == 0x50) {
+ int ifnum = intf->cur_altsetting->desc.bInterfaceNumber;
+/* XXX: Shouldn't assume that 1 is the alternative we want */
+ int ret = usb_set_interface(udev, ifnum, 1);
+ if (ret)
+ return -ENODEV;
+ }
+
+ devinfo = kmalloc(sizeof(struct uas_dev_info), GFP_KERNEL);
+ if (!devinfo)
+ return -ENOMEM;
+
+ result = -ENOMEM;
+ shost = scsi_host_alloc(&uas_host_template, sizeof(void *));
+ if (!shost)
+ goto free;
+
+ shost->max_cmd_len = 16 + 252;
+ shost->max_id = 1;
+ shost->sg_tablesize = udev->bus->sg_tablesize;
+
+ result = scsi_add_host(shost, &intf->dev);
+ if (result)
+ goto free;
+ shost->hostdata[0] = (unsigned long)devinfo;
+
+ devinfo->intf = intf;
+ devinfo->udev = udev;
+ uas_configure_endpoints(devinfo);
+
+ scsi_scan_host(shost);
+ usb_set_intfdata(intf, shost);
+ return result;
+ free:
+ kfree(devinfo);
+ if (shost)
+ scsi_host_put(shost);
+ return result;
+}
+
+static int uas_pre_reset(struct usb_interface *intf)
+{
+/* XXX: Need to return 1 if it's not our device in error handling */
+ return 0;
+}
+
+static int uas_post_reset(struct usb_interface *intf)
+{
+/* XXX: Need to return 1 if it's not our device in error handling */
+ return 0;
+}
+
+static void uas_disconnect(struct usb_interface *intf)
+{
+ struct usb_device *udev = interface_to_usbdev(intf);
+ struct usb_host_endpoint *eps[3];
+ struct Scsi_Host *shost = usb_get_intfdata(intf);
+ struct uas_dev_info *devinfo = (void *)shost->hostdata[0];
+
+ scsi_remove_host(shost);
+
+ eps[0] = usb_pipe_endpoint(udev, devinfo->status_pipe);
+ eps[1] = usb_pipe_endpoint(udev, devinfo->data_in_pipe);
+ eps[2] = usb_pipe_endpoint(udev, devinfo->data_out_pipe);
+ usb_free_streams(intf, eps, 3, GFP_KERNEL);
+
+ kfree(devinfo);
+}
+
+/*
+ * XXX: Should this plug into libusual so we can auto-upgrade devices from
+ * Bulk-Only to UAS?
+ */
+static struct usb_driver uas_driver = {
+ .name = "uas",
+ .probe = uas_probe,
+ .disconnect = uas_disconnect,
+ .pre_reset = uas_pre_reset,
+ .post_reset = uas_post_reset,
+ .id_table = uas_usb_ids,
+};
+
+static int uas_init(void)
+{
+ return usb_register(&uas_driver);
+}
+
+static void uas_exit(void)
+{
+ usb_deregister(&uas_driver);
+}
+
+module_init(uas_init);
+module_exit(uas_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_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 @@
UNUSUAL_DEV( 0x0584, 0x0008, 0x0102, 0x0102,
"Fujifilm",
"DPC-R1 (Alauda)",
- US_SC_SCSI, US_PR_ALAUDA, init_alauda, 0),
+ USB_SC_SCSI, USB_PR_ALAUDA, init_alauda, 0),
UNUSUAL_DEV( 0x07b4, 0x010a, 0x0102, 0x0102,
"Olympus",
"MAUSB-10 (Alauda)",
- US_SC_SCSI, US_PR_ALAUDA, init_alauda, 0),
+ USB_SC_SCSI, USB_PR_ALAUDA, init_alauda, 0),
#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 @@
UNUSUAL_DEV( 0x04b4, 0x6830, 0x0000, 0x9999,
"Cypress",
"Cypress AT2LP",
- US_SC_CYP_ATACB, US_PR_DEVICE, NULL, 0),
+ USB_SC_CYP_ATACB, USB_PR_DEVICE, NULL, 0),
/* CY7C68310 : support atacb and atacb2 */
UNUSUAL_DEV( 0x04b4, 0x6831, 0x0000, 0x9999,
"Cypress",
"Cypress ISD-300LP",
- US_SC_CYP_ATACB, US_PR_DEVICE, NULL, 0),
+ USB_SC_CYP_ATACB, USB_PR_DEVICE, NULL, 0),
#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 @@
UNUSUAL_DEV( 0x07c4, 0xa000, 0x0000, 0x0015,
"Datafab",
"MDCFE-B USB CF Reader",
- US_SC_SCSI, US_PR_DATAFAB, NULL,
+ USB_SC_SCSI, USB_PR_DATAFAB, NULL,
0),
/*
@@ -38,45 +38,45 @@ UNUSUAL_DEV( 0x07c4, 0xa000, 0x0000, 0x0015,
UNUSUAL_DEV( 0x07c4, 0xa001, 0x0000, 0xffff,
"SIIG/Datafab",
"SIIG/Datafab Memory Stick+CF Reader/Writer",
- US_SC_SCSI, US_PR_DATAFAB, NULL,
+ USB_SC_SCSI, USB_PR_DATAFAB, NULL,
0),
/* Reported by Josef Reisinger <josef.reisinger@netcologne.de> */
UNUSUAL_DEV( 0x07c4, 0xa002, 0x0000, 0xffff,
"Datafab/Unknown",
"MD2/MD3 Disk enclosure",
- US_SC_SCSI, US_PR_DATAFAB, NULL,
+ USB_SC_SCSI, USB_PR_DATAFAB, NULL,
US_FL_SINGLE_LUN),
UNUSUAL_DEV( 0x07c4, 0xa003, 0x0000, 0xffff,
"Datafab/Unknown",
"Datafab-based Reader",
- US_SC_SCSI, US_PR_DATAFAB, NULL,
+ USB_SC_SCSI, USB_PR_DATAFAB, NULL,
0),
UNUSUAL_DEV( 0x07c4, 0xa004, 0x0000, 0xffff,
"Datafab/Unknown",
"Datafab-based Reader",
- US_SC_SCSI, US_PR_DATAFAB, NULL,
+ USB_SC_SCSI, USB_PR_DATAFAB, NULL,
0),
UNUSUAL_DEV( 0x07c4, 0xa005, 0x0000, 0xffff,
"PNY/Datafab",
"PNY/Datafab CF+SM Reader",
- US_SC_SCSI, US_PR_DATAFAB, NULL,
+ USB_SC_SCSI, USB_PR_DATAFAB, NULL,
0),
UNUSUAL_DEV( 0x07c4, 0xa006, 0x0000, 0xffff,
"Simple Tech/Datafab",
"Simple Tech/Datafab CF+SM Reader",
- US_SC_SCSI, US_PR_DATAFAB, NULL,
+ USB_SC_SCSI, USB_PR_DATAFAB, NULL,
0),
/* Submitted by Olaf Hering <olh@suse.de> */
UNUSUAL_DEV( 0x07c4, 0xa109, 0x0000, 0xffff,
"Datafab Systems, Inc.",
"USB to CF + SM Combo (LC1)",
- US_SC_SCSI, US_PR_DATAFAB, NULL,
+ USB_SC_SCSI, USB_PR_DATAFAB, NULL,
0),
/* Reported by Felix Moeller <felix@derklecks.de>
@@ -86,13 +86,13 @@ UNUSUAL_DEV( 0x07c4, 0xa109, 0x0000, 0xffff,
UNUSUAL_DEV( 0x07c4, 0xa10b, 0x0000, 0xffff,
"DataFab Systems Inc.",
"USB CF+MS",
- US_SC_SCSI, US_PR_DATAFAB, NULL,
+ USB_SC_SCSI, USB_PR_DATAFAB, NULL,
0),
UNUSUAL_DEV( 0x0c0b, 0xa109, 0x0000, 0xffff,
"Acomdata",
"CF",
- US_SC_SCSI, US_PR_DATAFAB, NULL,
+ USB_SC_SCSI, USB_PR_DATAFAB, NULL,
US_FL_SINGLE_LUN),
#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 @@
UNUSUAL_DEV( 0x03eb, 0x2002, 0x0100, 0x0100,
"ATMEL",
"SND1 Storage",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_IGNORE_RESIDUE),
/* Reported by Rodolfo Quesada <rquesada@roqz.net> */
UNUSUAL_DEV( 0x03ee, 0x6906, 0x0003, 0x0003,
"VIA Technologies Inc.",
"Mitsumi multi cardreader",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_IGNORE_RESIDUE ),
UNUSUAL_DEV( 0x03f0, 0x0107, 0x0200, 0x0200,
"HP",
"CD-Writer+",
- US_SC_8070, US_PR_CB, NULL, 0),
+ USB_SC_8070, USB_PR_CB, NULL, 0),
/* Reported by Ben Efros <ben@pc-doctor.com> */
UNUSUAL_DEV( 0x03f0, 0x070c, 0x0000, 0x0000,
"HP",
"Personal Media Drive",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_SANE_SENSE ),
/* Reported by Grant Grundler <grundler@parisc-linux.org>
@@ -91,7 +91,7 @@ UNUSUAL_DEV( 0x03f0, 0x070c, 0x0000, 0x0000,
UNUSUAL_DEV( 0x03f0, 0x4002, 0x0001, 0x0001,
"HP",
"PhotoSmart R707",
- US_SC_DEVICE, US_PR_DEVICE, NULL, US_FL_FIX_CAPACITY),
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL, US_FL_FIX_CAPACITY),
/* Reported by Sebastian Kapfer <sebastian_kapfer@gmx.net>
* and Olaf Hering <olh@suse.de> (different bcd's, same vendor/product)
@@ -100,14 +100,14 @@ UNUSUAL_DEV( 0x03f0, 0x4002, 0x0001, 0x0001,
UNUSUAL_DEV( 0x0409, 0x0040, 0x0000, 0x9999,
"NEC",
"NEC USB UF000x",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_SINGLE_LUN ),
/* Patch submitted by Mihnea-Costin Grigore <mihnea@zulu.ro> */
UNUSUAL_DEV( 0x040d, 0x6205, 0x0003, 0x0003,
"VIA Technologies Inc.",
"USB 2.0 Card Reader",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_IGNORE_RESIDUE ),
/* Deduced by Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
@@ -117,40 +117,40 @@ UNUSUAL_DEV( 0x040d, 0x6205, 0x0003, 0x0003,
UNUSUAL_DEV( 0x0411, 0x001c, 0x0113, 0x0113,
"Buffalo",
"DUB-P40G HDD",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_FIX_INQUIRY ),
/* Submitted by Ernestas Vaiciukevicius <ernisv@gmail.com> */
UNUSUAL_DEV( 0x0419, 0x0100, 0x0100, 0x0100,
"Samsung Info. Systems America, Inc.",
"MP3 Player",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_IGNORE_RESIDUE ),
/* Reported by Orgad Shaneh <orgads@gmail.com> */
UNUSUAL_DEV( 0x0419, 0xaace, 0x0100, 0x0100,
"Samsung", "MP3 Player",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_IGNORE_RESIDUE ),
/* Reported by Christian Leber <christian@leber.de> */
UNUSUAL_DEV( 0x0419, 0xaaf5, 0x0100, 0x0100,
"TrekStor",
"i.Beat 115 2.0",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_IGNORE_RESIDUE | US_FL_NOT_LOCKABLE ),
/* Reported by Stefan Werner <dustbln@gmx.de> */
UNUSUAL_DEV( 0x0419, 0xaaf6, 0x0100, 0x0100,
"TrekStor",
"i.Beat Joy 2.0",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_IGNORE_RESIDUE ),
/* Reported by Pete Zaitcev <zaitcev@redhat.com>, bz#176584 */
UNUSUAL_DEV( 0x0420, 0x0001, 0x0100, 0x0100,
"GENERIC", "MP3 PLAYER", /* MyMusix PD-205 on the outside. */
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_IGNORE_RESIDUE ),
/* Reported by Andrew Nayenko <relan@bk.ru>
@@ -158,28 +158,28 @@ UNUSUAL_DEV( 0x0420, 0x0001, 0x0100, 0x0100,
UNUSUAL_DEV( 0x0421, 0x0019, 0x0592, 0x0610,
"Nokia",
"Nokia 6288",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_MAX_SECTORS_64 ),
/* Reported by Mario Rettig <mariorettig@web.de> */
UNUSUAL_DEV( 0x0421, 0x042e, 0x0100, 0x0100,
"Nokia",
"Nokia 3250",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_IGNORE_RESIDUE | US_FL_FIX_CAPACITY ),
/* Reported by <honkkis@gmail.com> */
UNUSUAL_DEV( 0x0421, 0x0433, 0x0100, 0x0100,
"Nokia",
"E70",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_IGNORE_RESIDUE | US_FL_FIX_CAPACITY ),
/* Reported by Jon Hart <Jon.Hart@web.de> */
UNUSUAL_DEV( 0x0421, 0x0434, 0x0100, 0x0100,
"Nokia",
"E60",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_FIX_CAPACITY | US_FL_IGNORE_RESIDUE ),
/* Reported by Sumedha Swamy <sumedhaswamy@gmail.com> and
@@ -187,7 +187,7 @@ UNUSUAL_DEV( 0x0421, 0x0434, 0x0100, 0x0100,
UNUSUAL_DEV( 0x0421, 0x0444, 0x0100, 0x0100,
"Nokia",
"N91",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_IGNORE_RESIDUE | US_FL_FIX_CAPACITY ),
/* Reported by Jiri Slaby <jirislaby@gmail.com> and
@@ -195,42 +195,42 @@ UNUSUAL_DEV( 0x0421, 0x0444, 0x0100, 0x0100,
UNUSUAL_DEV( 0x0421, 0x0446, 0x0100, 0x0100,
"Nokia",
"N80",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_IGNORE_RESIDUE | US_FL_FIX_CAPACITY ),
/* Reported by Matthew Bloch <matthew@bytemark.co.uk> */
UNUSUAL_DEV( 0x0421, 0x044e, 0x0100, 0x0100,
"Nokia",
"E61",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_IGNORE_RESIDUE | US_FL_FIX_CAPACITY ),
/* Reported by Bardur Arantsson <bardur@scientician.net> */
UNUSUAL_DEV( 0x0421, 0x047c, 0x0370, 0x0610,
"Nokia",
"6131",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_MAX_SECTORS_64 ),
/* Reported by Manuel Osdoba <manuel.osdoba@tu-ilmenau.de> */
UNUSUAL_DEV( 0x0421, 0x0492, 0x0452, 0x9999,
"Nokia",
"Nokia 6233",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_MAX_SECTORS_64 ),
/* Reported by Alex Corcoles <alex@corcoles.net> */
UNUSUAL_DEV( 0x0421, 0x0495, 0x0370, 0x0370,
"Nokia",
"6234",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_MAX_SECTORS_64 ),
#ifdef NO_SDDR09
UNUSUAL_DEV( 0x0436, 0x0005, 0x0100, 0x0100,
"Microtech",
"CameraMate",
- US_SC_SCSI, US_PR_CB, NULL,
+ USB_SC_SCSI, USB_PR_CB, NULL,
US_FL_SINGLE_LUN ),
#endif
@@ -239,7 +239,7 @@ UNUSUAL_DEV( 0x0436, 0x0005, 0x0100, 0x0100,
UNUSUAL_DEV( 0x0451, 0x5416, 0x0100, 0x0100,
"Neuros Audio",
"USB 2.0 HD 2.5",
- US_SC_DEVICE, US_PR_BULK, NULL,
+ USB_SC_DEVICE, USB_PR_BULK, NULL,
US_FL_NEED_OVERRIDE ),
/*
@@ -250,7 +250,7 @@ UNUSUAL_DEV( 0x0451, 0x5416, 0x0100, 0x0100,
UNUSUAL_DEV( 0x0457, 0x0150, 0x0100, 0x0100,
"USBest Technology", /* sold by Transcend */
"USB Mass Storage Device",
- US_SC_DEVICE, US_PR_DEVICE, NULL, US_FL_NOT_LOCKABLE ),
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL, US_FL_NOT_LOCKABLE ),
/*
* Bohdan Linda <bohdan.linda@gmail.com>
@@ -260,7 +260,7 @@ UNUSUAL_DEV( 0x0457, 0x0150, 0x0100, 0x0100,
UNUSUAL_DEV( 0x0457, 0x0151, 0x0100, 0x0100,
"USB 2.0",
"Flash Disk",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_NOT_LOCKABLE ),
/* Reported by Tamas Kerecsen <kerecsen@bigfoot.com>
@@ -272,7 +272,7 @@ UNUSUAL_DEV( 0x0457, 0x0151, 0x0100, 0x0100,
UNUSUAL_DEV( 0x045e, 0xffff, 0x0000, 0x0000,
"Mitac",
"GPS",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_MAX_SECTORS_64 ),
/*
@@ -284,32 +284,32 @@ UNUSUAL_DEV( 0x045e, 0xffff, 0x0000, 0x0000,
UNUSUAL_DEV( 0x046b, 0xff40, 0x0100, 0x0100,
"AMI",
"Virtual Floppy",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_NO_WP_DETECT),
/* Patch submitted by Philipp Friedrich <philipp@void.at> */
UNUSUAL_DEV( 0x0482, 0x0100, 0x0100, 0x0100,
"Kyocera",
"Finecam S3x",
- US_SC_8070, US_PR_CB, NULL, US_FL_FIX_INQUIRY),
+ USB_SC_8070, USB_PR_CB, NULL, US_FL_FIX_INQUIRY),
/* Patch submitted by Philipp Friedrich <philipp@void.at> */
UNUSUAL_DEV( 0x0482, 0x0101, 0x0100, 0x0100,
"Kyocera",
"Finecam S4",
- US_SC_8070, US_PR_CB, NULL, US_FL_FIX_INQUIRY),
+ USB_SC_8070, USB_PR_CB, NULL, US_FL_FIX_INQUIRY),
/* Patch submitted by Stephane Galles <stephane.galles@free.fr> */
UNUSUAL_DEV( 0x0482, 0x0103, 0x0100, 0x0100,
"Kyocera",
"Finecam S5",
- US_SC_DEVICE, US_PR_DEVICE, NULL, US_FL_FIX_INQUIRY),
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL, US_FL_FIX_INQUIRY),
/* Patch submitted by Jens Taprogge <jens.taprogge@taprogge.org> */
UNUSUAL_DEV( 0x0482, 0x0107, 0x0100, 0x0100,
"Kyocera",
"CONTAX SL300R T*",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_FIX_CAPACITY | US_FL_NOT_LOCKABLE),
/* Reported by Paul Stewart <stewart@wetlogic.net>
@@ -317,7 +317,7 @@ UNUSUAL_DEV( 0x0482, 0x0107, 0x0100, 0x0100,
UNUSUAL_DEV( 0x04a4, 0x0004, 0x0001, 0x0001,
"Hitachi",
"DVD-CAM DZ-MV100A Camcorder",
- US_SC_SCSI, US_PR_CB, NULL, US_FL_SINGLE_LUN),
+ USB_SC_SCSI, USB_PR_CB, NULL, US_FL_SINGLE_LUN),
/* BENQ DC5330
* Reported by Manuel Fombuena <mfombuena@ya.com> and
@@ -325,7 +325,7 @@ UNUSUAL_DEV( 0x04a4, 0x0004, 0x0001, 0x0001,
UNUSUAL_DEV( 0x04a5, 0x3010, 0x0100, 0x0100,
"Tekom Technologies, Inc",
"300_CAMERA",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_IGNORE_RESIDUE ),
/* Patch for Nikon coolpix 2000
@@ -333,14 +333,14 @@ UNUSUAL_DEV( 0x04a5, 0x3010, 0x0100, 0x0100,
UNUSUAL_DEV( 0x04b0, 0x0301, 0x0010, 0x0010,
"NIKON",
"NIKON DSC E2000",
- US_SC_DEVICE, US_PR_DEVICE,NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE,NULL,
US_FL_NOT_LOCKABLE ),
/* Reported by Doug Maxey (dwm@austin.ibm.com) */
UNUSUAL_DEV( 0x04b3, 0x4001, 0x0110, 0x0110,
"IBM",
"IBM RSA2",
- US_SC_DEVICE, US_PR_CB, NULL,
+ USB_SC_DEVICE, USB_PR_CB, NULL,
US_FL_MAX_SECTORS_MIN),
/* Reported by Simon Levitt <simon@whattf.com>
@@ -348,14 +348,14 @@ UNUSUAL_DEV( 0x04b3, 0x4001, 0x0110, 0x0110,
UNUSUAL_DEV( 0x04b8, 0x0601, 0x0100, 0x0100,
"Epson",
"875DC Storage",
- US_SC_SCSI, US_PR_CB, NULL, US_FL_FIX_INQUIRY),
+ USB_SC_SCSI, USB_PR_CB, NULL, US_FL_FIX_INQUIRY),
/* Reported by Khalid Aziz <khalid@gonehiking.org>
* This entry is needed because the device reports Sub=ff */
UNUSUAL_DEV( 0x04b8, 0x0602, 0x0110, 0x0110,
"Epson",
"785EPX Storage",
- US_SC_SCSI, US_PR_BULK, NULL, US_FL_SINGLE_LUN),
+ USB_SC_SCSI, USB_PR_BULK, NULL, US_FL_SINGLE_LUN),
/* Not sure who reported this originally but
* Pavel Machek <pavel@ucw.cz> reported that the extra US_FL_SINGLE_LUN
@@ -363,7 +363,7 @@ UNUSUAL_DEV( 0x04b8, 0x0602, 0x0110, 0x0110,
UNUSUAL_DEV( 0x04cb, 0x0100, 0x0000, 0x2210,
"Fujifilm",
"FinePix 1400Zoom",
- US_SC_UFI, US_PR_DEVICE, NULL, US_FL_FIX_INQUIRY | US_FL_SINGLE_LUN),
+ USB_SC_UFI, USB_PR_DEVICE, NULL, US_FL_FIX_INQUIRY | US_FL_SINGLE_LUN),
/* Reported by Ondrej Zary <linux@rainbow-software.org>
* The device reports one sector more and breaks when that sector is accessed
@@ -371,7 +371,7 @@ UNUSUAL_DEV( 0x04cb, 0x0100, 0x0000, 0x2210,
UNUSUAL_DEV( 0x04ce, 0x0002, 0x026c, 0x026c,
"ScanLogic",
"SL11R-IDE",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_FIX_CAPACITY),
/* Reported by Kriston Fincher <kriston@airmail.net>
@@ -382,27 +382,27 @@ UNUSUAL_DEV( 0x04ce, 0x0002, 0x026c, 0x026c,
UNUSUAL_DEV( 0x04da, 0x0901, 0x0100, 0x0200,
"Panasonic",
"LS-120 Camera",
- US_SC_UFI, US_PR_DEVICE, NULL, 0),
+ USB_SC_UFI, USB_PR_DEVICE, NULL, 0),
/* From Yukihiro Nakai, via zaitcev@yahoo.com.
* This is needed for CB instead of CBI */
UNUSUAL_DEV( 0x04da, 0x0d05, 0x0000, 0x0000,
"Sharp CE-CW05",
"CD-R/RW Drive",
- US_SC_8070, US_PR_CB, NULL, 0),
+ USB_SC_8070, USB_PR_CB, NULL, 0),
/* Reported by Adriaan Penning <a.penning@luon.net> */
UNUSUAL_DEV( 0x04da, 0x2372, 0x0000, 0x9999,
"Panasonic",
"DMC-LCx Camera",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_FIX_CAPACITY | US_FL_NOT_LOCKABLE ),
/* Reported by Simeon Simeonov <simeonov_2000@yahoo.com> */
UNUSUAL_DEV( 0x04da, 0x2373, 0x0000, 0x9999,
"LEICA",
"D-LUX Camera",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_FIX_CAPACITY | US_FL_NOT_LOCKABLE ),
/* Most of the following entries were developed with the help of
@@ -411,19 +411,19 @@ UNUSUAL_DEV( 0x04da, 0x2373, 0x0000, 0x9999,
UNUSUAL_DEV( 0x04e6, 0x0001, 0x0200, 0x0200,
"Matshita",
"LS-120",
- US_SC_8020, US_PR_CB, NULL, 0),
+ USB_SC_8020, USB_PR_CB, NULL, 0),
UNUSUAL_DEV( 0x04e6, 0x0002, 0x0100, 0x0100,
"Shuttle",
"eUSCSI Bridge",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_euscsi_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_euscsi_init,
US_FL_SCM_MULT_TARG ),
#ifdef NO_SDDR09
UNUSUAL_DEV( 0x04e6, 0x0005, 0x0100, 0x0208,
"SCM Microsystems",
"eUSB CompactFlash Adapter",
- US_SC_SCSI, US_PR_CB, NULL,
+ USB_SC_SCSI, USB_PR_CB, NULL,
US_FL_SINGLE_LUN),
#endif
@@ -431,54 +431,54 @@ UNUSUAL_DEV( 0x04e6, 0x0005, 0x0100, 0x0208,
UNUSUAL_DEV( 0x04e6, 0x0006, 0x0100, 0x0100,
"SCM Microsystems Inc.",
"eUSB MMC Adapter",
- US_SC_SCSI, US_PR_CB, NULL,
+ USB_SC_SCSI, USB_PR_CB, NULL,
US_FL_SINGLE_LUN),
/* Reported by Daniel Nouri <dpunktnpunkt@web.de> */
UNUSUAL_DEV( 0x04e6, 0x0006, 0x0205, 0x0205,
"Shuttle",
"eUSB MMC Adapter",
- US_SC_SCSI, US_PR_DEVICE, NULL,
+ USB_SC_SCSI, USB_PR_DEVICE, NULL,
US_FL_SINGLE_LUN),
UNUSUAL_DEV( 0x04e6, 0x0007, 0x0100, 0x0200,
"Sony",
"Hifd",
- US_SC_SCSI, US_PR_CB, NULL,
+ USB_SC_SCSI, USB_PR_CB, NULL,
US_FL_SINGLE_LUN),
UNUSUAL_DEV( 0x04e6, 0x0009, 0x0200, 0x0200,
"Shuttle",
"eUSB ATA/ATAPI Adapter",
- US_SC_8020, US_PR_CB, NULL, 0),
+ USB_SC_8020, USB_PR_CB, NULL, 0),
UNUSUAL_DEV( 0x04e6, 0x000a, 0x0200, 0x0200,
"Shuttle",
"eUSB CompactFlash Adapter",
- US_SC_8020, US_PR_CB, NULL, 0),
+ USB_SC_8020, USB_PR_CB, NULL, 0),
UNUSUAL_DEV( 0x04e6, 0x000B, 0x0100, 0x0100,
"Shuttle",
"eUSCSI Bridge",
- US_SC_SCSI, US_PR_BULK, usb_stor_euscsi_init,
+ USB_SC_SCSI, USB_PR_BULK, usb_stor_euscsi_init,
US_FL_SCM_MULT_TARG ),
UNUSUAL_DEV( 0x04e6, 0x000C, 0x0100, 0x0100,
"Shuttle",
"eUSCSI Bridge",
- US_SC_SCSI, US_PR_BULK, usb_stor_euscsi_init,
+ USB_SC_SCSI, USB_PR_BULK, usb_stor_euscsi_init,
US_FL_SCM_MULT_TARG ),
UNUSUAL_DEV( 0x04e6, 0x0101, 0x0200, 0x0200,
"Shuttle",
"CD-RW Device",
- US_SC_8020, US_PR_CB, NULL, 0),
+ USB_SC_8020, USB_PR_CB, NULL, 0),
/* Reported by Dmitry Khlystov <adminimus@gmail.com> */
UNUSUAL_DEV( 0x04e8, 0x507c, 0x0220, 0x0220,
"Samsung",
"YP-U3",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_MAX_SECTORS_64),
/* Entry and supporting patch by Theodore Kilgore <kilgota@auburn.edu>.
@@ -488,14 +488,14 @@ UNUSUAL_DEV( 0x04e8, 0x507c, 0x0220, 0x0220,
UNUSUAL_DEV( 0x04fc, 0x80c2, 0x0100, 0x0100,
"Kobian Mercury",
"Binocam DCB-132",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_BULK32),
/* Reported by Bob Sass <rls@vectordb.com> -- only rev 1.33 tested */
UNUSUAL_DEV( 0x050d, 0x0115, 0x0133, 0x0133,
"Belkin",
"USB SCSI Adaptor",
- US_SC_SCSI, US_PR_BULK, usb_stor_euscsi_init,
+ USB_SC_SCSI, USB_PR_BULK, usb_stor_euscsi_init,
US_FL_SCM_MULT_TARG ),
/* Iomega Clik! Drive
@@ -505,14 +505,14 @@ UNUSUAL_DEV( 0x050d, 0x0115, 0x0133, 0x0133,
UNUSUAL_DEV( 0x0525, 0xa140, 0x0100, 0x0100,
"Iomega",
"USB Clik! 40",
- US_SC_8070, US_PR_DEVICE, NULL,
+ USB_SC_8070, USB_PR_DEVICE, NULL,
US_FL_FIX_INQUIRY ),
/* Added by Alan Stern <stern@rowland.harvard.edu> */
COMPLIANT_DEV(0x0525, 0xa4a5, 0x0000, 0x9999,
"Linux",
"File-backed Storage Gadget",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_CAPACITY_OK ),
/* Yakumo Mega Image 37
@@ -520,7 +520,7 @@ COMPLIANT_DEV(0x0525, 0xa4a5, 0x0000, 0x9999,
UNUSUAL_DEV( 0x052b, 0x1801, 0x0100, 0x0100,
"Tekom Technologies, Inc",
"300_CAMERA",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_IGNORE_RESIDUE ),
/* Another Yakumo camera.
@@ -528,14 +528,14 @@ UNUSUAL_DEV( 0x052b, 0x1801, 0x0100, 0x0100,
UNUSUAL_DEV( 0x052b, 0x1804, 0x0100, 0x0100,
"Tekom Technologies, Inc",
"300_CAMERA",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_IGNORE_RESIDUE ),
/* Reported by Iacopo Spalletti <avvisi@spalletti.it> */
UNUSUAL_DEV( 0x052b, 0x1807, 0x0100, 0x0100,
"Tekom Technologies, Inc",
"300_CAMERA",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_IGNORE_RESIDUE ),
/* Yakumo Mega Image 47
@@ -543,7 +543,7 @@ UNUSUAL_DEV( 0x052b, 0x1807, 0x0100, 0x0100,
UNUSUAL_DEV( 0x052b, 0x1905, 0x0100, 0x0100,
"Tekom Technologies, Inc",
"400_CAMERA",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_IGNORE_RESIDUE ),
/* Reported by Paul Ortyl <ortylp@3miasto.net>
@@ -551,13 +551,13 @@ UNUSUAL_DEV( 0x052b, 0x1905, 0x0100, 0x0100,
UNUSUAL_DEV( 0x052b, 0x1911, 0x0100, 0x0100,
"Tekom Technologies, Inc",
"400_CAMERA",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_IGNORE_RESIDUE ),
UNUSUAL_DEV( 0x054c, 0x0010, 0x0106, 0x0450,
"Sony",
"DSC-S30/S70/S75/505V/F505/F707/F717/P8",
- US_SC_SCSI, US_PR_DEVICE, NULL,
+ USB_SC_SCSI, USB_PR_DEVICE, NULL,
US_FL_SINGLE_LUN | US_FL_NOT_LOCKABLE | US_FL_NO_WP_DETECT ),
/* Submitted by Lars Jacob <jacob.lars@googlemail.com>
@@ -565,7 +565,7 @@ UNUSUAL_DEV( 0x054c, 0x0010, 0x0106, 0x0450,
UNUSUAL_DEV( 0x054c, 0x0010, 0x0500, 0x0610,
"Sony",
"DSC-T1/T5/H5",
- US_SC_8070, US_PR_DEVICE, NULL,
+ USB_SC_8070, USB_PR_DEVICE, NULL,
US_FL_SINGLE_LUN ),
@@ -573,88 +573,88 @@ UNUSUAL_DEV( 0x054c, 0x0010, 0x0500, 0x0610,
UNUSUAL_DEV( 0x054c, 0x0025, 0x0100, 0x0100,
"Sony",
"Memorystick NW-MS7",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_SINGLE_LUN ),
/* Submitted by Olaf Hering, <olh@suse.de> SuSE Bugzilla #49049 */
UNUSUAL_DEV( 0x054c, 0x002c, 0x0501, 0x2000,
"Sony",
"USB Floppy Drive",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_SINGLE_LUN ),
UNUSUAL_DEV( 0x054c, 0x002d, 0x0100, 0x0100,
"Sony",
"Memorystick MSAC-US1",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_SINGLE_LUN ),
/* Submitted by Klaus Mueller <k.mueller@intershop.de> */
UNUSUAL_DEV( 0x054c, 0x002e, 0x0106, 0x0310,
"Sony",
"Handycam",
- US_SC_SCSI, US_PR_DEVICE, NULL,
+ USB_SC_SCSI, USB_PR_DEVICE, NULL,
US_FL_SINGLE_LUN ),
/* Submitted by Rajesh Kumble Nayak <nayak@obs-nice.fr> */
UNUSUAL_DEV( 0x054c, 0x002e, 0x0500, 0x0500,
"Sony",
"Handycam HC-85",
- US_SC_UFI, US_PR_DEVICE, NULL,
+ USB_SC_UFI, USB_PR_DEVICE, NULL,
US_FL_SINGLE_LUN ),
UNUSUAL_DEV( 0x054c, 0x0032, 0x0000, 0x9999,
"Sony",
"Memorystick MSC-U01N",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_SINGLE_LUN ),
/* Submitted by Michal Mlotek <mlotek@foobar.pl> */
UNUSUAL_DEV( 0x054c, 0x0058, 0x0000, 0x9999,
"Sony",
"PEG N760c Memorystick",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_FIX_INQUIRY ),
UNUSUAL_DEV( 0x054c, 0x0069, 0x0000, 0x9999,
"Sony",
"Memorystick MSC-U03",
- US_SC_UFI, US_PR_CB, NULL,
+ USB_SC_UFI, USB_PR_CB, NULL,
US_FL_SINGLE_LUN ),
/* Submitted by Nathan Babb <nathan@lexi.com> */
UNUSUAL_DEV( 0x054c, 0x006d, 0x0000, 0x9999,
"Sony",
"PEG Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_FIX_INQUIRY ),
/* Submitted by Frank Engel <frankie@cse.unsw.edu.au> */
UNUSUAL_DEV( 0x054c, 0x0099, 0x0000, 0x9999,
"Sony",
"PEG Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_FIX_INQUIRY ),
/* Submitted by Mike Alborn <malborn@deandra.homeip.net> */
UNUSUAL_DEV( 0x054c, 0x016a, 0x0000, 0x9999,
"Sony",
"PEG Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_FIX_INQUIRY ),
/* floppy reports multiple luns */
UNUSUAL_DEV( 0x055d, 0x2020, 0x0000, 0x0210,
"SAMSUNG",
"SFD-321U [FW 0C]",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_SINGLE_LUN ),
/* We keep this entry to force the transport; firmware 3.00 and later is ok. */
UNUSUAL_DEV( 0x057b, 0x0000, 0x0000, 0x0299,
"Y-E Data",
"Flashbuster-U",
- US_SC_DEVICE, US_PR_CB, NULL,
+ USB_SC_DEVICE, USB_PR_CB, NULL,
US_FL_SINGLE_LUN),
/* Reported by Johann Cardon <johann.cardon@free.fr>
@@ -664,20 +664,20 @@ UNUSUAL_DEV( 0x057b, 0x0000, 0x0000, 0x0299,
UNUSUAL_DEV( 0x057b, 0x0022, 0x0000, 0x9999,
"Y-E Data",
"Silicon Media R/W",
- US_SC_DEVICE, US_PR_DEVICE, NULL, 0),
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL, 0),
/* Reported by RTE <raszilki@yandex.ru> */
UNUSUAL_DEV( 0x058f, 0x6387, 0x0141, 0x0141,
"JetFlash",
"TS1GJF2A/120",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_MAX_SECTORS_64 ),
/* Fabrizio Fellini <fello@libero.it> */
UNUSUAL_DEV( 0x0595, 0x4343, 0x0000, 0x2210,
"Fujifilm",
"Digital Camera EX-20 DSC",
- US_SC_8070, US_PR_DEVICE, NULL, 0 ),
+ USB_SC_8070, USB_PR_DEVICE, NULL, 0 ),
/* Reported by Andre Welter <a.r.welter@gmx.de>
* This antique device predates the release of the Bulk-only Transport
@@ -688,14 +688,14 @@ UNUSUAL_DEV( 0x0595, 0x4343, 0x0000, 0x2210,
UNUSUAL_DEV( 0x059b, 0x0001, 0x0100, 0x0100,
"Iomega",
"ZIP 100",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_SINGLE_LUN ),
/* Reported by <Hendryk.Pfeiffer@gmx.de> */
UNUSUAL_DEV( 0x059f, 0x0643, 0x0000, 0x0000,
"LaCie",
"DVD+-RW",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_GO_SLOW ),
/* Submitted by Joel Bourquard <numlock@freesurf.ch>
@@ -705,7 +705,7 @@ UNUSUAL_DEV( 0x059f, 0x0643, 0x0000, 0x0000,
UNUSUAL_DEV( 0x05ab, 0x0060, 0x1104, 0x1110,
"In-System",
"PyroGate External CD-ROM Enclosure (FCD-523)",
- US_SC_SCSI, US_PR_BULK, NULL,
+ USB_SC_SCSI, USB_PR_BULK, NULL,
US_FL_NEED_OVERRIDE ),
/* Submitted by Sven Anderson <sven-linux@anderson.de>
@@ -717,26 +717,26 @@ UNUSUAL_DEV( 0x05ab, 0x0060, 0x1104, 0x1110,
UNUSUAL_DEV( 0x05ac, 0x1202, 0x0000, 0x9999,
"Apple",
"iPod",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_FIX_CAPACITY ),
/* Reported by Avi Kivity <avi@argo.co.il> */
UNUSUAL_DEV( 0x05ac, 0x1203, 0x0000, 0x9999,
"Apple",
"iPod",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_FIX_CAPACITY ),
UNUSUAL_DEV( 0x05ac, 0x1204, 0x0000, 0x9999,
"Apple",
"iPod",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_FIX_CAPACITY | US_FL_NOT_LOCKABLE ),
UNUSUAL_DEV( 0x05ac, 0x1205, 0x0000, 0x9999,
"Apple",
"iPod",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_FIX_CAPACITY ),
/*
@@ -746,7 +746,7 @@ UNUSUAL_DEV( 0x05ac, 0x1205, 0x0000, 0x9999,
UNUSUAL_DEV( 0x05ac, 0x120a, 0x0000, 0x9999,
"Apple",
"iPod",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_FIX_CAPACITY ),
/* Reported by Dan Williams <dcbw@redhat.com>
@@ -758,14 +758,14 @@ UNUSUAL_DEV( 0x05ac, 0x120a, 0x0000, 0x9999,
UNUSUAL_DEV( 0x05c6, 0x1000, 0x0000, 0x9999,
"Option N.V.",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, option_ms_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, option_ms_init,
0),
/* Reported by Blake Matheny <bmatheny@purdue.edu> */
UNUSUAL_DEV( 0x05dc, 0xb002, 0x0000, 0x0113,
"Lexar",
"USB CF Reader",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_FIX_INQUIRY ),
/* The following two entries are for a Genesys USB to IDE
@@ -782,20 +782,20 @@ UNUSUAL_DEV( 0x05dc, 0xb002, 0x0000, 0x0113,
UNUSUAL_DEV( 0x05e3, 0x0701, 0x0000, 0xffff,
"Genesys Logic",
"USB to IDE Optical",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_GO_SLOW | US_FL_MAX_SECTORS_64 | US_FL_IGNORE_RESIDUE ),
UNUSUAL_DEV( 0x05e3, 0x0702, 0x0000, 0xffff,
"Genesys Logic",
"USB to IDE Disk",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_GO_SLOW | US_FL_MAX_SECTORS_64 | US_FL_IGNORE_RESIDUE ),
/* Reported by Ben Efros <ben@pc-doctor.com> */
UNUSUAL_DEV( 0x05e3, 0x0723, 0x9451, 0x9451,
"Genesys Logic",
"USB to SATA",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_SANE_SENSE ),
/* Reported by Hanno Boeck <hanno@gmx.de>
@@ -803,33 +803,33 @@ UNUSUAL_DEV( 0x05e3, 0x0723, 0x9451, 0x9451,
UNUSUAL_DEV( 0x0636, 0x0003, 0x0000, 0x9999,
"Vivitar",
"Vivicam 35Xx",
- US_SC_SCSI, US_PR_BULK, NULL,
+ USB_SC_SCSI, USB_PR_BULK, NULL,
US_FL_FIX_INQUIRY ),
UNUSUAL_DEV( 0x0644, 0x0000, 0x0100, 0x0100,
"TEAC",
"Floppy Drive",
- US_SC_UFI, US_PR_CB, NULL, 0 ),
+ USB_SC_UFI, USB_PR_CB, NULL, 0 ),
/* Reported by Darsen Lu <darsen@micro.ee.nthu.edu.tw> */
UNUSUAL_DEV( 0x066f, 0x8000, 0x0001, 0x0001,
"SigmaTel",
"USBMSC Audio Player",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_FIX_CAPACITY ),
/* Reported by Daniel Kukula <daniel.kuku@gmail.com> */
UNUSUAL_DEV( 0x067b, 0x1063, 0x0100, 0x0100,
"Prolific Technology, Inc.",
"Prolific Storage Gadget",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_BAD_SENSE ),
/* Reported by Rogerio Brito <rbrito@ime.usp.br> */
UNUSUAL_DEV( 0x067b, 0x2317, 0x0001, 0x001,
"Prolific Technology, Inc.",
"Mass Storage Device",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_NOT_LOCKABLE ),
/* Reported by Richard -=[]=- <micro_flyer@hotmail.com> */
@@ -838,46 +838,47 @@ UNUSUAL_DEV( 0x067b, 0x2317, 0x0001, 0x001,
UNUSUAL_DEV( 0x067b, 0x2507, 0x0001, 0x0100,
"Prolific Technology Inc.",
"Mass Storage Device",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_FIX_CAPACITY | US_FL_GO_SLOW ),
/* Reported by Alex Butcher <alex.butcher@assursys.co.uk> */
UNUSUAL_DEV( 0x067b, 0x3507, 0x0001, 0x0101,
"Prolific Technology Inc.",
"ATAPI-6 Bridge Controller",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_FIX_CAPACITY | US_FL_GO_SLOW ),
/* Submitted by Benny Sjostrand <benny@hostmobility.com> */
UNUSUAL_DEV( 0x0686, 0x4011, 0x0001, 0x0001,
"Minolta",
"Dimage F300",
- US_SC_SCSI, US_PR_BULK, NULL, 0 ),
+ USB_SC_SCSI, USB_PR_BULK, NULL, 0 ),
/* Reported by Miguel A. Fosas <amn3s1a@ono.com> */
UNUSUAL_DEV( 0x0686, 0x4017, 0x0001, 0x0001,
"Minolta",
"DIMAGE E223",
- US_SC_SCSI, US_PR_DEVICE, NULL, 0 ),
+ USB_SC_SCSI, USB_PR_DEVICE, NULL, 0 ),
UNUSUAL_DEV( 0x0693, 0x0005, 0x0100, 0x0100,
"Hagiwara",
"Flashgate",
- US_SC_SCSI, US_PR_BULK, NULL, 0 ),
+ USB_SC_SCSI, USB_PR_BULK, NULL, 0 ),
/* Reported by David Hamilton <niftimusmaximus@lycos.com> */
UNUSUAL_DEV( 0x069b, 0x3004, 0x0001, 0x0001,
"Thomson Multimedia Inc.",
"RCA RD1080 MP3 Player",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_FIX_CAPACITY ),
/* Reported by Adrian Pilchowiec <adi1981@epf.pl> */
UNUSUAL_DEV( 0x071b, 0x3203, 0x0000, 0x0000,
"RockChip",
"MP3",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
- US_FL_NO_WP_DETECT | US_FL_MAX_SECTORS_64),
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
+ US_FL_NO_WP_DETECT | US_FL_MAX_SECTORS_64 |
+ US_FL_NO_READ_CAPACITY_16),
/* Reported by Jean-Baptiste Onofre <jb@nanthrax.net>
* Support the following product :
@@ -886,7 +887,7 @@ UNUSUAL_DEV( 0x071b, 0x3203, 0x0000, 0x0000,
UNUSUAL_DEV( 0x071b, 0x32bb, 0x0000, 0x0000,
"RockChip",
"MTP",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_NO_WP_DETECT | US_FL_MAX_SECTORS_64),
/* Reported by Massimiliano Ghilardi <massimiliano.ghilardi@gmail.com>
@@ -902,59 +903,59 @@ UNUSUAL_DEV( 0x071b, 0x32bb, 0x0000, 0x0000,
UNUSUAL_DEV( 0x071b, 0x3203, 0x0100, 0x0100,
"RockChip",
"ROCK MP3",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_MAX_SECTORS_64),
/* Reported by Olivier Blondeau <zeitoun@gmail.com> */
UNUSUAL_DEV( 0x0727, 0x0306, 0x0100, 0x0100,
"ATMEL",
"SND1 Storage",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_IGNORE_RESIDUE),
/* Submitted by Roman Hodek <roman@hodek.net> */
UNUSUAL_DEV( 0x0781, 0x0001, 0x0200, 0x0200,
"Sandisk",
"ImageMate SDDR-05a",
- US_SC_SCSI, US_PR_CB, NULL,
+ USB_SC_SCSI, USB_PR_CB, NULL,
US_FL_SINGLE_LUN ),
UNUSUAL_DEV( 0x0781, 0x0002, 0x0009, 0x0009,
"SanDisk Corporation",
"ImageMate CompactFlash USB",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_FIX_CAPACITY ),
UNUSUAL_DEV( 0x0781, 0x0100, 0x0100, 0x0100,
"Sandisk",
"ImageMate SDDR-12",
- US_SC_SCSI, US_PR_CB, NULL,
+ USB_SC_SCSI, USB_PR_CB, NULL,
US_FL_SINGLE_LUN ),
/* Reported by Eero Volotinen <eero@ping-viini.org> */
UNUSUAL_DEV( 0x07ab, 0xfccd, 0x0000, 0x9999,
"Freecom Technologies",
"FHD-Classic",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_FIX_CAPACITY),
UNUSUAL_DEV( 0x07af, 0x0004, 0x0100, 0x0133,
"Microtech",
"USB-SCSI-DB25",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_euscsi_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_euscsi_init,
US_FL_SCM_MULT_TARG ),
UNUSUAL_DEV( 0x07af, 0x0005, 0x0100, 0x0100,
"Microtech",
"USB-SCSI-HD50",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_euscsi_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_euscsi_init,
US_FL_SCM_MULT_TARG ),
#ifdef NO_SDDR09
UNUSUAL_DEV( 0x07af, 0x0006, 0x0100, 0x0100,
"Microtech",
"CameraMate",
- US_SC_SCSI, US_PR_CB, NULL,
+ USB_SC_SCSI, USB_PR_CB, NULL,
US_FL_SINGLE_LUN ),
#endif
@@ -967,7 +968,7 @@ UNUSUAL_DEV( 0x07af, 0x0006, 0x0100, 0x0100,
UNUSUAL_DEV( 0x07c4, 0xa400, 0x0000, 0xffff,
"Datafab",
"KECF-USB",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_FIX_INQUIRY | US_FL_FIX_CAPACITY ),
/* Reported by Rauch Wolke <rauchwolke@gmx.net>
@@ -976,7 +977,7 @@ UNUSUAL_DEV( 0x07c4, 0xa400, 0x0000, 0xffff,
UNUSUAL_DEV( 0x07c4, 0xa4a5, 0x0000, 0xffff,
"Simple Tech/Datafab",
"CF+SM Reader",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_IGNORE_RESIDUE | US_FL_MAX_SECTORS_64 ),
/* Casio QV 2x00/3x00/4000/8000 digital still cameras are not conformant
@@ -986,42 +987,42 @@ UNUSUAL_DEV( 0x07c4, 0xa4a5, 0x0000, 0xffff,
* - They don't like the INQUIRY command. So we must handle this command
* of the SCSI layer ourselves.
* - Some cameras with idProduct=0x1001 and bcdDevice=0x1000 have
- * bInterfaceProtocol=0x00 (US_PR_CBI) while others have 0x01 (US_PR_CB).
- * So don't remove the US_PR_CB override!
- * - Cameras with bcdDevice=0x9009 require the US_SC_8070 override.
+ * bInterfaceProtocol=0x00 (USB_PR_CBI) while others have 0x01 (USB_PR_CB).
+ * So don't remove the USB_PR_CB override!
+ * - Cameras with bcdDevice=0x9009 require the USB_SC_8070 override.
*/
UNUSUAL_DEV( 0x07cf, 0x1001, 0x1000, 0x9999,
"Casio",
"QV DigitalCamera",
- US_SC_8070, US_PR_CB, NULL,
+ USB_SC_8070, USB_PR_CB, NULL,
US_FL_NEED_OVERRIDE | US_FL_FIX_INQUIRY ),
/* Submitted by Hartmut Wahl <hwahl@hwahl.de>*/
UNUSUAL_DEV( 0x0839, 0x000a, 0x0001, 0x0001,
"Samsung",
"Digimax 410",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_FIX_INQUIRY),
/* Reported by Luciano Rocha <luciano@eurotux.com> */
UNUSUAL_DEV( 0x0840, 0x0082, 0x0001, 0x0001,
"Argosy",
"Storage",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_FIX_CAPACITY),
/* Reported and patched by Nguyen Anh Quynh <aquynh@gmail.com> */
UNUSUAL_DEV( 0x0840, 0x0084, 0x0001, 0x0001,
"Argosy",
"Storage",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_FIX_CAPACITY),
/* Reported by Martijn Hijdra <martijn.hijdra@gmail.com> */
UNUSUAL_DEV( 0x0840, 0x0085, 0x0001, 0x0001,
"Argosy",
"Storage",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_FIX_CAPACITY),
/* Entry and supporting patch by Theodore Kilgore <kilgota@auburn.edu>.
@@ -1033,7 +1034,7 @@ UNUSUAL_DEV( 0x0840, 0x0085, 0x0001, 0x0001,
UNUSUAL_DEV( 0x084d, 0x0011, 0x0110, 0x0110,
"Grandtech",
"DC2MEGA",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_BULK32),
/* Andrew Lunn <andrew@lunn.ch>
@@ -1044,14 +1045,14 @@ UNUSUAL_DEV( 0x084d, 0x0011, 0x0110, 0x0110,
UNUSUAL_DEV( 0x0851, 0x1543, 0x0200, 0x0200,
"PanDigital",
"Photo Frame",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_NOT_LOCKABLE),
/* Submitted by Jan De Luyck <lkml@kcore.org> */
UNUSUAL_DEV( 0x08bd, 0x1100, 0x0000, 0x0000,
"CITIZEN",
"X1DE-USB",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_SINGLE_LUN),
/* Submitted by Dylan Taft <d13f00l@gmail.com>
@@ -1060,7 +1061,7 @@ UNUSUAL_DEV( 0x08bd, 0x1100, 0x0000, 0x0000,
UNUSUAL_DEV( 0x08ca, 0x3103, 0x0100, 0x0100,
"AIPTEK",
"Aiptek USB Keychain MP3 Player",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_IGNORE_RESIDUE),
/* Entry needed for flags. Moreover, all devices with this ID use
@@ -1071,7 +1072,7 @@ UNUSUAL_DEV( 0x08ca, 0x3103, 0x0100, 0x0100,
UNUSUAL_DEV( 0x090a, 0x1001, 0x0100, 0x0100,
"Trumpion",
"t33520 USB Flash Card Controller",
- US_SC_DEVICE, US_PR_BULK, NULL,
+ USB_SC_DEVICE, USB_PR_BULK, NULL,
US_FL_NEED_OVERRIDE ),
/* Reported by Filippo Bardelli <filibard@libero.it>
@@ -1080,21 +1081,21 @@ UNUSUAL_DEV( 0x090a, 0x1001, 0x0100, 0x0100,
UNUSUAL_DEV( 0x090a, 0x1050, 0x0100, 0x0100,
"Trumpion Microelectronics, Inc.",
"33520 USB Digital Voice Recorder",
- US_SC_UFI, US_PR_DEVICE, NULL,
+ USB_SC_UFI, USB_PR_DEVICE, NULL,
0),
/* Trumpion Microelectronics MP3 player (felipe_alfaro@linuxmail.org) */
UNUSUAL_DEV( 0x090a, 0x1200, 0x0000, 0x9999,
"Trumpion",
"MP3 player",
- US_SC_RBC, US_PR_BULK, NULL,
+ USB_SC_RBC, USB_PR_BULK, NULL,
0 ),
/* aeb */
UNUSUAL_DEV( 0x090c, 0x1132, 0x0000, 0xffff,
"Feiya",
"5-in-1 Card Reader",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_FIX_CAPACITY ),
/* This Pentax still camera is not conformant
@@ -1107,7 +1108,7 @@ UNUSUAL_DEV( 0x090c, 0x1132, 0x0000, 0xffff,
UNUSUAL_DEV( 0x0a17, 0x0004, 0x1000, 0x1000,
"Pentax",
"Optio 2/3/400",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_FIX_INQUIRY ),
/* These are virtual windows driver CDs, which the zd1211rw driver
@@ -1115,13 +1116,13 @@ UNUSUAL_DEV( 0x0a17, 0x0004, 0x1000, 0x1000,
UNUSUAL_DEV( 0x0ace, 0x2011, 0x0101, 0x0101,
"ZyXEL",
"G-220F USB-WLAN Install",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_IGNORE_DEVICE ),
UNUSUAL_DEV( 0x0ace, 0x20ff, 0x0101, 0x0101,
"SiteCom",
"WL-117 USB-WLAN Install",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_IGNORE_DEVICE ),
/* Reported by Dan Williams <dcbw@redhat.com>
@@ -1133,7 +1134,7 @@ UNUSUAL_DEV( 0x0ace, 0x20ff, 0x0101, 0x0101,
UNUSUAL_DEV( 0x0af0, 0x6971, 0x0000, 0x9999,
"Option N.V.",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, option_ms_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, option_ms_init,
0),
/* Reported by F. Aben <f.aben@option.com>
@@ -1143,7 +1144,7 @@ UNUSUAL_DEV( 0x0af0, 0x6971, 0x0000, 0x9999,
UNUSUAL_DEV( 0x0af0, 0x7401, 0x0000, 0x0000,
"Option",
"GI 0401 SD-Card",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
0 ),
/* Reported by Jan Dumon <j.dumon@option.com>
@@ -1153,104 +1154,104 @@ UNUSUAL_DEV( 0x0af0, 0x7401, 0x0000, 0x0000,
UNUSUAL_DEV( 0x0af0, 0x7501, 0x0000, 0x0000,
"Option",
"GI 0431 SD-Card",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
0 ),
UNUSUAL_DEV( 0x0af0, 0x7701, 0x0000, 0x0000,
"Option",
"GI 0451 SD-Card",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
0 ),
UNUSUAL_DEV( 0x0af0, 0x7706, 0x0000, 0x0000,
"Option",
"GI 0451 SD-Card",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
0 ),
UNUSUAL_DEV( 0x0af0, 0x7901, 0x0000, 0x0000,
"Option",
"GI 0452 SD-Card",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
0 ),
UNUSUAL_DEV( 0x0af0, 0x7A01, 0x0000, 0x0000,
"Option",
"GI 0461 SD-Card",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
0 ),
UNUSUAL_DEV( 0x0af0, 0x7A05, 0x0000, 0x0000,
"Option",
"GI 0461 SD-Card",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
0 ),
UNUSUAL_DEV( 0x0af0, 0x8300, 0x0000, 0x0000,
"Option",
"GI 033x SD-Card",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
0 ),
UNUSUAL_DEV( 0x0af0, 0x8302, 0x0000, 0x0000,
"Option",
"GI 033x SD-Card",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
0 ),
UNUSUAL_DEV( 0x0af0, 0x8304, 0x0000, 0x0000,
"Option",
"GI 033x SD-Card",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
0 ),
UNUSUAL_DEV( 0x0af0, 0xc100, 0x0000, 0x0000,
"Option",
"GI 070x SD-Card",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
0 ),
UNUSUAL_DEV( 0x0af0, 0xd057, 0x0000, 0x0000,
"Option",
"GI 1505 SD-Card",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
0 ),
UNUSUAL_DEV( 0x0af0, 0xd058, 0x0000, 0x0000,
"Option",
"GI 1509 SD-Card",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
0 ),
UNUSUAL_DEV( 0x0af0, 0xd157, 0x0000, 0x0000,
"Option",
"GI 1515 SD-Card",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
0 ),
UNUSUAL_DEV( 0x0af0, 0xd257, 0x0000, 0x0000,
"Option",
"GI 1215 SD-Card",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
0 ),
UNUSUAL_DEV( 0x0af0, 0xd357, 0x0000, 0x0000,
"Option",
"GI 1505 SD-Card",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
0 ),
/* Reported by Ben Efros <ben@pc-doctor.com> */
UNUSUAL_DEV( 0x0bc2, 0x3010, 0x0000, 0x0000,
"Seagate",
"FreeAgent Pro",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_SANE_SENSE ),
UNUSUAL_DEV( 0x0d49, 0x7310, 0x0000, 0x9999,
"Maxtor",
"USB to SATA",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_SANE_SENSE),
/*
@@ -1260,14 +1261,14 @@ UNUSUAL_DEV( 0x0d49, 0x7310, 0x0000, 0x9999,
UNUSUAL_DEV( 0x0c45, 0x1060, 0x0100, 0x0100,
"Unknown",
"Unknown",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_SINGLE_LUN ),
/* Submitted by Joris Struyve <joris@struyve.be> */
UNUSUAL_DEV( 0x0d96, 0x410a, 0x0001, 0xffff,
"Medion",
"MD 7425",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_FIX_INQUIRY),
/*
@@ -1278,13 +1279,13 @@ UNUSUAL_DEV( 0x0d96, 0x410a, 0x0001, 0xffff,
UNUSUAL_DEV( 0x0d96, 0x5200, 0x0001, 0x0200,
"Jenoptik",
"JD 5200 z3",
- US_SC_DEVICE, US_PR_DEVICE, NULL, US_FL_FIX_INQUIRY),
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL, US_FL_FIX_INQUIRY),
/* Reported by Jason Johnston <killean@shaw.ca> */
UNUSUAL_DEV( 0x0dc4, 0x0073, 0x0000, 0x0000,
"Macpower Technology Co.LTD.",
"USB 2.0 3.5\" DEVICE",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_FIX_CAPACITY),
/* Reported by Lubomir Blaha <tritol@trilogic.cz>
@@ -1295,7 +1296,7 @@ UNUSUAL_DEV( 0x0dc4, 0x0073, 0x0000, 0x0000,
UNUSUAL_DEV( 0x0dd8, 0x1060, 0x0000, 0xffff,
"Netac",
"USB-CF-Card",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_FIX_INQUIRY ),
/* Reported by Edward Chapman (taken from linux-usb mailing list)
@@ -1303,7 +1304,7 @@ UNUSUAL_DEV( 0x0dd8, 0x1060, 0x0000, 0xffff,
UNUSUAL_DEV( 0x0dd8, 0xd202, 0x0000, 0x9999,
"Netac",
"USB Flash Disk",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_IGNORE_RESIDUE ),
@@ -1312,28 +1313,28 @@ UNUSUAL_DEV( 0x0dd8, 0xd202, 0x0000, 0x9999,
UNUSUAL_DEV( 0x0dda, 0x0001, 0x0012, 0x0012,
"WINWARD",
"Music Disk",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_IGNORE_RESIDUE ),
/* Reported by Ian McConnell <ian at emit.demon.co.uk> */
UNUSUAL_DEV( 0x0dda, 0x0301, 0x0012, 0x0012,
"PNP_MP3",
"PNP_MP3 PLAYER",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_IGNORE_RESIDUE ),
/* Reported by Jim McCloskey <mcclosk@ucsc.edu> */
UNUSUAL_DEV( 0x0e21, 0x0520, 0x0100, 0x0100,
"Cowon Systems",
"iAUDIO M5",
- US_SC_DEVICE, US_PR_BULK, NULL,
+ USB_SC_DEVICE, USB_PR_BULK, NULL,
US_FL_NEED_OVERRIDE ),
/* Submitted by Antoine Mairesse <antoine.mairesse@free.fr> */
UNUSUAL_DEV( 0x0ed1, 0x6660, 0x0100, 0x0300,
"USB",
"Solid state disk",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_FIX_INQUIRY ),
/* Submitted by Daniel Drake <dsd@gentoo.org>
@@ -1341,14 +1342,14 @@ UNUSUAL_DEV( 0x0ed1, 0x6660, 0x0100, 0x0300,
UNUSUAL_DEV( 0x0ea0, 0x2168, 0x0110, 0x0110,
"Ours Technology",
"Flash Disk",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_IGNORE_RESIDUE ),
/* Reported by Rastislav Stanik <rs_kernel@yahoo.com> */
UNUSUAL_DEV( 0x0ea0, 0x6828, 0x0110, 0x0110,
"USB",
"Flash Disk",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_IGNORE_RESIDUE ),
/* Reported by Benjamin Schiller <sbenni@gmx.de>
@@ -1356,7 +1357,7 @@ UNUSUAL_DEV( 0x0ea0, 0x6828, 0x0110, 0x0110,
UNUSUAL_DEV( 0x0ed1, 0x7636, 0x0103, 0x0103,
"Typhoon",
"My DJ 1820",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_IGNORE_RESIDUE | US_FL_GO_SLOW | US_FL_MAX_SECTORS_64),
/* Patch by Leonid Petrov mail at lpetrov.net
@@ -1367,7 +1368,7 @@ UNUSUAL_DEV( 0x0ed1, 0x7636, 0x0103, 0x0103,
UNUSUAL_DEV( 0x0f19, 0x0103, 0x0100, 0x0100,
"Oracom Co., Ltd",
"ORC-200M",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_IGNORE_RESIDUE ),
/* David Kuehling <dvdkhlng@gmx.de>:
@@ -1377,21 +1378,21 @@ UNUSUAL_DEV( 0x0f19, 0x0103, 0x0100, 0x0100,
UNUSUAL_DEV( 0x0f19, 0x0105, 0x0100, 0x0100,
"C-MEX",
"A-VOX",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_IGNORE_RESIDUE ),
/* Reported by Michael Stattmann <michael@stattmann.com> */
UNUSUAL_DEV( 0x0fce, 0xd008, 0x0000, 0x0000,
"Sony Ericsson",
"V800-Vodafone 802",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_NO_WP_DETECT ),
/* Reported by The Solutor <thesolutor@gmail.com> */
UNUSUAL_DEV( 0x0fce, 0xd0e1, 0x0000, 0x0000,
"Sony Ericsson",
"MD400",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_IGNORE_DEVICE),
/* Reported by Jan Mate <mate@fiit.stuba.sk>
@@ -1399,21 +1400,21 @@ UNUSUAL_DEV( 0x0fce, 0xd0e1, 0x0000, 0x0000,
UNUSUAL_DEV( 0x0fce, 0xe030, 0x0000, 0x0000,
"Sony Ericsson",
"P990i",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_FIX_CAPACITY | US_FL_IGNORE_RESIDUE ),
/* Reported by Emmanuel Vasilakis <evas@forthnet.gr> */
UNUSUAL_DEV( 0x0fce, 0xe031, 0x0000, 0x0000,
"Sony Ericsson",
"M600i",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_IGNORE_RESIDUE | US_FL_FIX_CAPACITY ),
/* Reported by Ricardo Barberis <ricardo@dattatec.com> */
UNUSUAL_DEV( 0x0fce, 0xe092, 0x0000, 0x0000,
"Sony Ericsson",
"P1i",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_IGNORE_RESIDUE ),
/* Reported by Kevin Cernekee <kpc-usbdev@gelato.uiuc.edu>
@@ -1425,13 +1426,13 @@ UNUSUAL_DEV( 0x0fce, 0xe092, 0x0000, 0x0000,
UNUSUAL_DEV( 0x1019, 0x0c55, 0x0000, 0x0110,
"Desknote",
"UCR-61S2B",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_ucr61s2b_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_ucr61s2b_init,
0 ),
UNUSUAL_DEV( 0x1058, 0x0704, 0x0000, 0x9999,
"Western Digital",
"External HDD",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_SANE_SENSE),
/* Reported by Fabio Venturi <f.venturi@tdnet.it>
@@ -1440,7 +1441,7 @@ UNUSUAL_DEV( 0x1058, 0x0704, 0x0000, 0x9999,
UNUSUAL_DEV( 0x10d6, 0x2200, 0x0100, 0x0100,
"Actions Semiconductor",
"Mtp device",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
0),
/* Reported by Pascal Terjan <pterjan@mandriva.com>
@@ -1449,7 +1450,7 @@ UNUSUAL_DEV( 0x10d6, 0x2200, 0x0100, 0x0100,
UNUSUAL_DEV( 0x1186, 0x3e04, 0x0000, 0x0000,
"D-Link",
"USB Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, option_ms_init, US_FL_IGNORE_DEVICE),
+ USB_SC_DEVICE, USB_PR_DEVICE, option_ms_init, US_FL_IGNORE_DEVICE),
/* Reported by Kevin Lloyd <linux@sierrawireless.com>
* Entry is needed for the initializer function override,
@@ -1459,7 +1460,7 @@ UNUSUAL_DEV( 0x1186, 0x3e04, 0x0000, 0x0000,
UNUSUAL_DEV( 0x1199, 0x0fff, 0x0000, 0x9999,
"Sierra Wireless",
"USB MMC Storage",
- US_SC_DEVICE, US_PR_DEVICE, sierra_ms_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, sierra_ms_init,
0),
/* Reported by Jaco Kroon <jaco@kroon.co.za>
@@ -1469,7 +1470,7 @@ UNUSUAL_DEV( 0x1199, 0x0fff, 0x0000, 0x9999,
UNUSUAL_DEV( 0x1210, 0x0003, 0x0100, 0x0100,
"Digitech HMG",
"DigiTech Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_IGNORE_RESIDUE ),
/* Reported by fangxiaozhi <huananhu@huawei.com>
@@ -1478,353 +1479,353 @@ UNUSUAL_DEV( 0x1210, 0x0003, 0x0100, 0x0100,
UNUSUAL_DEV( 0x12d1, 0x1001, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x1003, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x1004, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x1401, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x1402, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x1403, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x1404, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x1405, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x1406, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x1407, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x1408, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x1409, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x140A, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x140B, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x140C, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x140D, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x140E, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x140F, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x1410, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x1411, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x1412, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x1413, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x1414, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x1415, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x1416, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x1417, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x1418, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x1419, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x141A, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x141B, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x141C, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x141D, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x141E, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x141F, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x1420, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x1421, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x1422, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x1423, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x1424, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x1425, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x1426, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x1427, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x1428, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x1429, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x142A, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x142B, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x142C, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x142D, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x142E, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x142F, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x1430, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x1431, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x1432, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x1433, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x1434, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x1435, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x1436, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x1437, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x1438, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x1439, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x143A, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x143B, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x143C, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x143D, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x143E, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
UNUSUAL_DEV( 0x12d1, 0x143F, 0x0000, 0x0000,
"HUAWEI MOBILE",
"Mass Storage",
- US_SC_DEVICE, US_PR_DEVICE, usb_stor_huawei_e220_init,
+ USB_SC_DEVICE, USB_PR_DEVICE, usb_stor_huawei_e220_init,
0),
/* Reported by Vilius Bilinkevicius <vilisas AT xxx DOT lt) */
UNUSUAL_DEV( 0x132b, 0x000b, 0x0001, 0x0001,
"Minolta",
"Dimage Z10",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
0 ),
/* Reported by Kotrla Vitezslav <kotrla@ceb.cz> */
UNUSUAL_DEV( 0x1370, 0x6828, 0x0110, 0x0110,
"SWISSBIT",
"Black Silver",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_IGNORE_RESIDUE ),
/* Reported by Francesco Foresti <frafore@tiscali.it> */
UNUSUAL_DEV( 0x14cd, 0x6600, 0x0201, 0x0201,
"Super Top",
"IDE DEVICE",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_IGNORE_RESIDUE ),
/* Reported by Alexandre Oliva <oliva@lsd.ic.unicamp.br>
@@ -1833,7 +1834,7 @@ UNUSUAL_DEV( 0x14cd, 0x6600, 0x0201, 0x0201,
UNUSUAL_DEV( 0x152d, 0x2329, 0x0100, 0x0100,
"JMicron",
"USB to ATA/ATAPI Bridge",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_IGNORE_RESIDUE | US_FL_SANE_SENSE ),
/* Reported by Robert Schedel <r.schedel@yahoo.de>
@@ -1841,7 +1842,7 @@ UNUSUAL_DEV( 0x152d, 0x2329, 0x0100, 0x0100,
UNUSUAL_DEV( 0x1652, 0x6600, 0x0201, 0x0201,
"Teac",
"HD-35PUK-B",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_IGNORE_RESIDUE ),
/* Reported by Hans de Goede <hdegoede@redhat.com>
@@ -1851,18 +1852,23 @@ UNUSUAL_DEV( 0x1652, 0x6600, 0x0201, 0x0201,
UNUSUAL_DEV( 0x1908, 0x1315, 0x0000, 0x0000,
"BUILDWIN",
"Photo Frame",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_BAD_SENSE ),
UNUSUAL_DEV( 0x1908, 0x1320, 0x0000, 0x0000,
"BUILDWIN",
"Photo Frame",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_BAD_SENSE ),
+UNUSUAL_DEV( 0x1908, 0x3335, 0x0200, 0x0200,
+ "BUILDWIN",
+ "Photo Frame",
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
+ US_FL_NO_READ_DISC_INFO ),
UNUSUAL_DEV( 0x2116, 0x0320, 0x0001, 0x0001,
"ST",
"2A",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_FIX_CAPACITY),
/* patch submitted by Davide Perini <perini.davide@dpsoftware.org>
@@ -1871,7 +1877,7 @@ UNUSUAL_DEV( 0x2116, 0x0320, 0x0001, 0x0001,
UNUSUAL_DEV( 0x22b8, 0x3010, 0x0001, 0x0001,
"Motorola",
"RAZR V3x",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_FIX_CAPACITY | US_FL_IGNORE_RESIDUE ),
/*
@@ -1882,14 +1888,14 @@ UNUSUAL_DEV( 0x22b8, 0x3010, 0x0001, 0x0001,
UNUSUAL_DEV( 0x22b8, 0x6426, 0x0101, 0x0101,
"Motorola",
"MSnc.",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_FIX_INQUIRY | US_FL_FIX_CAPACITY | US_FL_BULK_IGNORE_TAG),
/* Reported by Radovan Garabik <garabik@kassiopeia.juls.savba.sk> */
UNUSUAL_DEV( 0x2735, 0x100b, 0x0000, 0x9999,
"MPIO",
"HS200",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_GO_SLOW ),
/* Reported by Frederic Marchal <frederic.marchal@wowcompany.com>
@@ -1898,21 +1904,21 @@ UNUSUAL_DEV( 0x2735, 0x100b, 0x0000, 0x9999,
UNUSUAL_DEV( 0x3340, 0xffff, 0x0000, 0x0000,
"Mitac",
"Mio DigiWalker USB Sync",
- US_SC_DEVICE,US_PR_DEVICE,NULL,
+ USB_SC_DEVICE,USB_PR_DEVICE,NULL,
US_FL_MAX_SECTORS_64 ),
/* Reported by Andrey Rahmatullin <wrar@altlinux.org> */
UNUSUAL_DEV( 0x4102, 0x1020, 0x0100, 0x0100,
"iRiver",
"MP3 T10",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_IGNORE_RESIDUE ),
/* Reported by Sergey Pinaev <dfo@antex.ru> */
UNUSUAL_DEV( 0x4102, 0x1059, 0x0000, 0x0000,
"iRiver",
"P7K",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_MAX_SECTORS_64 ),
/*
@@ -1922,41 +1928,41 @@ UNUSUAL_DEV( 0x4102, 0x1059, 0x0000, 0x0000,
UNUSUAL_DEV( 0x4146, 0xba01, 0x0100, 0x0100,
"Iomega",
"Micro Mini 1GB",
- US_SC_DEVICE, US_PR_DEVICE, NULL, US_FL_NOT_LOCKABLE ),
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL, US_FL_NOT_LOCKABLE ),
/* Reported by Andrew Simmons <andrew.simmons@gmail.com> */
UNUSUAL_DEV( 0xed06, 0x4500, 0x0001, 0x0001,
"DataStor",
"USB4500 FW1.04",
- US_SC_DEVICE, US_PR_DEVICE, NULL,
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
US_FL_CAPACITY_HEURISTICS),
/* Reported by Alessio Treglia <quadrispro@ubuntu.com> */
UNUSUAL_DEV( 0xed10, 0x7636, 0x0001, 0x0001,
"TGE",
"Digital MP3 Audio Player",
- US_SC_DEVICE, US_PR_DEVICE, NULL, US_FL_NOT_LOCKABLE ),
+ USB_SC_DEVICE, USB_PR_DEVICE, NULL, US_FL_NOT_LOCKABLE ),
/* Control/Bulk transport for all SubClass values */
-USUAL_DEV(US_SC_RBC, US_PR_CB, USB_US_TYPE_STOR),
-USUAL_DEV(US_SC_8020, US_PR_CB, USB_US_TYPE_STOR),
-USUAL_DEV(US_SC_QIC, US_PR_CB, USB_US_TYPE_STOR),
-USUAL_DEV(US_SC_UFI, US_PR_CB, USB_US_TYPE_STOR),
-USUAL_DEV(US_SC_8070, US_PR_CB, USB_US_TYPE_STOR),
-USUAL_DEV(US_SC_SCSI, US_PR_CB, USB_US_TYPE_STOR),
+USUAL_DEV(USB_SC_RBC, USB_PR_CB, USB_US_TYPE_STOR),
+USUAL_DEV(USB_SC_8020, USB_PR_CB, USB_US_TYPE_STOR),
+USUAL_DEV(USB_SC_QIC, USB_PR_CB, USB_US_TYPE_STOR),
+USUAL_DEV(USB_SC_UFI, USB_PR_CB, USB_US_TYPE_STOR),
+USUAL_DEV(USB_SC_8070, USB_PR_CB, USB_US_TYPE_STOR),
+USUAL_DEV(USB_SC_SCSI, USB_PR_CB, USB_US_TYPE_STOR),
/* Control/Bulk/Interrupt transport for all SubClass values */
-USUAL_DEV(US_SC_RBC, US_PR_CBI, USB_US_TYPE_STOR),
-USUAL_DEV(US_SC_8020, US_PR_CBI, USB_US_TYPE_STOR),
-USUAL_DEV(US_SC_QIC, US_PR_CBI, USB_US_TYPE_STOR),
-USUAL_DEV(US_SC_UFI, US_PR_CBI, USB_US_TYPE_STOR),
-USUAL_DEV(US_SC_8070, US_PR_CBI, USB_US_TYPE_STOR),
-USUAL_DEV(US_SC_SCSI, US_PR_CBI, USB_US_TYPE_STOR),
+USUAL_DEV(USB_SC_RBC, USB_PR_CBI, USB_US_TYPE_STOR),
+USUAL_DEV(USB_SC_8020, USB_PR_CBI, USB_US_TYPE_STOR),
+USUAL_DEV(USB_SC_QIC, USB_PR_CBI, USB_US_TYPE_STOR),
+USUAL_DEV(USB_SC_UFI, USB_PR_CBI, USB_US_TYPE_STOR),
+USUAL_DEV(USB_SC_8070, USB_PR_CBI, USB_US_TYPE_STOR),
+USUAL_DEV(USB_SC_SCSI, USB_PR_CBI, USB_US_TYPE_STOR),
/* Bulk-only transport for all SubClass values */
-USUAL_DEV(US_SC_RBC, US_PR_BULK, USB_US_TYPE_STOR),
-USUAL_DEV(US_SC_8020, US_PR_BULK, USB_US_TYPE_STOR),
-USUAL_DEV(US_SC_QIC, US_PR_BULK, USB_US_TYPE_STOR),
-USUAL_DEV(US_SC_UFI, US_PR_BULK, USB_US_TYPE_STOR),
-USUAL_DEV(US_SC_8070, US_PR_BULK, USB_US_TYPE_STOR),
-USUAL_DEV(US_SC_SCSI, US_PR_BULK, 0),
+USUAL_DEV(USB_SC_RBC, USB_PR_BULK, USB_US_TYPE_STOR),
+USUAL_DEV(USB_SC_8020, USB_PR_BULK, USB_US_TYPE_STOR),
+USUAL_DEV(USB_SC_QIC, USB_PR_BULK, USB_US_TYPE_STOR),
+USUAL_DEV(USB_SC_UFI, USB_PR_BULK, USB_US_TYPE_STOR),
+USUAL_DEV(USB_SC_8070, USB_PR_BULK, USB_US_TYPE_STOR),
+USUAL_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 @@
UNUSUAL_DEV( 0x07ab, 0xfc01, 0x0000, 0x9999,
"Freecom",
"USB-IDE",
- US_SC_QIC, US_PR_FREECOM, init_freecom, 0),
+ USB_SC_QIC, USB_PR_FREECOM, init_freecom, 0),
#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 @@
UNUSUAL_DEV( 0x054c, 0x002b, 0x0100, 0x0110,
"Sony",
"Portable USB Harddrive V2",
- US_SC_ISD200, US_PR_BULK, isd200_Initialization,
+ USB_SC_ISD200, USB_PR_BULK, isd200_Initialization,
0),
UNUSUAL_DEV( 0x05ab, 0x0031, 0x0100, 0x0110,
"In-System",
"USB/IDE Bridge (ATA/ATAPI)",
- US_SC_ISD200, US_PR_BULK, isd200_Initialization,
+ USB_SC_ISD200, USB_PR_BULK, isd200_Initialization,
0),
UNUSUAL_DEV( 0x05ab, 0x0301, 0x0100, 0x0110,
"In-System",
"Portable USB Harddrive V2",
- US_SC_ISD200, US_PR_BULK, isd200_Initialization,
+ USB_SC_ISD200, USB_PR_BULK, isd200_Initialization,
0),
UNUSUAL_DEV( 0x05ab, 0x0351, 0x0100, 0x0110,
"In-System",
"Portable USB Harddrive V2",
- US_SC_ISD200, US_PR_BULK, isd200_Initialization,
+ USB_SC_ISD200, USB_PR_BULK, isd200_Initialization,
0),
UNUSUAL_DEV( 0x05ab, 0x5701, 0x0100, 0x0110,
"In-System",
"USB Storage Adapter V2",
- US_SC_ISD200, US_PR_BULK, isd200_Initialization,
+ USB_SC_ISD200, USB_PR_BULK, isd200_Initialization,
0),
UNUSUAL_DEV( 0x0bf6, 0xa001, 0x0100, 0x0110,
"ATI",
"USB Cable 205",
- US_SC_ISD200, US_PR_BULK, isd200_Initialization,
+ USB_SC_ISD200, USB_PR_BULK, isd200_Initialization,
0),
#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 @@
UNUSUAL_DEV( 0x05dc, 0x0001, 0x0000, 0x0001,
"Lexar",
"Jumpshot USB CF Reader",
- US_SC_SCSI, US_PR_JUMPSHOT, NULL,
+ USB_SC_SCSI, USB_PR_JUMPSHOT, NULL,
US_FL_NEED_OVERRIDE),
#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 @@
UNUSUAL_DEV( 0x045a, 0x5210, 0x0101, 0x0101,
"Rio",
"Rio Karma",
- US_SC_SCSI, US_PR_KARMA, rio_karma_init, 0),
+ USB_SC_SCSI, USB_PR_KARMA, rio_karma_init, 0),
#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 @@
UNUSUAL_DEV( 0x0d49, 0x7000, 0x0000, 0x9999,
"Maxtor",
"OneTouch External Harddrive",
- US_SC_DEVICE, US_PR_DEVICE, onetouch_connect_input,
+ USB_SC_DEVICE, USB_PR_DEVICE, onetouch_connect_input,
0),
UNUSUAL_DEV( 0x0d49, 0x7010, 0x0000, 0x9999,
"Maxtor",
"OneTouch External Harddrive",
- US_SC_DEVICE, US_PR_DEVICE, onetouch_connect_input,
+ USB_SC_DEVICE, USB_PR_DEVICE, onetouch_connect_input,
0),
#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 @@
UNUSUAL_DEV( 0x0436, 0x0005, 0x0100, 0x0100,
"Microtech",
"CameraMate (DPCM_USB)",
- US_SC_SCSI, US_PR_DPCM_USB, NULL, 0),
+ USB_SC_SCSI, USB_PR_DPCM_USB, NULL, 0),
UNUSUAL_DEV( 0x04e6, 0x0003, 0x0000, 0x9999,
"Sandisk",
"ImageMate SDDR09",
- US_SC_SCSI, US_PR_EUSB_SDDR09, usb_stor_sddr09_init,
+ USB_SC_SCSI, USB_PR_EUSB_SDDR09, usb_stor_sddr09_init,
0),
/* This entry is from Andries.Brouwer@cwi.nl */
UNUSUAL_DEV( 0x04e6, 0x0005, 0x0100, 0x0208,
"SCM Microsystems",
"eUSB SmartMedia / CompactFlash Adapter",
- US_SC_SCSI, US_PR_DPCM_USB, usb_stor_sddr09_dpcm_init,
+ USB_SC_SCSI, USB_PR_DPCM_USB, usb_stor_sddr09_dpcm_init,
0),
UNUSUAL_DEV( 0x066b, 0x0105, 0x0100, 0x0100,
"Olympus",
"Camedia MAUSB-2",
- US_SC_SCSI, US_PR_EUSB_SDDR09, usb_stor_sddr09_init,
+ USB_SC_SCSI, USB_PR_EUSB_SDDR09, usb_stor_sddr09_init,
0),
UNUSUAL_DEV( 0x0781, 0x0200, 0x0000, 0x9999,
"Sandisk",
"ImageMate SDDR-09",
- US_SC_SCSI, US_PR_EUSB_SDDR09, usb_stor_sddr09_init,
+ USB_SC_SCSI, USB_PR_EUSB_SDDR09, usb_stor_sddr09_init,
0),
UNUSUAL_DEV( 0x07af, 0x0006, 0x0100, 0x0100,
"Microtech",
"CameraMate (DPCM_USB)",
- US_SC_SCSI, US_PR_DPCM_USB, NULL, 0),
+ USB_SC_SCSI, USB_PR_DPCM_USB, NULL, 0),
#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 @@
UNUSUAL_DEV( 0x07c4, 0xa103, 0x0000, 0x9999,
"Datafab",
"MDSM-B reader",
- US_SC_SCSI, US_PR_SDDR55, NULL,
+ USB_SC_SCSI, USB_PR_SDDR55, NULL,
US_FL_FIX_INQUIRY),
/* SM part - aeb <Andries.Brouwer@cwi.nl> */
UNUSUAL_DEV( 0x07c4, 0xa109, 0x0000, 0xffff,
"Datafab Systems, Inc.",
"USB to CF + SM Combo (LC1)",
- US_SC_SCSI, US_PR_SDDR55, NULL, 0),
+ USB_SC_SCSI, USB_PR_SDDR55, NULL, 0),
UNUSUAL_DEV( 0x0c0b, 0xa109, 0x0000, 0xffff,
"Acomdata",
"SM",
- US_SC_SCSI, US_PR_SDDR55, NULL, 0),
+ USB_SC_SCSI, USB_PR_SDDR55, NULL, 0),
UNUSUAL_DEV( 0x55aa, 0xa103, 0x0000, 0x9999,
"Sandisk",
"ImageMate SDDR55",
- US_SC_SCSI, US_PR_SDDR55, NULL, 0),
+ USB_SC_SCSI, USB_PR_SDDR55, NULL, 0),
#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 @@
UNUSUAL_DEV( 0x03f0, 0x0207, 0x0001, 0x0001,
"HP",
"CD-Writer+ 8200e",
- US_SC_8070, US_PR_USBAT, init_usbat_cd, 0),
+ USB_SC_8070, USB_PR_USBAT, init_usbat_cd, 0),
UNUSUAL_DEV( 0x03f0, 0x0307, 0x0001, 0x0001,
"HP",
"CD-Writer+ CD-4e",
- US_SC_8070, US_PR_USBAT, init_usbat_cd, 0),
+ USB_SC_8070, USB_PR_USBAT, init_usbat_cd, 0),
UNUSUAL_DEV( 0x04e6, 0x1010, 0x0000, 0x9999,
"Shuttle/SCM",
"USBAT-02",
- US_SC_SCSI, US_PR_USBAT, init_usbat_flash,
+ USB_SC_SCSI, USB_PR_USBAT, init_usbat_flash,
US_FL_SINGLE_LUN),
UNUSUAL_DEV( 0x0781, 0x0005, 0x0005, 0x0005,
"Sandisk",
"ImageMate SDDR-05b",
- US_SC_SCSI, US_PR_USBAT, init_usbat_flash,
+ USB_SC_SCSI, USB_PR_USBAT, init_usbat_flash,
US_FL_SINGLE_LUN),
#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,
/* Store the entries */
us->unusual_dev = unusual_dev;
- us->subclass = (unusual_dev->useProtocol == US_SC_DEVICE) ?
+ us->subclass = (unusual_dev->useProtocol == USB_SC_DEVICE) ?
idesc->bInterfaceSubClass :
unusual_dev->useProtocol;
- us->protocol = (unusual_dev->useTransport == US_PR_DEVICE) ?
+ us->protocol = (unusual_dev->useTransport == USB_PR_DEVICE) ?
idesc->bInterfaceProtocol :
unusual_dev->useTransport;
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,
struct usb_device_descriptor *ddesc = &dev->descriptor;
int msg = -1;
- if (unusual_dev->useProtocol != US_SC_DEVICE &&
+ if (unusual_dev->useProtocol != USB_SC_DEVICE &&
us->subclass == idesc->bInterfaceSubClass)
msg += 1;
- if (unusual_dev->useTransport != US_PR_DEVICE &&
+ if (unusual_dev->useTransport != USB_PR_DEVICE &&
us->protocol == idesc->bInterfaceProtocol)
msg += 2;
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,
static void get_transport(struct us_data *us)
{
switch (us->protocol) {
- case US_PR_CB:
+ case USB_PR_CB:
us->transport_name = "Control/Bulk";
us->transport = usb_stor_CB_transport;
us->transport_reset = usb_stor_CB_reset;
us->max_lun = 7;
break;
- case US_PR_CBI:
+ case USB_PR_CBI:
us->transport_name = "Control/Bulk/Interrupt";
us->transport = usb_stor_CB_transport;
us->transport_reset = usb_stor_CB_reset;
us->max_lun = 7;
break;
- case US_PR_BULK:
+ case USB_PR_BULK:
us->transport_name = "Bulk";
us->transport = usb_stor_Bulk_transport;
us->transport_reset = usb_stor_Bulk_reset;
@@ -608,35 +608,35 @@ static void get_transport(struct us_data *us)
static void get_protocol(struct us_data *us)
{
switch (us->subclass) {
- case US_SC_RBC:
+ case USB_SC_RBC:
us->protocol_name = "Reduced Block Commands (RBC)";
us->proto_handler = usb_stor_transparent_scsi_command;
break;
- case US_SC_8020:
+ case USB_SC_8020:
us->protocol_name = "8020i";
us->proto_handler = usb_stor_pad12_command;
us->max_lun = 0;
break;
- case US_SC_QIC:
+ case USB_SC_QIC:
us->protocol_name = "QIC-157";
us->proto_handler = usb_stor_pad12_command;
us->max_lun = 0;
break;
- case US_SC_8070:
+ case USB_SC_8070:
us->protocol_name = "8070i";
us->proto_handler = usb_stor_pad12_command;
us->max_lun = 0;
break;
- case US_SC_SCSI:
+ case USB_SC_SCSI:
us->protocol_name = "Transparent SCSI";
us->proto_handler = usb_stor_transparent_scsi_command;
break;
- case US_SC_UFI:
+ case USB_SC_UFI:
us->protocol_name = "Uniform Floppy Interface (UFI)";
us->proto_handler = usb_stor_ufi_command;
break;
@@ -679,7 +679,7 @@ static int get_pipes(struct us_data *us)
}
}
- if (!ep_in || !ep_out || (us->protocol == US_PR_CBI && !ep_int)) {
+ if (!ep_in || !ep_out || (us->protocol == USB_PR_CBI && !ep_int)) {
US_DEBUGP("Endpoint sanity check failed! Rejecting dev.\n");
return -EIO;
}
@@ -834,7 +834,7 @@ static int usb_stor_scan_thread(void * __us)
if (!test_bit(US_FLIDX_DONT_SCAN, &us->dflags)) {
/* For bulk-only devices, determine the max LUN value */
- if (us->protocol == US_PR_BULK &&
+ if (us->protocol == USB_PR_BULK &&
!(us->fflags & US_FL_SINGLE_LUN)) {
mutex_lock(&us->dev_mutex);
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 @@
+ccflags-$(CONFIG_USB_WUSB_CBAF_DEBUG) := -DDEBUG
+
obj-$(CONFIG_USB_WUSB) += wusbcore.o
obj-$(CONFIG_USB_HWA_HCD) += wusb-wa.o
obj-$(CONFIG_USB_WUSB_CBAF) += wusb-cbaf.o
-wusbcore-objs := \
+wusbcore-y := \
crypto.o \
devconnect.o \
dev-sysfs.o \
@@ -14,13 +16,10 @@ wusbcore-objs := \
security.o \
wusbhc.o
-wusb-cbaf-objs := cbaf.o
-
-wusb-wa-objs := wa-hc.o \
- wa-nep.o \
- wa-rpipe.o \
- wa-xfer.o
+wusb-cbaf-y := cbaf.o
-ifeq ($(CONFIG_USB_WUSB_CBAF_DEBUG),y)
-EXTRA_CFLAGS += -DDEBUG
-endif
+wusb-wa-y := \
+ wa-hc.o \
+ wa-nep.o \
+ wa-rpipe.o \
+ 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,
{
size_t result;
if (type)
- result = scnprintf(buf, buf_size,
- "%02x:%02x:%02x:%02x:%02x:%02x",
- addr[0], addr[1], addr[2],
- addr[3], addr[4], addr[5]);
+ result = scnprintf(buf, buf_size, "%pM", addr);
else
result = scnprintf(buf, buf_size, "%02x:%02x",
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,
} else {
if (printk_ratelimit())
dev_err(dev, "WLP: Destination neighbor (Ethernet: "
- "%02x:%02x:%02x:%02x:%02x:%02x, Dev: "
- "%02x:%02x) is not connected. \n", eth_addr[0],
- eth_addr[1], eth_addr[2], eth_addr[3],
- eth_addr[4], eth_addr[5], dev_addr->data[1],
- dev_addr->data[0]);
+ "%pM, Dev: %02x:%02x) is not connected.\n",
+ eth_addr, dev_addr->data[1], dev_addr->data[0]);
result = -EINVAL;
}
return result;