aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.osdl.org>2006-12-21 03:01:06 -0500
committerLinus Torvalds <torvalds@woody.osdl.org>2006-12-21 03:01:06 -0500
commitfb34d203d0b5ac1b8284973eb0db3fdff101fc5e (patch)
treed882cb10f1bb69f0058881df5dad6bd433cd28e5 /drivers
parent5576d187a0eef3bb3c47500eaab33fb5485bc352 (diff)
parentc3052905033f8785bcb2c71d5ce40b84259e3a80 (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/usb-2.6
* master.kernel.org:/pub/scm/linux/kernel/git/gregkh/usb-2.6: (34 commits) USB Storage: remove duplicate Nokia entry in unusual_devs.h [PATCH] bluetooth: add support for another Kensington dongle [PATCH] usb serial: add support for Novatel S720/U720 CDMA/EV-DO modems [PATCH] USB: Nokia E70 is an unusual device USB: fix to usbfs_snoop logging of user defined control urbs USB: at91_udc: Additional checks USB: at91_udc: Cleanup variables after failure in usb_gadget_register_driver() USB: at91_udc: allow drivers that support high speed USB: u132-hcd/ftdi-elan: add support for Option GT 3G Quad card USB: at91_udc, misc fixes USB: at91 udc, support at91sam926x addresses USB: OHCI support for PNX8550 USB: ohci handles hardware faults during root port resets USB: ohci at91 warning fix USB: ohci whitespace/comment fixups USB: MAINTAINERS update, EHCI and OHCI USB: gadget driver unbind() is optional; section fixes; misc UHCI: module parameter to ignore overcurrent changes USB: Nokia E70 is an unusual device USB AUERSWALD: replace kmalloc+memset with kzalloc ...
Diffstat (limited to 'drivers')
-rw-r--r--drivers/bluetooth/hci_usb.c1
-rw-r--r--drivers/usb/class/usblp.c54
-rw-r--r--drivers/usb/core/devio.c6
-rw-r--r--drivers/usb/gadget/at91_udc.c236
-rw-r--r--drivers/usb/gadget/at91_udc.h7
-rw-r--r--drivers/usb/gadget/dummy_hcd.c7
-rw-r--r--drivers/usb/gadget/file_storage.c2
-rw-r--r--drivers/usb/gadget/gmidi.c12
-rw-r--r--drivers/usb/gadget/goku_udc.c12
-rw-r--r--drivers/usb/gadget/lh7a40x_udc.c13
-rw-r--r--drivers/usb/gadget/net2280.c11
-rw-r--r--drivers/usb/gadget/omap_udc.c13
-rw-r--r--drivers/usb/gadget/pxa2xx_udc.c7
-rw-r--r--drivers/usb/gadget/serial.c2
-rw-r--r--drivers/usb/host/ohci-at91.c3
-rw-r--r--drivers/usb/host/ohci-au1xxx.c4
-rw-r--r--drivers/usb/host/ohci-dbg.c8
-rw-r--r--drivers/usb/host/ohci-ep93xx.c2
-rw-r--r--drivers/usb/host/ohci-hcd.c110
-rw-r--r--drivers/usb/host/ohci-hub.c21
-rw-r--r--drivers/usb/host/ohci-lh7a404.c8
-rw-r--r--drivers/usb/host/ohci-mem.c10
-rw-r--r--drivers/usb/host/ohci-omap.c4
-rw-r--r--drivers/usb/host/ohci-pci.c16
-rw-r--r--drivers/usb/host/ohci-pnx4008.c4
-rw-r--r--drivers/usb/host/ohci-pnx8550.c258
-rw-r--r--drivers/usb/host/ohci-ppc-soc.c8
-rw-r--r--drivers/usb/host/ohci-pxa27x.c10
-rw-r--r--drivers/usb/host/ohci-q.c103
-rw-r--r--drivers/usb/host/ohci-s3c2410.c4
-rw-r--r--drivers/usb/host/ohci-sa1111.c8
-rw-r--r--drivers/usb/host/ohci.h92
-rw-r--r--drivers/usb/host/u132-hcd.c92
-rw-r--r--drivers/usb/host/uhci-hcd.c13
-rw-r--r--drivers/usb/host/uhci-hub.c14
-rw-r--r--drivers/usb/input/wacom_sys.c4
-rw-r--r--drivers/usb/input/wacom_wac.c26
-rw-r--r--drivers/usb/misc/auerswald.c6
-rw-r--r--drivers/usb/misc/ftdi-elan.c592
-rw-r--r--drivers/usb/misc/phidgetservo.c1
-rw-r--r--drivers/usb/misc/trancevibrator.c2
-rw-r--r--drivers/usb/net/gl620a.c154
-rw-r--r--drivers/usb/net/rtl8150.c6
-rw-r--r--drivers/usb/serial/airprime.c3
-rw-r--r--drivers/usb/serial/cp2101.c1
-rw-r--r--drivers/usb/serial/cypress_m8.c15
-rw-r--r--drivers/usb/serial/ftdi_sio.c1
-rw-r--r--drivers/usb/serial/ftdi_sio.h5
-rw-r--r--drivers/usb/serial/funsoft.c27
-rw-r--r--drivers/usb/serial/kl5kusb105.c68
-rw-r--r--drivers/usb/serial/mos7840.c6
-rw-r--r--drivers/usb/serial/option.c3
-rw-r--r--drivers/usb/storage/unusual_devs.h16
53 files changed, 1183 insertions, 928 deletions
diff --git a/drivers/bluetooth/hci_usb.c b/drivers/bluetooth/hci_usb.c
index fdea58ae16b2..aeefec97fdee 100644
--- a/drivers/bluetooth/hci_usb.c
+++ b/drivers/bluetooth/hci_usb.c
@@ -126,6 +126,7 @@ static struct usb_device_id blacklist_ids[] = {
126 126
127 /* Kensington Bluetooth USB adapter */ 127 /* Kensington Bluetooth USB adapter */
128 { USB_DEVICE(0x047d, 0x105d), .driver_info = HCI_RESET }, 128 { USB_DEVICE(0x047d, 0x105d), .driver_info = HCI_RESET },
129 { USB_DEVICE(0x047d, 0x105e), .driver_info = HCI_WRONG_SCO_MTU },
129 130
130 /* ISSC Bluetooth Adapter v3.1 */ 131 /* ISSC Bluetooth Adapter v3.1 */
131 { USB_DEVICE(0x1131, 0x1001), .driver_info = HCI_RESET }, 132 { USB_DEVICE(0x1131, 0x1001), .driver_info = HCI_RESET },
diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c
index 6303970e93c1..24ee8be359f5 100644
--- a/drivers/usb/class/usblp.c
+++ b/drivers/usb/class/usblp.c
@@ -130,7 +130,7 @@ MFG:HEWLETT-PACKARD;MDL:DESKJET 970C;CMD:MLC,PCL,PML;CLASS:PRINTER;DESCRIPTION:H
130 130
131struct usblp { 131struct usblp {
132 struct usb_device *dev; /* USB device */ 132 struct usb_device *dev; /* USB device */
133 struct semaphore sem; /* locks this struct, especially "dev" */ 133 struct mutex mut; /* locks this struct, especially "dev" */
134 char *writebuf; /* write transfer_buffer */ 134 char *writebuf; /* write transfer_buffer */
135 char *readbuf; /* read transfer_buffer */ 135 char *readbuf; /* read transfer_buffer */
136 char *statusbuf; /* status transfer_buffer */ 136 char *statusbuf; /* status transfer_buffer */
@@ -465,7 +465,7 @@ static long usblp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
465 int twoints[2]; 465 int twoints[2];
466 int retval = 0; 466 int retval = 0;
467 467
468 down (&usblp->sem); 468 mutex_lock (&usblp->mut);
469 if (!usblp->present) { 469 if (!usblp->present) {
470 retval = -ENODEV; 470 retval = -ENODEV;
471 goto done; 471 goto done;
@@ -644,14 +644,14 @@ static long usblp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
644 } 644 }
645 645
646done: 646done:
647 up (&usblp->sem); 647 mutex_unlock (&usblp->mut);
648 return retval; 648 return retval;
649} 649}
650 650
651static ssize_t usblp_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) 651static ssize_t usblp_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos)
652{ 652{
653 struct usblp *usblp = file->private_data; 653 struct usblp *usblp = file->private_data;
654 int timeout, rv, err = 0, transfer_length = 0; 654 int timeout, intr, rv, err = 0, transfer_length = 0;
655 size_t writecount = 0; 655 size_t writecount = 0;
656 656
657 while (writecount < count) { 657 while (writecount < count) {
@@ -668,14 +668,16 @@ static ssize_t usblp_write(struct file *file, const char __user *buffer, size_t
668 if (rv < 0) 668 if (rv < 0)
669 return writecount ? writecount : -EINTR; 669 return writecount ? writecount : -EINTR;
670 } 670 }
671 down (&usblp->sem); 671 intr = mutex_lock_interruptible (&usblp->mut);
672 if (intr)
673 return writecount ? writecount : -EINTR;
672 if (!usblp->present) { 674 if (!usblp->present) {
673 up (&usblp->sem); 675 mutex_unlock (&usblp->mut);
674 return -ENODEV; 676 return -ENODEV;
675 } 677 }
676 678
677 if (usblp->sleeping) { 679 if (usblp->sleeping) {
678 up (&usblp->sem); 680 mutex_unlock (&usblp->mut);
679 return writecount ? writecount : -ENODEV; 681 return writecount ? writecount : -ENODEV;
680 } 682 }
681 683
@@ -687,10 +689,10 @@ static ssize_t usblp_write(struct file *file, const char __user *buffer, size_t
687 err = usblp->writeurb->status; 689 err = usblp->writeurb->status;
688 } else 690 } else
689 err = usblp_check_status(usblp, err); 691 err = usblp_check_status(usblp, err);
690 up (&usblp->sem); 692 mutex_unlock (&usblp->mut);
691 693
692 /* if the fault was due to disconnect, let khubd's 694 /* if the fault was due to disconnect, let khubd's
693 * call to usblp_disconnect() grab usblp->sem ... 695 * call to usblp_disconnect() grab usblp->mut ...
694 */ 696 */
695 schedule (); 697 schedule ();
696 continue; 698 continue;
@@ -702,7 +704,7 @@ static ssize_t usblp_write(struct file *file, const char __user *buffer, size_t
702 */ 704 */
703 writecount += transfer_length; 705 writecount += transfer_length;
704 if (writecount == count) { 706 if (writecount == count) {
705 up(&usblp->sem); 707 mutex_unlock(&usblp->mut);
706 break; 708 break;
707 } 709 }
708 710
@@ -714,7 +716,7 @@ static ssize_t usblp_write(struct file *file, const char __user *buffer, size_t
714 716
715 if (copy_from_user(usblp->writeurb->transfer_buffer, 717 if (copy_from_user(usblp->writeurb->transfer_buffer,
716 buffer + writecount, transfer_length)) { 718 buffer + writecount, transfer_length)) {
717 up(&usblp->sem); 719 mutex_unlock(&usblp->mut);
718 return writecount ? writecount : -EFAULT; 720 return writecount ? writecount : -EFAULT;
719 } 721 }
720 722
@@ -727,10 +729,10 @@ static ssize_t usblp_write(struct file *file, const char __user *buffer, size_t
727 count = -EIO; 729 count = -EIO;
728 else 730 else
729 count = writecount ? writecount : -ENOMEM; 731 count = writecount ? writecount : -ENOMEM;
730 up (&usblp->sem); 732 mutex_unlock (&usblp->mut);
731 break; 733 break;
732 } 734 }
733 up (&usblp->sem); 735 mutex_unlock (&usblp->mut);
734 } 736 }
735 737
736 return count; 738 return count;
@@ -739,12 +741,14 @@ static ssize_t usblp_write(struct file *file, const char __user *buffer, size_t
739static ssize_t usblp_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos) 741static ssize_t usblp_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)
740{ 742{
741 struct usblp *usblp = file->private_data; 743 struct usblp *usblp = file->private_data;
742 int rv; 744 int rv, intr;
743 745
744 if (!usblp->bidir) 746 if (!usblp->bidir)
745 return -EINVAL; 747 return -EINVAL;
746 748
747 down (&usblp->sem); 749 intr = mutex_lock_interruptible (&usblp->mut);
750 if (intr)
751 return -EINTR;
748 if (!usblp->present) { 752 if (!usblp->present) {
749 count = -ENODEV; 753 count = -ENODEV;
750 goto done; 754 goto done;
@@ -757,9 +761,9 @@ static ssize_t usblp_read(struct file *file, char __user *buffer, size_t count,
757 count = -EAGAIN; 761 count = -EAGAIN;
758 goto done; 762 goto done;
759 } 763 }
760 up(&usblp->sem); 764 mutex_unlock(&usblp->mut);
761 rv = wait_event_interruptible(usblp->wait, usblp->rcomplete || !usblp->present); 765 rv = wait_event_interruptible(usblp->wait, usblp->rcomplete || !usblp->present);
762 down(&usblp->sem); 766 mutex_lock(&usblp->mut);
763 if (rv < 0) { 767 if (rv < 0) {
764 count = -EINTR; 768 count = -EINTR;
765 goto done; 769 goto done;
@@ -807,7 +811,7 @@ static ssize_t usblp_read(struct file *file, char __user *buffer, size_t count,
807 } 811 }
808 812
809done: 813done:
810 up (&usblp->sem); 814 mutex_unlock (&usblp->mut);
811 return count; 815 return count;
812} 816}
813 817
@@ -886,7 +890,7 @@ static int usblp_probe(struct usb_interface *intf,
886 goto abort; 890 goto abort;
887 } 891 }
888 usblp->dev = dev; 892 usblp->dev = dev;
889 init_MUTEX (&usblp->sem); 893 mutex_init (&usblp->mut);
890 init_waitqueue_head(&usblp->wait); 894 init_waitqueue_head(&usblp->wait);
891 usblp->ifnum = intf->cur_altsetting->desc.bInterfaceNumber; 895 usblp->ifnum = intf->cur_altsetting->desc.bInterfaceNumber;
892 usblp->intf = intf; 896 usblp->intf = intf;
@@ -1178,7 +1182,7 @@ static void usblp_disconnect(struct usb_interface *intf)
1178 device_remove_file(&intf->dev, &dev_attr_ieee1284_id); 1182 device_remove_file(&intf->dev, &dev_attr_ieee1284_id);
1179 1183
1180 mutex_lock (&usblp_mutex); 1184 mutex_lock (&usblp_mutex);
1181 down (&usblp->sem); 1185 mutex_lock (&usblp->mut);
1182 usblp->present = 0; 1186 usblp->present = 0;
1183 usb_set_intfdata (intf, NULL); 1187 usb_set_intfdata (intf, NULL);
1184 1188
@@ -1187,7 +1191,7 @@ static void usblp_disconnect(struct usb_interface *intf)
1187 usblp->writebuf, usblp->writeurb->transfer_dma); 1191 usblp->writebuf, usblp->writeurb->transfer_dma);
1188 usb_buffer_free (usblp->dev, USBLP_BUF_SIZE, 1192 usb_buffer_free (usblp->dev, USBLP_BUF_SIZE,
1189 usblp->readbuf, usblp->readurb->transfer_dma); 1193 usblp->readbuf, usblp->readurb->transfer_dma);
1190 up (&usblp->sem); 1194 mutex_unlock (&usblp->mut);
1191 1195
1192 if (!usblp->used) 1196 if (!usblp->used)
1193 usblp_cleanup (usblp); 1197 usblp_cleanup (usblp);
@@ -1200,11 +1204,11 @@ static int usblp_suspend (struct usb_interface *intf, pm_message_t message)
1200 1204
1201 /* this races against normal access and open */ 1205 /* this races against normal access and open */
1202 mutex_lock (&usblp_mutex); 1206 mutex_lock (&usblp_mutex);
1203 down (&usblp->sem); 1207 mutex_lock (&usblp->mut);
1204 /* we take no more IO */ 1208 /* we take no more IO */
1205 usblp->sleeping = 1; 1209 usblp->sleeping = 1;
1206 usblp_unlink_urbs(usblp); 1210 usblp_unlink_urbs(usblp);
1207 up (&usblp->sem); 1211 mutex_unlock (&usblp->mut);
1208 mutex_unlock (&usblp_mutex); 1212 mutex_unlock (&usblp_mutex);
1209 1213
1210 return 0; 1214 return 0;
@@ -1216,12 +1220,12 @@ static int usblp_resume (struct usb_interface *intf)
1216 int r; 1220 int r;
1217 1221
1218 mutex_lock (&usblp_mutex); 1222 mutex_lock (&usblp_mutex);
1219 down (&usblp->sem); 1223 mutex_lock (&usblp->mut);
1220 1224
1221 usblp->sleeping = 0; 1225 usblp->sleeping = 0;
1222 r = handle_bidir (usblp); 1226 r = handle_bidir (usblp);
1223 1227
1224 up (&usblp->sem); 1228 mutex_unlock (&usblp->mut);
1225 mutex_unlock (&usblp_mutex); 1229 mutex_unlock (&usblp_mutex);
1226 1230
1227 return r; 1231 return r;
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 3ed4cb2d56d9..4b3a6ab29bd3 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -962,7 +962,11 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
962 kfree(dr); 962 kfree(dr);
963 return -EFAULT; 963 return -EFAULT;
964 } 964 }
965 snoop(&ps->dev->dev, "control urb\n"); 965 snoop(&ps->dev->dev, "control urb: bRequest=%02x "
966 "bRrequestType=%02x wValue=%04x "
967 "wIndex=%04x wLength=%04x\n",
968 dr->bRequest, dr->bRequestType, dr->wValue,
969 dr->wIndex, dr->wLength);
966 break; 970 break;
967 971
968 case USBDEVFS_URB_TYPE_BULK: 972 case USBDEVFS_URB_TYPE_BULK:
diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
index 3e0abbb49fe1..812c733ba8ce 100644
--- a/drivers/usb/gadget/at91_udc.c
+++ b/drivers/usb/gadget/at91_udc.c
@@ -43,14 +43,16 @@
43#include <linux/usb_gadget.h> 43#include <linux/usb_gadget.h>
44 44
45#include <asm/byteorder.h> 45#include <asm/byteorder.h>
46#include <asm/hardware.h>
46#include <asm/io.h> 47#include <asm/io.h>
47#include <asm/irq.h> 48#include <asm/irq.h>
48#include <asm/system.h> 49#include <asm/system.h>
49#include <asm/mach-types.h> 50#include <asm/mach-types.h>
50 51
51#include <asm/arch/hardware.h>
52#include <asm/arch/gpio.h> 52#include <asm/arch/gpio.h>
53#include <asm/arch/board.h> 53#include <asm/arch/board.h>
54#include <asm/arch/cpu.h>
55#include <asm/arch/at91sam9261_matrix.h>
54 56
55#include "at91_udc.h" 57#include "at91_udc.h"
56 58
@@ -78,27 +80,11 @@
78static const char driver_name [] = "at91_udc"; 80static const char driver_name [] = "at91_udc";
79static const char ep0name[] = "ep0"; 81static const char ep0name[] = "ep0";
80 82
81/*-------------------------------------------------------------------------*/
82 83
83/* 84#define at91_udp_read(dev, reg) \
84 * Read from a UDP register. 85 __raw_readl((dev)->udp_baseaddr + (reg))
85 */ 86#define at91_udp_write(dev, reg, val) \
86static inline unsigned long at91_udp_read(unsigned int reg) 87 __raw_writel((val), (dev)->udp_baseaddr + (reg))
87{
88 void __iomem *udp_base = (void __iomem *)AT91_VA_BASE_UDP;
89
90 return __raw_readl(udp_base + reg);
91}
92
93/*
94 * Write to a UDP register.
95 */
96static inline void at91_udp_write(unsigned int reg, unsigned long value)
97{
98 void __iomem *udp_base = (void __iomem *)AT91_VA_BASE_UDP;
99
100 __raw_writel(value, udp_base + reg);
101}
102 88
103/*-------------------------------------------------------------------------*/ 89/*-------------------------------------------------------------------------*/
104 90
@@ -210,13 +196,13 @@ static int proc_udc_show(struct seq_file *s, void *unused)
210 return 0; 196 return 0;
211 } 197 }
212 198
213 tmp = at91_udp_read(AT91_UDP_FRM_NUM); 199 tmp = at91_udp_read(udc, AT91_UDP_FRM_NUM);
214 seq_printf(s, "frame %05x:%s%s frame=%d\n", tmp, 200 seq_printf(s, "frame %05x:%s%s frame=%d\n", tmp,
215 (tmp & AT91_UDP_FRM_OK) ? " ok" : "", 201 (tmp & AT91_UDP_FRM_OK) ? " ok" : "",
216 (tmp & AT91_UDP_FRM_ERR) ? " err" : "", 202 (tmp & AT91_UDP_FRM_ERR) ? " err" : "",
217 (tmp & AT91_UDP_NUM)); 203 (tmp & AT91_UDP_NUM));
218 204
219 tmp = at91_udp_read(AT91_UDP_GLB_STAT); 205 tmp = at91_udp_read(udc, AT91_UDP_GLB_STAT);
220 seq_printf(s, "glbstate %02x:%s" FOURBITS "\n", tmp, 206 seq_printf(s, "glbstate %02x:%s" FOURBITS "\n", tmp,
221 (tmp & AT91_UDP_RMWUPE) ? " rmwupe" : "", 207 (tmp & AT91_UDP_RMWUPE) ? " rmwupe" : "",
222 (tmp & AT91_UDP_RSMINPR) ? " rsminpr" : "", 208 (tmp & AT91_UDP_RSMINPR) ? " rsminpr" : "",
@@ -224,13 +210,13 @@ static int proc_udc_show(struct seq_file *s, void *unused)
224 (tmp & AT91_UDP_CONFG) ? " confg" : "", 210 (tmp & AT91_UDP_CONFG) ? " confg" : "",
225 (tmp & AT91_UDP_FADDEN) ? " fadden" : ""); 211 (tmp & AT91_UDP_FADDEN) ? " fadden" : "");
226 212
227 tmp = at91_udp_read(AT91_UDP_FADDR); 213 tmp = at91_udp_read(udc, AT91_UDP_FADDR);
228 seq_printf(s, "faddr %03x:%s fadd=%d\n", tmp, 214 seq_printf(s, "faddr %03x:%s fadd=%d\n", tmp,
229 (tmp & AT91_UDP_FEN) ? " fen" : "", 215 (tmp & AT91_UDP_FEN) ? " fen" : "",
230 (tmp & AT91_UDP_FADD)); 216 (tmp & AT91_UDP_FADD));
231 217
232 proc_irq_show(s, "imr ", at91_udp_read(AT91_UDP_IMR)); 218 proc_irq_show(s, "imr ", at91_udp_read(udc, AT91_UDP_IMR));
233 proc_irq_show(s, "isr ", at91_udp_read(AT91_UDP_ISR)); 219 proc_irq_show(s, "isr ", at91_udp_read(udc, AT91_UDP_ISR));
234 220
235 if (udc->enabled && udc->vbus) { 221 if (udc->enabled && udc->vbus) {
236 proc_ep_show(s, &udc->ep[0]); 222 proc_ep_show(s, &udc->ep[0]);
@@ -286,6 +272,7 @@ static inline void remove_debug_file(struct at91_udc *udc) {}
286static void done(struct at91_ep *ep, struct at91_request *req, int status) 272static void done(struct at91_ep *ep, struct at91_request *req, int status)
287{ 273{
288 unsigned stopped = ep->stopped; 274 unsigned stopped = ep->stopped;
275 struct at91_udc *udc = ep->udc;
289 276
290 list_del_init(&req->queue); 277 list_del_init(&req->queue);
291 if (req->req.status == -EINPROGRESS) 278 if (req->req.status == -EINPROGRESS)
@@ -301,7 +288,7 @@ static void done(struct at91_ep *ep, struct at91_request *req, int status)
301 288
302 /* ep0 is always ready; other endpoints need a non-empty queue */ 289 /* ep0 is always ready; other endpoints need a non-empty queue */
303 if (list_empty(&ep->queue) && ep->int_mask != (1 << 0)) 290 if (list_empty(&ep->queue) && ep->int_mask != (1 << 0))
304 at91_udp_write(AT91_UDP_IDR, ep->int_mask); 291 at91_udp_write(udc, AT91_UDP_IDR, ep->int_mask);
305} 292}
306 293
307/*-------------------------------------------------------------------------*/ 294/*-------------------------------------------------------------------------*/
@@ -554,8 +541,8 @@ ok:
554 * reset/init endpoint fifo. NOTE: leaves fifo_bank alone, 541 * reset/init endpoint fifo. NOTE: leaves fifo_bank alone,
555 * since endpoint resets don't reset hw pingpong state. 542 * since endpoint resets don't reset hw pingpong state.
556 */ 543 */
557 at91_udp_write(AT91_UDP_RST_EP, ep->int_mask); 544 at91_udp_write(dev, AT91_UDP_RST_EP, ep->int_mask);
558 at91_udp_write(AT91_UDP_RST_EP, 0); 545 at91_udp_write(dev, AT91_UDP_RST_EP, 0);
559 546
560 local_irq_restore(flags); 547 local_irq_restore(flags);
561 return 0; 548 return 0;
@@ -564,6 +551,7 @@ ok:
564static int at91_ep_disable (struct usb_ep * _ep) 551static int at91_ep_disable (struct usb_ep * _ep)
565{ 552{
566 struct at91_ep *ep = container_of(_ep, struct at91_ep, ep); 553 struct at91_ep *ep = container_of(_ep, struct at91_ep, ep);
554 struct at91_udc *udc = ep->udc;
567 unsigned long flags; 555 unsigned long flags;
568 556
569 if (ep == &ep->udc->ep[0]) 557 if (ep == &ep->udc->ep[0])
@@ -579,8 +567,8 @@ static int at91_ep_disable (struct usb_ep * _ep)
579 567
580 /* reset fifos and endpoint */ 568 /* reset fifos and endpoint */
581 if (ep->udc->clocked) { 569 if (ep->udc->clocked) {
582 at91_udp_write(AT91_UDP_RST_EP, ep->int_mask); 570 at91_udp_write(udc, AT91_UDP_RST_EP, ep->int_mask);
583 at91_udp_write(AT91_UDP_RST_EP, 0); 571 at91_udp_write(udc, AT91_UDP_RST_EP, 0);
584 __raw_writel(0, ep->creg); 572 __raw_writel(0, ep->creg);
585 } 573 }
586 574
@@ -695,10 +683,10 @@ static int at91_ep_queue(struct usb_ep *_ep,
695 * reconfigures the endpoints. 683 * reconfigures the endpoints.
696 */ 684 */
697 if (dev->wait_for_config_ack) { 685 if (dev->wait_for_config_ack) {
698 tmp = at91_udp_read(AT91_UDP_GLB_STAT); 686 tmp = at91_udp_read(dev, AT91_UDP_GLB_STAT);
699 tmp ^= AT91_UDP_CONFG; 687 tmp ^= AT91_UDP_CONFG;
700 VDBG("toggle config\n"); 688 VDBG("toggle config\n");
701 at91_udp_write(AT91_UDP_GLB_STAT, tmp); 689 at91_udp_write(dev, AT91_UDP_GLB_STAT, tmp);
702 } 690 }
703 if (req->req.length == 0) { 691 if (req->req.length == 0) {
704ep0_in_status: 692ep0_in_status:
@@ -727,7 +715,7 @@ ep0_in_status:
727 715
728 if (req && !status) { 716 if (req && !status) {
729 list_add_tail (&req->queue, &ep->queue); 717 list_add_tail (&req->queue, &ep->queue);
730 at91_udp_write(AT91_UDP_IER, ep->int_mask); 718 at91_udp_write(dev, AT91_UDP_IER, ep->int_mask);
731 } 719 }
732done: 720done:
733 local_irq_restore(flags); 721 local_irq_restore(flags);
@@ -758,6 +746,7 @@ static int at91_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
758static int at91_ep_set_halt(struct usb_ep *_ep, int value) 746static int at91_ep_set_halt(struct usb_ep *_ep, int value)
759{ 747{
760 struct at91_ep *ep = container_of(_ep, struct at91_ep, ep); 748 struct at91_ep *ep = container_of(_ep, struct at91_ep, ep);
749 struct at91_udc *udc = ep->udc;
761 u32 __iomem *creg; 750 u32 __iomem *creg;
762 u32 csr; 751 u32 csr;
763 unsigned long flags; 752 unsigned long flags;
@@ -785,8 +774,8 @@ static int at91_ep_set_halt(struct usb_ep *_ep, int value)
785 csr |= AT91_UDP_FORCESTALL; 774 csr |= AT91_UDP_FORCESTALL;
786 VDBG("halt %s\n", ep->ep.name); 775 VDBG("halt %s\n", ep->ep.name);
787 } else { 776 } else {
788 at91_udp_write(AT91_UDP_RST_EP, ep->int_mask); 777 at91_udp_write(udc, AT91_UDP_RST_EP, ep->int_mask);
789 at91_udp_write(AT91_UDP_RST_EP, 0); 778 at91_udp_write(udc, AT91_UDP_RST_EP, 0);
790 csr &= ~AT91_UDP_FORCESTALL; 779 csr &= ~AT91_UDP_FORCESTALL;
791 } 780 }
792 __raw_writel(csr, creg); 781 __raw_writel(csr, creg);
@@ -813,9 +802,11 @@ static struct usb_ep_ops at91_ep_ops = {
813 802
814static int at91_get_frame(struct usb_gadget *gadget) 803static int at91_get_frame(struct usb_gadget *gadget)
815{ 804{
805 struct at91_udc *udc = to_udc(gadget);
806
816 if (!to_udc(gadget)->clocked) 807 if (!to_udc(gadget)->clocked)
817 return -EINVAL; 808 return -EINVAL;
818 return at91_udp_read(AT91_UDP_FRM_NUM) & AT91_UDP_NUM; 809 return at91_udp_read(udc, AT91_UDP_FRM_NUM) & AT91_UDP_NUM;
819} 810}
820 811
821static int at91_wakeup(struct usb_gadget *gadget) 812static int at91_wakeup(struct usb_gadget *gadget)
@@ -833,11 +824,11 @@ static int at91_wakeup(struct usb_gadget *gadget)
833 824
834 /* NOTE: some "early versions" handle ESR differently ... */ 825 /* NOTE: some "early versions" handle ESR differently ... */
835 826
836 glbstate = at91_udp_read(AT91_UDP_GLB_STAT); 827 glbstate = at91_udp_read(udc, AT91_UDP_GLB_STAT);
837 if (!(glbstate & AT91_UDP_ESR)) 828 if (!(glbstate & AT91_UDP_ESR))
838 goto done; 829 goto done;
839 glbstate |= AT91_UDP_ESR; 830 glbstate |= AT91_UDP_ESR;
840 at91_udp_write(AT91_UDP_GLB_STAT, glbstate); 831 at91_udp_write(udc, AT91_UDP_GLB_STAT, glbstate);
841 832
842done: 833done:
843 local_irq_restore(flags); 834 local_irq_restore(flags);
@@ -861,6 +852,7 @@ static void udc_reinit(struct at91_udc *udc)
861 ep->stopped = 0; 852 ep->stopped = 0;
862 ep->fifo_bank = 0; 853 ep->fifo_bank = 0;
863 ep->ep.maxpacket = ep->maxpacket; 854 ep->ep.maxpacket = ep->maxpacket;
855 ep->creg = (void __iomem *) udc->udp_baseaddr + AT91_UDP_CSR(i);
864 // initialiser une queue par endpoint 856 // initialiser une queue par endpoint
865 INIT_LIST_HEAD(&ep->queue); 857 INIT_LIST_HEAD(&ep->queue);
866 } 858 }
@@ -915,14 +907,41 @@ static void pullup(struct at91_udc *udc, int is_on)
915 if (!udc->enabled || !udc->vbus) 907 if (!udc->enabled || !udc->vbus)
916 is_on = 0; 908 is_on = 0;
917 DBG("%sactive\n", is_on ? "" : "in"); 909 DBG("%sactive\n", is_on ? "" : "in");
910
918 if (is_on) { 911 if (is_on) {
919 clk_on(udc); 912 clk_on(udc);
920 at91_udp_write(AT91_UDP_TXVC, 0); 913 at91_udp_write(udc, AT91_UDP_TXVC, 0);
921 at91_set_gpio_value(udc->board.pullup_pin, 1); 914 if (cpu_is_at91rm9200())
922 } else { 915 at91_set_gpio_value(udc->board.pullup_pin, 1);
916 else if (cpu_is_at91sam9260()) {
917 u32 txvc = at91_udp_read(udc, AT91_UDP_TXVC);
918
919 txvc |= AT91_UDP_TXVC_PUON;
920 at91_udp_write(udc, AT91_UDP_TXVC, txvc);
921 } else if (cpu_is_at91sam9261()) {
922 u32 usbpucr;
923
924 usbpucr = at91_sys_read(AT91_MATRIX_USBPUCR);
925 usbpucr |= AT91_MATRIX_USBPUCR_PUON;
926 at91_sys_write(AT91_MATRIX_USBPUCR, usbpucr);
927 }
928 } else {
923 stop_activity(udc); 929 stop_activity(udc);
924 at91_udp_write(AT91_UDP_TXVC, AT91_UDP_TXVC_TXVDIS); 930 at91_udp_write(udc, AT91_UDP_TXVC, AT91_UDP_TXVC_TXVDIS);
925 at91_set_gpio_value(udc->board.pullup_pin, 0); 931 if (cpu_is_at91rm9200())
932 at91_set_gpio_value(udc->board.pullup_pin, 0);
933 else if (cpu_is_at91sam9260()) {
934 u32 txvc = at91_udp_read(udc, AT91_UDP_TXVC);
935
936 txvc &= ~AT91_UDP_TXVC_PUON;
937 at91_udp_write(udc, AT91_UDP_TXVC, txvc);
938 } else if (cpu_is_at91sam9261()) {
939 u32 usbpucr;
940
941 usbpucr = at91_sys_read(AT91_MATRIX_USBPUCR);
942 usbpucr &= ~AT91_MATRIX_USBPUCR_PUON;
943 at91_sys_write(AT91_MATRIX_USBPUCR, usbpucr);
944 }
926 clk_off(udc); 945 clk_off(udc);
927 } 946 }
928} 947}
@@ -936,7 +955,10 @@ static int at91_vbus_session(struct usb_gadget *gadget, int is_active)
936 // VDBG("vbus %s\n", is_active ? "on" : "off"); 955 // VDBG("vbus %s\n", is_active ? "on" : "off");
937 local_irq_save(flags); 956 local_irq_save(flags);
938 udc->vbus = (is_active != 0); 957 udc->vbus = (is_active != 0);
939 pullup(udc, is_active); 958 if (udc->driver)
959 pullup(udc, is_active);
960 else
961 pullup(udc, 0);
940 local_irq_restore(flags); 962 local_irq_restore(flags);
941 return 0; 963 return 0;
942} 964}
@@ -1086,7 +1108,7 @@ static void handle_setup(struct at91_udc *udc, struct at91_ep *ep, u32 csr)
1086 1108
1087 case ((USB_TYPE_STANDARD|USB_RECIP_DEVICE) << 8) 1109 case ((USB_TYPE_STANDARD|USB_RECIP_DEVICE) << 8)
1088 | USB_REQ_SET_CONFIGURATION: 1110 | USB_REQ_SET_CONFIGURATION:
1089 tmp = at91_udp_read(AT91_UDP_GLB_STAT) & AT91_UDP_CONFG; 1111 tmp = at91_udp_read(udc, AT91_UDP_GLB_STAT) & AT91_UDP_CONFG;
1090 if (pkt.r.wValue) 1112 if (pkt.r.wValue)
1091 udc->wait_for_config_ack = (tmp == 0); 1113 udc->wait_for_config_ack = (tmp == 0);
1092 else 1114 else
@@ -1103,7 +1125,7 @@ static void handle_setup(struct at91_udc *udc, struct at91_ep *ep, u32 csr)
1103 case ((USB_DIR_IN|USB_TYPE_STANDARD|USB_RECIP_DEVICE) << 8) 1125 case ((USB_DIR_IN|USB_TYPE_STANDARD|USB_RECIP_DEVICE) << 8)
1104 | USB_REQ_GET_STATUS: 1126 | USB_REQ_GET_STATUS:
1105 tmp = (udc->selfpowered << USB_DEVICE_SELF_POWERED); 1127 tmp = (udc->selfpowered << USB_DEVICE_SELF_POWERED);
1106 if (at91_udp_read(AT91_UDP_GLB_STAT) & AT91_UDP_ESR) 1128 if (at91_udp_read(udc, AT91_UDP_GLB_STAT) & AT91_UDP_ESR)
1107 tmp |= (1 << USB_DEVICE_REMOTE_WAKEUP); 1129 tmp |= (1 << USB_DEVICE_REMOTE_WAKEUP);
1108 PACKET("get device status\n"); 1130 PACKET("get device status\n");
1109 __raw_writeb(tmp, dreg); 1131 __raw_writeb(tmp, dreg);
@@ -1114,17 +1136,17 @@ static void handle_setup(struct at91_udc *udc, struct at91_ep *ep, u32 csr)
1114 | USB_REQ_SET_FEATURE: 1136 | USB_REQ_SET_FEATURE:
1115 if (w_value != USB_DEVICE_REMOTE_WAKEUP) 1137 if (w_value != USB_DEVICE_REMOTE_WAKEUP)
1116 goto stall; 1138 goto stall;
1117 tmp = at91_udp_read(AT91_UDP_GLB_STAT); 1139 tmp = at91_udp_read(udc, AT91_UDP_GLB_STAT);
1118 tmp |= AT91_UDP_ESR; 1140 tmp |= AT91_UDP_ESR;
1119 at91_udp_write(AT91_UDP_GLB_STAT, tmp); 1141 at91_udp_write(udc, AT91_UDP_GLB_STAT, tmp);
1120 goto succeed; 1142 goto succeed;
1121 case ((USB_TYPE_STANDARD|USB_RECIP_DEVICE) << 8) 1143 case ((USB_TYPE_STANDARD|USB_RECIP_DEVICE) << 8)
1122 | USB_REQ_CLEAR_FEATURE: 1144 | USB_REQ_CLEAR_FEATURE:
1123 if (w_value != USB_DEVICE_REMOTE_WAKEUP) 1145 if (w_value != USB_DEVICE_REMOTE_WAKEUP)
1124 goto stall; 1146 goto stall;
1125 tmp = at91_udp_read(AT91_UDP_GLB_STAT); 1147 tmp = at91_udp_read(udc, AT91_UDP_GLB_STAT);
1126 tmp &= ~AT91_UDP_ESR; 1148 tmp &= ~AT91_UDP_ESR;
1127 at91_udp_write(AT91_UDP_GLB_STAT, tmp); 1149 at91_udp_write(udc, AT91_UDP_GLB_STAT, tmp);
1128 goto succeed; 1150 goto succeed;
1129 1151
1130 /* 1152 /*
@@ -1206,8 +1228,8 @@ static void handle_setup(struct at91_udc *udc, struct at91_ep *ep, u32 csr)
1206 } else if (ep->is_in) 1228 } else if (ep->is_in)
1207 goto stall; 1229 goto stall;
1208 1230
1209 at91_udp_write(AT91_UDP_RST_EP, ep->int_mask); 1231 at91_udp_write(udc, AT91_UDP_RST_EP, ep->int_mask);
1210 at91_udp_write(AT91_UDP_RST_EP, 0); 1232 at91_udp_write(udc, AT91_UDP_RST_EP, 0);
1211 tmp = __raw_readl(ep->creg); 1233 tmp = __raw_readl(ep->creg);
1212 tmp |= CLR_FX; 1234 tmp |= CLR_FX;
1213 tmp &= ~(SET_FX | AT91_UDP_FORCESTALL); 1235 tmp &= ~(SET_FX | AT91_UDP_FORCESTALL);
@@ -1222,7 +1244,10 @@ static void handle_setup(struct at91_udc *udc, struct at91_ep *ep, u32 csr)
1222#undef w_length 1244#undef w_length
1223 1245
1224 /* pass request up to the gadget driver */ 1246 /* pass request up to the gadget driver */
1225 status = udc->driver->setup(&udc->gadget, &pkt.r); 1247 if (udc->driver)
1248 status = udc->driver->setup(&udc->gadget, &pkt.r);
1249 else
1250 status = -ENODEV;
1226 if (status < 0) { 1251 if (status < 0) {
1227stall: 1252stall:
1228 VDBG("req %02x.%02x protocol STALL; stat %d\n", 1253 VDBG("req %02x.%02x protocol STALL; stat %d\n",
@@ -1300,13 +1325,13 @@ static void handle_ep0(struct at91_udc *udc)
1300 if (udc->wait_for_addr_ack) { 1325 if (udc->wait_for_addr_ack) {
1301 u32 tmp; 1326 u32 tmp;
1302 1327
1303 at91_udp_write(AT91_UDP_FADDR, 1328 at91_udp_write(udc, AT91_UDP_FADDR,
1304 AT91_UDP_FEN | udc->addr); 1329 AT91_UDP_FEN | udc->addr);
1305 tmp = at91_udp_read(AT91_UDP_GLB_STAT); 1330 tmp = at91_udp_read(udc, AT91_UDP_GLB_STAT);
1306 tmp &= ~AT91_UDP_FADDEN; 1331 tmp &= ~AT91_UDP_FADDEN;
1307 if (udc->addr) 1332 if (udc->addr)
1308 tmp |= AT91_UDP_FADDEN; 1333 tmp |= AT91_UDP_FADDEN;
1309 at91_udp_write(AT91_UDP_GLB_STAT, tmp); 1334 at91_udp_write(udc, AT91_UDP_GLB_STAT, tmp);
1310 1335
1311 udc->wait_for_addr_ack = 0; 1336 udc->wait_for_addr_ack = 0;
1312 VDBG("address %d\n", udc->addr); 1337 VDBG("address %d\n", udc->addr);
@@ -1374,28 +1399,28 @@ static irqreturn_t at91_udc_irq (int irq, void *_udc)
1374 while (rescans--) { 1399 while (rescans--) {
1375 u32 status; 1400 u32 status;
1376 1401
1377 status = at91_udp_read(AT91_UDP_ISR) 1402 status = at91_udp_read(udc, AT91_UDP_ISR)
1378 & at91_udp_read(AT91_UDP_IMR); 1403 & at91_udp_read(udc, AT91_UDP_IMR);
1379 if (!status) 1404 if (!status)
1380 break; 1405 break;
1381 1406
1382 /* USB reset irq: not maskable */ 1407 /* USB reset irq: not maskable */
1383 if (status & AT91_UDP_ENDBUSRES) { 1408 if (status & AT91_UDP_ENDBUSRES) {
1384 at91_udp_write(AT91_UDP_IDR, ~MINIMUS_INTERRUPTUS); 1409 at91_udp_write(udc, AT91_UDP_IDR, ~MINIMUS_INTERRUPTUS);
1385 at91_udp_write(AT91_UDP_IER, MINIMUS_INTERRUPTUS); 1410 at91_udp_write(udc, AT91_UDP_IER, MINIMUS_INTERRUPTUS);
1386 /* Atmel code clears this irq twice */ 1411 /* Atmel code clears this irq twice */
1387 at91_udp_write(AT91_UDP_ICR, AT91_UDP_ENDBUSRES); 1412 at91_udp_write(udc, AT91_UDP_ICR, AT91_UDP_ENDBUSRES);
1388 at91_udp_write(AT91_UDP_ICR, AT91_UDP_ENDBUSRES); 1413 at91_udp_write(udc, AT91_UDP_ICR, AT91_UDP_ENDBUSRES);
1389 VDBG("end bus reset\n"); 1414 VDBG("end bus reset\n");
1390 udc->addr = 0; 1415 udc->addr = 0;
1391 stop_activity(udc); 1416 stop_activity(udc);
1392 1417
1393 /* enable ep0 */ 1418 /* enable ep0 */
1394 at91_udp_write(AT91_UDP_CSR(0), 1419 at91_udp_write(udc, AT91_UDP_CSR(0),
1395 AT91_UDP_EPEDS | AT91_UDP_EPTYPE_CTRL); 1420 AT91_UDP_EPEDS | AT91_UDP_EPTYPE_CTRL);
1396 udc->gadget.speed = USB_SPEED_FULL; 1421 udc->gadget.speed = USB_SPEED_FULL;
1397 udc->suspended = 0; 1422 udc->suspended = 0;
1398 at91_udp_write(AT91_UDP_IER, AT91_UDP_EP(0)); 1423 at91_udp_write(udc, AT91_UDP_IER, AT91_UDP_EP(0));
1399 1424
1400 /* 1425 /*
1401 * NOTE: this driver keeps clocks off unless the 1426 * NOTE: this driver keeps clocks off unless the
@@ -1406,9 +1431,9 @@ static irqreturn_t at91_udc_irq (int irq, void *_udc)
1406 1431
1407 /* host initiated suspend (3+ms bus idle) */ 1432 /* host initiated suspend (3+ms bus idle) */
1408 } else if (status & AT91_UDP_RXSUSP) { 1433 } else if (status & AT91_UDP_RXSUSP) {
1409 at91_udp_write(AT91_UDP_IDR, AT91_UDP_RXSUSP); 1434 at91_udp_write(udc, AT91_UDP_IDR, AT91_UDP_RXSUSP);
1410 at91_udp_write(AT91_UDP_IER, AT91_UDP_RXRSM); 1435 at91_udp_write(udc, AT91_UDP_IER, AT91_UDP_RXRSM);
1411 at91_udp_write(AT91_UDP_ICR, AT91_UDP_RXSUSP); 1436 at91_udp_write(udc, AT91_UDP_ICR, AT91_UDP_RXSUSP);
1412 // VDBG("bus suspend\n"); 1437 // VDBG("bus suspend\n");
1413 if (udc->suspended) 1438 if (udc->suspended)
1414 continue; 1439 continue;
@@ -1425,9 +1450,9 @@ static irqreturn_t at91_udc_irq (int irq, void *_udc)
1425 1450
1426 /* host initiated resume */ 1451 /* host initiated resume */
1427 } else if (status & AT91_UDP_RXRSM) { 1452 } else if (status & AT91_UDP_RXRSM) {
1428 at91_udp_write(AT91_UDP_IDR, AT91_UDP_RXRSM); 1453 at91_udp_write(udc, AT91_UDP_IDR, AT91_UDP_RXRSM);
1429 at91_udp_write(AT91_UDP_IER, AT91_UDP_RXSUSP); 1454 at91_udp_write(udc, AT91_UDP_IER, AT91_UDP_RXSUSP);
1430 at91_udp_write(AT91_UDP_ICR, AT91_UDP_RXRSM); 1455 at91_udp_write(udc, AT91_UDP_ICR, AT91_UDP_RXRSM);
1431 // VDBG("bus resume\n"); 1456 // VDBG("bus resume\n");
1432 if (!udc->suspended) 1457 if (!udc->suspended)
1433 continue; 1458 continue;
@@ -1485,8 +1510,6 @@ static struct at91_udc controller = {
1485 }, 1510 },
1486 .udc = &controller, 1511 .udc = &controller,
1487 .maxpacket = 8, 1512 .maxpacket = 8,
1488 .creg = (void __iomem *)(AT91_VA_BASE_UDP
1489 + AT91_UDP_CSR(0)),
1490 .int_mask = 1 << 0, 1513 .int_mask = 1 << 0,
1491 }, 1514 },
1492 .ep[1] = { 1515 .ep[1] = {
@@ -1497,8 +1520,6 @@ static struct at91_udc controller = {
1497 .udc = &controller, 1520 .udc = &controller,
1498 .is_pingpong = 1, 1521 .is_pingpong = 1,
1499 .maxpacket = 64, 1522 .maxpacket = 64,
1500 .creg = (void __iomem *)(AT91_VA_BASE_UDP
1501 + AT91_UDP_CSR(1)),
1502 .int_mask = 1 << 1, 1523 .int_mask = 1 << 1,
1503 }, 1524 },
1504 .ep[2] = { 1525 .ep[2] = {
@@ -1509,8 +1530,6 @@ static struct at91_udc controller = {
1509 .udc = &controller, 1530 .udc = &controller,
1510 .is_pingpong = 1, 1531 .is_pingpong = 1,
1511 .maxpacket = 64, 1532 .maxpacket = 64,
1512 .creg = (void __iomem *)(AT91_VA_BASE_UDP
1513 + AT91_UDP_CSR(2)),
1514 .int_mask = 1 << 2, 1533 .int_mask = 1 << 2,
1515 }, 1534 },
1516 .ep[3] = { 1535 .ep[3] = {
@@ -1521,8 +1540,6 @@ static struct at91_udc controller = {
1521 }, 1540 },
1522 .udc = &controller, 1541 .udc = &controller,
1523 .maxpacket = 8, 1542 .maxpacket = 8,
1524 .creg = (void __iomem *)(AT91_VA_BASE_UDP
1525 + AT91_UDP_CSR(3)),
1526 .int_mask = 1 << 3, 1543 .int_mask = 1 << 3,
1527 }, 1544 },
1528 .ep[4] = { 1545 .ep[4] = {
@@ -1533,8 +1550,6 @@ static struct at91_udc controller = {
1533 .udc = &controller, 1550 .udc = &controller,
1534 .is_pingpong = 1, 1551 .is_pingpong = 1,
1535 .maxpacket = 256, 1552 .maxpacket = 256,
1536 .creg = (void __iomem *)(AT91_VA_BASE_UDP
1537 + AT91_UDP_CSR(4)),
1538 .int_mask = 1 << 4, 1553 .int_mask = 1 << 4,
1539 }, 1554 },
1540 .ep[5] = { 1555 .ep[5] = {
@@ -1545,8 +1560,6 @@ static struct at91_udc controller = {
1545 .udc = &controller, 1560 .udc = &controller,
1546 .is_pingpong = 1, 1561 .is_pingpong = 1,
1547 .maxpacket = 256, 1562 .maxpacket = 256,
1548 .creg = (void __iomem *)(AT91_VA_BASE_UDP
1549 + AT91_UDP_CSR(5)),
1550 .int_mask = 1 << 5, 1563 .int_mask = 1 << 5,
1551 }, 1564 },
1552 /* ep6 and ep7 are also reserved (custom silicon might use them) */ 1565 /* ep6 and ep7 are also reserved (custom silicon might use them) */
@@ -1572,9 +1585,8 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver)
1572 int retval; 1585 int retval;
1573 1586
1574 if (!driver 1587 if (!driver
1575 || driver->speed != USB_SPEED_FULL 1588 || driver->speed < USB_SPEED_FULL
1576 || !driver->bind 1589 || !driver->bind
1577 || !driver->unbind
1578 || !driver->setup) { 1590 || !driver->setup) {
1579 DBG("bad parameter.\n"); 1591 DBG("bad parameter.\n");
1580 return -EINVAL; 1592 return -EINVAL;
@@ -1595,6 +1607,10 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver)
1595 if (retval) { 1607 if (retval) {
1596 DBG("driver->bind() returned %d\n", retval); 1608 DBG("driver->bind() returned %d\n", retval);
1597 udc->driver = NULL; 1609 udc->driver = NULL;
1610 udc->gadget.dev.driver = NULL;
1611 udc->gadget.dev.driver_data = NULL;
1612 udc->enabled = 0;
1613 udc->selfpowered = 0;
1598 return retval; 1614 return retval;
1599 } 1615 }
1600 1616
@@ -1611,12 +1627,12 @@ int usb_gadget_unregister_driver (struct usb_gadget_driver *driver)
1611{ 1627{
1612 struct at91_udc *udc = &controller; 1628 struct at91_udc *udc = &controller;
1613 1629
1614 if (!driver || driver != udc->driver) 1630 if (!driver || driver != udc->driver || !driver->unbind)
1615 return -EINVAL; 1631 return -EINVAL;
1616 1632
1617 local_irq_disable(); 1633 local_irq_disable();
1618 udc->enabled = 0; 1634 udc->enabled = 0;
1619 at91_udp_write(AT91_UDP_IDR, ~0); 1635 at91_udp_write(udc, AT91_UDP_IDR, ~0);
1620 pullup(udc, 0); 1636 pullup(udc, 0);
1621 local_irq_enable(); 1637 local_irq_enable();
1622 1638
@@ -1641,6 +1657,7 @@ static int __devinit at91udc_probe(struct platform_device *pdev)
1641 struct device *dev = &pdev->dev; 1657 struct device *dev = &pdev->dev;
1642 struct at91_udc *udc; 1658 struct at91_udc *udc;
1643 int retval; 1659 int retval;
1660 struct resource *res;
1644 1661
1645 if (!dev->platform_data) { 1662 if (!dev->platform_data) {
1646 /* small (so we copy it) but critical! */ 1663 /* small (so we copy it) but critical! */
@@ -1658,7 +1675,13 @@ static int __devinit at91udc_probe(struct platform_device *pdev)
1658 return -ENODEV; 1675 return -ENODEV;
1659 } 1676 }
1660 1677
1661 if (!request_mem_region(AT91RM9200_BASE_UDP, SZ_16K, driver_name)) { 1678 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1679 if (!res)
1680 return -ENXIO;
1681
1682 if (!request_mem_region(res->start,
1683 res->end - res->start + 1,
1684 driver_name)) {
1662 DBG("someone's using UDC memory\n"); 1685 DBG("someone's using UDC memory\n");
1663 return -EBUSY; 1686 return -EBUSY;
1664 } 1687 }
@@ -1668,15 +1691,23 @@ static int __devinit at91udc_probe(struct platform_device *pdev)
1668 udc->gadget.dev.parent = dev; 1691 udc->gadget.dev.parent = dev;
1669 udc->board = *(struct at91_udc_data *) dev->platform_data; 1692 udc->board = *(struct at91_udc_data *) dev->platform_data;
1670 udc->pdev = pdev; 1693 udc->pdev = pdev;
1671 udc_reinit(udc);
1672 udc->enabled = 0; 1694 udc->enabled = 0;
1673 1695
1696 udc->udp_baseaddr = ioremap(res->start, res->end - res->start + 1);
1697 if (!udc->udp_baseaddr) {
1698 release_mem_region(res->start, res->end - res->start + 1);
1699 return -ENOMEM;
1700 }
1701
1702 udc_reinit(udc);
1703
1674 /* get interface and function clocks */ 1704 /* get interface and function clocks */
1675 udc->iclk = clk_get(dev, "udc_clk"); 1705 udc->iclk = clk_get(dev, "udc_clk");
1676 udc->fclk = clk_get(dev, "udpck"); 1706 udc->fclk = clk_get(dev, "udpck");
1677 if (IS_ERR(udc->iclk) || IS_ERR(udc->fclk)) { 1707 if (IS_ERR(udc->iclk) || IS_ERR(udc->fclk)) {
1678 DBG("clocks missing\n"); 1708 DBG("clocks missing\n");
1679 return -ENODEV; 1709 retval = -ENODEV;
1710 goto fail0;
1680 } 1711 }
1681 1712
1682 retval = device_register(&udc->gadget.dev); 1713 retval = device_register(&udc->gadget.dev);
@@ -1685,8 +1716,10 @@ static int __devinit at91udc_probe(struct platform_device *pdev)
1685 1716
1686 /* don't do anything until we have both gadget driver and VBUS */ 1717 /* don't do anything until we have both gadget driver and VBUS */
1687 clk_enable(udc->iclk); 1718 clk_enable(udc->iclk);
1688 at91_udp_write(AT91_UDP_TXVC, AT91_UDP_TXVC_TXVDIS); 1719 at91_udp_write(udc, AT91_UDP_TXVC, AT91_UDP_TXVC_TXVDIS);
1689 at91_udp_write(AT91_UDP_IDR, 0xffffffff); 1720 at91_udp_write(udc, AT91_UDP_IDR, 0xffffffff);
1721 /* Clear all pending interrupts - UDP may be used by bootloader. */
1722 at91_udp_write(udc, AT91_UDP_ICR, 0xffffffff);
1690 clk_disable(udc->iclk); 1723 clk_disable(udc->iclk);
1691 1724
1692 /* request UDC and maybe VBUS irqs */ 1725 /* request UDC and maybe VBUS irqs */
@@ -1698,6 +1731,11 @@ static int __devinit at91udc_probe(struct platform_device *pdev)
1698 goto fail1; 1731 goto fail1;
1699 } 1732 }
1700 if (udc->board.vbus_pin > 0) { 1733 if (udc->board.vbus_pin > 0) {
1734 /*
1735 * Get the initial state of VBUS - we cannot expect
1736 * a pending interrupt.
1737 */
1738 udc->vbus = at91_get_gpio_value(udc->board.vbus_pin);
1701 if (request_irq(udc->board.vbus_pin, at91_vbus_irq, 1739 if (request_irq(udc->board.vbus_pin, at91_vbus_irq,
1702 IRQF_DISABLED, driver_name, udc)) { 1740 IRQF_DISABLED, driver_name, udc)) {
1703 DBG("request vbus irq %d failed\n", 1741 DBG("request vbus irq %d failed\n",
@@ -1720,7 +1758,7 @@ static int __devinit at91udc_probe(struct platform_device *pdev)
1720fail1: 1758fail1:
1721 device_unregister(&udc->gadget.dev); 1759 device_unregister(&udc->gadget.dev);
1722fail0: 1760fail0:
1723 release_mem_region(AT91RM9200_BASE_UDP, SZ_16K); 1761 release_mem_region(res->start, res->end - res->start + 1);
1724 DBG("%s probe failed, %d\n", driver_name, retval); 1762 DBG("%s probe failed, %d\n", driver_name, retval);
1725 return retval; 1763 return retval;
1726} 1764}
@@ -1728,13 +1766,14 @@ fail0:
1728static int __devexit at91udc_remove(struct platform_device *pdev) 1766static int __devexit at91udc_remove(struct platform_device *pdev)
1729{ 1767{
1730 struct at91_udc *udc = platform_get_drvdata(pdev); 1768 struct at91_udc *udc = platform_get_drvdata(pdev);
1769 struct resource *res;
1731 1770
1732 DBG("remove\n"); 1771 DBG("remove\n");
1733 1772
1734 pullup(udc, 0); 1773 if (udc->driver)
1774 return -EBUSY;
1735 1775
1736 if (udc->driver != 0) 1776 pullup(udc, 0);
1737 usb_gadget_unregister_driver(udc->driver);
1738 1777
1739 device_init_wakeup(&pdev->dev, 0); 1778 device_init_wakeup(&pdev->dev, 0);
1740 remove_debug_file(udc); 1779 remove_debug_file(udc);
@@ -1742,7 +1781,10 @@ static int __devexit at91udc_remove(struct platform_device *pdev)
1742 free_irq(udc->board.vbus_pin, udc); 1781 free_irq(udc->board.vbus_pin, udc);
1743 free_irq(udc->udp_irq, udc); 1782 free_irq(udc->udp_irq, udc);
1744 device_unregister(&udc->gadget.dev); 1783 device_unregister(&udc->gadget.dev);
1745 release_mem_region(AT91RM9200_BASE_UDP, SZ_16K); 1784
1785 iounmap(udc->udp_baseaddr);
1786 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1787 release_mem_region(res->start, res->end - res->start + 1);
1746 1788
1747 clk_put(udc->iclk); 1789 clk_put(udc->iclk);
1748 clk_put(udc->fclk); 1790 clk_put(udc->fclk);
diff --git a/drivers/usb/gadget/at91_udc.h b/drivers/usb/gadget/at91_udc.h
index 882af42e86cc..677089baa59d 100644
--- a/drivers/usb/gadget/at91_udc.h
+++ b/drivers/usb/gadget/at91_udc.h
@@ -51,10 +51,10 @@
51#define AT91_UDP_EP(n) (1 << (n)) /* Endpoint Interrupt Status */ 51#define AT91_UDP_EP(n) (1 << (n)) /* Endpoint Interrupt Status */
52#define AT91_UDP_RXSUSP (1 << 8) /* USB Suspend Interrupt Status */ 52#define AT91_UDP_RXSUSP (1 << 8) /* USB Suspend Interrupt Status */
53#define AT91_UDP_RXRSM (1 << 9) /* USB Resume Interrupt Status */ 53#define AT91_UDP_RXRSM (1 << 9) /* USB Resume Interrupt Status */
54#define AT91_UDP_EXTRSM (1 << 10) /* External Resume Interrupt Status */ 54#define AT91_UDP_EXTRSM (1 << 10) /* External Resume Interrupt Status [AT91RM9200 only] */
55#define AT91_UDP_SOFINT (1 << 11) /* Start of Frame Interrupt Status */ 55#define AT91_UDP_SOFINT (1 << 11) /* Start of Frame Interrupt Status */
56#define AT91_UDP_ENDBUSRES (1 << 12) /* End of Bus Reset Interrpt Status */ 56#define AT91_UDP_ENDBUSRES (1 << 12) /* End of Bus Reset Interrpt Status */
57#define AT91_UDP_WAKEUP (1 << 13) /* USB Wakeup Interrupt Status */ 57#define AT91_UDP_WAKEUP (1 << 13) /* USB Wakeup Interrupt Status [AT91RM9200 only] */
58 58
59#define AT91_UDP_ICR 0x20 /* Interrupt Clear Register */ 59#define AT91_UDP_ICR 0x20 /* Interrupt Clear Register */
60#define AT91_UDP_RST_EP 0x28 /* Reset Endpoint Register */ 60#define AT91_UDP_RST_EP 0x28 /* Reset Endpoint Register */
@@ -84,7 +84,7 @@
84 84
85#define AT91_UDP_TXVC 0x74 /* Transceiver Control Register */ 85#define AT91_UDP_TXVC 0x74 /* Transceiver Control Register */
86#define AT91_UDP_TXVC_TXVDIS (1 << 8) /* Transceiver Disable */ 86#define AT91_UDP_TXVC_TXVDIS (1 << 8) /* Transceiver Disable */
87 87#define AT91_UDP_TXVC_PUON (1 << 9) /* PullUp On [AT91SAM9260 only] */
88 88
89/*-------------------------------------------------------------------------*/ 89/*-------------------------------------------------------------------------*/
90 90
@@ -141,6 +141,7 @@ struct at91_udc {
141 struct clk *iclk, *fclk; 141 struct clk *iclk, *fclk;
142 struct platform_device *pdev; 142 struct platform_device *pdev;
143 struct proc_dir_entry *pde; 143 struct proc_dir_entry *pde;
144 void __iomem *udp_baseaddr;
144 int udp_irq; 145 int udp_irq;
145}; 146};
146 147
diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c
index f1f32d7be5f9..3c2bc075ef4f 100644
--- a/drivers/usb/gadget/dummy_hcd.c
+++ b/drivers/usb/gadget/dummy_hcd.c
@@ -779,7 +779,7 @@ usb_gadget_register_driver (struct usb_gadget_driver *driver)
779 return -EINVAL; 779 return -EINVAL;
780 if (dum->driver) 780 if (dum->driver)
781 return -EBUSY; 781 return -EBUSY;
782 if (!driver->bind || !driver->unbind || !driver->setup 782 if (!driver->bind || !driver->setup
783 || driver->speed == USB_SPEED_UNKNOWN) 783 || driver->speed == USB_SPEED_UNKNOWN)
784 return -EINVAL; 784 return -EINVAL;
785 785
@@ -837,7 +837,8 @@ usb_gadget_register_driver (struct usb_gadget_driver *driver)
837err_bind_driver: 837err_bind_driver:
838 driver_unregister (&driver->driver); 838 driver_unregister (&driver->driver);
839err_register: 839err_register:
840 driver->unbind (&dum->gadget); 840 if (driver->unbind)
841 driver->unbind (&dum->gadget);
841 spin_lock_irq (&dum->lock); 842 spin_lock_irq (&dum->lock);
842 dum->pullup = 0; 843 dum->pullup = 0;
843 set_link_state (dum); 844 set_link_state (dum);
@@ -857,7 +858,7 @@ usb_gadget_unregister_driver (struct usb_gadget_driver *driver)
857 858
858 if (!dum) 859 if (!dum)
859 return -ENODEV; 860 return -ENODEV;
860 if (!driver || driver != dum->driver) 861 if (!driver || driver != dum->driver || !driver->unbind)
861 return -EINVAL; 862 return -EINVAL;
862 863
863 dev_dbg (udc_dev(dum), "unregister gadget driver '%s'\n", 864 dev_dbg (udc_dev(dum), "unregister gadget driver '%s'\n",
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c
index a265e262a2ee..72f2ae96fbf3 100644
--- a/drivers/usb/gadget/file_storage.c
+++ b/drivers/usb/gadget/file_storage.c
@@ -4100,7 +4100,7 @@ static struct usb_gadget_driver fsg_driver = {
4100#endif 4100#endif
4101 .function = (char *) longname, 4101 .function = (char *) longname,
4102 .bind = fsg_bind, 4102 .bind = fsg_bind,
4103 .unbind = __exit_p(fsg_unbind), 4103 .unbind = fsg_unbind,
4104 .disconnect = fsg_disconnect, 4104 .disconnect = fsg_disconnect,
4105 .setup = fsg_setup, 4105 .setup = fsg_setup,
4106 .suspend = fsg_suspend, 4106 .suspend = fsg_suspend,
diff --git a/drivers/usb/gadget/gmidi.c b/drivers/usb/gadget/gmidi.c
index 31351826f2ba..f1a679656c96 100644
--- a/drivers/usb/gadget/gmidi.c
+++ b/drivers/usb/gadget/gmidi.c
@@ -123,7 +123,7 @@ struct gmidi_device {
123 struct usb_request *req; /* for control responses */ 123 struct usb_request *req; /* for control responses */
124 u8 config; 124 u8 config;
125 struct usb_ep *in_ep, *out_ep; 125 struct usb_ep *in_ep, *out_ep;
126 struct snd_card *card; 126 struct snd_card *card;
127 struct snd_rawmidi *rmidi; 127 struct snd_rawmidi *rmidi;
128 struct snd_rawmidi_substream *in_substream; 128 struct snd_rawmidi_substream *in_substream;
129 struct snd_rawmidi_substream *out_substream; 129 struct snd_rawmidi_substream *out_substream;
@@ -490,7 +490,7 @@ static void gmidi_complete(struct usb_ep *ep, struct usb_request *req)
490 int status = req->status; 490 int status = req->status;
491 491
492 switch (status) { 492 switch (status) {
493 case 0: /* normal completion */ 493 case 0: /* normal completion */
494 if (ep == dev->out_ep) { 494 if (ep == dev->out_ep) {
495 /* we received stuff. 495 /* we received stuff.
496 req is queued again, below */ 496 req is queued again, below */
@@ -505,7 +505,7 @@ static void gmidi_complete(struct usb_ep *ep, struct usb_request *req)
505 break; 505 break;
506 506
507 /* this endpoint is normally active while we're configured */ 507 /* this endpoint is normally active while we're configured */
508 case -ECONNABORTED: /* hardware forced ep reset */ 508 case -ECONNABORTED: /* hardware forced ep reset */
509 case -ECONNRESET: /* request dequeued */ 509 case -ECONNRESET: /* request dequeued */
510 case -ESHUTDOWN: /* disconnect from host */ 510 case -ESHUTDOWN: /* disconnect from host */
511 VDBG(dev, "%s gone (%d), %d/%d\n", ep->name, status, 511 VDBG(dev, "%s gone (%d), %d/%d\n", ep->name, status,
@@ -656,7 +656,7 @@ gmidi_set_config(struct gmidi_device *dev, unsigned number, gfp_t gfp_flags)
656 case USB_SPEED_LOW: speed = "low"; break; 656 case USB_SPEED_LOW: speed = "low"; break;
657 case USB_SPEED_FULL: speed = "full"; break; 657 case USB_SPEED_FULL: speed = "full"; break;
658 case USB_SPEED_HIGH: speed = "high"; break; 658 case USB_SPEED_HIGH: speed = "high"; break;
659 default: speed = "?"; break; 659 default: speed = "?"; break;
660 } 660 }
661 661
662 dev->config = number; 662 dev->config = number;
@@ -1308,7 +1308,7 @@ static struct usb_gadget_driver gmidi_driver = {
1308 .speed = USB_SPEED_FULL, 1308 .speed = USB_SPEED_FULL,
1309 .function = (char *)longname, 1309 .function = (char *)longname,
1310 .bind = gmidi_bind, 1310 .bind = gmidi_bind,
1311 .unbind = __exit_p(gmidi_unbind), 1311 .unbind = gmidi_unbind,
1312 1312
1313 .setup = gmidi_setup, 1313 .setup = gmidi_setup,
1314 .disconnect = gmidi_disconnect, 1314 .disconnect = gmidi_disconnect,
@@ -1316,7 +1316,7 @@ static struct usb_gadget_driver gmidi_driver = {
1316 .suspend = gmidi_suspend, 1316 .suspend = gmidi_suspend,
1317 .resume = gmidi_resume, 1317 .resume = gmidi_resume,
1318 1318
1319 .driver = { 1319 .driver = {
1320 .name = (char *)shortname, 1320 .name = (char *)shortname,
1321 .owner = THIS_MODULE, 1321 .owner = THIS_MODULE,
1322 }, 1322 },
diff --git a/drivers/usb/gadget/goku_udc.c b/drivers/usb/gadget/goku_udc.c
index 805a9826842d..d0ef1d6b3fac 100644
--- a/drivers/usb/gadget/goku_udc.c
+++ b/drivers/usb/gadget/goku_udc.c
@@ -1432,7 +1432,6 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
1432 if (!driver 1432 if (!driver
1433 || driver->speed != USB_SPEED_FULL 1433 || driver->speed != USB_SPEED_FULL
1434 || !driver->bind 1434 || !driver->bind
1435 || !driver->unbind
1436 || !driver->disconnect 1435 || !driver->disconnect
1437 || !driver->setup) 1436 || !driver->setup)
1438 return -EINVAL; 1437 return -EINVAL;
@@ -1495,7 +1494,7 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
1495 1494
1496 if (!dev) 1495 if (!dev)
1497 return -ENODEV; 1496 return -ENODEV;
1498 if (!driver || driver != dev->driver) 1497 if (!driver || driver != dev->driver || !driver->unbind)
1499 return -EINVAL; 1498 return -EINVAL;
1500 1499
1501 spin_lock_irqsave(&dev->lock, flags); 1500 spin_lock_irqsave(&dev->lock, flags);
@@ -1808,13 +1807,8 @@ static void goku_remove(struct pci_dev *pdev)
1808 struct goku_udc *dev = pci_get_drvdata(pdev); 1807 struct goku_udc *dev = pci_get_drvdata(pdev);
1809 1808
1810 DBG(dev, "%s\n", __FUNCTION__); 1809 DBG(dev, "%s\n", __FUNCTION__);
1811 /* start with the driver above us */ 1810
1812 if (dev->driver) { 1811 BUG_ON(dev->driver);
1813 /* should have been done already by driver model core */
1814 WARN(dev, "pci remove, driver '%s' is still registered\n",
1815 dev->driver->driver.name);
1816 usb_gadget_unregister_driver(dev->driver);
1817 }
1818 1812
1819#ifdef CONFIG_USB_GADGET_DEBUG_FILES 1813#ifdef CONFIG_USB_GADGET_DEBUG_FILES
1820 remove_proc_entry(proc_node_name, NULL); 1814 remove_proc_entry(proc_node_name, NULL);
diff --git a/drivers/usb/gadget/lh7a40x_udc.c b/drivers/usb/gadget/lh7a40x_udc.c
index 4a991564a03e..a0a73c08a344 100644
--- a/drivers/usb/gadget/lh7a40x_udc.c
+++ b/drivers/usb/gadget/lh7a40x_udc.c
@@ -422,9 +422,10 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
422 DEBUG("%s: %s\n", __FUNCTION__, driver->driver.name); 422 DEBUG("%s: %s\n", __FUNCTION__, driver->driver.name);
423 423
424 if (!driver 424 if (!driver
425 || driver->speed != USB_SPEED_FULL 425 || driver->speed != USB_SPEED_FULL
426 || !driver->bind 426 || !driver->bind
427 || !driver->unbind || !driver->disconnect || !driver->setup) 427 || !driver->disconnect
428 || !driver->setup)
428 return -EINVAL; 429 return -EINVAL;
429 if (!dev) 430 if (!dev)
430 return -ENODEV; 431 return -ENODEV;
@@ -471,7 +472,7 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
471 472
472 if (!dev) 473 if (!dev)
473 return -ENODEV; 474 return -ENODEV;
474 if (!driver || driver != dev->driver) 475 if (!driver || driver != dev->driver || !driver->unbind)
475 return -EINVAL; 476 return -EINVAL;
476 477
477 spin_lock_irqsave(&dev->lock, flags); 478 spin_lock_irqsave(&dev->lock, flags);
@@ -2125,9 +2126,11 @@ static int lh7a40x_udc_remove(struct platform_device *pdev)
2125 2126
2126 DEBUG("%s: %p\n", __FUNCTION__, pdev); 2127 DEBUG("%s: %p\n", __FUNCTION__, pdev);
2127 2128
2129 if (dev->driver)
2130 return -EBUSY;
2131
2128 udc_disable(dev); 2132 udc_disable(dev);
2129 remove_proc_files(); 2133 remove_proc_files();
2130 usb_gadget_unregister_driver(dev->driver);
2131 2134
2132 free_irq(IRQ_USBINTR, dev); 2135 free_irq(IRQ_USBINTR, dev);
2133 2136
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index 3024c679e38e..569eb8ccf232 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -2020,7 +2020,6 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver)
2020 if (!driver 2020 if (!driver
2021 || driver->speed != USB_SPEED_HIGH 2021 || driver->speed != USB_SPEED_HIGH
2022 || !driver->bind 2022 || !driver->bind
2023 || !driver->unbind
2024 || !driver->setup) 2023 || !driver->setup)
2025 return -EINVAL; 2024 return -EINVAL;
2026 if (!dev) 2025 if (!dev)
@@ -2107,7 +2106,7 @@ int usb_gadget_unregister_driver (struct usb_gadget_driver *driver)
2107 2106
2108 if (!dev) 2107 if (!dev)
2109 return -ENODEV; 2108 return -ENODEV;
2110 if (!driver || driver != dev->driver) 2109 if (!driver || driver != dev->driver || !driver->unbind)
2111 return -EINVAL; 2110 return -EINVAL;
2112 2111
2113 spin_lock_irqsave (&dev->lock, flags); 2112 spin_lock_irqsave (&dev->lock, flags);
@@ -2803,13 +2802,7 @@ static void net2280_remove (struct pci_dev *pdev)
2803{ 2802{
2804 struct net2280 *dev = pci_get_drvdata (pdev); 2803 struct net2280 *dev = pci_get_drvdata (pdev);
2805 2804
2806 /* start with the driver above us */ 2805 BUG_ON(dev->driver);
2807 if (dev->driver) {
2808 /* should have been done already by driver model core */
2809 WARN (dev, "pci remove, driver '%s' is still registered\n",
2810 dev->driver->driver.name);
2811 usb_gadget_unregister_driver (dev->driver);
2812 }
2813 2806
2814 /* then clean up the resources we allocated during probe() */ 2807 /* then clean up the resources we allocated during probe() */
2815 net2280_led_shutdown (dev); 2808 net2280_led_shutdown (dev);
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c
index 030d87c28c2f..15d77c307930 100644
--- a/drivers/usb/gadget/omap_udc.c
+++ b/drivers/usb/gadget/omap_udc.c
@@ -2043,7 +2043,6 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver)
2043 // FIXME if otg, check: driver->is_otg 2043 // FIXME if otg, check: driver->is_otg
2044 || driver->speed < USB_SPEED_FULL 2044 || driver->speed < USB_SPEED_FULL
2045 || !driver->bind 2045 || !driver->bind
2046 || !driver->unbind
2047 || !driver->setup) 2046 || !driver->setup)
2048 return -EINVAL; 2047 return -EINVAL;
2049 2048
@@ -2087,9 +2086,11 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver)
2087 status = otg_set_peripheral(udc->transceiver, &udc->gadget); 2086 status = otg_set_peripheral(udc->transceiver, &udc->gadget);
2088 if (status < 0) { 2087 if (status < 0) {
2089 ERR("can't bind to transceiver\n"); 2088 ERR("can't bind to transceiver\n");
2090 driver->unbind (&udc->gadget); 2089 if (driver->unbind) {
2091 udc->gadget.dev.driver = NULL; 2090 driver->unbind (&udc->gadget);
2092 udc->driver = NULL; 2091 udc->gadget.dev.driver = NULL;
2092 udc->driver = NULL;
2093 }
2093 goto done; 2094 goto done;
2094 } 2095 }
2095 } else { 2096 } else {
@@ -2117,7 +2118,7 @@ int usb_gadget_unregister_driver (struct usb_gadget_driver *driver)
2117 2118
2118 if (!udc) 2119 if (!udc)
2119 return -ENODEV; 2120 return -ENODEV;
2120 if (!driver || driver != udc->driver) 2121 if (!driver || driver != udc->driver || !driver->unbind)
2121 return -EINVAL; 2122 return -EINVAL;
2122 2123
2123 if (machine_is_omap_innovator() || machine_is_omap_osk()) 2124 if (machine_is_omap_innovator() || machine_is_omap_osk())
@@ -2870,6 +2871,8 @@ static int __exit omap_udc_remove(struct platform_device *pdev)
2870 2871
2871 if (!udc) 2872 if (!udc)
2872 return -ENODEV; 2873 return -ENODEV;
2874 if (udc->driver)
2875 return -EBUSY;
2873 2876
2874 udc->done = &done; 2877 udc->done = &done;
2875 2878
diff --git a/drivers/usb/gadget/pxa2xx_udc.c b/drivers/usb/gadget/pxa2xx_udc.c
index 1ed506e95985..b78de9694665 100644
--- a/drivers/usb/gadget/pxa2xx_udc.c
+++ b/drivers/usb/gadget/pxa2xx_udc.c
@@ -1623,7 +1623,6 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
1623 if (!driver 1623 if (!driver
1624 || driver->speed < USB_SPEED_FULL 1624 || driver->speed < USB_SPEED_FULL
1625 || !driver->bind 1625 || !driver->bind
1626 || !driver->unbind
1627 || !driver->disconnect 1626 || !driver->disconnect
1628 || !driver->setup) 1627 || !driver->setup)
1629 return -EINVAL; 1628 return -EINVAL;
@@ -1694,7 +1693,7 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
1694 1693
1695 if (!dev) 1694 if (!dev)
1696 return -ENODEV; 1695 return -ENODEV;
1697 if (!driver || driver != dev->driver) 1696 if (!driver || driver != dev->driver || !driver->unbind)
1698 return -EINVAL; 1697 return -EINVAL;
1699 1698
1700 local_irq_disable(); 1699 local_irq_disable();
@@ -2638,9 +2637,11 @@ static int __exit pxa2xx_udc_remove(struct platform_device *pdev)
2638{ 2637{
2639 struct pxa2xx_udc *dev = platform_get_drvdata(pdev); 2638 struct pxa2xx_udc *dev = platform_get_drvdata(pdev);
2640 2639
2640 if (dev->driver)
2641 return -EBUSY;
2642
2641 udc_disable(dev); 2643 udc_disable(dev);
2642 remove_proc_files(); 2644 remove_proc_files();
2643 usb_gadget_unregister_driver(dev->driver);
2644 2645
2645 if (dev->got_irq) { 2646 if (dev->got_irq) {
2646 free_irq(IRQ_USB, dev); 2647 free_irq(IRQ_USB, dev);
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c
index 2d12bf9f19d6..f8a3ec64635d 100644
--- a/drivers/usb/gadget/serial.c
+++ b/drivers/usb/gadget/serial.c
@@ -296,7 +296,7 @@ static struct usb_gadget_driver gs_gadget_driver = {
296#endif /* CONFIG_USB_GADGET_DUALSPEED */ 296#endif /* CONFIG_USB_GADGET_DUALSPEED */
297 .function = GS_LONG_NAME, 297 .function = GS_LONG_NAME,
298 .bind = gs_bind, 298 .bind = gs_bind,
299 .unbind = __exit_p(gs_unbind), 299 .unbind = gs_unbind,
300 .setup = gs_setup, 300 .setup = gs_setup,
301 .disconnect = gs_disconnect, 301 .disconnect = gs_disconnect,
302 .driver = { 302 .driver = {
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index b466581beb4a..cc405512fa1c 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -187,7 +187,6 @@ ohci_at91_start (struct usb_hcd *hcd)
187{ 187{
188 struct at91_usbh_data *board = hcd->self.controller->platform_data; 188 struct at91_usbh_data *board = hcd->self.controller->platform_data;
189 struct ohci_hcd *ohci = hcd_to_ohci (hcd); 189 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
190 struct usb_device *root = hcd->self.root_hub;
191 int ret; 190 int ret;
192 191
193 if ((ret = ohci_init(ohci)) < 0) 192 if ((ret = ohci_init(ohci)) < 0)
@@ -221,7 +220,7 @@ static const struct hc_driver ohci_at91_hc_driver = {
221 */ 220 */
222 .start = ohci_at91_start, 221 .start = ohci_at91_start,
223 .stop = ohci_stop, 222 .stop = ohci_stop,
224 .shutdown = ohci_shutdown, 223 .shutdown = ohci_shutdown,
225 224
226 /* 225 /*
227 * managing i/o requests and associated device resources 226 * managing i/o requests and associated device resources
diff --git a/drivers/usb/host/ohci-au1xxx.c b/drivers/usb/host/ohci-au1xxx.c
index 24e23c5783d8..e70b2430e2a9 100644
--- a/drivers/usb/host/ohci-au1xxx.c
+++ b/drivers/usb/host/ohci-au1xxx.c
@@ -269,7 +269,7 @@ static const struct hc_driver ohci_au1xxx_hc_driver = {
269 */ 269 */
270 .start = ohci_au1xxx_start, 270 .start = ohci_au1xxx_start,
271 .stop = ohci_stop, 271 .stop = ohci_stop,
272 .shutdown = ohci_shutdown, 272 .shutdown = ohci_shutdown,
273 273
274 /* 274 /*
275 * managing i/o requests and associated device resources 275 * managing i/o requests and associated device resources
@@ -336,7 +336,7 @@ static int ohci_hcd_au1xxx_drv_resume(struct platform_device *dev)
336static struct platform_driver ohci_hcd_au1xxx_driver = { 336static struct platform_driver ohci_hcd_au1xxx_driver = {
337 .probe = ohci_hcd_au1xxx_drv_probe, 337 .probe = ohci_hcd_au1xxx_drv_probe,
338 .remove = ohci_hcd_au1xxx_drv_remove, 338 .remove = ohci_hcd_au1xxx_drv_remove,
339 .shutdown = usb_hcd_platform_shutdown, 339 .shutdown = usb_hcd_platform_shutdown,
340 /*.suspend = ohci_hcd_au1xxx_drv_suspend, */ 340 /*.suspend = ohci_hcd_au1xxx_drv_suspend, */
341 /*.resume = ohci_hcd_au1xxx_drv_resume, */ 341 /*.resume = ohci_hcd_au1xxx_drv_resume, */
342 .driver = { 342 .driver = {
diff --git a/drivers/usb/host/ohci-dbg.c b/drivers/usb/host/ohci-dbg.c
index 0f47a57dac28..273d5ddb72be 100644
--- a/drivers/usb/host/ohci-dbg.c
+++ b/drivers/usb/host/ohci-dbg.c
@@ -16,7 +16,7 @@
16 case PIPE_CONTROL: temp = "ctrl"; break; \ 16 case PIPE_CONTROL: temp = "ctrl"; break; \
17 case PIPE_BULK: temp = "bulk"; break; \ 17 case PIPE_BULK: temp = "bulk"; break; \
18 case PIPE_INTERRUPT: temp = "intr"; break; \ 18 case PIPE_INTERRUPT: temp = "intr"; break; \
19 default: temp = "isoc"; break; \ 19 default: temp = "isoc"; break; \
20 }; temp;}) 20 }; temp;})
21#define pipestring(pipe) edstring(usb_pipetype(pipe)) 21#define pipestring(pipe) edstring(usb_pipetype(pipe))
22 22
@@ -205,13 +205,13 @@ ohci_dump_status (struct ohci_hcd *controller, char **next, unsigned *size)
205 (temp & RH_PS_PSSC) ? " PSSC" : "", \ 205 (temp & RH_PS_PSSC) ? " PSSC" : "", \
206 (temp & RH_PS_PESC) ? " PESC" : "", \ 206 (temp & RH_PS_PESC) ? " PESC" : "", \
207 (temp & RH_PS_CSC) ? " CSC" : "", \ 207 (temp & RH_PS_CSC) ? " CSC" : "", \
208 \ 208 \
209 (temp & RH_PS_LSDA) ? " LSDA" : "", \ 209 (temp & RH_PS_LSDA) ? " LSDA" : "", \
210 (temp & RH_PS_PPS) ? " PPS" : "", \ 210 (temp & RH_PS_PPS) ? " PPS" : "", \
211 (temp & RH_PS_PRS) ? " PRS" : "", \ 211 (temp & RH_PS_PRS) ? " PRS" : "", \
212 (temp & RH_PS_POCI) ? " POCI" : "", \ 212 (temp & RH_PS_POCI) ? " POCI" : "", \
213 (temp & RH_PS_PSS) ? " PSS" : "", \ 213 (temp & RH_PS_PSS) ? " PSS" : "", \
214 \ 214 \
215 (temp & RH_PS_PES) ? " PES" : "", \ 215 (temp & RH_PS_PES) ? " PES" : "", \
216 (temp & RH_PS_CCS) ? " CCS" : "" \ 216 (temp & RH_PS_CCS) ? " CCS" : "" \
217 ); 217 );
@@ -563,7 +563,7 @@ show_periodic (struct class_device *class_dev, char *buf)
563 (info & ED_SKIP) ? " K" : "", 563 (info & ED_SKIP) ? " K" : "",
564 (ed->hwHeadP & 564 (ed->hwHeadP &
565 cpu_to_hc32(ohci, ED_H)) ? 565 cpu_to_hc32(ohci, ED_H)) ?
566 " H" : ""); 566 " H" : "");
567 size -= temp; 567 size -= temp;
568 next += temp; 568 next += temp;
569 569
diff --git a/drivers/usb/host/ohci-ep93xx.c b/drivers/usb/host/ohci-ep93xx.c
index 1bf5e7a4e735..43ae696b2ec2 100644
--- a/drivers/usb/host/ohci-ep93xx.c
+++ b/drivers/usb/host/ohci-ep93xx.c
@@ -204,7 +204,7 @@ static int ohci_hcd_ep93xx_drv_resume(struct platform_device *pdev)
204static struct platform_driver ohci_hcd_ep93xx_driver = { 204static struct platform_driver ohci_hcd_ep93xx_driver = {
205 .probe = ohci_hcd_ep93xx_drv_probe, 205 .probe = ohci_hcd_ep93xx_drv_probe,
206 .remove = ohci_hcd_ep93xx_drv_remove, 206 .remove = ohci_hcd_ep93xx_drv_remove,
207 .shutdown = usb_hcd_platform_shutdown, 207 .shutdown = usb_hcd_platform_shutdown,
208#ifdef CONFIG_PM 208#ifdef CONFIG_PM
209 .suspend = ohci_hcd_ep93xx_drv_suspend, 209 .suspend = ohci_hcd_ep93xx_drv_suspend,
210 .resume = ohci_hcd_ep93xx_drv_resume, 210 .resume = ohci_hcd_ep93xx_drv_resume,
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index b28a9b602066..c1c1d871aba4 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -3,77 +3,21 @@
3 * 3 *
4 * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at> 4 * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at>
5 * (C) Copyright 2000-2004 David Brownell <dbrownell@users.sourceforge.net> 5 * (C) Copyright 2000-2004 David Brownell <dbrownell@users.sourceforge.net>
6 * 6 *
7 * [ Initialisation is based on Linus' ] 7 * [ Initialisation is based on Linus' ]
8 * [ uhci code and gregs ohci fragments ] 8 * [ uhci code and gregs ohci fragments ]
9 * [ (C) Copyright 1999 Linus Torvalds ] 9 * [ (C) Copyright 1999 Linus Torvalds ]
10 * [ (C) Copyright 1999 Gregory P. Smith] 10 * [ (C) Copyright 1999 Gregory P. Smith]
11 * 11 *
12 * 12 *
13 * OHCI is the main "non-Intel/VIA" standard for USB 1.1 host controller 13 * OHCI is the main "non-Intel/VIA" standard for USB 1.1 host controller
14 * interfaces (though some non-x86 Intel chips use it). It supports 14 * interfaces (though some non-x86 Intel chips use it). It supports
15 * smarter hardware than UHCI. A download link for the spec available 15 * smarter hardware than UHCI. A download link for the spec available
16 * through the http://www.usb.org website. 16 * through the http://www.usb.org website.
17 * 17 *
18 * History:
19 *
20 * 2004/03/24 LH7A404 support (Durgesh Pattamatta & Marc Singer)
21 * 2004/02/04 use generic dma_* functions instead of pci_* (dsaxena@plexity.net)
22 * 2003/02/24 show registers in sysfs (Kevin Brosius)
23 *
24 * 2002/09/03 get rid of ed hashtables, rework periodic scheduling and
25 * bandwidth accounting; if debugging, show schedules in driverfs
26 * 2002/07/19 fixes to management of ED and schedule state.
27 * 2002/06/09 SA-1111 support (Christopher Hoover)
28 * 2002/06/01 remember frame when HC won't see EDs any more; use that info
29 * to fix urb unlink races caused by interrupt latency assumptions;
30 * minor ED field and function naming updates
31 * 2002/01/18 package as a patch for 2.5.3; this should match the
32 * 2.4.17 kernel modulo some bugs being fixed.
33 *
34 * 2001/10/18 merge pmac cleanup (Benjamin Herrenschmidt) and bugfixes
35 * from post-2.4.5 patches.
36 * 2001/09/20 URB_ZERO_PACKET support; hcca_dma portability, OPTi warning
37 * 2001/09/07 match PCI PM changes, errnos from Linus' tree
38 * 2001/05/05 fork 2.4.5 version into "hcd" framework, cleanup, simplify;
39 * pbook pci quirks gone (please fix pbook pci sw!) (db)
40 *
41 * 2001/04/08 Identify version on module load (gb)
42 * 2001/03/24 td/ed hashing to remove bus_to_virt (Steve Longerbeam);
43 pci_map_single (db)
44 * 2001/03/21 td and dev/ed allocation uses new pci_pool API (db)
45 * 2001/03/07 hcca allocation uses pci_alloc_consistent (Steve Longerbeam)
46 *
47 * 2000/09/26 fixed races in removing the private portion of the urb
48 * 2000/09/07 disable bulk and control lists when unlinking the last
49 * endpoint descriptor in order to avoid unrecoverable errors on
50 * the Lucent chips. (rwc@sgi)
51 * 2000/08/29 use bandwidth claiming hooks (thanks Randy!), fix some
52 * urb unlink probs, indentation fixes
53 * 2000/08/11 various oops fixes mostly affecting iso and cleanup from
54 * device unplugs.
55 * 2000/06/28 use PCI hotplug framework, for better power management
56 * and for Cardbus support (David Brownell)
57 * 2000/earlier: fixes for NEC/Lucent chips; suspend/resume handling
58 * when the controller loses power; handle UE; cleanup; ...
59 *
60 * v5.2 1999/12/07 URB 3rd preview,
61 * v5.1 1999/11/30 URB 2nd preview, cpia, (usb-scsi)
62 * v5.0 1999/11/22 URB Technical preview, Paul Mackerras powerbook susp/resume
63 * i386: HUB, Keyboard, Mouse, Printer
64 *
65 * v4.3 1999/10/27 multiple HCs, bulk_request
66 * v4.2 1999/09/05 ISO API alpha, new dev alloc, neg Error-codes
67 * v4.1 1999/08/27 Randy Dunlap's - ISO API first impl.
68 * v4.0 1999/08/18
69 * v3.0 1999/06/25
70 * v2.1 1999/05/09 code clean up
71 * v2.0 1999/05/04
72 * v1.0 1999/04/27 initial release
73 *
74 * This file is licenced under the GPL. 18 * This file is licenced under the GPL.
75 */ 19 */
76 20
77#include <linux/module.h> 21#include <linux/module.h>
78#include <linux/moduleparam.h> 22#include <linux/moduleparam.h>
79#include <linux/pci.h> 23#include <linux/pci.h>
@@ -89,7 +33,7 @@
89#include <linux/list.h> 33#include <linux/list.h>
90#include <linux/usb.h> 34#include <linux/usb.h>
91#include <linux/usb/otg.h> 35#include <linux/usb/otg.h>
92#include <linux/dma-mapping.h> 36#include <linux/dma-mapping.h>
93#include <linux/dmapool.h> 37#include <linux/dmapool.h>
94#include <linux/reboot.h> 38#include <linux/reboot.h>
95 39
@@ -183,11 +127,11 @@ static int ohci_urb_enqueue (
183 int i, size = 0; 127 int i, size = 0;
184 unsigned long flags; 128 unsigned long flags;
185 int retval = 0; 129 int retval = 0;
186 130
187#ifdef OHCI_VERBOSE_DEBUG 131#ifdef OHCI_VERBOSE_DEBUG
188 urb_print (urb, "SUB", usb_pipein (pipe)); 132 urb_print (urb, "SUB", usb_pipein (pipe));
189#endif 133#endif
190 134
191 /* every endpoint has a ed, locate and maybe (re)initialize it */ 135 /* every endpoint has a ed, locate and maybe (re)initialize it */
192 if (! (ed = ed_get (ohci, ep, urb->dev, pipe, urb->interval))) 136 if (! (ed = ed_get (ohci, ep, urb->dev, pipe, urb->interval)))
193 return -ENOMEM; 137 return -ENOMEM;
@@ -232,7 +176,7 @@ static int ohci_urb_enqueue (
232 memset (urb_priv, 0, sizeof (urb_priv_t) + size * sizeof (struct td *)); 176 memset (urb_priv, 0, sizeof (urb_priv_t) + size * sizeof (struct td *));
233 INIT_LIST_HEAD (&urb_priv->pending); 177 INIT_LIST_HEAD (&urb_priv->pending);
234 urb_priv->length = size; 178 urb_priv->length = size;
235 urb_priv->ed = ed; 179 urb_priv->ed = ed;
236 180
237 /* allocate the TDs (deferring hash chain updates) */ 181 /* allocate the TDs (deferring hash chain updates) */
238 for (i = 0; i < size; i++) { 182 for (i = 0; i < size; i++) {
@@ -242,7 +186,7 @@ static int ohci_urb_enqueue (
242 urb_free_priv (ohci, urb_priv); 186 urb_free_priv (ohci, urb_priv);
243 return -ENOMEM; 187 return -ENOMEM;
244 } 188 }
245 } 189 }
246 190
247 spin_lock_irqsave (&ohci->lock, flags); 191 spin_lock_irqsave (&ohci->lock, flags);
248 192
@@ -313,13 +257,13 @@ static int ohci_urb_dequeue (struct usb_hcd *hcd, struct urb *urb)
313{ 257{
314 struct ohci_hcd *ohci = hcd_to_ohci (hcd); 258 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
315 unsigned long flags; 259 unsigned long flags;
316 260
317#ifdef OHCI_VERBOSE_DEBUG 261#ifdef OHCI_VERBOSE_DEBUG
318 urb_print (urb, "UNLINK", 1); 262 urb_print (urb, "UNLINK", 1);
319#endif 263#endif
320 264
321 spin_lock_irqsave (&ohci->lock, flags); 265 spin_lock_irqsave (&ohci->lock, flags);
322 if (HC_IS_RUNNING(hcd->state)) { 266 if (HC_IS_RUNNING(hcd->state)) {
323 urb_priv_t *urb_priv; 267 urb_priv_t *urb_priv;
324 268
325 /* Unless an IRQ completed the unlink while it was being 269 /* Unless an IRQ completed the unlink while it was being
@@ -512,11 +456,11 @@ static int ohci_init (struct ohci_hcd *ohci)
512 456
513/* Start an OHCI controller, set the BUS operational 457/* Start an OHCI controller, set the BUS operational
514 * resets USB and controller 458 * resets USB and controller
515 * enable interrupts 459 * enable interrupts
516 */ 460 */
517static int ohci_run (struct ohci_hcd *ohci) 461static int ohci_run (struct ohci_hcd *ohci)
518{ 462{
519 u32 mask, temp; 463 u32 mask, temp;
520 int first = ohci->fminterval == 0; 464 int first = ohci->fminterval == 0;
521 struct usb_hcd *hcd = ohci_to_hcd(ohci); 465 struct usb_hcd *hcd = ohci_to_hcd(ohci);
522 466
@@ -534,7 +478,7 @@ static int ohci_run (struct ohci_hcd *ohci)
534 /* also: power/overcurrent flags in roothub.a */ 478 /* also: power/overcurrent flags in roothub.a */
535 } 479 }
536 480
537 /* Reset USB nearly "by the book". RemoteWakeupConnected was 481 /* Reset USB nearly "by the book". RemoteWakeupConnected was
538 * saved if boot firmware (BIOS/SMM/...) told us it's connected, 482 * saved if boot firmware (BIOS/SMM/...) told us it's connected,
539 * or if bus glue did the same (e.g. for PCI add-in cards with 483 * or if bus glue did the same (e.g. for PCI add-in cards with
540 * PCI PM support). 484 * PCI PM support).
@@ -765,9 +709,9 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd)
765 dl_done_list (ohci); 709 dl_done_list (ohci);
766 spin_unlock (&ohci->lock); 710 spin_unlock (&ohci->lock);
767 if (HC_IS_RUNNING(hcd->state)) 711 if (HC_IS_RUNNING(hcd->state))
768 ohci_writel (ohci, OHCI_INTR_WDH, &regs->intrenable); 712 ohci_writel (ohci, OHCI_INTR_WDH, &regs->intrenable);
769 } 713 }
770 714
771 /* could track INTR_SO to reduce available PCI/... bandwidth */ 715 /* could track INTR_SO to reduce available PCI/... bandwidth */
772 716
773 /* handle any pending URB/ED unlinks, leaving INTR_SF enabled 717 /* handle any pending URB/ED unlinks, leaving INTR_SF enabled
@@ -778,12 +722,12 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd)
778 finish_unlinks (ohci, ohci_frame_no(ohci)); 722 finish_unlinks (ohci, ohci_frame_no(ohci));
779 if ((ints & OHCI_INTR_SF) != 0 && !ohci->ed_rm_list 723 if ((ints & OHCI_INTR_SF) != 0 && !ohci->ed_rm_list
780 && HC_IS_RUNNING(hcd->state)) 724 && HC_IS_RUNNING(hcd->state))
781 ohci_writel (ohci, OHCI_INTR_SF, &regs->intrdisable); 725 ohci_writel (ohci, OHCI_INTR_SF, &regs->intrdisable);
782 spin_unlock (&ohci->lock); 726 spin_unlock (&ohci->lock);
783 727
784 if (HC_IS_RUNNING(hcd->state)) { 728 if (HC_IS_RUNNING(hcd->state)) {
785 ohci_writel (ohci, ints, &regs->intrstatus); 729 ohci_writel (ohci, ints, &regs->intrstatus);
786 ohci_writel (ohci, OHCI_INTR_MIE, &regs->intrenable); 730 ohci_writel (ohci, OHCI_INTR_MIE, &regs->intrenable);
787 // flush those writes 731 // flush those writes
788 (void) ohci_readl (ohci, &ohci->regs->control); 732 (void) ohci_readl (ohci, &ohci->regs->control);
789 } 733 }
@@ -794,7 +738,7 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd)
794/*-------------------------------------------------------------------------*/ 738/*-------------------------------------------------------------------------*/
795 739
796static void ohci_stop (struct usb_hcd *hcd) 740static void ohci_stop (struct usb_hcd *hcd)
797{ 741{
798 struct ohci_hcd *ohci = hcd_to_ohci (hcd); 742 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
799 743
800 ohci_dbg (ohci, "stop %s controller (state 0x%02x)\n", 744 ohci_dbg (ohci, "stop %s controller (state 0x%02x)\n",
@@ -812,8 +756,8 @@ static void ohci_stop (struct usb_hcd *hcd)
812 remove_debug_files (ohci); 756 remove_debug_files (ohci);
813 ohci_mem_cleanup (ohci); 757 ohci_mem_cleanup (ohci);
814 if (ohci->hcca) { 758 if (ohci->hcca) {
815 dma_free_coherent (hcd->self.controller, 759 dma_free_coherent (hcd->self.controller,
816 sizeof *ohci->hcca, 760 sizeof *ohci->hcca,
817 ohci->hcca, ohci->hcca_dma); 761 ohci->hcca, ohci->hcca_dma);
818 ohci->hcca = NULL; 762 ohci->hcca = NULL;
819 ohci->hcca_dma = 0; 763 ohci->hcca_dma = 0;
@@ -836,7 +780,7 @@ static int ohci_restart (struct ohci_hcd *ohci)
836 * recycle any "live" eds/tds (and urbs) right away. 780 * recycle any "live" eds/tds (and urbs) right away.
837 * later, khubd disconnect processing will recycle the other state, 781 * later, khubd disconnect processing will recycle the other state,
838 * (either as disconnect/reconnect, or maybe someday as a reset). 782 * (either as disconnect/reconnect, or maybe someday as a reset).
839 */ 783 */
840 spin_lock_irq(&ohci->lock); 784 spin_lock_irq(&ohci->lock);
841 disable (ohci); 785 disable (ohci);
842 usb_root_hub_lost_power(ohci_to_hcd(ohci)->self.root_hub); 786 usb_root_hub_lost_power(ohci_to_hcd(ohci)->self.root_hub);
@@ -875,11 +819,11 @@ static int ohci_restart (struct ohci_hcd *ohci)
875 /* empty the interrupt branches */ 819 /* empty the interrupt branches */
876 for (i = 0; i < NUM_INTS; i++) ohci->load [i] = 0; 820 for (i = 0; i < NUM_INTS; i++) ohci->load [i] = 0;
877 for (i = 0; i < NUM_INTS; i++) ohci->hcca->int_table [i] = 0; 821 for (i = 0; i < NUM_INTS; i++) ohci->hcca->int_table [i] = 0;
878 822
879 /* no EDs to remove */ 823 /* no EDs to remove */
880 ohci->ed_rm_list = NULL; 824 ohci->ed_rm_list = NULL;
881 825
882 /* empty control and bulk lists */ 826 /* empty control and bulk lists */
883 ohci->ed_controltail = NULL; 827 ohci->ed_controltail = NULL;
884 ohci->ed_bulktail = NULL; 828 ohci->ed_bulktail = NULL;
885 829
@@ -941,6 +885,10 @@ MODULE_LICENSE ("GPL");
941#include "ohci-au1xxx.c" 885#include "ohci-au1xxx.c"
942#endif 886#endif
943 887
888#ifdef CONFIG_PNX8550
889#include "ohci-pnx8550.c"
890#endif
891
944#ifdef CONFIG_USB_OHCI_HCD_PPC_SOC 892#ifdef CONFIG_USB_OHCI_HCD_PPC_SOC
945#include "ohci-ppc-soc.c" 893#include "ohci-ppc-soc.c"
946#endif 894#endif
diff --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c
index 2441642cb7b4..216c9c9d4d6d 100644
--- a/drivers/usb/host/ohci-hub.c
+++ b/drivers/usb/host/ohci-hub.c
@@ -1,9 +1,9 @@
1/* 1/*
2 * OHCI HCD (Host Controller Driver) for USB. 2 * OHCI HCD (Host Controller Driver) for USB.
3 * 3 *
4 * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at> 4 * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at>
5 * (C) Copyright 2000-2004 David Brownell <dbrownell@users.sourceforge.net> 5 * (C) Copyright 2000-2004 David Brownell <dbrownell@users.sourceforge.net>
6 * 6 *
7 * This file is licenced under GPL 7 * This file is licenced under GPL
8 */ 8 */
9 9
@@ -23,13 +23,13 @@
23 (temp & RH_PS_PSSC) ? " PSSC" : "", \ 23 (temp & RH_PS_PSSC) ? " PSSC" : "", \
24 (temp & RH_PS_PESC) ? " PESC" : "", \ 24 (temp & RH_PS_PESC) ? " PESC" : "", \
25 (temp & RH_PS_CSC) ? " CSC" : "", \ 25 (temp & RH_PS_CSC) ? " CSC" : "", \
26 \ 26 \
27 (temp & RH_PS_LSDA) ? " LSDA" : "", \ 27 (temp & RH_PS_LSDA) ? " LSDA" : "", \
28 (temp & RH_PS_PPS) ? " PPS" : "", \ 28 (temp & RH_PS_PPS) ? " PPS" : "", \
29 (temp & RH_PS_PRS) ? " PRS" : "", \ 29 (temp & RH_PS_PRS) ? " PRS" : "", \
30 (temp & RH_PS_POCI) ? " POCI" : "", \ 30 (temp & RH_PS_POCI) ? " POCI" : "", \
31 (temp & RH_PS_PSS) ? " PSS" : "", \ 31 (temp & RH_PS_PSS) ? " PSS" : "", \
32 \ 32 \
33 (temp & RH_PS_PES) ? " PES" : "", \ 33 (temp & RH_PS_PES) ? " PES" : "", \
34 (temp & RH_PS_CCS) ? " CCS" : "" \ 34 (temp & RH_PS_CCS) ? " CCS" : "" \
35 ); 35 );
@@ -484,7 +484,7 @@ ohci_hub_descriptor (
484 temp = 0; 484 temp = 0;
485 if (rh & RH_A_NPS) /* no power switching? */ 485 if (rh & RH_A_NPS) /* no power switching? */
486 temp |= 0x0002; 486 temp |= 0x0002;
487 if (rh & RH_A_PSM) /* per-port power switching? */ 487 if (rh & RH_A_PSM) /* per-port power switching? */
488 temp |= 0x0001; 488 temp |= 0x0001;
489 if (rh & RH_A_NOCP) /* no overcurrent reporting? */ 489 if (rh & RH_A_NOCP) /* no overcurrent reporting? */
490 temp |= 0x0010; 490 temp |= 0x0010;
@@ -555,7 +555,7 @@ static void start_hnp(struct ohci_hcd *ohci);
555#define tick_before(t1,t2) ((s16)(((s16)(t1))-((s16)(t2))) < 0) 555#define tick_before(t1,t2) ((s16)(((s16)(t1))-((s16)(t2))) < 0)
556 556
557/* called from some task, normally khubd */ 557/* called from some task, normally khubd */
558static inline void root_port_reset (struct ohci_hcd *ohci, unsigned port) 558static inline int root_port_reset (struct ohci_hcd *ohci, unsigned port)
559{ 559{
560 __hc32 __iomem *portstat = &ohci->regs->roothub.portstatus [port]; 560 __hc32 __iomem *portstat = &ohci->regs->roothub.portstatus [port];
561 u32 temp; 561 u32 temp;
@@ -570,10 +570,13 @@ static inline void root_port_reset (struct ohci_hcd *ohci, unsigned port)
570 /* spin until any current reset finishes */ 570 /* spin until any current reset finishes */
571 for (;;) { 571 for (;;) {
572 temp = ohci_readl (ohci, portstat); 572 temp = ohci_readl (ohci, portstat);
573 /* handle e.g. CardBus eject */
574 if (temp == ~(u32)0)
575 return -ESHUTDOWN;
573 if (!(temp & RH_PS_PRS)) 576 if (!(temp & RH_PS_PRS))
574 break; 577 break;
575 udelay (500); 578 udelay (500);
576 } 579 }
577 580
578 if (!(temp & RH_PS_CCS)) 581 if (!(temp & RH_PS_CCS))
579 break; 582 break;
@@ -586,6 +589,8 @@ static inline void root_port_reset (struct ohci_hcd *ohci, unsigned port)
586 now = ohci_readl(ohci, &ohci->regs->fmnumber); 589 now = ohci_readl(ohci, &ohci->regs->fmnumber);
587 } while (tick_before(now, reset_done)); 590 } while (tick_before(now, reset_done));
588 /* caller synchronizes using PRSC */ 591 /* caller synchronizes using PRSC */
592
593 return 0;
589} 594}
590 595
591static int ohci_hub_control ( 596static int ohci_hub_control (
@@ -702,7 +707,7 @@ static int ohci_hub_control (
702 &ohci->regs->roothub.portstatus [wIndex]); 707 &ohci->regs->roothub.portstatus [wIndex]);
703 break; 708 break;
704 case USB_PORT_FEAT_RESET: 709 case USB_PORT_FEAT_RESET:
705 root_port_reset (ohci, wIndex); 710 retval = root_port_reset (ohci, wIndex);
706 break; 711 break;
707 default: 712 default:
708 goto error; 713 goto error;
diff --git a/drivers/usb/host/ohci-lh7a404.c b/drivers/usb/host/ohci-lh7a404.c
index e121d97ed91c..e9807cf73a2f 100644
--- a/drivers/usb/host/ohci-lh7a404.c
+++ b/drivers/usb/host/ohci-lh7a404.c
@@ -38,7 +38,7 @@ static void lh7a404_start_hc(struct platform_device *dev)
38 CSC_PWRCNT |= CSC_PWRCNT_USBH_EN; /* Enable clock */ 38 CSC_PWRCNT |= CSC_PWRCNT_USBH_EN; /* Enable clock */
39 udelay(1000); 39 udelay(1000);
40 USBH_CMDSTATUS = OHCI_HCR; 40 USBH_CMDSTATUS = OHCI_HCR;
41 41
42 printk(KERN_DEBUG __FILE__ 42 printk(KERN_DEBUG __FILE__
43 ": Clock to USB host has been enabled \n"); 43 ": Clock to USB host has been enabled \n");
44} 44}
@@ -89,7 +89,7 @@ int usb_hcd_lh7a404_probe (const struct hc_driver *driver,
89 retval = -EBUSY; 89 retval = -EBUSY;
90 goto err1; 90 goto err1;
91 } 91 }
92 92
93 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); 93 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
94 if (!hcd->regs) { 94 if (!hcd->regs) {
95 pr_debug("ioremap failed"); 95 pr_debug("ioremap failed");
@@ -174,7 +174,7 @@ static const struct hc_driver ohci_lh7a404_hc_driver = {
174 */ 174 */
175 .start = ohci_lh7a404_start, 175 .start = ohci_lh7a404_start,
176 .stop = ohci_stop, 176 .stop = ohci_stop,
177 .shutdown = ohci_shutdown, 177 .shutdown = ohci_shutdown,
178 178
179 /* 179 /*
180 * managing i/o requests and associated device resources 180 * managing i/o requests and associated device resources
@@ -242,7 +242,7 @@ static int ohci_hcd_lh7a404_drv_resume(struct platform_device *dev)
242static struct platform_driver ohci_hcd_lh7a404_driver = { 242static struct platform_driver ohci_hcd_lh7a404_driver = {
243 .probe = ohci_hcd_lh7a404_drv_probe, 243 .probe = ohci_hcd_lh7a404_drv_probe,
244 .remove = ohci_hcd_lh7a404_drv_remove, 244 .remove = ohci_hcd_lh7a404_drv_remove,
245 .shutdown = usb_hcd_platform_shutdown, 245 .shutdown = usb_hcd_platform_shutdown,
246 /*.suspend = ohci_hcd_lh7a404_drv_suspend, */ 246 /*.suspend = ohci_hcd_lh7a404_drv_suspend, */
247 /*.resume = ohci_hcd_lh7a404_drv_resume, */ 247 /*.resume = ohci_hcd_lh7a404_drv_resume, */
248 .driver = { 248 .driver = {
diff --git a/drivers/usb/host/ohci-mem.c b/drivers/usb/host/ohci-mem.c
index d976614eebd3..2f20d3dc895b 100644
--- a/drivers/usb/host/ohci-mem.c
+++ b/drivers/usb/host/ohci-mem.c
@@ -1,24 +1,24 @@
1/* 1/*
2 * OHCI HCD (Host Controller Driver) for USB. 2 * OHCI HCD (Host Controller Driver) for USB.
3 * 3 *
4 * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at> 4 * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at>
5 * (C) Copyright 2000-2002 David Brownell <dbrownell@users.sourceforge.net> 5 * (C) Copyright 2000-2002 David Brownell <dbrownell@users.sourceforge.net>
6 * 6 *
7 * This file is licenced under the GPL. 7 * This file is licenced under the GPL.
8 */ 8 */
9 9
10/*-------------------------------------------------------------------------*/ 10/*-------------------------------------------------------------------------*/
11 11
12/* 12/*
13 * There's basically three types of memory: 13 * OHCI deals with three types of memory:
14 * - data used only by the HCD ... kmalloc is fine 14 * - data used only by the HCD ... kmalloc is fine
15 * - async and periodic schedules, shared by HC and HCD ... these 15 * - async and periodic schedules, shared by HC and HCD ... these
16 * need to use dma_pool or dma_alloc_coherent 16 * need to use dma_pool or dma_alloc_coherent
17 * - driver buffers, read/written by HC ... the hcd glue or the 17 * - driver buffers, read/written by HC ... the hcd glue or the
18 * device driver provides us with dma addresses 18 * device driver provides us with dma addresses
19 * 19 *
20 * There's also PCI "register" data, which is memory mapped. 20 * There's also "register" data, which is memory mapped.
21 * No memory seen by this driver is pagable. 21 * No memory seen by this driver (or any HCD) may be paged out.
22 */ 22 */
23 23
24/*-------------------------------------------------------------------------*/ 24/*-------------------------------------------------------------------------*/
diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c
index 9c02177de50a..27be1f936885 100644
--- a/drivers/usb/host/ohci-omap.c
+++ b/drivers/usb/host/ohci-omap.c
@@ -447,7 +447,7 @@ static const struct hc_driver ohci_omap_hc_driver = {
447 .reset = ohci_omap_init, 447 .reset = ohci_omap_init,
448 .start = ohci_omap_start, 448 .start = ohci_omap_start,
449 .stop = ohci_omap_stop, 449 .stop = ohci_omap_stop,
450 .shutdown = ohci_shutdown, 450 .shutdown = ohci_shutdown,
451 451
452 /* 452 /*
453 * managing i/o requests and associated device resources 453 * managing i/o requests and associated device resources
@@ -533,7 +533,7 @@ static int ohci_omap_resume(struct platform_device *dev)
533static struct platform_driver ohci_hcd_omap_driver = { 533static struct platform_driver ohci_hcd_omap_driver = {
534 .probe = ohci_hcd_omap_drv_probe, 534 .probe = ohci_hcd_omap_drv_probe,
535 .remove = ohci_hcd_omap_drv_remove, 535 .remove = ohci_hcd_omap_drv_remove,
536 .shutdown = usb_hcd_platform_shutdown, 536 .shutdown = usb_hcd_platform_shutdown,
537#ifdef CONFIG_PM 537#ifdef CONFIG_PM
538 .suspend = ohci_omap_suspend, 538 .suspend = ohci_omap_suspend,
539 .resume = ohci_omap_resume, 539 .resume = ohci_omap_resume,
diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c
index 874418552789..596e0b41e606 100644
--- a/drivers/usb/host/ohci-pci.c
+++ b/drivers/usb/host/ohci-pci.c
@@ -3,17 +3,17 @@
3 * 3 *
4 * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at> 4 * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at>
5 * (C) Copyright 2000-2002 David Brownell <dbrownell@users.sourceforge.net> 5 * (C) Copyright 2000-2002 David Brownell <dbrownell@users.sourceforge.net>
6 * 6 *
7 * [ Initialisation is based on Linus' ] 7 * [ Initialisation is based on Linus' ]
8 * [ uhci code and gregs ohci fragments ] 8 * [ uhci code and gregs ohci fragments ]
9 * [ (C) Copyright 1999 Linus Torvalds ] 9 * [ (C) Copyright 1999 Linus Torvalds ]
10 * [ (C) Copyright 1999 Gregory P. Smith] 10 * [ (C) Copyright 1999 Gregory P. Smith]
11 * 11 *
12 * PCI Bus Glue 12 * PCI Bus Glue
13 * 13 *
14 * This file is licenced under the GPL. 14 * This file is licenced under the GPL.
15 */ 15 */
16 16
17#ifndef CONFIG_PCI 17#ifndef CONFIG_PCI
18#error "This file is PCI bus glue. CONFIG_PCI must be defined." 18#error "This file is PCI bus glue. CONFIG_PCI must be defined."
19#endif 19#endif
@@ -83,7 +83,7 @@ ohci_pci_start (struct usb_hcd *hcd)
83 pci_dev_put(b); 83 pci_dev_put(b);
84 } 84 }
85 85
86 /* Check for Compaq's ZFMicro chipset, which needs short 86 /* Check for Compaq's ZFMicro chipset, which needs short
87 * delays before control or bulk queues get re-activated 87 * delays before control or bulk queues get re-activated
88 * in finish_unlinks() 88 * in finish_unlinks()
89 */ 89 */
@@ -238,8 +238,8 @@ static struct pci_driver ohci_pci_driver = {
238 .shutdown = usb_hcd_pci_shutdown, 238 .shutdown = usb_hcd_pci_shutdown,
239}; 239};
240 240
241 241
242static int __init ohci_hcd_pci_init (void) 242static int __init ohci_hcd_pci_init (void)
243{ 243{
244 printk (KERN_DEBUG "%s: " DRIVER_INFO " (PCI)\n", hcd_name); 244 printk (KERN_DEBUG "%s: " DRIVER_INFO " (PCI)\n", hcd_name);
245 if (usb_disabled()) 245 if (usb_disabled())
@@ -253,8 +253,8 @@ module_init (ohci_hcd_pci_init);
253 253
254/*-------------------------------------------------------------------------*/ 254/*-------------------------------------------------------------------------*/
255 255
256static void __exit ohci_hcd_pci_cleanup (void) 256static void __exit ohci_hcd_pci_cleanup (void)
257{ 257{
258 pci_unregister_driver (&ohci_pci_driver); 258 pci_unregister_driver (&ohci_pci_driver);
259} 259}
260module_exit (ohci_hcd_pci_cleanup); 260module_exit (ohci_hcd_pci_cleanup);
diff --git a/drivers/usb/host/ohci-pnx4008.c b/drivers/usb/host/ohci-pnx4008.c
index 7f26f9bdbaf1..3a8cbfb69054 100644
--- a/drivers/usb/host/ohci-pnx4008.c
+++ b/drivers/usb/host/ohci-pnx4008.c
@@ -4,7 +4,7 @@
4 * driver for Philips PNX4008 USB Host 4 * driver for Philips PNX4008 USB Host
5 * 5 *
6 * Authors: Dmitry Chigirev <source@mvista.com> 6 * Authors: Dmitry Chigirev <source@mvista.com>
7 * Vitaly Wool <vitalywool@gmail.com> 7 * Vitaly Wool <vitalywool@gmail.com>
8 * 8 *
9 * register initialization is based on code examples provided by Philips 9 * register initialization is based on code examples provided by Philips
10 * Copyright (c) 2005 Koninklijke Philips Electronics N.V. 10 * Copyright (c) 2005 Koninklijke Philips Electronics N.V.
@@ -29,7 +29,7 @@
29#include <asm/arch/irqs.h> 29#include <asm/arch/irqs.h>
30#include <asm/arch/gpio.h> 30#include <asm/arch/gpio.h>
31 31
32#define USB_CTRL IO_ADDRESS(PNX4008_PWRMAN_BASE + 0x64) 32#define USB_CTRL IO_ADDRESS(PNX4008_PWRMAN_BASE + 0x64)
33 33
34/* USB_CTRL bit defines */ 34/* USB_CTRL bit defines */
35#define USB_SLAVE_HCLK_EN (1 << 24) 35#define USB_SLAVE_HCLK_EN (1 << 24)
diff --git a/drivers/usb/host/ohci-pnx8550.c b/drivers/usb/host/ohci-pnx8550.c
new file mode 100644
index 000000000000..6922b91b1704
--- /dev/null
+++ b/drivers/usb/host/ohci-pnx8550.c
@@ -0,0 +1,258 @@
1/*
2 * OHCI HCD (Host Controller Driver) for USB.
3 *
4 * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at>
5 * (C) Copyright 2000-2002 David Brownell <dbrownell@users.sourceforge.net>
6 * (C) Copyright 2002 Hewlett-Packard Company
7 * (C) Copyright 2005 Embedded Alley Solutions, Inc.
8 *
9 * Bus Glue for PNX8550
10 *
11 * Written by Christopher Hoover <ch@hpl.hp.com>
12 * Based on fragments of previous driver by Russell King et al.
13 *
14 * Modified for LH7A404 from ohci-sa1111.c
15 * by Durgesh Pattamatta <pattamattad@sharpsec.com>
16 *
17 * Modified for PNX8550 from ohci-sa1111.c and sa-omap.c
18 * by Vitaly Wool <vitalywool@gmail.com>
19 *
20 * This file is licenced under the GPL.
21 */
22
23#include <linux/device.h>
24#include <linux/platform_device.h>
25#include <asm/mach-pnx8550/usb.h>
26#include <asm/mach-pnx8550/int.h>
27#include <asm/mach-pnx8550/pci.h>
28
29#ifndef CONFIG_PNX8550
30#error "This file is PNX8550 bus glue. CONFIG_PNX8550 must be defined."
31#endif
32
33extern int usb_disabled(void);
34
35/*-------------------------------------------------------------------------*/
36
37static void pnx8550_start_hc(struct platform_device *dev)
38{
39 /*
40 * Set register CLK48CTL to enable and 48MHz
41 */
42 outl(0x00000003, PCI_BASE | 0x0004770c);
43
44 /*
45 * Set register CLK12CTL to enable and 48MHz
46 */
47 outl(0x00000003, PCI_BASE | 0x00047710);
48
49 udelay(100);
50}
51
52static void pnx8550_stop_hc(struct platform_device *dev)
53{
54 udelay(10);
55}
56
57
58/*-------------------------------------------------------------------------*/
59
60/* configure so an HC device and id are always provided */
61/* always called with process context; sleeping is OK */
62
63
64/**
65 * usb_hcd_pnx8550_probe - initialize pnx8550-based HCDs
66 * Context: !in_interrupt()
67 *
68 * Allocates basic resources for this USB host controller, and
69 * then invokes the start() method for the HCD associated with it
70 * through the hotplug entry's driver_data.
71 *
72 */
73int usb_hcd_pnx8550_probe (const struct hc_driver *driver,
74 struct platform_device *dev)
75{
76 int retval;
77 struct usb_hcd *hcd;
78
79 if (dev->resource[0].flags != IORESOURCE_MEM ||
80 dev->resource[1].flags != IORESOURCE_IRQ) {
81 dev_err (&dev->dev,"invalid resource type\n");
82 return -ENOMEM;
83 }
84
85 hcd = usb_create_hcd (driver, &dev->dev, "pnx8550");
86 if (!hcd)
87 return -ENOMEM;
88 hcd->rsrc_start = dev->resource[0].start;
89 hcd->rsrc_len = dev->resource[0].end - dev->resource[0].start + 1;
90
91 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
92 dev_err(&dev->dev, "request_mem_region [0x%08llx, 0x%08llx] "
93 "failed\n", hcd->rsrc_start, hcd->rsrc_len);
94 retval = -EBUSY;
95 goto err1;
96 }
97
98 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
99 if (!hcd->regs) {
100 dev_err(&dev->dev, "ioremap [[0x%08llx, 0x%08llx] failed\n",
101 hcd->rsrc_start, hcd->rsrc_len);
102 retval = -ENOMEM;
103 goto err2;
104 }
105
106 pnx8550_start_hc(dev);
107
108 ohci_hcd_init(hcd_to_ohci(hcd));
109
110 retval = usb_add_hcd(hcd, dev->resource[1].start, SA_INTERRUPT);
111 if (retval == 0)
112 return retval;
113
114 pnx8550_stop_hc(dev);
115 iounmap(hcd->regs);
116 err2:
117 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
118 err1:
119 usb_put_hcd(hcd);
120 return retval;
121}
122
123
124/* may be called without controller electrically present */
125/* may be called with controller, bus, and devices active */
126
127/**
128 * usb_hcd_pnx8550_remove - shutdown processing for pnx8550-based HCDs
129 * @dev: USB Host Controller being removed
130 * Context: !in_interrupt()
131 *
132 * Reverses the effect of usb_hcd_pnx8550_probe(), first invoking
133 * the HCD's stop() method. It is always called from a thread
134 * context, normally "rmmod", "apmd", or something similar.
135 *
136 */
137void usb_hcd_pnx8550_remove (struct usb_hcd *hcd, struct platform_device *dev)
138{
139 usb_remove_hcd(hcd);
140 pnx8550_stop_hc(dev);
141 iounmap(hcd->regs);
142 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
143 usb_put_hcd(hcd);
144}
145
146/*-------------------------------------------------------------------------*/
147
148static int __devinit
149ohci_pnx8550_start (struct usb_hcd *hcd)
150{
151 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
152 int ret;
153
154 ohci_dbg (ohci, "ohci_pnx8550_start, ohci:%p", ohci);
155
156 if ((ret = ohci_init(ohci)) < 0)
157 return ret;
158
159 if ((ret = ohci_run (ohci)) < 0) {
160 err ("can't start %s", hcd->self.bus_name);
161 ohci_stop (hcd);
162 return ret;
163 }
164
165 return 0;
166}
167
168/*-------------------------------------------------------------------------*/
169
170static const struct hc_driver ohci_pnx8550_hc_driver = {
171 .description = hcd_name,
172 .product_desc = "PNX8550 OHCI",
173 .hcd_priv_size = sizeof(struct ohci_hcd),
174
175 /*
176 * generic hardware linkage
177 */
178 .irq = ohci_irq,
179 .flags = HCD_USB11 | HCD_MEMORY,
180
181 /*
182 * basic lifecycle operations
183 */
184 .start = ohci_pnx8550_start,
185 .stop = ohci_stop,
186
187 /*
188 * managing i/o requests and associated device resources
189 */
190 .urb_enqueue = ohci_urb_enqueue,
191 .urb_dequeue = ohci_urb_dequeue,
192 .endpoint_disable = ohci_endpoint_disable,
193
194 /*
195 * scheduling support
196 */
197 .get_frame_number = ohci_get_frame,
198
199 /*
200 * root hub support
201 */
202 .hub_status_data = ohci_hub_status_data,
203 .hub_control = ohci_hub_control,
204 .hub_irq_enable = ohci_rhsc_enable,
205#ifdef CONFIG_PM
206 .bus_suspend = ohci_bus_suspend,
207 .bus_resume = ohci_bus_resume,
208#endif
209 .start_port_reset = ohci_start_port_reset,
210};
211
212/*-------------------------------------------------------------------------*/
213
214static int ohci_hcd_pnx8550_drv_probe(struct platform_device *pdev)
215{
216 int ret;
217
218 if (usb_disabled())
219 return -ENODEV;
220
221 ret = usb_hcd_pnx8550_probe(&ohci_pnx8550_hc_driver, pdev);
222 return ret;
223}
224
225static int ohci_hcd_pnx8550_drv_remove(struct platform_device *pdev)
226{
227 struct usb_hcd *hcd = platform_get_drvdata(pdev);
228
229 usb_hcd_pnx8550_remove(hcd, pdev);
230 return 0;
231}
232
233MODULE_ALIAS("pnx8550-ohci");
234
235static struct platform_driver ohci_hcd_pnx8550_driver = {
236 .driver = {
237 .name = "pnx8550-ohci",
238 },
239 .probe = ohci_hcd_pnx8550_drv_probe,
240 .remove = ohci_hcd_pnx8550_drv_remove,
241};
242
243static int __init ohci_hcd_pnx8550_init (void)
244{
245 pr_debug (DRIVER_INFO " (pnx8550)");
246 pr_debug ("block sizes: ed %d td %d\n",
247 sizeof (struct ed), sizeof (struct td));
248
249 return platform_driver_register(&ohci_hcd_pnx8550_driver);
250}
251
252static void __exit ohci_hcd_pnx8550_cleanup (void)
253{
254 platform_driver_unregister(&ohci_hcd_pnx8550_driver);
255}
256
257module_init (ohci_hcd_pnx8550_init);
258module_exit (ohci_hcd_pnx8550_cleanup);
diff --git a/drivers/usb/host/ohci-ppc-soc.c b/drivers/usb/host/ohci-ppc-soc.c
index d9d1ae236bd5..e1a7eb817313 100644
--- a/drivers/usb/host/ohci-ppc-soc.c
+++ b/drivers/usb/host/ohci-ppc-soc.c
@@ -5,7 +5,7 @@
5 * (C) Copyright 2000-2002 David Brownell <dbrownell@users.sourceforge.net> 5 * (C) Copyright 2000-2002 David Brownell <dbrownell@users.sourceforge.net>
6 * (C) Copyright 2002 Hewlett-Packard Company 6 * (C) Copyright 2002 Hewlett-Packard Company
7 * (C) Copyright 2003-2005 MontaVista Software Inc. 7 * (C) Copyright 2003-2005 MontaVista Software Inc.
8 * 8 *
9 * Bus Glue for PPC On-Chip OHCI driver 9 * Bus Glue for PPC On-Chip OHCI driver
10 * Tested on Freescale MPC5200 and IBM STB04xxx 10 * Tested on Freescale MPC5200 and IBM STB04xxx
11 * 11 *
@@ -85,7 +85,7 @@ static int usb_hcd_ppc_soc_probe(const struct hc_driver *driver,
85 err2: 85 err2:
86 release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 86 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
87 err1: 87 err1:
88 usb_put_hcd(hcd); 88 usb_put_hcd(hcd);
89 return retval; 89 return retval;
90} 90}
91 91
@@ -148,7 +148,7 @@ static const struct hc_driver ohci_ppc_soc_hc_driver = {
148 */ 148 */
149 .start = ohci_ppc_soc_start, 149 .start = ohci_ppc_soc_start,
150 .stop = ohci_stop, 150 .stop = ohci_stop,
151 .shutdown = ohci_shutdown, 151 .shutdown = ohci_shutdown,
152 152
153 /* 153 /*
154 * managing i/o requests and associated device resources 154 * managing i/o requests and associated device resources
@@ -197,7 +197,7 @@ static int ohci_hcd_ppc_soc_drv_remove(struct platform_device *pdev)
197static struct platform_driver ohci_hcd_ppc_soc_driver = { 197static struct platform_driver ohci_hcd_ppc_soc_driver = {
198 .probe = ohci_hcd_ppc_soc_drv_probe, 198 .probe = ohci_hcd_ppc_soc_drv_probe,
199 .remove = ohci_hcd_ppc_soc_drv_remove, 199 .remove = ohci_hcd_ppc_soc_drv_remove,
200 .shutdown = usb_hcd_platform_shutdown, 200 .shutdown = usb_hcd_platform_shutdown,
201#ifdef CONFIG_PM 201#ifdef CONFIG_PM
202 /*.suspend = ohci_hcd_ppc_soc_drv_suspend,*/ 202 /*.suspend = ohci_hcd_ppc_soc_drv_suspend,*/
203 /*.resume = ohci_hcd_ppc_soc_drv_resume,*/ 203 /*.resume = ohci_hcd_ppc_soc_drv_resume,*/
diff --git a/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c
index e176b04d7aeb..3bbea844a9e3 100644
--- a/drivers/usb/host/ohci-pxa27x.c
+++ b/drivers/usb/host/ohci-pxa27x.c
@@ -47,7 +47,7 @@ static int pxa27x_ohci_select_pmm( int mode )
47 switch ( mode ) { 47 switch ( mode ) {
48 case PMM_NPS_MODE: 48 case PMM_NPS_MODE:
49 UHCRHDA |= RH_A_NPS; 49 UHCRHDA |= RH_A_NPS;
50 break; 50 break;
51 case PMM_GLOBAL_MODE: 51 case PMM_GLOBAL_MODE:
52 UHCRHDA &= ~(RH_A_NPS & RH_A_PSM); 52 UHCRHDA &= ~(RH_A_NPS & RH_A_PSM);
53 break; 53 break;
@@ -60,7 +60,7 @@ static int pxa27x_ohci_select_pmm( int mode )
60 break; 60 break;
61 default: 61 default:
62 printk( KERN_ERR 62 printk( KERN_ERR
63 "Invalid mode %d, set to non-power switch mode.\n", 63 "Invalid mode %d, set to non-power switch mode.\n",
64 mode ); 64 mode );
65 65
66 UHCRHDA |= RH_A_NPS; 66 UHCRHDA |= RH_A_NPS;
@@ -270,7 +270,7 @@ static const struct hc_driver ohci_pxa27x_hc_driver = {
270 */ 270 */
271 .start = ohci_pxa27x_start, 271 .start = ohci_pxa27x_start,
272 .stop = ohci_stop, 272 .stop = ohci_stop,
273 .shutdown = ohci_shutdown, 273 .shutdown = ohci_shutdown,
274 274
275 /* 275 /*
276 * managing i/o requests and associated device resources 276 * managing i/o requests and associated device resources
@@ -359,9 +359,9 @@ static int ohci_hcd_pxa27x_drv_resume(struct platform_device *pdev)
359static struct platform_driver ohci_hcd_pxa27x_driver = { 359static struct platform_driver ohci_hcd_pxa27x_driver = {
360 .probe = ohci_hcd_pxa27x_drv_probe, 360 .probe = ohci_hcd_pxa27x_drv_probe,
361 .remove = ohci_hcd_pxa27x_drv_remove, 361 .remove = ohci_hcd_pxa27x_drv_remove,
362 .shutdown = usb_hcd_platform_shutdown, 362 .shutdown = usb_hcd_platform_shutdown,
363#ifdef CONFIG_PM 363#ifdef CONFIG_PM
364 .suspend = ohci_hcd_pxa27x_drv_suspend, 364 .suspend = ohci_hcd_pxa27x_drv_suspend,
365 .resume = ohci_hcd_pxa27x_drv_resume, 365 .resume = ohci_hcd_pxa27x_drv_resume,
366#endif 366#endif
367 .driver = { 367 .driver = {
diff --git a/drivers/usb/host/ohci-q.c b/drivers/usb/host/ohci-q.c
index fe1fe2f97cb5..830a3fe8615e 100644
--- a/drivers/usb/host/ohci-q.c
+++ b/drivers/usb/host/ohci-q.c
@@ -1,9 +1,9 @@
1/* 1/*
2 * OHCI HCD (Host Controller Driver) for USB. 2 * OHCI HCD (Host Controller Driver) for USB.
3 * 3 *
4 * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at> 4 * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at>
5 * (C) Copyright 2000-2002 David Brownell <dbrownell@users.sourceforge.net> 5 * (C) Copyright 2000-2002 David Brownell <dbrownell@users.sourceforge.net>
6 * 6 *
7 * This file is licenced under the GPL. 7 * This file is licenced under the GPL.
8 */ 8 */
9 9
@@ -89,7 +89,7 @@ __acquires(ohci->lock)
89 89
90/*-------------------------------------------------------------------------* 90/*-------------------------------------------------------------------------*
91 * ED handling functions 91 * ED handling functions
92 *-------------------------------------------------------------------------*/ 92 *-------------------------------------------------------------------------*/
93 93
94/* search for the right schedule branch to use for a periodic ed. 94/* search for the right schedule branch to use for a periodic ed.
95 * does some load balancing; returns the branch, or negative errno. 95 * does some load balancing; returns the branch, or negative errno.
@@ -107,7 +107,6 @@ static int balance (struct ohci_hcd *ohci, int interval, int load)
107 */ 107 */
108 for (i = 0; i < interval ; i++) { 108 for (i = 0; i < interval ; i++) {
109 if (branch < 0 || ohci->load [branch] > ohci->load [i]) { 109 if (branch < 0 || ohci->load [branch] > ohci->load [i]) {
110#if 1 /* CONFIG_USB_BANDWIDTH */
111 int j; 110 int j;
112 111
113 /* usb 1.1 says 90% of one frame */ 112 /* usb 1.1 says 90% of one frame */
@@ -117,8 +116,7 @@ static int balance (struct ohci_hcd *ohci, int interval, int load)
117 } 116 }
118 if (j < NUM_INTS) 117 if (j < NUM_INTS)
119 continue; 118 continue;
120#endif 119 branch = i;
121 branch = i;
122 } 120 }
123 } 121 }
124 return branch; 122 return branch;
@@ -171,7 +169,7 @@ static void periodic_link (struct ohci_hcd *ohci, struct ed *ed)
171/* link an ed into one of the HC chains */ 169/* link an ed into one of the HC chains */
172 170
173static int ed_schedule (struct ohci_hcd *ohci, struct ed *ed) 171static int ed_schedule (struct ohci_hcd *ohci, struct ed *ed)
174{ 172{
175 int branch; 173 int branch;
176 174
177 if (ohci_to_hcd(ohci)->state == HC_STATE_QUIESCING) 175 if (ohci_to_hcd(ohci)->state == HC_STATE_QUIESCING)
@@ -248,7 +246,7 @@ static int ed_schedule (struct ohci_hcd *ohci, struct ed *ed)
248 } 246 }
249 ed->branch = branch; 247 ed->branch = branch;
250 periodic_link (ohci, ed); 248 periodic_link (ohci, ed);
251 } 249 }
252 250
253 /* the HC may not see the schedule updates yet, but if it does 251 /* the HC may not see the schedule updates yet, but if it does
254 * then they'll be properly ordered. 252 * then they'll be properly ordered.
@@ -277,7 +275,7 @@ static void periodic_unlink (struct ohci_hcd *ohci, struct ed *ed)
277 *prev = ed->ed_next; 275 *prev = ed->ed_next;
278 } 276 }
279 ohci->load [i] -= ed->load; 277 ohci->load [i] -= ed->load;
280 } 278 }
281 ohci_to_hcd(ohci)->self.bandwidth_allocated -= ed->load / ed->interval; 279 ohci_to_hcd(ohci)->self.bandwidth_allocated -= ed->load / ed->interval;
282 280
283 ohci_vdbg (ohci, "unlink %sed %p branch %d [%dus.], interval %d\n", 281 ohci_vdbg (ohci, "unlink %sed %p branch %d [%dus.], interval %d\n",
@@ -285,7 +283,7 @@ static void periodic_unlink (struct ohci_hcd *ohci, struct ed *ed)
285 ed, ed->branch, ed->load, ed->interval); 283 ed, ed->branch, ed->load, ed->interval);
286} 284}
287 285
288/* unlink an ed from one of the HC chains. 286/* unlink an ed from one of the HC chains.
289 * just the link to the ed is unlinked. 287 * just the link to the ed is unlinked.
290 * the link from the ed still points to another operational ed or 0 288 * the link from the ed still points to another operational ed or 0
291 * so the HC can eventually finish the processing of the unlinked ed 289 * so the HC can eventually finish the processing of the unlinked ed
@@ -307,7 +305,7 @@ static void periodic_unlink (struct ohci_hcd *ohci, struct ed *ed)
307 * When finish_unlinks() runs later, after SOF interrupt, it will often 305 * When finish_unlinks() runs later, after SOF interrupt, it will often
308 * complete one or more URB unlinks before making that state change. 306 * complete one or more URB unlinks before making that state change.
309 */ 307 */
310static void ed_deschedule (struct ohci_hcd *ohci, struct ed *ed) 308static void ed_deschedule (struct ohci_hcd *ohci, struct ed *ed)
311{ 309{
312 ed->hwINFO |= cpu_to_hc32 (ohci, ED_SKIP); 310 ed->hwINFO |= cpu_to_hc32 (ohci, ED_SKIP);
313 wmb (); 311 wmb ();
@@ -397,7 +395,7 @@ static struct ed *ed_get (
397 unsigned int pipe, 395 unsigned int pipe,
398 int interval 396 int interval
399) { 397) {
400 struct ed *ed; 398 struct ed *ed;
401 unsigned long flags; 399 unsigned long flags;
402 400
403 spin_lock_irqsave (&ohci->lock, flags); 401 spin_lock_irqsave (&ohci->lock, flags);
@@ -413,9 +411,9 @@ static struct ed *ed_get (
413 goto done; 411 goto done;
414 } 412 }
415 413
416 /* dummy td; end of td list for ed */ 414 /* dummy td; end of td list for ed */
417 td = td_alloc (ohci, GFP_ATOMIC); 415 td = td_alloc (ohci, GFP_ATOMIC);
418 if (!td) { 416 if (!td) {
419 /* out of memory */ 417 /* out of memory */
420 ed_free (ohci, ed); 418 ed_free (ohci, ed);
421 ed = NULL; 419 ed = NULL;
@@ -462,7 +460,7 @@ static struct ed *ed_get (
462 460
463done: 461done:
464 spin_unlock_irqrestore (&ohci->lock, flags); 462 spin_unlock_irqrestore (&ohci->lock, flags);
465 return ed; 463 return ed;
466} 464}
467 465
468/*-------------------------------------------------------------------------*/ 466/*-------------------------------------------------------------------------*/
@@ -474,7 +472,7 @@ done:
474 * and that ed->state is ED_OPER 472 * and that ed->state is ED_OPER
475 */ 473 */
476static void start_ed_unlink (struct ohci_hcd *ohci, struct ed *ed) 474static void start_ed_unlink (struct ohci_hcd *ohci, struct ed *ed)
477{ 475{
478 ed->hwINFO |= cpu_to_hc32 (ohci, ED_DEQUEUE); 476 ed->hwINFO |= cpu_to_hc32 (ohci, ED_DEQUEUE);
479 ed_deschedule (ohci, ed); 477 ed_deschedule (ohci, ed);
480 478
@@ -541,7 +539,7 @@ td_fill (struct ohci_hcd *ohci, u32 info,
541 td->ed = urb_priv->ed; 539 td->ed = urb_priv->ed;
542 td->next_dl_td = NULL; 540 td->next_dl_td = NULL;
543 td->index = index; 541 td->index = index;
544 td->urb = urb; 542 td->urb = urb;
545 td->data_dma = data; 543 td->data_dma = data;
546 if (!len) 544 if (!len)
547 data = 0; 545 data = 0;
@@ -553,8 +551,8 @@ td_fill (struct ohci_hcd *ohci, u32 info,
553 (data & 0x0FFF) | 0xE000); 551 (data & 0x0FFF) | 0xE000);
554 td->ed->last_iso = info & 0xffff; 552 td->ed->last_iso = info & 0xffff;
555 } else { 553 } else {
556 td->hwCBP = cpu_to_hc32 (ohci, data); 554 td->hwCBP = cpu_to_hc32 (ohci, data);
557 } 555 }
558 if (data) 556 if (data)
559 td->hwBE = cpu_to_hc32 (ohci, data + len - 1); 557 td->hwBE = cpu_to_hc32 (ohci, data + len - 1);
560 else 558 else
@@ -597,7 +595,7 @@ static void td_submit_urb (
597 * use the device toggle bits for resetting, and rely on the fact 595 * use the device toggle bits for resetting, and rely on the fact
598 * that resetting toggle is meaningless if the endpoint is active. 596 * that resetting toggle is meaningless if the endpoint is active.
599 */ 597 */
600 if (!usb_gettoggle (urb->dev, usb_pipeendpoint (urb->pipe), is_out)) { 598 if (!usb_gettoggle (urb->dev, usb_pipeendpoint (urb->pipe), is_out)) {
601 usb_settoggle (urb->dev, usb_pipeendpoint (urb->pipe), 599 usb_settoggle (urb->dev, usb_pipeendpoint (urb->pipe),
602 is_out, 1); 600 is_out, 1);
603 urb_priv->ed->hwHeadP &= ~cpu_to_hc32 (ohci, ED_C); 601 urb_priv->ed->hwHeadP &= ~cpu_to_hc32 (ohci, ED_C);
@@ -721,16 +719,16 @@ static void td_done (struct ohci_hcd *ohci, struct urb *urb, struct td *td)
721 list_del (&td->td_list); 719 list_del (&td->td_list);
722 720
723 /* ISO ... drivers see per-TD length/status */ 721 /* ISO ... drivers see per-TD length/status */
724 if (tdINFO & TD_ISO) { 722 if (tdINFO & TD_ISO) {
725 u16 tdPSW = ohci_hwPSW (ohci, td, 0); 723 u16 tdPSW = ohci_hwPSW (ohci, td, 0);
726 int dlen = 0; 724 int dlen = 0;
727 725
728 /* NOTE: assumes FC in tdINFO == 0, and that 726 /* NOTE: assumes FC in tdINFO == 0, and that
729 * only the first of 0..MAXPSW psws is used. 727 * only the first of 0..MAXPSW psws is used.
730 */ 728 */
731 729
732 cc = (tdPSW >> 12) & 0xF; 730 cc = (tdPSW >> 12) & 0xF;
733 if (tdINFO & TD_CC) /* hc didn't touch? */ 731 if (tdINFO & TD_CC) /* hc didn't touch? */
734 return; 732 return;
735 733
736 if (usb_pipeout (urb->pipe)) 734 if (usb_pipeout (urb->pipe))
@@ -758,7 +756,7 @@ static void td_done (struct ohci_hcd *ohci, struct urb *urb, struct td *td)
758 int type = usb_pipetype (urb->pipe); 756 int type = usb_pipetype (urb->pipe);
759 u32 tdBE = hc32_to_cpup (ohci, &td->hwBE); 757 u32 tdBE = hc32_to_cpup (ohci, &td->hwBE);
760 758
761 cc = TD_CC_GET (tdINFO); 759 cc = TD_CC_GET (tdINFO);
762 760
763 /* update packet status if needed (short is normally ok) */ 761 /* update packet status if needed (short is normally ok) */
764 if (cc == TD_DATAUNDERRUN 762 if (cc == TD_DATAUNDERRUN
@@ -787,7 +785,7 @@ static void td_done (struct ohci_hcd *ohci, struct urb *urb, struct td *td)
787 urb, td, 1 + td->index, cc, 785 urb, td, 1 + td->index, cc,
788 urb->actual_length, 786 urb->actual_length,
789 urb->transfer_buffer_length); 787 urb->transfer_buffer_length);
790 } 788 }
791} 789}
792 790
793/*-------------------------------------------------------------------------*/ 791/*-------------------------------------------------------------------------*/
@@ -795,7 +793,7 @@ static void td_done (struct ohci_hcd *ohci, struct urb *urb, struct td *td)
795static inline struct td * 793static inline struct td *
796ed_halted (struct ohci_hcd *ohci, struct td *td, int cc, struct td *rev) 794ed_halted (struct ohci_hcd *ohci, struct td *td, int cc, struct td *rev)
797{ 795{
798 struct urb *urb = td->urb; 796 struct urb *urb = td->urb;
799 struct ed *ed = td->ed; 797 struct ed *ed = td->ed;
800 struct list_head *tmp = td->td_list.next; 798 struct list_head *tmp = td->td_list.next;
801 __hc32 toggle = ed->hwHeadP & cpu_to_hc32 (ohci, ED_C); 799 __hc32 toggle = ed->hwHeadP & cpu_to_hc32 (ohci, ED_C);
@@ -805,7 +803,7 @@ ed_halted (struct ohci_hcd *ohci, struct td *td, int cc, struct td *rev)
805 */ 803 */
806 ed->hwINFO |= cpu_to_hc32 (ohci, ED_SKIP); 804 ed->hwINFO |= cpu_to_hc32 (ohci, ED_SKIP);
807 wmb (); 805 wmb ();
808 ed->hwHeadP &= ~cpu_to_hc32 (ohci, ED_H); 806 ed->hwHeadP &= ~cpu_to_hc32 (ohci, ED_H);
809 807
810 /* put any later tds from this urb onto the donelist, after 'td', 808 /* put any later tds from this urb onto the donelist, after 'td',
811 * order won't matter here: no errors, and nothing was transferred. 809 * order won't matter here: no errors, and nothing was transferred.
@@ -833,7 +831,7 @@ ed_halted (struct ohci_hcd *ohci, struct td *td, int cc, struct td *rev)
833 info &= ~cpu_to_hc32 (ohci, TD_CC); 831 info &= ~cpu_to_hc32 (ohci, TD_CC);
834 next->hwINFO = info; 832 next->hwINFO = info;
835 833
836 next->next_dl_td = rev; 834 next->next_dl_td = rev;
837 rev = next; 835 rev = next;
838 836
839 ed->hwHeadP = next->hwNextTD | toggle; 837 ed->hwHeadP = next->hwNextTD | toggle;
@@ -881,8 +879,8 @@ static struct td *dl_reverse_done_list (struct ohci_hcd *ohci)
881 /* get TD from hc's singly linked list, and 879 /* get TD from hc's singly linked list, and
882 * prepend to ours. ed->td_list changes later. 880 * prepend to ours. ed->td_list changes later.
883 */ 881 */
884 while (td_dma) { 882 while (td_dma) {
885 int cc; 883 int cc;
886 884
887 td = dma_to_td (ohci, td_dma); 885 td = dma_to_td (ohci, td_dma);
888 if (!td) { 886 if (!td) {
@@ -901,10 +899,10 @@ static struct td *dl_reverse_done_list (struct ohci_hcd *ohci)
901 && (td->ed->hwHeadP & cpu_to_hc32 (ohci, ED_H))) 899 && (td->ed->hwHeadP & cpu_to_hc32 (ohci, ED_H)))
902 td_rev = ed_halted (ohci, td, cc, td_rev); 900 td_rev = ed_halted (ohci, td, cc, td_rev);
903 901
904 td->next_dl_td = td_rev; 902 td->next_dl_td = td_rev;
905 td_rev = td; 903 td_rev = td;
906 td_dma = hc32_to_cpup (ohci, &td->hwNextTD); 904 td_dma = hc32_to_cpup (ohci, &td->hwNextTD);
907 } 905 }
908 return td_rev; 906 return td_rev;
909} 907}
910 908
@@ -1013,9 +1011,9 @@ rescan_this:
1013 1011
1014 if (modified) 1012 if (modified)
1015 goto rescan_all; 1013 goto rescan_all;
1016 } 1014 }
1017 1015
1018 /* maybe reenable control and bulk lists */ 1016 /* maybe reenable control and bulk lists */
1019 if (HC_IS_RUNNING(ohci_to_hcd(ohci)->state) 1017 if (HC_IS_RUNNING(ohci_to_hcd(ohci)->state)
1020 && ohci_to_hcd(ohci)->state != HC_STATE_QUIESCING 1018 && ohci_to_hcd(ohci)->state != HC_STATE_QUIESCING
1021 && !ohci->ed_rm_list) { 1019 && !ohci->ed_rm_list) {
@@ -1041,20 +1039,20 @@ rescan_this:
1041 &ohci->regs->ed_bulkcurrent); 1039 &ohci->regs->ed_bulkcurrent);
1042 } 1040 }
1043 } 1041 }
1044 1042
1045 /* CLE/BLE to enable, CLF/BLF to (maybe) kickstart */ 1043 /* CLE/BLE to enable, CLF/BLF to (maybe) kickstart */
1046 if (control) { 1044 if (control) {
1047 ohci->hc_control |= control; 1045 ohci->hc_control |= control;
1048 if (ohci->flags & OHCI_QUIRK_ZFMICRO) 1046 if (ohci->flags & OHCI_QUIRK_ZFMICRO)
1049 mdelay(1); 1047 mdelay(1);
1050 ohci_writel (ohci, ohci->hc_control, 1048 ohci_writel (ohci, ohci->hc_control,
1051 &ohci->regs->control); 1049 &ohci->regs->control);
1052 } 1050 }
1053 if (command) { 1051 if (command) {
1054 if (ohci->flags & OHCI_QUIRK_ZFMICRO) 1052 if (ohci->flags & OHCI_QUIRK_ZFMICRO)
1055 mdelay(1); 1053 mdelay(1);
1056 ohci_writel (ohci, command, &ohci->regs->cmdstatus); 1054 ohci_writel (ohci, command, &ohci->regs->cmdstatus);
1057 } 1055 }
1058 } 1056 }
1059} 1057}
1060 1058
@@ -1074,19 +1072,19 @@ dl_done_list (struct ohci_hcd *ohci)
1074{ 1072{
1075 struct td *td = dl_reverse_done_list (ohci); 1073 struct td *td = dl_reverse_done_list (ohci);
1076 1074
1077 while (td) { 1075 while (td) {
1078 struct td *td_next = td->next_dl_td; 1076 struct td *td_next = td->next_dl_td;
1079 struct urb *urb = td->urb; 1077 struct urb *urb = td->urb;
1080 urb_priv_t *urb_priv = urb->hcpriv; 1078 urb_priv_t *urb_priv = urb->hcpriv;
1081 struct ed *ed = td->ed; 1079 struct ed *ed = td->ed;
1082 1080
1083 /* update URB's length and status from TD */ 1081 /* update URB's length and status from TD */
1084 td_done (ohci, urb, td); 1082 td_done (ohci, urb, td);
1085 urb_priv->td_cnt++; 1083 urb_priv->td_cnt++;
1086 1084
1087 /* If all this urb's TDs are done, call complete() */ 1085 /* If all this urb's TDs are done, call complete() */
1088 if (urb_priv->td_cnt == urb_priv->length) 1086 if (urb_priv->td_cnt == urb_priv->length)
1089 finish_urb (ohci, urb); 1087 finish_urb (ohci, urb);
1090 1088
1091 /* clean schedule: unlink EDs that are no longer busy */ 1089 /* clean schedule: unlink EDs that are no longer busy */
1092 if (list_empty (&ed->td_list)) { 1090 if (list_empty (&ed->td_list)) {
@@ -1094,25 +1092,26 @@ dl_done_list (struct ohci_hcd *ohci)
1094 start_ed_unlink (ohci, ed); 1092 start_ed_unlink (ohci, ed);
1095 1093
1096 /* ... reenabling halted EDs only after fault cleanup */ 1094 /* ... reenabling halted EDs only after fault cleanup */
1097 } else if ((ed->hwINFO & cpu_to_hc32 (ohci, ED_SKIP | ED_DEQUEUE)) 1095 } else if ((ed->hwINFO & cpu_to_hc32 (ohci,
1096 ED_SKIP | ED_DEQUEUE))
1098 == cpu_to_hc32 (ohci, ED_SKIP)) { 1097 == cpu_to_hc32 (ohci, ED_SKIP)) {
1099 td = list_entry (ed->td_list.next, struct td, td_list); 1098 td = list_entry (ed->td_list.next, struct td, td_list);
1100 if (!(td->hwINFO & cpu_to_hc32 (ohci, TD_DONE))) { 1099 if (!(td->hwINFO & cpu_to_hc32 (ohci, TD_DONE))) {
1101 ed->hwINFO &= ~cpu_to_hc32 (ohci, ED_SKIP); 1100 ed->hwINFO &= ~cpu_to_hc32 (ohci, ED_SKIP);
1102 /* ... hc may need waking-up */ 1101 /* ... hc may need waking-up */
1103 switch (ed->type) { 1102 switch (ed->type) {
1104 case PIPE_CONTROL: 1103 case PIPE_CONTROL:
1105 ohci_writel (ohci, OHCI_CLF, 1104 ohci_writel (ohci, OHCI_CLF,
1106 &ohci->regs->cmdstatus); 1105 &ohci->regs->cmdstatus);
1107 break; 1106 break;
1108 case PIPE_BULK: 1107 case PIPE_BULK:
1109 ohci_writel (ohci, OHCI_BLF, 1108 ohci_writel (ohci, OHCI_BLF,
1110 &ohci->regs->cmdstatus); 1109 &ohci->regs->cmdstatus);
1111 break; 1110 break;
1112 } 1111 }
1113 } 1112 }
1114 } 1113 }
1115 1114
1116 td = td_next; 1115 td = td_next;
1117 } 1116 }
1118} 1117}
diff --git a/drivers/usb/host/ohci-s3c2410.c b/drivers/usb/host/ohci-s3c2410.c
index 59e436424d41..b350d45033e7 100644
--- a/drivers/usb/host/ohci-s3c2410.c
+++ b/drivers/usb/host/ohci-s3c2410.c
@@ -447,7 +447,7 @@ static const struct hc_driver ohci_s3c2410_hc_driver = {
447 */ 447 */
448 .start = ohci_s3c2410_start, 448 .start = ohci_s3c2410_start,
449 .stop = ohci_stop, 449 .stop = ohci_stop,
450 .shutdown = ohci_shutdown, 450 .shutdown = ohci_shutdown,
451 451
452 /* 452 /*
453 * managing i/o requests and associated device resources 453 * managing i/o requests and associated device resources
@@ -492,7 +492,7 @@ static int ohci_hcd_s3c2410_drv_remove(struct platform_device *pdev)
492static struct platform_driver ohci_hcd_s3c2410_driver = { 492static struct platform_driver ohci_hcd_s3c2410_driver = {
493 .probe = ohci_hcd_s3c2410_drv_probe, 493 .probe = ohci_hcd_s3c2410_drv_probe,
494 .remove = ohci_hcd_s3c2410_drv_remove, 494 .remove = ohci_hcd_s3c2410_drv_remove,
495 .shutdown = usb_hcd_platform_shutdown, 495 .shutdown = usb_hcd_platform_shutdown,
496 /*.suspend = ohci_hcd_s3c2410_drv_suspend, */ 496 /*.suspend = ohci_hcd_s3c2410_drv_suspend, */
497 /*.resume = ohci_hcd_s3c2410_drv_resume, */ 497 /*.resume = ohci_hcd_s3c2410_drv_resume, */
498 .driver = { 498 .driver = {
diff --git a/drivers/usb/host/ohci-sa1111.c b/drivers/usb/host/ohci-sa1111.c
index 71371de32ada..fe0090e33675 100644
--- a/drivers/usb/host/ohci-sa1111.c
+++ b/drivers/usb/host/ohci-sa1111.c
@@ -4,7 +4,7 @@
4 * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at> 4 * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at>
5 * (C) Copyright 2000-2002 David Brownell <dbrownell@users.sourceforge.net> 5 * (C) Copyright 2000-2002 David Brownell <dbrownell@users.sourceforge.net>
6 * (C) Copyright 2002 Hewlett-Packard Company 6 * (C) Copyright 2002 Hewlett-Packard Company
7 * 7 *
8 * SA1111 Bus Glue 8 * SA1111 Bus Glue
9 * 9 *
10 * Written by Christopher Hoover <ch@hpl.hp.com> 10 * Written by Christopher Hoover <ch@hpl.hp.com>
@@ -12,7 +12,7 @@
12 * 12 *
13 * This file is licenced under the GPL. 13 * This file is licenced under the GPL.
14 */ 14 */
15 15
16#include <asm/hardware.h> 16#include <asm/hardware.h>
17#include <asm/mach-types.h> 17#include <asm/mach-types.h>
18#include <asm/arch/assabet.h> 18#include <asm/arch/assabet.h>
@@ -31,7 +31,7 @@ static void sa1111_start_hc(struct sa1111_dev *dev)
31{ 31{
32 unsigned int usb_rst = 0; 32 unsigned int usb_rst = 0;
33 33
34 printk(KERN_DEBUG __FILE__ 34 printk(KERN_DEBUG __FILE__
35 ": starting SA-1111 OHCI USB Controller\n"); 35 ": starting SA-1111 OHCI USB Controller\n");
36 36
37#ifdef CONFIG_SA1100_BADGE4 37#ifdef CONFIG_SA1100_BADGE4
@@ -65,7 +65,7 @@ static void sa1111_start_hc(struct sa1111_dev *dev)
65static void sa1111_stop_hc(struct sa1111_dev *dev) 65static void sa1111_stop_hc(struct sa1111_dev *dev)
66{ 66{
67 unsigned int usb_rst; 67 unsigned int usb_rst;
68 printk(KERN_DEBUG __FILE__ 68 printk(KERN_DEBUG __FILE__
69 ": stopping SA-1111 OHCI USB Controller\n"); 69 ": stopping SA-1111 OHCI USB Controller\n");
70 70
71 /* 71 /*
diff --git a/drivers/usb/host/ohci.h b/drivers/usb/host/ohci.h
index a2f42a2f47c6..405257f3e853 100644
--- a/drivers/usb/host/ohci.h
+++ b/drivers/usb/host/ohci.h
@@ -1,9 +1,9 @@
1/* 1/*
2 * OHCI HCD (Host Controller Driver) for USB. 2 * OHCI HCD (Host Controller Driver) for USB.
3 * 3 *
4 * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at> 4 * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at>
5 * (C) Copyright 2000-2002 David Brownell <dbrownell@users.sourceforge.net> 5 * (C) Copyright 2000-2002 David Brownell <dbrownell@users.sourceforge.net>
6 * 6 *
7 * This file is licenced under the GPL. 7 * This file is licenced under the GPL.
8 */ 8 */
9 9
@@ -14,7 +14,7 @@
14 */ 14 */
15typedef __u32 __bitwise __hc32; 15typedef __u32 __bitwise __hc32;
16typedef __u16 __bitwise __hc16; 16typedef __u16 __bitwise __hc16;
17 17
18/* 18/*
19 * OHCI Endpoint Descriptor (ED) ... holds TD queue 19 * OHCI Endpoint Descriptor (ED) ... holds TD queue
20 * See OHCI spec, section 4.2 20 * See OHCI spec, section 4.2
@@ -24,7 +24,7 @@ typedef __u16 __bitwise __hc16;
24 */ 24 */
25struct ed { 25struct ed {
26 /* first fields are hardware-specified */ 26 /* first fields are hardware-specified */
27 __hc32 hwINFO; /* endpoint config bitmap */ 27 __hc32 hwINFO; /* endpoint config bitmap */
28 /* info bits defined by hcd */ 28 /* info bits defined by hcd */
29#define ED_DEQUEUE (1 << 27) 29#define ED_DEQUEUE (1 << 27)
30 /* info bits defined by the hardware */ 30 /* info bits defined by the hardware */
@@ -52,11 +52,11 @@ struct ed {
52 * usually: OPER --> UNLINK --> (IDLE | OPER) --> ... 52 * usually: OPER --> UNLINK --> (IDLE | OPER) --> ...
53 */ 53 */
54 u8 state; /* ED_{IDLE,UNLINK,OPER} */ 54 u8 state; /* ED_{IDLE,UNLINK,OPER} */
55#define ED_IDLE 0x00 /* NOT linked to HC */ 55#define ED_IDLE 0x00 /* NOT linked to HC */
56#define ED_UNLINK 0x01 /* being unlinked from hc */ 56#define ED_UNLINK 0x01 /* being unlinked from hc */
57#define ED_OPER 0x02 /* IS linked to hc */ 57#define ED_OPER 0x02 /* IS linked to hc */
58 58
59 u8 type; /* PIPE_{BULK,...} */ 59 u8 type; /* PIPE_{BULK,...} */
60 60
61 /* periodic scheduling params (for intr and iso) */ 61 /* periodic scheduling params (for intr and iso) */
62 u8 branch; 62 u8 branch;
@@ -70,7 +70,7 @@ struct ed {
70 70
71#define ED_MASK ((u32)~0x0f) /* strip hw status in low addr bits */ 71#define ED_MASK ((u32)~0x0f) /* strip hw status in low addr bits */
72 72
73 73
74/* 74/*
75 * OHCI Transfer Descriptor (TD) ... one per transfer segment 75 * OHCI Transfer Descriptor (TD) ... one per transfer segment
76 * See OHCI spec, sections 4.3.1 (general = control/bulk/interrupt) 76 * See OHCI spec, sections 4.3.1 (general = control/bulk/interrupt)
@@ -107,22 +107,22 @@ struct td {
107 107
108 /* (no hwINFO #defines yet for iso tds) */ 108 /* (no hwINFO #defines yet for iso tds) */
109 109
110 __hc32 hwCBP; /* Current Buffer Pointer (or 0) */ 110 __hc32 hwCBP; /* Current Buffer Pointer (or 0) */
111 __hc32 hwNextTD; /* Next TD Pointer */ 111 __hc32 hwNextTD; /* Next TD Pointer */
112 __hc32 hwBE; /* Memory Buffer End Pointer */ 112 __hc32 hwBE; /* Memory Buffer End Pointer */
113 113
114 /* PSW is only for ISO. Only 1 PSW entry is used, but on 114 /* PSW is only for ISO. Only 1 PSW entry is used, but on
115 * big-endian PPC hardware that's the second entry. 115 * big-endian PPC hardware that's the second entry.
116 */ 116 */
117#define MAXPSW 2 117#define MAXPSW 2
118 __hc16 hwPSW [MAXPSW]; 118 __hc16 hwPSW [MAXPSW];
119 119
120 /* rest are purely for the driver's use */ 120 /* rest are purely for the driver's use */
121 __u8 index; 121 __u8 index;
122 struct ed *ed; 122 struct ed *ed;
123 struct td *td_hash; /* dma-->td hashtable */ 123 struct td *td_hash; /* dma-->td hashtable */
124 struct td *next_dl_td; 124 struct td *next_dl_td;
125 struct urb *urb; 125 struct urb *urb;
126 126
127 dma_addr_t td_dma; /* addr of this TD */ 127 dma_addr_t td_dma; /* addr of this TD */
128 dma_addr_t data_dma; /* addr of data it points to */ 128 dma_addr_t data_dma; /* addr of data it points to */
@@ -152,8 +152,8 @@ struct td {
152#define TD_NOTACCESSED 0x0F 152#define TD_NOTACCESSED 0x0F
153 153
154 154
155/* map OHCI TD status codes (CC) to errno values */ 155/* map OHCI TD status codes (CC) to errno values */
156static const int cc_to_error [16] = { 156static const int cc_to_error [16] = {
157 /* No Error */ 0, 157 /* No Error */ 0,
158 /* CRC Error */ -EILSEQ, 158 /* CRC Error */ -EILSEQ,
159 /* Bit Stuff */ -EPROTO, 159 /* Bit Stuff */ -EPROTO,
@@ -169,7 +169,7 @@ static const int cc_to_error [16] = {
169 /* BufferOver */ -ECOMM, 169 /* BufferOver */ -ECOMM,
170 /* BuffUnder */ -ENOSR, 170 /* BuffUnder */ -ENOSR,
171 /* (for HCD) */ -EALREADY, 171 /* (for HCD) */ -EALREADY,
172 /* (for HCD) */ -EALREADY 172 /* (for HCD) */ -EALREADY
173}; 173};
174 174
175 175
@@ -182,7 +182,7 @@ struct ohci_hcca {
182#define NUM_INTS 32 182#define NUM_INTS 32
183 __hc32 int_table [NUM_INTS]; /* periodic schedule */ 183 __hc32 int_table [NUM_INTS]; /* periodic schedule */
184 184
185 /* 185 /*
186 * OHCI defines u16 frame_no, followed by u16 zero pad. 186 * OHCI defines u16 frame_no, followed by u16 zero pad.
187 * Since some processors can't do 16 bit bus accesses, 187 * Since some processors can't do 16 bit bus accesses,
188 * portable access must be a 32 bits wide. 188 * portable access must be a 32 bits wide.
@@ -262,10 +262,10 @@ struct ohci_regs {
262 * HcCommandStatus (cmdstatus) register masks 262 * HcCommandStatus (cmdstatus) register masks
263 */ 263 */
264#define OHCI_HCR (1 << 0) /* host controller reset */ 264#define OHCI_HCR (1 << 0) /* host controller reset */
265#define OHCI_CLF (1 << 1) /* control list filled */ 265#define OHCI_CLF (1 << 1) /* control list filled */
266#define OHCI_BLF (1 << 2) /* bulk list filled */ 266#define OHCI_BLF (1 << 2) /* bulk list filled */
267#define OHCI_OCR (1 << 3) /* ownership change request */ 267#define OHCI_OCR (1 << 3) /* ownership change request */
268#define OHCI_SOC (3 << 16) /* scheduling overrun count */ 268#define OHCI_SOC (3 << 16) /* scheduling overrun count */
269 269
270/* 270/*
271 * masks used with interrupt registers: 271 * masks used with interrupt registers:
@@ -285,20 +285,20 @@ struct ohci_regs {
285 285
286 286
287/* OHCI ROOT HUB REGISTER MASKS */ 287/* OHCI ROOT HUB REGISTER MASKS */
288 288
289/* roothub.portstatus [i] bits */ 289/* roothub.portstatus [i] bits */
290#define RH_PS_CCS 0x00000001 /* current connect status */ 290#define RH_PS_CCS 0x00000001 /* current connect status */
291#define RH_PS_PES 0x00000002 /* port enable status*/ 291#define RH_PS_PES 0x00000002 /* port enable status*/
292#define RH_PS_PSS 0x00000004 /* port suspend status */ 292#define RH_PS_PSS 0x00000004 /* port suspend status */
293#define RH_PS_POCI 0x00000008 /* port over current indicator */ 293#define RH_PS_POCI 0x00000008 /* port over current indicator */
294#define RH_PS_PRS 0x00000010 /* port reset status */ 294#define RH_PS_PRS 0x00000010 /* port reset status */
295#define RH_PS_PPS 0x00000100 /* port power status */ 295#define RH_PS_PPS 0x00000100 /* port power status */
296#define RH_PS_LSDA 0x00000200 /* low speed device attached */ 296#define RH_PS_LSDA 0x00000200 /* low speed device attached */
297#define RH_PS_CSC 0x00010000 /* connect status change */ 297#define RH_PS_CSC 0x00010000 /* connect status change */
298#define RH_PS_PESC 0x00020000 /* port enable status change */ 298#define RH_PS_PESC 0x00020000 /* port enable status change */
299#define RH_PS_PSSC 0x00040000 /* port suspend status change */ 299#define RH_PS_PSSC 0x00040000 /* port suspend status change */
300#define RH_PS_OCIC 0x00080000 /* over current indicator change */ 300#define RH_PS_OCIC 0x00080000 /* over current indicator change */
301#define RH_PS_PRSC 0x00100000 /* port reset status change */ 301#define RH_PS_PRSC 0x00100000 /* port reset status change */
302 302
303/* roothub.status bits */ 303/* roothub.status bits */
304#define RH_HS_LPS 0x00000001 /* local power status */ 304#define RH_HS_LPS 0x00000001 /* local power status */
@@ -333,7 +333,7 @@ typedef struct urb_priv {
333} urb_priv_t; 333} urb_priv_t;
334 334
335#define TD_HASH_SIZE 64 /* power'o'two */ 335#define TD_HASH_SIZE 64 /* power'o'two */
336// sizeof (struct td) ~= 64 == 2^6 ... 336// sizeof (struct td) ~= 64 == 2^6 ...
337#define TD_HASH_FUNC(td_dma) ((td_dma ^ (td_dma >> 6)) % TD_HASH_SIZE) 337#define TD_HASH_FUNC(td_dma) ((td_dma ^ (td_dma >> 6)) % TD_HASH_SIZE)
338 338
339 339
@@ -364,11 +364,11 @@ struct ohci_hcd {
364 364
365 struct ed *ed_bulktail; /* last in bulk list */ 365 struct ed *ed_bulktail; /* last in bulk list */
366 struct ed *ed_controltail; /* last in ctrl list */ 366 struct ed *ed_controltail; /* last in ctrl list */
367 struct ed *periodic [NUM_INTS]; /* shadow int_table */ 367 struct ed *periodic [NUM_INTS]; /* shadow int_table */
368 368
369 /* 369 /*
370 * OTG controllers and transceivers need software interaction; 370 * OTG controllers and transceivers need software interaction;
371 * other external transceivers should be software-transparent 371 * other external transceivers should be software-transparent
372 */ 372 */
373 struct otg_transceiver *transceiver; 373 struct otg_transceiver *transceiver;
374 374
@@ -385,7 +385,7 @@ struct ohci_hcd {
385 */ 385 */
386 int num_ports; 386 int num_ports;
387 int load [NUM_INTS]; 387 int load [NUM_INTS];
388 u32 hc_control; /* copy of hc control reg */ 388 u32 hc_control; /* copy of hc control reg */
389 unsigned long next_statechange; /* suspend/resume */ 389 unsigned long next_statechange; /* suspend/resume */
390 u32 fminterval; /* saved register */ 390 u32 fminterval; /* saved register */
391 unsigned autostop:1; /* rh auto stopping/stopped */ 391 unsigned autostop:1; /* rh auto stopping/stopped */
@@ -598,11 +598,11 @@ static inline void disable (struct ohci_hcd *ohci)
598} 598}
599 599
600#define FI 0x2edf /* 12000 bits per frame (-1) */ 600#define FI 0x2edf /* 12000 bits per frame (-1) */
601#define FSMP(fi) (0x7fff & ((6 * ((fi) - 210)) / 7)) 601#define FSMP(fi) (0x7fff & ((6 * ((fi) - 210)) / 7))
602#define FIT (1 << 31) 602#define FIT (1 << 31)
603#define LSTHRESH 0x628 /* lowspeed bit threshold */ 603#define LSTHRESH 0x628 /* lowspeed bit threshold */
604 604
605static void periodic_reinit (struct ohci_hcd *ohci) 605static inline void periodic_reinit (struct ohci_hcd *ohci)
606{ 606{
607 u32 fi = ohci->fminterval & 0x03fff; 607 u32 fi = ohci->fminterval & 0x03fff;
608 u32 fit = ohci_readl(ohci, &ohci->regs->fminterval) & FIT; 608 u32 fit = ohci_readl(ohci, &ohci->regs->fminterval) & FIT;
@@ -626,11 +626,11 @@ static void periodic_reinit (struct ohci_hcd *ohci)
626 temp = ohci_readl (hc, &hc->regs->roothub.register); \ 626 temp = ohci_readl (hc, &hc->regs->roothub.register); \
627 temp; }) 627 temp; })
628 628
629static u32 roothub_a (struct ohci_hcd *hc) 629static inline u32 roothub_a (struct ohci_hcd *hc)
630 { return read_roothub (hc, a, 0xfc0fe000); } 630 { return read_roothub (hc, a, 0xfc0fe000); }
631static inline u32 roothub_b (struct ohci_hcd *hc) 631static inline u32 roothub_b (struct ohci_hcd *hc)
632 { return ohci_readl (hc, &hc->regs->roothub.b); } 632 { return ohci_readl (hc, &hc->regs->roothub.b); }
633static inline u32 roothub_status (struct ohci_hcd *hc) 633static inline u32 roothub_status (struct ohci_hcd *hc)
634 { return ohci_readl (hc, &hc->regs->roothub.status); } 634 { return ohci_readl (hc, &hc->regs->roothub.status); }
635static u32 roothub_portstatus (struct ohci_hcd *hc, int i) 635static inline u32 roothub_portstatus (struct ohci_hcd *hc, int i)
636 { return read_roothub (hc, portstatus [i], 0xffe0fce0); } 636 { return read_roothub (hc, portstatus [i], 0xffe0fce0); }
diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c
index a9d7119e3176..a7fa0d75567d 100644
--- a/drivers/usb/host/u132-hcd.c
+++ b/drivers/usb/host/u132-hcd.c
@@ -40,6 +40,7 @@
40#include <linux/moduleparam.h> 40#include <linux/moduleparam.h>
41#include <linux/delay.h> 41#include <linux/delay.h>
42#include <linux/ioport.h> 42#include <linux/ioport.h>
43#include <linux/pci_ids.h>
43#include <linux/sched.h> 44#include <linux/sched.h>
44#include <linux/slab.h> 45#include <linux/slab.h>
45#include <linux/smp_lock.h> 46#include <linux/smp_lock.h>
@@ -210,15 +211,16 @@ struct u132 {
210* these cannot be inlines because we need the structure offset!! 211* these cannot be inlines because we need the structure offset!!
211* Does anyone have a better way????? 212* Does anyone have a better way?????
212*/ 213*/
214#define ftdi_read_pcimem(pdev, member, data) usb_ftdi_elan_read_pcimem(pdev, \
215 offsetof(struct ohci_regs, member), 0, data);
216#define ftdi_write_pcimem(pdev, member, data) usb_ftdi_elan_write_pcimem(pdev, \
217 offsetof(struct ohci_regs, member), 0, data);
213#define u132_read_pcimem(u132, member, data) \ 218#define u132_read_pcimem(u132, member, data) \
214 usb_ftdi_elan_read_pcimem(u132->platform_dev, offsetof(struct \ 219 usb_ftdi_elan_read_pcimem(u132->platform_dev, offsetof(struct \
215 ohci_regs, member), 0, data); 220 ohci_regs, member), 0, data);
216#define u132_write_pcimem(u132, member, data) \ 221#define u132_write_pcimem(u132, member, data) \
217 usb_ftdi_elan_write_pcimem(u132->platform_dev, offsetof(struct \ 222 usb_ftdi_elan_write_pcimem(u132->platform_dev, offsetof(struct \
218 ohci_regs, member), 0, data); 223 ohci_regs, member), 0, data);
219#define u132_write_pcimem_byte(u132, member, data) \
220 usb_ftdi_elan_write_pcimem(u132->platform_dev, offsetof(struct \
221 ohci_regs, member), 0x0e, data);
222static inline struct u132 *udev_to_u132(struct u132_udev *udev) 224static inline struct u132 *udev_to_u132(struct u132_udev *udev)
223{ 225{
224 u8 udev_number = udev->udev_number; 226 u8 udev_number = udev->udev_number;
@@ -1574,59 +1576,12 @@ static char *hcfs2string(int state)
1574 return "?"; 1576 return "?";
1575} 1577}
1576 1578
1577static int u132_usb_reset(struct u132 *u132)
1578{
1579 int retval;
1580 retval = u132_read_pcimem(u132, control, &u132->hc_control);
1581 if (retval)
1582 return retval;
1583 u132->hc_control &= OHCI_CTRL_RWC;
1584 retval = u132_write_pcimem(u132, control, u132->hc_control);
1585 if (retval)
1586 return retval;
1587 return 0;
1588}
1589
1590static int u132_init(struct u132 *u132) 1579static int u132_init(struct u132 *u132)
1591{ 1580{
1592 int retval; 1581 int retval;
1593 u32 control; 1582 u32 control;
1594 u132_disable(u132); 1583 u132_disable(u132);
1595 u132->next_statechange = 1584 u132->next_statechange = jiffies;
1596 jiffies; /* SMM owns the HC? not for long! */ {
1597 u32 control;
1598 retval = u132_read_pcimem(u132, control, &control);
1599 if (retval)
1600 return retval;
1601 if (control & OHCI_CTRL_IR) {
1602 u32 temp = 50;
1603 retval = u132_write_pcimem(u132, intrenable,
1604 OHCI_INTR_OC);
1605 if (retval)
1606 return retval;
1607 retval = u132_write_pcimem_byte(u132, cmdstatus,
1608 OHCI_OCR);
1609 if (retval)
1610 return retval;
1611 check:{
1612 retval = u132_read_pcimem(u132, control,
1613 &control);
1614 if (retval)
1615 return retval;
1616 }
1617 if (control & OHCI_CTRL_IR) {
1618 msleep(10);
1619 if (--temp == 0) {
1620 dev_err(&u132->platform_dev->dev, "USB "
1621 "HC takeover failed!(BIOS/SMM b"
1622 "ug) control=%08X\n", control);
1623 return -EBUSY;
1624 }
1625 goto check;
1626 }
1627 u132_usb_reset(u132);
1628 }
1629 }
1630 retval = u132_write_pcimem(u132, intrdisable, OHCI_INTR_MIE); 1585 retval = u132_write_pcimem(u132, intrdisable, OHCI_INTR_MIE);
1631 if (retval) 1586 if (retval)
1632 return retval; 1587 return retval;
@@ -1725,7 +1680,7 @@ static int u132_run(struct u132 *u132)
1725 retry:retval = u132_read_pcimem(u132, cmdstatus, &status); 1680 retry:retval = u132_read_pcimem(u132, cmdstatus, &status);
1726 if (retval) 1681 if (retval)
1727 return retval; 1682 return retval;
1728 retval = u132_write_pcimem_byte(u132, cmdstatus, OHCI_HCR); 1683 retval = u132_write_pcimem(u132, cmdstatus, OHCI_HCR);
1729 if (retval) 1684 if (retval)
1730 return retval; 1685 return retval;
1731 extra:{ 1686 extra:{
@@ -1782,7 +1737,7 @@ static int u132_run(struct u132 *u132)
1782 retval = u132_write_pcimem(u132, control, u132->hc_control); 1737 retval = u132_write_pcimem(u132, control, u132->hc_control);
1783 if (retval) 1738 if (retval)
1784 return retval; 1739 return retval;
1785 retval = u132_write_pcimem_byte(u132, cmdstatus, OHCI_BLF); 1740 retval = u132_write_pcimem(u132, cmdstatus, OHCI_BLF);
1786 if (retval) 1741 if (retval)
1787 return retval; 1742 return retval;
1788 retval = u132_read_pcimem(u132, cmdstatus, &cmdstatus); 1743 retval = u132_read_pcimem(u132, cmdstatus, &cmdstatus);
@@ -1839,8 +1794,8 @@ static void u132_hcd_stop(struct usb_hcd *hcd)
1839{ 1794{
1840 struct u132 *u132 = hcd_to_u132(hcd); 1795 struct u132 *u132 = hcd_to_u132(hcd);
1841 if (u132->going > 1) { 1796 if (u132->going > 1) {
1842 dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 1797 dev_err(&u132->platform_dev->dev, "u132 device %p(hcd=%p) has b"
1843 , u132->going); 1798 "een removed %d\n", u132, hcd, u132->going);
1844 } else if (u132->going > 0) { 1799 } else if (u132->going > 0) {
1845 dev_err(&u132->platform_dev->dev, "device hcd=%p is being remov" 1800 dev_err(&u132->platform_dev->dev, "device hcd=%p is being remov"
1846 "ed\n", hcd); 1801 "ed\n", hcd);
@@ -2545,8 +2500,9 @@ static void u132_endpoint_disable(struct usb_hcd *hcd,
2545{ 2500{
2546 struct u132 *u132 = hcd_to_u132(hcd); 2501 struct u132 *u132 = hcd_to_u132(hcd);
2547 if (u132->going > 2) { 2502 if (u132->going > 2) {
2548 dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 2503 dev_err(&u132->platform_dev->dev, "u132 device %p(hcd=%p hep=%p"
2549 , u132->going); 2504 ") has been removed %d\n", u132, hcd, hep,
2505 u132->going);
2550 } else { 2506 } else {
2551 struct u132_endp *endp = hep->hcpriv; 2507 struct u132_endp *endp = hep->hcpriv;
2552 if (endp) 2508 if (endp)
@@ -2790,7 +2746,6 @@ static int u132_hub_status_data(struct usb_hcd *hcd, char *buf)
2790 } else if (u132->going > 0) { 2746 } else if (u132->going > 0) {
2791 dev_err(&u132->platform_dev->dev, "device hcd=%p is being remov" 2747 dev_err(&u132->platform_dev->dev, "device hcd=%p is being remov"
2792 "ed\n", hcd); 2748 "ed\n", hcd);
2793 dump_stack();
2794 return -ESHUTDOWN; 2749 return -ESHUTDOWN;
2795 } else { 2750 } else {
2796 int i, changed = 0, length = 1; 2751 int i, changed = 0, length = 1;
@@ -3034,12 +2989,15 @@ static int __devexit u132_remove(struct platform_device *pdev)
3034 struct usb_hcd *hcd = platform_get_drvdata(pdev); 2989 struct usb_hcd *hcd = platform_get_drvdata(pdev);
3035 if (hcd) { 2990 if (hcd) {
3036 struct u132 *u132 = hcd_to_u132(hcd); 2991 struct u132 *u132 = hcd_to_u132(hcd);
3037 dump_stack();
3038 if (u132->going++ > 1) { 2992 if (u132->going++ > 1) {
2993 dev_err(&u132->platform_dev->dev, "already being remove"
2994 "d\n");
3039 return -ENODEV; 2995 return -ENODEV;
3040 } else { 2996 } else {
3041 int rings = MAX_U132_RINGS; 2997 int rings = MAX_U132_RINGS;
3042 int endps = MAX_U132_ENDPS; 2998 int endps = MAX_U132_ENDPS;
2999 dev_err(&u132->platform_dev->dev, "removing device u132"
3000 ".%d\n", u132->sequence_num);
3043 msleep(100); 3001 msleep(100);
3044 down(&u132->sw_lock); 3002 down(&u132->sw_lock);
3045 u132_monitor_cancel_work(u132); 3003 u132_monitor_cancel_work(u132);
@@ -3121,10 +3079,24 @@ static void u132_initialise(struct u132 *u132, struct platform_device *pdev)
3121static int __devinit u132_probe(struct platform_device *pdev) 3079static int __devinit u132_probe(struct platform_device *pdev)
3122{ 3080{
3123 struct usb_hcd *hcd; 3081 struct usb_hcd *hcd;
3082 int retval;
3083 u32 control;
3084 u32 rh_a = -1;
3085 u32 num_ports;
3124 msleep(100); 3086 msleep(100);
3125 if (u132_exiting > 0) { 3087 if (u132_exiting > 0) {
3126 return -ENODEV; 3088 return -ENODEV;
3127 } /* refuse to confuse usbcore */ 3089 }
3090 retval = ftdi_write_pcimem(pdev, intrdisable, OHCI_INTR_MIE);
3091 if (retval)
3092 return retval;
3093 retval = ftdi_read_pcimem(pdev, control, &control);
3094 if (retval)
3095 return retval;
3096 retval = ftdi_read_pcimem(pdev, roothub.a, &rh_a);
3097 if (retval)
3098 return retval;
3099 num_ports = rh_a & RH_A_NDP; /* refuse to confuse usbcore */
3128 if (pdev->dev.dma_mask) { 3100 if (pdev->dev.dma_mask) {
3129 return -EINVAL; 3101 return -EINVAL;
3130 } 3102 }
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
index e87692c31be4..acd101caeeeb 100644
--- a/drivers/usb/host/uhci-hcd.c
+++ b/drivers/usb/host/uhci-hcd.c
@@ -60,6 +60,11 @@ Randy Dunlap, Georg Acher, Deti Fliegl, Thomas Sailer, Roman Weissgaerber, \
60Alan Stern" 60Alan Stern"
61#define DRIVER_DESC "USB Universal Host Controller Interface driver" 61#define DRIVER_DESC "USB Universal Host Controller Interface driver"
62 62
63/* for flakey hardware, ignore overcurrent indicators */
64static int ignore_oc;
65module_param(ignore_oc, bool, S_IRUGO);
66MODULE_PARM_DESC(ignore_oc, "ignore hardware overcurrent indications");
67
63/* 68/*
64 * debug = 0, no debugging messages 69 * debug = 0, no debugging messages
65 * debug = 1, dump failed URBs except for stalls 70 * debug = 1, dump failed URBs except for stalls
@@ -169,6 +174,11 @@ static int resume_detect_interrupts_are_broken(struct uhci_hcd *uhci)
169{ 174{
170 int port; 175 int port;
171 176
177 /* If we have to ignore overcurrent events then almost by definition
178 * we can't depend on resume-detect interrupts. */
179 if (ignore_oc)
180 return 1;
181
172 switch (to_pci_dev(uhci_dev(uhci))->vendor) { 182 switch (to_pci_dev(uhci_dev(uhci))->vendor) {
173 default: 183 default:
174 break; 184 break;
@@ -921,7 +931,8 @@ static int __init uhci_hcd_init(void)
921{ 931{
922 int retval = -ENOMEM; 932 int retval = -ENOMEM;
923 933
924 printk(KERN_INFO DRIVER_DESC " " DRIVER_VERSION "\n"); 934 printk(KERN_INFO DRIVER_DESC " " DRIVER_VERSION "%s\n",
935 ignore_oc ? ", overcurrent ignored" : "");
925 936
926 if (usb_disabled()) 937 if (usb_disabled())
927 return -ENODEV; 938 return -ENODEV;
diff --git a/drivers/usb/host/uhci-hub.c b/drivers/usb/host/uhci-hub.c
index f8347f1a10b6..bacc25c53ba3 100644
--- a/drivers/usb/host/uhci-hub.c
+++ b/drivers/usb/host/uhci-hub.c
@@ -52,10 +52,20 @@ static int any_ports_active(struct uhci_hcd *uhci)
52static inline int get_hub_status_data(struct uhci_hcd *uhci, char *buf) 52static inline int get_hub_status_data(struct uhci_hcd *uhci, char *buf)
53{ 53{
54 int port; 54 int port;
55 int mask = RWC_BITS;
56
57 /* Some boards (both VIA and Intel apparently) report bogus
58 * overcurrent indications, causing massive log spam unless
59 * we completely ignore them. This doesn't seem to be a problem
60 * with the chipset so much as with the way it is connected on
61 * the motherboard; if the overcurrent input is left to float
62 * then it may constantly register false positives. */
63 if (ignore_oc)
64 mask &= ~USBPORTSC_OCC;
55 65
56 *buf = 0; 66 *buf = 0;
57 for (port = 0; port < uhci->rh_numports; ++port) { 67 for (port = 0; port < uhci->rh_numports; ++port) {
58 if ((inw(uhci->io_addr + USBPORTSC1 + port * 2) & RWC_BITS) || 68 if ((inw(uhci->io_addr + USBPORTSC1 + port * 2) & mask) ||
59 test_bit(port, &uhci->port_c_suspend)) 69 test_bit(port, &uhci->port_c_suspend))
60 *buf |= (1 << (port + 1)); 70 *buf |= (1 << (port + 1));
61 } 71 }
@@ -263,7 +273,7 @@ static int uhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
263 wPortChange |= USB_PORT_STAT_C_CONNECTION; 273 wPortChange |= USB_PORT_STAT_C_CONNECTION;
264 if (status & USBPORTSC_PEC) 274 if (status & USBPORTSC_PEC)
265 wPortChange |= USB_PORT_STAT_C_ENABLE; 275 wPortChange |= USB_PORT_STAT_C_ENABLE;
266 if (status & USBPORTSC_OCC) 276 if ((status & USBPORTSC_OCC) && !ignore_oc)
267 wPortChange |= USB_PORT_STAT_C_OVERCURRENT; 277 wPortChange |= USB_PORT_STAT_C_OVERCURRENT;
268 278
269 if (test_bit(port, &uhci->port_c_suspend)) { 279 if (test_bit(port, &uhci->port_c_suspend)) {
diff --git a/drivers/usb/input/wacom_sys.c b/drivers/usb/input/wacom_sys.c
index e7cc20ab8155..12b42746ded8 100644
--- a/drivers/usb/input/wacom_sys.c
+++ b/drivers/usb/input/wacom_sys.c
@@ -159,13 +159,13 @@ void input_dev_i3s(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
159{ 159{
160 input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_FINGER); 160 input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_FINGER);
161 input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_0) | BIT(BTN_1) | BIT(BTN_2) | BIT(BTN_3); 161 input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_0) | BIT(BTN_1) | BIT(BTN_2) | BIT(BTN_3);
162 input_set_abs_params(input_dev, ABS_RX, 0, 4097, 0, 0); 162 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
163} 163}
164 164
165void input_dev_i3(struct input_dev *input_dev, struct wacom_wac *wacom_wac) 165void input_dev_i3(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
166{ 166{
167 input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_4) | BIT(BTN_5) | BIT(BTN_6) | BIT(BTN_7); 167 input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_4) | BIT(BTN_5) | BIT(BTN_6) | BIT(BTN_7);
168 input_set_abs_params(input_dev, ABS_RY, 0, 4097, 0, 0); 168 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
169} 169}
170 170
171void input_dev_i(struct input_dev *input_dev, struct wacom_wac *wacom_wac) 171void input_dev_i(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
diff --git a/drivers/usb/input/wacom_wac.c b/drivers/usb/input/wacom_wac.c
index 92726fe89379..4142e36730fc 100644
--- a/drivers/usb/input/wacom_wac.c
+++ b/drivers/usb/input/wacom_wac.c
@@ -209,13 +209,15 @@ static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
209 wacom_report_key(wcombo, BTN_STYLUS, data[1] & 0x02); 209 wacom_report_key(wcombo, BTN_STYLUS, data[1] & 0x02);
210 wacom_report_key(wcombo, BTN_STYLUS2, data[1] & 0x04); 210 wacom_report_key(wcombo, BTN_STYLUS2, data[1] & 0x04);
211 } 211 }
212 }
213
214 if (data[1] & 0x10)
215 wacom_report_abs(wcombo, ABS_MISC, id); /* report tool id */ 212 wacom_report_abs(wcombo, ABS_MISC, id); /* report tool id */
213 }
216 else 214 else
217 wacom_report_abs(wcombo, ABS_MISC, 0); /* reset tool id */ 215 wacom_report_abs(wcombo, ABS_MISC, 0); /* reset tool id */
218 wacom_report_key(wcombo, wacom->tool[0], data[1] & 0x10); 216
217 if (data[1] & 0x10) /* only report prox-in when in area */
218 wacom_report_key(wcombo, wacom->tool[0], 1);
219 if (!(data[1] & 0x90)) /* report prox-out when physically out */
220 wacom_report_key(wcombo, wacom->tool[0], 0);
219 wacom_input_sync(wcombo); 221 wacom_input_sync(wcombo);
220 222
221 /* send pad data */ 223 /* send pad data */
@@ -405,7 +407,7 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
405 if ((wacom->features->type == CINTIQ) && !(data[1] & 0x40)) 407 if ((wacom->features->type == CINTIQ) && !(data[1] & 0x40))
406 return 0; 408 return 0;
407 409
408 if (wacom->features->type >= INTUOS3) { 410 if (wacom->features->type >= INTUOS3S) {
409 wacom_report_abs(wcombo, ABS_X, (data[2] << 9) | (data[3] << 1) | ((data[9] >> 1) & 1)); 411 wacom_report_abs(wcombo, ABS_X, (data[2] << 9) | (data[3] << 1) | ((data[9] >> 1) & 1));
410 wacom_report_abs(wcombo, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1)); 412 wacom_report_abs(wcombo, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1));
411 wacom_report_abs(wcombo, ABS_DISTANCE, ((data[9] >> 2) & 0x3f)); 413 wacom_report_abs(wcombo, ABS_DISTANCE, ((data[9] >> 2) & 0x3f));
@@ -423,7 +425,7 @@ static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
423 425
424 if (data[1] & 0x02) { 426 if (data[1] & 0x02) {
425 /* Rotation packet */ 427 /* Rotation packet */
426 if (wacom->features->type >= INTUOS3) { 428 if (wacom->features->type >= INTUOS3S) {
427 /* I3 marker pen rotation reported as wheel 429 /* I3 marker pen rotation reported as wheel
428 * due to valuator limitation 430 * due to valuator limitation
429 */ 431 */
@@ -547,11 +549,11 @@ static struct wacom_features wacom_features[] = {
547 { "Wacom Graphire3 6x8", 8, 16704, 12064, 511, 63, GRAPHIRE }, 549 { "Wacom Graphire3 6x8", 8, 16704, 12064, 511, 63, GRAPHIRE },
548 { "Wacom Graphire4 4x5", 8, 10208, 7424, 511, 63, WACOM_G4 }, 550 { "Wacom Graphire4 4x5", 8, 10208, 7424, 511, 63, WACOM_G4 },
549 { "Wacom Graphire4 6x8", 8, 16704, 12064, 511, 63, WACOM_G4 }, 551 { "Wacom Graphire4 6x8", 8, 16704, 12064, 511, 63, WACOM_G4 },
550 { "Wacom Volito", 8, 5104, 3712, 511, 0, GRAPHIRE }, 552 { "Wacom Volito", 8, 5104, 3712, 511, 63, GRAPHIRE },
551 { "Wacom PenStation2", 8, 3250, 2320, 255, 0, GRAPHIRE }, 553 { "Wacom PenStation2", 8, 3250, 2320, 255, 63, GRAPHIRE },
552 { "Wacom Volito2 4x5", 8, 5104, 3712, 511, 0, GRAPHIRE }, 554 { "Wacom Volito2 4x5", 8, 5104, 3712, 511, 63, GRAPHIRE },
553 { "Wacom Volito2 2x3", 8, 3248, 2320, 511, 0, GRAPHIRE }, 555 { "Wacom Volito2 2x3", 8, 3248, 2320, 511, 63, GRAPHIRE },
554 { "Wacom PenPartner2", 8, 3250, 2320, 255, 0, GRAPHIRE }, 556 { "Wacom PenPartner2", 8, 3250, 2320, 255, 63, GRAPHIRE },
555 { "Wacom Intuos 4x5", 10, 12700, 10600, 1023, 63, INTUOS }, 557 { "Wacom Intuos 4x5", 10, 12700, 10600, 1023, 63, INTUOS },
556 { "Wacom Intuos 6x8", 10, 20320, 16240, 1023, 63, INTUOS }, 558 { "Wacom Intuos 6x8", 10, 20320, 16240, 1023, 63, INTUOS },
557 { "Wacom Intuos 9x12", 10, 30480, 24060, 1023, 63, INTUOS }, 559 { "Wacom Intuos 9x12", 10, 30480, 24060, 1023, 63, INTUOS },
@@ -580,7 +582,7 @@ static struct wacom_features wacom_features[] = {
580 { "Wacom Intuos3 12x12", 10, 60960, 60960, 1023, 63, INTUOS3L }, 582 { "Wacom Intuos3 12x12", 10, 60960, 60960, 1023, 63, INTUOS3L },
581 { "Wacom Intuos3 12x19", 10, 97536, 60960, 1023, 63, INTUOS3L }, 583 { "Wacom Intuos3 12x19", 10, 97536, 60960, 1023, 63, INTUOS3L },
582 { "Wacom Intuos3 6x11", 10, 54204, 31750, 1023, 63, INTUOS3 }, 584 { "Wacom Intuos3 6x11", 10, 54204, 31750, 1023, 63, INTUOS3 },
583 { "Wacom Intuos3 4x6", 10, 31496, 19685, 1023, 15, INTUOS3S }, 585 { "Wacom Intuos3 4x6", 10, 31496, 19685, 1023, 63, INTUOS3S },
584 { "Wacom Cintiq 21UX", 10, 87200, 65600, 1023, 63, CINTIQ }, 586 { "Wacom Cintiq 21UX", 10, 87200, 65600, 1023, 63, CINTIQ },
585 { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 63, INTUOS }, 587 { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 63, INTUOS },
586 { } 588 { }
diff --git a/drivers/usb/misc/auerswald.c b/drivers/usb/misc/auerswald.c
index 6c7f3efb1d40..b5332e679c46 100644
--- a/drivers/usb/misc/auerswald.c
+++ b/drivers/usb/misc/auerswald.c
@@ -1376,7 +1376,7 @@ static int auerchar_open (struct inode *inode, struct file *file)
1376 } 1376 }
1377 1377
1378 /* we have access to the device. Now lets allocate memory */ 1378 /* we have access to the device. Now lets allocate memory */
1379 ccp = (pauerchar_t) kmalloc(sizeof(auerchar_t), GFP_KERNEL); 1379 ccp = kzalloc(sizeof(auerchar_t), GFP_KERNEL);
1380 if (ccp == NULL) { 1380 if (ccp == NULL) {
1381 err ("out of memory"); 1381 err ("out of memory");
1382 ret = -ENOMEM; 1382 ret = -ENOMEM;
@@ -1384,7 +1384,6 @@ static int auerchar_open (struct inode *inode, struct file *file)
1384 } 1384 }
1385 1385
1386 /* Initialize device descriptor */ 1386 /* Initialize device descriptor */
1387 memset( ccp, 0, sizeof(auerchar_t));
1388 init_MUTEX( &ccp->mutex); 1387 init_MUTEX( &ccp->mutex);
1389 init_MUTEX( &ccp->readmutex); 1388 init_MUTEX( &ccp->readmutex);
1390 auerbuf_init (&ccp->bufctl); 1389 auerbuf_init (&ccp->bufctl);
@@ -1912,14 +1911,13 @@ static int auerswald_probe (struct usb_interface *intf,
1912 return -ENODEV; 1911 return -ENODEV;
1913 1912
1914 /* allocate memory for our device and initialize it */ 1913 /* allocate memory for our device and initialize it */
1915 cp = kmalloc (sizeof(auerswald_t), GFP_KERNEL); 1914 cp = kzalloc (sizeof(auerswald_t), GFP_KERNEL);
1916 if (cp == NULL) { 1915 if (cp == NULL) {
1917 err ("out of memory"); 1916 err ("out of memory");
1918 goto pfail; 1917 goto pfail;
1919 } 1918 }
1920 1919
1921 /* Initialize device descriptor */ 1920 /* Initialize device descriptor */
1922 memset (cp, 0, sizeof(auerswald_t));
1923 init_MUTEX (&cp->mutex); 1921 init_MUTEX (&cp->mutex);
1924 cp->usbdev = usbdev; 1922 cp->usbdev = usbdev;
1925 auerchain_init (&cp->controlchain); 1923 auerchain_init (&cp->controlchain);
diff --git a/drivers/usb/misc/ftdi-elan.c b/drivers/usb/misc/ftdi-elan.c
index 18b1925032a8..41c0161abdb9 100644
--- a/drivers/usb/misc/ftdi-elan.c
+++ b/drivers/usb/misc/ftdi-elan.c
@@ -40,6 +40,7 @@
40#include <linux/init.h> 40#include <linux/init.h>
41#include <linux/list.h> 41#include <linux/list.h>
42#include <linux/ioctl.h> 42#include <linux/ioctl.h>
43#include <linux/pci_ids.h>
43#include <linux/slab.h> 44#include <linux/slab.h>
44#include <linux/module.h> 45#include <linux/module.h>
45#include <linux/kref.h> 46#include <linux/kref.h>
@@ -51,6 +52,10 @@ MODULE_AUTHOR("Tony Olech");
51MODULE_DESCRIPTION("FTDI ELAN driver"); 52MODULE_DESCRIPTION("FTDI ELAN driver");
52MODULE_LICENSE("GPL"); 53MODULE_LICENSE("GPL");
53#define INT_MODULE_PARM(n, v) static int n = v;module_param(n, int, 0444) 54#define INT_MODULE_PARM(n, v) static int n = v;module_param(n, int, 0444)
55static int distrust_firmware = 1;
56module_param(distrust_firmware, bool, 0);
57MODULE_PARM_DESC(distrust_firmware, "true to distrust firmware power/overcurren"
58 "t setup");
54extern struct platform_driver u132_platform_driver; 59extern struct platform_driver u132_platform_driver;
55static struct workqueue_struct *status_queue; 60static struct workqueue_struct *status_queue;
56static struct workqueue_struct *command_queue; 61static struct workqueue_struct *command_queue;
@@ -66,7 +71,9 @@ static struct list_head ftdi_static_list;
66* end of the global variables protected by ftdi_module_lock 71* end of the global variables protected by ftdi_module_lock
67*/ 72*/
68#include "usb_u132.h" 73#include "usb_u132.h"
69#define TD_DEVNOTRESP 5 74#include <asm/io.h>
75#include "../core/hcd.h"
76#include "../host/ohci.h"
70/* Define these values to match your devices*/ 77/* Define these values to match your devices*/
71#define USB_FTDI_ELAN_VENDOR_ID 0x0403 78#define USB_FTDI_ELAN_VENDOR_ID 0x0403
72#define USB_FTDI_ELAN_PRODUCT_ID 0xd6ea 79#define USB_FTDI_ELAN_PRODUCT_ID 0xd6ea
@@ -551,7 +558,7 @@ static void ftdi_elan_status_work(struct work_struct *work)
551 } else { 558 } else {
552 dev_err(&ftdi->udev->dev, "initialized failed - trying " 559 dev_err(&ftdi->udev->dev, "initialized failed - trying "
553 "again in 10 seconds\n"); 560 "again in 10 seconds\n");
554 work_delay_in_msec = 10 *1000; 561 work_delay_in_msec = 1 *1000;
555 } 562 }
556 } else if (ftdi->registered == 0) { 563 } else if (ftdi->registered == 0) {
557 work_delay_in_msec = 10; 564 work_delay_in_msec = 10;
@@ -2288,82 +2295,288 @@ static int ftdi_elan_checkingPCI(struct usb_ftdi *ftdi)
2288 } 2295 }
2289} 2296}
2290 2297
2291static int ftdi_elan_enumeratePCI(struct usb_ftdi *ftdi) 2298
2299#define ftdi_read_pcimem(ftdi, member, data) ftdi_elan_read_pcimem(ftdi, \
2300 offsetof(struct ohci_regs, member), 0, data);
2301#define ftdi_write_pcimem(ftdi, member, data) ftdi_elan_write_pcimem(ftdi, \
2302 offsetof(struct ohci_regs, member), 0, data);
2303#define OHCI_QUIRK_AMD756 0x01
2304#define OHCI_QUIRK_SUPERIO 0x02
2305#define OHCI_QUIRK_INITRESET 0x04
2306#define OHCI_BIG_ENDIAN 0x08
2307#define OHCI_QUIRK_ZFMICRO 0x10
2308#define OHCI_CONTROL_INIT OHCI_CTRL_CBSR
2309#define OHCI_INTR_INIT (OHCI_INTR_MIE | OHCI_INTR_UE | OHCI_INTR_RD | \
2310 OHCI_INTR_WDH)
2311static int ftdi_elan_check_controller(struct usb_ftdi *ftdi, int quirk)
2312{
2313 int devices = 0;
2314 int retval;
2315 u32 hc_control;
2316 int num_ports;
2317 u32 control;
2318 u32 rh_a = -1;
2319 u32 status;
2320 u32 fminterval;
2321 u32 hc_fminterval;
2322 u32 periodicstart;
2323 u32 cmdstatus;
2324 u32 roothub_a;
2325 int mask = OHCI_INTR_INIT;
2326 int sleep_time = 0;
2327 int reset_timeout = 30; /* ... allow extra time */
2328 int temp;
2329 retval = ftdi_write_pcimem(ftdi, intrdisable, OHCI_INTR_MIE);
2330 if (retval)
2331 return retval;
2332 retval = ftdi_read_pcimem(ftdi, control, &control);
2333 if (retval)
2334 return retval;
2335 retval = ftdi_read_pcimem(ftdi, roothub.a, &rh_a);
2336 if (retval)
2337 return retval;
2338 num_ports = rh_a & RH_A_NDP;
2339 retval = ftdi_read_pcimem(ftdi, fminterval, &hc_fminterval);
2340 if (retval)
2341 return retval;
2342 hc_fminterval &= 0x3fff;
2343 if (hc_fminterval != FI) {
2344 }
2345 hc_fminterval |= FSMP(hc_fminterval) << 16;
2346 retval = ftdi_read_pcimem(ftdi, control, &hc_control);
2347 if (retval)
2348 return retval;
2349 switch (hc_control & OHCI_CTRL_HCFS) {
2350 case OHCI_USB_OPER:
2351 sleep_time = 0;
2352 break;
2353 case OHCI_USB_SUSPEND:
2354 case OHCI_USB_RESUME:
2355 hc_control &= OHCI_CTRL_RWC;
2356 hc_control |= OHCI_USB_RESUME;
2357 sleep_time = 10;
2358 break;
2359 default:
2360 hc_control &= OHCI_CTRL_RWC;
2361 hc_control |= OHCI_USB_RESET;
2362 sleep_time = 50;
2363 break;
2364 }
2365 retval = ftdi_write_pcimem(ftdi, control, hc_control);
2366 if (retval)
2367 return retval;
2368 retval = ftdi_read_pcimem(ftdi, control, &control);
2369 if (retval)
2370 return retval;
2371 msleep(sleep_time);
2372 retval = ftdi_read_pcimem(ftdi, roothub.a, &roothub_a);
2373 if (retval)
2374 return retval;
2375 if (!(roothub_a & RH_A_NPS)) { /* power down each port */
2376 for (temp = 0; temp < num_ports; temp++) {
2377 retval = ftdi_write_pcimem(ftdi,
2378 roothub.portstatus[temp], RH_PS_LSDA);
2379 if (retval)
2380 return retval;
2381 }
2382 }
2383 retval = ftdi_read_pcimem(ftdi, control, &control);
2384 if (retval)
2385 return retval;
2386 retry:retval = ftdi_read_pcimem(ftdi, cmdstatus, &status);
2387 if (retval)
2388 return retval;
2389 retval = ftdi_write_pcimem(ftdi, cmdstatus, OHCI_HCR);
2390 if (retval)
2391 return retval;
2392 extra:{
2393 retval = ftdi_read_pcimem(ftdi, cmdstatus, &status);
2394 if (retval)
2395 return retval;
2396 if (0 != (status & OHCI_HCR)) {
2397 if (--reset_timeout == 0) {
2398 dev_err(&ftdi->udev->dev, "USB HC reset timed o"
2399 "ut!\n");
2400 return -ENODEV;
2401 } else {
2402 msleep(5);
2403 goto extra;
2404 }
2405 }
2406 }
2407 if (quirk & OHCI_QUIRK_INITRESET) {
2408 retval = ftdi_write_pcimem(ftdi, control, hc_control);
2409 if (retval)
2410 return retval;
2411 retval = ftdi_read_pcimem(ftdi, control, &control);
2412 if (retval)
2413 return retval;
2414 }
2415 retval = ftdi_write_pcimem(ftdi, ed_controlhead, 0x00000000);
2416 if (retval)
2417 return retval;
2418 retval = ftdi_write_pcimem(ftdi, ed_bulkhead, 0x11000000);
2419 if (retval)
2420 return retval;
2421 retval = ftdi_write_pcimem(ftdi, hcca, 0x00000000);
2422 if (retval)
2423 return retval;
2424 retval = ftdi_read_pcimem(ftdi, fminterval, &fminterval);
2425 if (retval)
2426 return retval;
2427 retval = ftdi_write_pcimem(ftdi, fminterval,
2428 ((fminterval & FIT) ^ FIT) | hc_fminterval);
2429 if (retval)
2430 return retval;
2431 retval = ftdi_write_pcimem(ftdi, periodicstart,
2432 ((9 *hc_fminterval) / 10) & 0x3fff);
2433 if (retval)
2434 return retval;
2435 retval = ftdi_read_pcimem(ftdi, fminterval, &fminterval);
2436 if (retval)
2437 return retval;
2438 retval = ftdi_read_pcimem(ftdi, periodicstart, &periodicstart);
2439 if (retval)
2440 return retval;
2441 if (0 == (fminterval & 0x3fff0000) || 0 == periodicstart) {
2442 if (!(quirk & OHCI_QUIRK_INITRESET)) {
2443 quirk |= OHCI_QUIRK_INITRESET;
2444 goto retry;
2445 } else
2446 dev_err(&ftdi->udev->dev, "init err(%08x %04x)\n",
2447 fminterval, periodicstart);
2448 } /* start controller operations */
2449 hc_control &= OHCI_CTRL_RWC;
2450 hc_control |= OHCI_CONTROL_INIT | OHCI_CTRL_BLE | OHCI_USB_OPER;
2451 retval = ftdi_write_pcimem(ftdi, control, hc_control);
2452 if (retval)
2453 return retval;
2454 retval = ftdi_write_pcimem(ftdi, cmdstatus, OHCI_BLF);
2455 if (retval)
2456 return retval;
2457 retval = ftdi_read_pcimem(ftdi, cmdstatus, &cmdstatus);
2458 if (retval)
2459 return retval;
2460 retval = ftdi_read_pcimem(ftdi, control, &control);
2461 if (retval)
2462 return retval;
2463 retval = ftdi_write_pcimem(ftdi, roothub.status, RH_HS_DRWE);
2464 if (retval)
2465 return retval;
2466 retval = ftdi_write_pcimem(ftdi, intrstatus, mask);
2467 if (retval)
2468 return retval;
2469 retval = ftdi_write_pcimem(ftdi, intrdisable,
2470 OHCI_INTR_MIE | OHCI_INTR_OC | OHCI_INTR_RHSC | OHCI_INTR_FNO |
2471 OHCI_INTR_UE | OHCI_INTR_RD | OHCI_INTR_SF | OHCI_INTR_WDH |
2472 OHCI_INTR_SO);
2473 if (retval)
2474 return retval; /* handle root hub init quirks ... */
2475 retval = ftdi_read_pcimem(ftdi, roothub.a, &roothub_a);
2476 if (retval)
2477 return retval;
2478 roothub_a &= ~(RH_A_PSM | RH_A_OCPM);
2479 if (quirk & OHCI_QUIRK_SUPERIO) {
2480 roothub_a |= RH_A_NOCP;
2481 roothub_a &= ~(RH_A_POTPGT | RH_A_NPS);
2482 retval = ftdi_write_pcimem(ftdi, roothub.a, roothub_a);
2483 if (retval)
2484 return retval;
2485 } else if ((quirk & OHCI_QUIRK_AMD756) || distrust_firmware) {
2486 roothub_a |= RH_A_NPS;
2487 retval = ftdi_write_pcimem(ftdi, roothub.a, roothub_a);
2488 if (retval)
2489 return retval;
2490 }
2491 retval = ftdi_write_pcimem(ftdi, roothub.status, RH_HS_LPSC);
2492 if (retval)
2493 return retval;
2494 retval = ftdi_write_pcimem(ftdi, roothub.b,
2495 (roothub_a & RH_A_NPS) ? 0 : RH_B_PPCM);
2496 if (retval)
2497 return retval;
2498 retval = ftdi_read_pcimem(ftdi, control, &control);
2499 if (retval)
2500 return retval;
2501 mdelay((roothub_a >> 23) & 0x1fe);
2502 for (temp = 0; temp < num_ports; temp++) {
2503 u32 portstatus;
2504 retval = ftdi_read_pcimem(ftdi, roothub.portstatus[temp],
2505 &portstatus);
2506 if (retval)
2507 return retval;
2508 if (1 & portstatus)
2509 devices += 1;
2510 }
2511 return devices;
2512}
2513
2514static int ftdi_elan_setup_controller(struct usb_ftdi *ftdi, int fn)
2292{ 2515{
2293 u32 latence_timer; 2516 u32 latence_timer;
2294 u32 controlreg;
2295 int UxxxStatus; 2517 int UxxxStatus;
2296 u32 pcidata; 2518 u32 pcidata;
2297 int reg = 0; 2519 int reg = 0;
2298 int foundOHCI = 0; 2520 int activePCIfn = fn << 8;
2299 u8 fn; 2521 UxxxStatus = ftdi_elan_write_reg(ftdi, 0x0000025FL | 0x2800);
2300 int activePCIfn = 0;
2301 u32 pciVID = 0;
2302 u32 pciPID = 0;
2303 UxxxStatus = ftdi_elan_read_reg(ftdi, &controlreg);
2304 if (UxxxStatus)
2305 return UxxxStatus;
2306 UxxxStatus = ftdi_elan_write_reg(ftdi, 0x00000000L);
2307 if (UxxxStatus)
2308 return UxxxStatus;
2309 msleep(750);
2310 UxxxStatus = ftdi_elan_write_reg(ftdi, 0x00000200L | 0x100);
2311 if (UxxxStatus) 2522 if (UxxxStatus)
2312 return UxxxStatus; 2523 return UxxxStatus;
2313 UxxxStatus = ftdi_elan_write_reg(ftdi, 0x00000200L | 0x500); 2524 reg = 16;
2525 UxxxStatus = ftdi_elan_write_config(ftdi, activePCIfn | reg, 0,
2526 0xFFFFFFFF);
2314 if (UxxxStatus) 2527 if (UxxxStatus)
2315 return UxxxStatus; 2528 return UxxxStatus;
2316 UxxxStatus = ftdi_elan_read_reg(ftdi, &controlreg); 2529 UxxxStatus = ftdi_elan_read_config(ftdi, activePCIfn | reg, 0,
2530 &pcidata);
2317 if (UxxxStatus) 2531 if (UxxxStatus)
2318 return UxxxStatus; 2532 return UxxxStatus;
2319 UxxxStatus = ftdi_elan_write_reg(ftdi, 0x0000020CL | 0x000); 2533 UxxxStatus = ftdi_elan_write_config(ftdi, activePCIfn | reg, 0,
2534 0xF0000000);
2320 if (UxxxStatus) 2535 if (UxxxStatus)
2321 return UxxxStatus; 2536 return UxxxStatus;
2322 UxxxStatus = ftdi_elan_write_reg(ftdi, 0x0000020DL | 0x000); 2537 UxxxStatus = ftdi_elan_read_config(ftdi, activePCIfn | reg, 0,
2538 &pcidata);
2323 if (UxxxStatus) 2539 if (UxxxStatus)
2324 return UxxxStatus; 2540 return UxxxStatus;
2325 msleep(250); 2541 reg = 12;
2326 UxxxStatus = ftdi_elan_write_reg(ftdi, 0x0000020FL | 0x000); 2542 UxxxStatus = ftdi_elan_read_config(ftdi, activePCIfn | reg, 0,
2543 &latence_timer);
2327 if (UxxxStatus) 2544 if (UxxxStatus)
2328 return UxxxStatus; 2545 return UxxxStatus;
2329 UxxxStatus = ftdi_elan_read_reg(ftdi, &controlreg); 2546 latence_timer &= 0xFFFF00FF;
2547 latence_timer |= 0x00001600;
2548 UxxxStatus = ftdi_elan_write_config(ftdi, activePCIfn | reg, 0x00,
2549 latence_timer);
2330 if (UxxxStatus) 2550 if (UxxxStatus)
2331 return UxxxStatus; 2551 return UxxxStatus;
2332 UxxxStatus = ftdi_elan_write_reg(ftdi, 0x0000025FL | 0x800); 2552 UxxxStatus = ftdi_elan_read_config(ftdi, activePCIfn | reg, 0,
2553 &pcidata);
2333 if (UxxxStatus) 2554 if (UxxxStatus)
2334 return UxxxStatus; 2555 return UxxxStatus;
2335 UxxxStatus = ftdi_elan_read_reg(ftdi, &controlreg); 2556 reg = 4;
2557 UxxxStatus = ftdi_elan_write_config(ftdi, activePCIfn | reg, 0x00,
2558 0x06);
2336 if (UxxxStatus) 2559 if (UxxxStatus)
2337 return UxxxStatus; 2560 return UxxxStatus;
2338 UxxxStatus = ftdi_elan_read_reg(ftdi, &controlreg); 2561 UxxxStatus = ftdi_elan_read_config(ftdi, activePCIfn | reg, 0,
2562 &pcidata);
2339 if (UxxxStatus) 2563 if (UxxxStatus)
2340 return UxxxStatus; 2564 return UxxxStatus;
2341 msleep(1000); 2565 for (reg = 0; reg <= 0x54; reg += 4) {
2342 for (fn = 0; (fn < 4) && (!foundOHCI); fn++) { 2566 UxxxStatus = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata);
2343 activePCIfn = fn << 8;
2344 ftdi->function = fn + 1;
2345 UxxxStatus = ftdi_elan_read_config(ftdi, activePCIfn | reg, 0,
2346 &pcidata);
2347 if (UxxxStatus) 2567 if (UxxxStatus)
2348 return UxxxStatus; 2568 return UxxxStatus;
2349 pciVID = pcidata & 0xFFFF;
2350 pciPID = (pcidata >> 16) & 0xFFFF;
2351 if ((pciVID == 0x1045) && (pciPID == 0xc861)) {
2352 foundOHCI = 1;
2353 } else if ((pciVID == 0x1033) && (pciPID == 0x0035)) {
2354 foundOHCI = 1;
2355 } else if ((pciVID == 0x10b9) && (pciPID == 0x5237)) {
2356 foundOHCI = 1;
2357 } else if ((pciVID == 0x11c1) && (pciPID == 0x5802)) {
2358 foundOHCI = 1;
2359 } else if ((pciVID == 0x11AB) && (pciPID == 0x1FA6)) {
2360 }
2361 }
2362 if (foundOHCI == 0) {
2363 return -ENXIO;
2364 } 2569 }
2365 ftdi->platform_data.vendor = pciVID; 2570 return 0;
2366 ftdi->platform_data.device = pciPID; 2571}
2572
2573static int ftdi_elan_close_controller(struct usb_ftdi *ftdi, int fn)
2574{
2575 u32 latence_timer;
2576 int UxxxStatus;
2577 u32 pcidata;
2578 int reg = 0;
2579 int activePCIfn = fn << 8;
2367 UxxxStatus = ftdi_elan_write_reg(ftdi, 0x0000025FL | 0x2800); 2580 UxxxStatus = ftdi_elan_write_reg(ftdi, 0x0000025FL | 0x2800);
2368 if (UxxxStatus) 2581 if (UxxxStatus)
2369 return UxxxStatus; 2582 return UxxxStatus;
@@ -2377,7 +2590,7 @@ static int ftdi_elan_enumeratePCI(struct usb_ftdi *ftdi)
2377 if (UxxxStatus) 2590 if (UxxxStatus)
2378 return UxxxStatus; 2591 return UxxxStatus;
2379 UxxxStatus = ftdi_elan_write_config(ftdi, activePCIfn | reg, 0, 2592 UxxxStatus = ftdi_elan_write_config(ftdi, activePCIfn | reg, 0,
2380 0xF0000000); 2593 0x00000000);
2381 if (UxxxStatus) 2594 if (UxxxStatus)
2382 return UxxxStatus; 2595 return UxxxStatus;
2383 UxxxStatus = ftdi_elan_read_config(ftdi, activePCIfn | reg, 0, 2596 UxxxStatus = ftdi_elan_read_config(ftdi, activePCIfn | reg, 0,
@@ -2401,7 +2614,7 @@ static int ftdi_elan_enumeratePCI(struct usb_ftdi *ftdi)
2401 return UxxxStatus; 2614 return UxxxStatus;
2402 reg = 4; 2615 reg = 4;
2403 UxxxStatus = ftdi_elan_write_config(ftdi, activePCIfn | reg, 0x00, 2616 UxxxStatus = ftdi_elan_write_config(ftdi, activePCIfn | reg, 0x00,
2404 0x06); 2617 0x00);
2405 if (UxxxStatus) 2618 if (UxxxStatus)
2406 return UxxxStatus; 2619 return UxxxStatus;
2407 UxxxStatus = ftdi_elan_read_config(ftdi, activePCIfn | reg, 0, 2620 UxxxStatus = ftdi_elan_read_config(ftdi, activePCIfn | reg, 0,
@@ -2411,159 +2624,139 @@ static int ftdi_elan_enumeratePCI(struct usb_ftdi *ftdi)
2411 return 0; 2624 return 0;
2412} 2625}
2413 2626
2627static int ftdi_elan_found_controller(struct usb_ftdi *ftdi, int fn, int quirk)
2628{
2629 int result;
2630 int UxxxStatus;
2631 UxxxStatus = ftdi_elan_setup_controller(ftdi, fn);
2632 if (UxxxStatus)
2633 return UxxxStatus;
2634 result = ftdi_elan_check_controller(ftdi, quirk);
2635 UxxxStatus = ftdi_elan_close_controller(ftdi, fn);
2636 if (UxxxStatus)
2637 return UxxxStatus;
2638 return result;
2639}
2640
2641static int ftdi_elan_enumeratePCI(struct usb_ftdi *ftdi)
2642{
2643 u32 controlreg;
2644 u8 sensebits;
2645 int UxxxStatus;
2646 UxxxStatus = ftdi_elan_read_reg(ftdi, &controlreg);
2647 if (UxxxStatus)
2648 return UxxxStatus;
2649 UxxxStatus = ftdi_elan_write_reg(ftdi, 0x00000000L);
2650 if (UxxxStatus)
2651 return UxxxStatus;
2652 msleep(750);
2653 UxxxStatus = ftdi_elan_write_reg(ftdi, 0x00000200L | 0x100);
2654 if (UxxxStatus)
2655 return UxxxStatus;
2656 UxxxStatus = ftdi_elan_write_reg(ftdi, 0x00000200L | 0x500);
2657 if (UxxxStatus)
2658 return UxxxStatus;
2659 UxxxStatus = ftdi_elan_read_reg(ftdi, &controlreg);
2660 if (UxxxStatus)
2661 return UxxxStatus;
2662 UxxxStatus = ftdi_elan_write_reg(ftdi, 0x0000020CL | 0x000);
2663 if (UxxxStatus)
2664 return UxxxStatus;
2665 UxxxStatus = ftdi_elan_write_reg(ftdi, 0x0000020DL | 0x000);
2666 if (UxxxStatus)
2667 return UxxxStatus;
2668 msleep(250);
2669 UxxxStatus = ftdi_elan_write_reg(ftdi, 0x0000020FL | 0x000);
2670 if (UxxxStatus)
2671 return UxxxStatus;
2672 UxxxStatus = ftdi_elan_read_reg(ftdi, &controlreg);
2673 if (UxxxStatus)
2674 return UxxxStatus;
2675 UxxxStatus = ftdi_elan_write_reg(ftdi, 0x0000025FL | 0x800);
2676 if (UxxxStatus)
2677 return UxxxStatus;
2678 UxxxStatus = ftdi_elan_read_reg(ftdi, &controlreg);
2679 if (UxxxStatus)
2680 return UxxxStatus;
2681 UxxxStatus = ftdi_elan_read_reg(ftdi, &controlreg);
2682 if (UxxxStatus)
2683 return UxxxStatus;
2684 msleep(1000);
2685 sensebits = (controlreg >> 16) & 0x000F;
2686 if (0x0D == sensebits)
2687 return 0;
2688 else
2689 return - ENXIO;
2690}
2691
2414static int ftdi_elan_setupOHCI(struct usb_ftdi *ftdi) 2692static int ftdi_elan_setupOHCI(struct usb_ftdi *ftdi)
2415{ 2693{
2694 int UxxxStatus;
2416 u32 pcidata; 2695 u32 pcidata;
2417 int U132Status; 2696 int reg = 0;
2418 int reg; 2697 u8 fn;
2419 int reset_repeat = 0; 2698 int activePCIfn = 0;
2420 do_reset:reg = 8; 2699 int max_devices = 0;
2421 U132Status = ftdi_elan_write_pcimem(ftdi, reg, 0x0e, 0x01); 2700 int controllers = 0;
2422 if (U132Status) 2701 int unrecognized = 0;
2423 return U132Status; 2702 ftdi->function = 0;
2424 reset_check:{ 2703 for (fn = 0; (fn < 4); fn++) {
2425 U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata); 2704 u32 pciVID = 0;
2426 if (U132Status) 2705 u32 pciPID = 0;
2427 return U132Status; 2706 int devices = 0;
2428 if (pcidata & 1) { 2707 activePCIfn = fn << 8;
2429 msleep(500); 2708 UxxxStatus = ftdi_elan_read_config(ftdi, activePCIfn | reg, 0,
2430 if (reset_repeat++ > 100) { 2709 &pcidata);
2431 reset_repeat = 0; 2710 if (UxxxStatus)
2432 goto do_reset; 2711 return UxxxStatus;
2433 } else 2712 pciVID = pcidata & 0xFFFF;
2434 goto reset_check; 2713 pciPID = (pcidata >> 16) & 0xFFFF;
2714 if ((pciVID == PCI_VENDOR_ID_OPTI) && (pciPID == 0xc861)) {
2715 devices = ftdi_elan_found_controller(ftdi, fn, 0);
2716 controllers += 1;
2717 } else if ((pciVID == PCI_VENDOR_ID_NEC) && (pciPID == 0x0035))
2718 {
2719 devices = ftdi_elan_found_controller(ftdi, fn, 0);
2720 controllers += 1;
2721 } else if ((pciVID == PCI_VENDOR_ID_AL) && (pciPID == 0x5237)) {
2722 devices = ftdi_elan_found_controller(ftdi, fn, 0);
2723 controllers += 1;
2724 } else if ((pciVID == PCI_VENDOR_ID_ATT) && (pciPID == 0x5802))
2725 {
2726 devices = ftdi_elan_found_controller(ftdi, fn, 0);
2727 controllers += 1;
2728 } else if (pciVID == PCI_VENDOR_ID_AMD && pciPID == 0x740c) {
2729 devices = ftdi_elan_found_controller(ftdi, fn,
2730 OHCI_QUIRK_AMD756);
2731 controllers += 1;
2732 } else if (pciVID == PCI_VENDOR_ID_COMPAQ && pciPID == 0xa0f8) {
2733 devices = ftdi_elan_found_controller(ftdi, fn,
2734 OHCI_QUIRK_ZFMICRO);
2735 controllers += 1;
2736 } else if (0 == pcidata) {
2737 } else
2738 unrecognized += 1;
2739 if (devices > max_devices) {
2740 max_devices = devices;
2741 ftdi->function = fn + 1;
2742 ftdi->platform_data.vendor = pciVID;
2743 ftdi->platform_data.device = pciPID;
2435 } 2744 }
2436 } 2745 }
2437 goto dump_regs; 2746 if (ftdi->function > 0) {
2438 msleep(500); 2747 UxxxStatus = ftdi_elan_setup_controller(ftdi,
2439 reg = 0x28; 2748 ftdi->function - 1);
2440 U132Status = ftdi_elan_write_pcimem(ftdi, reg, 0x00, 0x11000000); 2749 if (UxxxStatus)
2441 if (U132Status) 2750 return UxxxStatus;
2442 return U132Status; 2751 return 0;
2443 U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata); 2752 } else if (controllers > 0) {
2444 if (U132Status) 2753 return -ENXIO;
2445 return U132Status; 2754 } else if (unrecognized > 0) {
2446 reg = 0x40; 2755 return -ENXIO;
2447 U132Status = ftdi_elan_write_pcimem(ftdi, reg, 0x00, 0x2edf); 2756 } else {
2448 if (U132Status) 2757 ftdi->enumerated = 0;
2449 return U132Status; 2758 return -ENXIO;
2450 U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata);
2451 if (U132Status)
2452 return U132Status;
2453 reg = 0x34;
2454 U132Status = ftdi_elan_write_pcimem(ftdi, reg, 0x00, 0x2edf2edf);
2455 if (U132Status)
2456 return U132Status;
2457 U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata);
2458 if (U132Status)
2459 return U132Status;
2460 reg = 4;
2461 U132Status = ftdi_elan_write_pcimem(ftdi, reg, 0x00, 0xA0);
2462 if (U132Status)
2463 return U132Status;
2464 U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata);
2465 if (U132Status)
2466 return U132Status;
2467 msleep(250);
2468 reg = 8;
2469 U132Status = ftdi_elan_write_pcimem(ftdi, reg, 0x0e, 0x04);
2470 if (U132Status)
2471 return U132Status;
2472 U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata);
2473 if (U132Status)
2474 return U132Status;
2475 reg = 0x28;
2476 U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata);
2477 if (U132Status)
2478 return U132Status;
2479 reg = 8;
2480 U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata);
2481 if (U132Status)
2482 return U132Status;
2483 reg = 0x48;
2484 U132Status = ftdi_elan_write_pcimem(ftdi, reg, 0x00, 0x00001200);
2485 if (U132Status)
2486 return U132Status;
2487 U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata);
2488 if (U132Status)
2489 return U132Status;
2490 reg = 0x54;
2491 U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata);
2492 if (U132Status)
2493 return U132Status;
2494 reg = 0x58;
2495 U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata);
2496 if (U132Status)
2497 return U132Status;
2498 reg = 0x34;
2499 U132Status = ftdi_elan_write_pcimem(ftdi, reg, 0x00, 0x28002edf);
2500 if (U132Status)
2501 return U132Status;
2502 U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata);
2503 if (U132Status)
2504 return U132Status;
2505 msleep(100);
2506 reg = 0x50;
2507 U132Status = ftdi_elan_write_pcimem(ftdi, reg, 0x00, 0x10000);
2508 if (U132Status)
2509 return U132Status;
2510 reg = 0x54;
2511 power_check:U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata);
2512 if (U132Status)
2513 return U132Status;
2514 if (!(pcidata & 1)) {
2515 msleep(500);
2516 goto power_check;
2517 }
2518 msleep(3000);
2519 reg = 0x54;
2520 U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata);
2521 if (U132Status)
2522 return U132Status;
2523 reg = 0x58;
2524 U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata);
2525 if (U132Status)
2526 return U132Status;
2527 reg = 0x54;
2528 U132Status = ftdi_elan_write_pcimem(ftdi, reg, 0x00, 0x02);
2529 if (U132Status)
2530 return U132Status;
2531 U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata);
2532 if (U132Status)
2533 return U132Status;
2534 reg = 0x54;
2535 U132Status = ftdi_elan_write_pcimem(ftdi, reg, 0x00, 0x10);
2536 if (U132Status)
2537 return U132Status;
2538 U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata);
2539 if (U132Status)
2540 return U132Status;
2541 msleep(750);
2542 reg = 0x54;
2543 if (0) {
2544 U132Status = ftdi_elan_write_pcimem(ftdi, reg, 0x00, 0x02);
2545 if (U132Status)
2546 return U132Status;
2547 }
2548 if (0) {
2549 U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata);
2550 if (U132Status)
2551 return U132Status;
2552 }
2553 reg = 0x54;
2554 U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata);
2555 if (U132Status)
2556 return U132Status;
2557 reg = 0x58;
2558 U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata);
2559 if (U132Status)
2560 return U132Status;
2561 dump_regs:for (reg = 0; reg <= 0x54; reg += 4) {
2562 U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata);
2563 if (U132Status)
2564 return U132Status;
2565 } 2759 }
2566 return 0;
2567} 2760}
2568 2761
2569 2762
@@ -2688,6 +2881,7 @@ static void ftdi_elan_disconnect(struct usb_interface *interface)
2688 platform_device_unregister(&ftdi->platform_dev); 2881 platform_device_unregister(&ftdi->platform_dev);
2689 ftdi->synchronized = 0; 2882 ftdi->synchronized = 0;
2690 ftdi->enumerated = 0; 2883 ftdi->enumerated = 0;
2884 ftdi->initialized = 0;
2691 ftdi->registered = 0; 2885 ftdi->registered = 0;
2692 } 2886 }
2693 flush_workqueue(status_queue); 2887 flush_workqueue(status_queue);
diff --git a/drivers/usb/misc/phidgetservo.c b/drivers/usb/misc/phidgetservo.c
index 7163f05c5b27..0d9de2f73930 100644
--- a/drivers/usb/misc/phidgetservo.c
+++ b/drivers/usb/misc/phidgetservo.c
@@ -282,6 +282,7 @@ servo_probe(struct usb_interface *interface, const struct usb_device_id *id)
282 dev->dev = NULL; 282 dev->dev = NULL;
283 goto out; 283 goto out;
284 } 284 }
285 dev_set_drvdata(dev->dev, dev);
285 286
286 servo_count = dev->type & SERVO_COUNT_QUAD ? 4 : 1; 287 servo_count = dev->type & SERVO_COUNT_QUAD ? 4 : 1;
287 288
diff --git a/drivers/usb/misc/trancevibrator.c b/drivers/usb/misc/trancevibrator.c
index 33cd91d11eca..67e2fc20eeeb 100644
--- a/drivers/usb/misc/trancevibrator.c
+++ b/drivers/usb/misc/trancevibrator.c
@@ -120,8 +120,8 @@ static void tv_disconnect(struct usb_interface *interface)
120 struct trancevibrator *dev; 120 struct trancevibrator *dev;
121 121
122 dev = usb_get_intfdata (interface); 122 dev = usb_get_intfdata (interface);
123 usb_set_intfdata(interface, NULL);
124 device_remove_file(&interface->dev, &dev_attr_speed); 123 device_remove_file(&interface->dev, &dev_attr_speed);
124 usb_set_intfdata(interface, NULL);
125 usb_put_dev(dev->udev); 125 usb_put_dev(dev->udev);
126 kfree(dev); 126 kfree(dev);
127} 127}
diff --git a/drivers/usb/net/gl620a.c b/drivers/usb/net/gl620a.c
index a3242be21959..a6f0f4d934df 100644
--- a/drivers/usb/net/gl620a.c
+++ b/drivers/usb/net/gl620a.c
@@ -79,160 +79,6 @@ struct gl_header {
79 struct gl_packet packets; 79 struct gl_packet packets;
80}; 80};
81 81
82#ifdef GENELINK_ACK
83
84// FIXME: this code is incomplete, not debugged; it doesn't
85// handle interrupts correctly; it should use the generic
86// status IRQ code (which didn't exist back in 2001).
87
88struct gl_priv {
89 struct urb *irq_urb;
90 char irq_buf [INTERRUPT_BUFSIZE];
91};
92
93static inline int gl_control_write(struct usbnet *dev, u8 request, u16 value)
94{
95 int retval;
96
97 retval = usb_control_msg(dev->udev,
98 usb_sndctrlpipe(dev->udev, 0),
99 request,
100 USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
101 value,
102 0, // index
103 0, // data buffer
104 0, // size
105 USB_CTRL_SET_TIMEOUT);
106 return retval;
107}
108
109static void gl_interrupt_complete(struct urb *urb)
110{
111 int status = urb->status;
112
113 switch (status) {
114 case 0:
115 /* success */
116 break;
117 case -ECONNRESET:
118 case -ENOENT:
119 case -ESHUTDOWN:
120 /* this urb is terminated, clean up */
121 dbg("%s - urb shutting down with status: %d",
122 __FUNCTION__, status);
123 return;
124 default:
125 dbg("%s - nonzero urb status received: %d",
126 __FUNCTION__, urb->status);
127 }
128
129 status = usb_submit_urb(urb, GFP_ATOMIC);
130 if (status)
131 err("%s - usb_submit_urb failed with result %d",
132 __FUNCTION__, status);
133}
134
135static int gl_interrupt_read(struct usbnet *dev)
136{
137 struct gl_priv *priv = dev->priv_data;
138 int retval;
139
140 // issue usb interrupt read
141 if (priv && priv->irq_urb) {
142 // submit urb
143 if ((retval = usb_submit_urb(priv->irq_urb, GFP_KERNEL)) != 0)
144 dbg("gl_interrupt_read: submit fail - %X...", retval);
145 else
146 dbg("gl_interrupt_read: submit success...");
147 }
148
149 return 0;
150}
151
152// check whether another side is connected
153static int genelink_check_connect(struct usbnet *dev)
154{
155 int retval;
156
157 dbg("genelink_check_connect...");
158
159 // detect whether another side is connected
160 if ((retval = gl_control_write(dev, GENELINK_CONNECT_WRITE, 0)) != 0) {
161 dbg("%s: genelink_check_connect write fail - %X",
162 dev->net->name, retval);
163 return retval;
164 }
165
166 // usb interrupt read to ack another side
167 if ((retval = gl_interrupt_read(dev)) != 0) {
168 dbg("%s: genelink_check_connect read fail - %X",
169 dev->net->name, retval);
170 return retval;
171 }
172
173 dbg("%s: genelink_check_connect read success", dev->net->name);
174 return 0;
175}
176
177// allocate and initialize the private data for genelink
178static int genelink_init(struct usbnet *dev)
179{
180 struct gl_priv *priv;
181
182 // allocate the private data structure
183 if ((priv = kmalloc(sizeof *priv, GFP_KERNEL)) == 0) {
184 dbg("%s: cannot allocate private data per device",
185 dev->net->name);
186 return -ENOMEM;
187 }
188
189 // allocate irq urb
190 if ((priv->irq_urb = usb_alloc_urb(0, GFP_KERNEL)) == 0) {
191 dbg("%s: cannot allocate private irq urb per device",
192 dev->net->name);
193 kfree(priv);
194 return -ENOMEM;
195 }
196
197 // fill irq urb
198 usb_fill_int_urb(priv->irq_urb, dev->udev,
199 usb_rcvintpipe(dev->udev, GENELINK_INTERRUPT_PIPE),
200 priv->irq_buf, INTERRUPT_BUFSIZE,
201 gl_interrupt_complete, 0,
202 GENELINK_INTERRUPT_INTERVAL);
203
204 // set private data pointer
205 dev->priv_data = priv;
206
207 return 0;
208}
209
210// release the private data
211static int genelink_free(struct usbnet *dev)
212{
213 struct gl_priv *priv = dev->priv_data;
214
215 if (!priv)
216 return 0;
217
218// FIXME: can't cancel here; it's synchronous, and
219// should have happened earlier in any case (interrupt
220// handling needs to be generic)
221
222 // cancel irq urb first
223 usb_kill_urb(priv->irq_urb);
224
225 // free irq urb
226 usb_free_urb(priv->irq_urb);
227
228 // free the private data structure
229 kfree(priv);
230
231 return 0;
232}
233
234#endif
235
236static int genelink_rx_fixup(struct usbnet *dev, struct sk_buff *skb) 82static int genelink_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
237{ 83{
238 struct gl_header *header; 84 struct gl_header *header;
diff --git a/drivers/usb/net/rtl8150.c b/drivers/usb/net/rtl8150.c
index c54235f73cb6..e0eecda78ec1 100644
--- a/drivers/usb/net/rtl8150.c
+++ b/drivers/usb/net/rtl8150.c
@@ -124,10 +124,11 @@
124#define RX_URB_FAIL 3 124#define RX_URB_FAIL 3
125 125
126/* Define these values to match your device */ 126/* Define these values to match your device */
127#define VENDOR_ID_REALTEK 0x0bda 127#define VENDOR_ID_REALTEK 0x0bda
128#define VENDOR_ID_MELCO 0x0411 128#define VENDOR_ID_MELCO 0x0411
129#define VENDOR_ID_MICRONET 0x3980 129#define VENDOR_ID_MICRONET 0x3980
130#define VENDOR_ID_LONGSHINE 0x07b8 130#define VENDOR_ID_LONGSHINE 0x07b8
131#define VENDOR_ID_OQO 0x1557
131#define VENDOR_ID_ZYXEL 0x0586 132#define VENDOR_ID_ZYXEL 0x0586
132 133
133#define PRODUCT_ID_RTL8150 0x8150 134#define PRODUCT_ID_RTL8150 0x8150
@@ -144,6 +145,7 @@ static struct usb_device_id rtl8150_table[] = {
144 {USB_DEVICE(VENDOR_ID_MELCO, PRODUCT_ID_LUAKTX)}, 145 {USB_DEVICE(VENDOR_ID_MELCO, PRODUCT_ID_LUAKTX)},
145 {USB_DEVICE(VENDOR_ID_MICRONET, PRODUCT_ID_SP128AR)}, 146 {USB_DEVICE(VENDOR_ID_MICRONET, PRODUCT_ID_SP128AR)},
146 {USB_DEVICE(VENDOR_ID_LONGSHINE, PRODUCT_ID_LCS8138TX)}, 147 {USB_DEVICE(VENDOR_ID_LONGSHINE, PRODUCT_ID_LCS8138TX)},
148 {USB_DEVICE(VENDOR_ID_OQO, PRODUCT_ID_RTL8150)},
147 {USB_DEVICE(VENDOR_ID_ZYXEL, PRODUCT_ID_PRESTIGE)}, 149 {USB_DEVICE(VENDOR_ID_ZYXEL, PRODUCT_ID_PRESTIGE)},
148 {} 150 {}
149}; 151};
diff --git a/drivers/usb/serial/airprime.c b/drivers/usb/serial/airprime.c
index 96c73726d74a..f2ca76a9cbac 100644
--- a/drivers/usb/serial/airprime.c
+++ b/drivers/usb/serial/airprime.c
@@ -19,8 +19,11 @@
19static struct usb_device_id id_table [] = { 19static struct usb_device_id id_table [] = {
20 { USB_DEVICE(0x0c88, 0x17da) }, /* Kyocera Wireless KPC650/Passport */ 20 { USB_DEVICE(0x0c88, 0x17da) }, /* Kyocera Wireless KPC650/Passport */
21 { USB_DEVICE(0x1410, 0x1110) }, /* Novatel Wireless Merlin CDMA */ 21 { USB_DEVICE(0x1410, 0x1110) }, /* Novatel Wireless Merlin CDMA */
22 { USB_DEVICE(0x1410, 0x1130) }, /* Novatel Wireless S720 CDMA/EV-DO */
23 { USB_DEVICE(0x1410, 0x2110) }, /* Novatel Wireless U720 CDMA/EV-DO */
22 { USB_DEVICE(0x1410, 0x1430) }, /* Novatel Merlin XU870 HSDPA/3G */ 24 { USB_DEVICE(0x1410, 0x1430) }, /* Novatel Merlin XU870 HSDPA/3G */
23 { USB_DEVICE(0x1410, 0x1100) }, /* ExpressCard34 Qualcomm 3G CDMA */ 25 { USB_DEVICE(0x1410, 0x1100) }, /* ExpressCard34 Qualcomm 3G CDMA */
26 { USB_DEVICE(0x413c, 0x8115) }, /* Dell Wireless HSDPA 5500 */
24 { }, 27 { },
25}; 28};
26MODULE_DEVICE_TABLE(usb, id_table); 29MODULE_DEVICE_TABLE(usb, id_table);
diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp2101.c
index 2f9b7ac32663..7ebaffd6ed86 100644
--- a/drivers/usb/serial/cp2101.c
+++ b/drivers/usb/serial/cp2101.c
@@ -69,6 +69,7 @@ static struct usb_device_id id_table [] = {
69 { USB_DEVICE(0x10C4, 0x8218) }, /* Lipowsky Industrie Elektronik GmbH, HARP-1 */ 69 { USB_DEVICE(0x10C4, 0x8218) }, /* Lipowsky Industrie Elektronik GmbH, HARP-1 */
70 { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */ 70 { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */
71 { USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */ 71 { USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */
72 { USB_DEVICE(0x13AD, 0x9999) }, /* Baltech card reader */
72 { USB_DEVICE(0x16D6, 0x0001) }, /* Jablotron serial interface */ 73 { USB_DEVICE(0x16D6, 0x0001) }, /* Jablotron serial interface */
73 { } /* Terminating Entry */ 74 { } /* Terminating Entry */
74}; 75};
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c
index 45cdf9bc43b2..6bc1f404e186 100644
--- a/drivers/usb/serial/cypress_m8.c
+++ b/drivers/usb/serial/cypress_m8.c
@@ -962,21 +962,6 @@ static int cypress_ioctl (struct usb_serial_port *port, struct file * file, unsi
962 cypress_set_termios(port, &priv->tmp_termios); 962 cypress_set_termios(port, &priv->tmp_termios);
963 return (0); 963 return (0);
964 break; 964 break;
965 /* these are called when setting baud rate from gpsd */
966 case TCGETS:
967 if (copy_to_user((void __user *)arg, port->tty->termios, sizeof(struct termios))) {
968 return -EFAULT;
969 }
970 return (0);
971 break;
972 case TCSETS:
973 if (copy_from_user(port->tty->termios, (void __user *)arg, sizeof(struct termios))) {
974 return -EFAULT;
975 }
976 /* here we need to call cypress_set_termios to invoke the new settings */
977 cypress_set_termios(port, &priv->tmp_termios);
978 return (0);
979 break;
980 /* This code comes from drivers/char/serial.c and ftdi_sio.c */ 965 /* This code comes from drivers/char/serial.c and ftdi_sio.c */
981 case TIOCMIWAIT: 966 case TIOCMIWAIT:
982 while (priv != NULL) { 967 while (priv != NULL) {
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 41b0ad2d56ac..6986e756f7c0 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -452,6 +452,7 @@ static struct usb_device_id id_table_combined [] = {
452 { USB_DEVICE(FTDI_VID, LINX_FUTURE_2_PID) }, 452 { USB_DEVICE(FTDI_VID, LINX_FUTURE_2_PID) },
453 { USB_DEVICE(FTDI_VID, FTDI_CCSICDU20_0_PID) }, 453 { USB_DEVICE(FTDI_VID, FTDI_CCSICDU20_0_PID) },
454 { USB_DEVICE(FTDI_VID, FTDI_CCSICDU40_1_PID) }, 454 { USB_DEVICE(FTDI_VID, FTDI_CCSICDU40_1_PID) },
455 { USB_DEVICE(FTDI_VID, FTDI_CCSMACHX_2_PID) },
455 { USB_DEVICE(FTDI_VID, INSIDE_ACCESSO) }, 456 { USB_DEVICE(FTDI_VID, INSIDE_ACCESSO) },
456 { USB_DEVICE(INTREPID_VID, INTREPID_VALUECAN_PID) }, 457 { USB_DEVICE(INTREPID_VID, INTREPID_VALUECAN_PID) },
457 { USB_DEVICE(INTREPID_VID, INTREPID_NEOVI_PID) }, 458 { USB_DEVICE(INTREPID_VID, INTREPID_NEOVI_PID) },
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h
index bae117d359af..40dd394de58d 100644
--- a/drivers/usb/serial/ftdi_sio.h
+++ b/drivers/usb/serial/ftdi_sio.h
@@ -312,8 +312,9 @@
312 312
313/* CCS Inc. ICDU/ICDU40 product ID - the FT232BM is used in an in-circuit-debugger */ 313/* CCS Inc. ICDU/ICDU40 product ID - the FT232BM is used in an in-circuit-debugger */
314/* unit for PIC16's/PIC18's */ 314/* unit for PIC16's/PIC18's */
315#define FTDI_CCSICDU20_0_PID 0xF9D0 315#define FTDI_CCSICDU20_0_PID 0xF9D0
316#define FTDI_CCSICDU40_1_PID 0xF9D1 316#define FTDI_CCSICDU40_1_PID 0xF9D1
317#define FTDI_CCSMACHX_2_PID 0xF9D2
317 318
318/* Inside Accesso contactless reader (http://www.insidefr.com) */ 319/* Inside Accesso contactless reader (http://www.insidefr.com) */
319#define INSIDE_ACCESSO 0xFAD0 320#define INSIDE_ACCESSO 0xFAD0
diff --git a/drivers/usb/serial/funsoft.c b/drivers/usb/serial/funsoft.c
index 77b977206a8c..d3be9214c7c1 100644
--- a/drivers/usb/serial/funsoft.c
+++ b/drivers/usb/serial/funsoft.c
@@ -14,6 +14,9 @@
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/usb.h> 15#include <linux/usb.h>
16#include <linux/usb/serial.h> 16#include <linux/usb/serial.h>
17#include <asm/uaccess.h>
18
19static int debug;
17 20
18static struct usb_device_id id_table [] = { 21static struct usb_device_id id_table [] = {
19 { USB_DEVICE(0x1404, 0xcddc) }, 22 { USB_DEVICE(0x1404, 0xcddc) },
@@ -21,6 +24,26 @@ static struct usb_device_id id_table [] = {
21}; 24};
22MODULE_DEVICE_TABLE(usb, id_table); 25MODULE_DEVICE_TABLE(usb, id_table);
23 26
27static int funsoft_ioctl(struct usb_serial_port *port, struct file *file,
28 unsigned int cmd, unsigned long arg)
29{
30 struct termios t;
31
32 dbg("%s - port %d, cmd 0x%04x", __FUNCTION__, port->number, cmd);
33
34 if (cmd == TCSETSF) {
35 if (user_termios_to_kernel_termios(&t, (void __user *)arg))
36 return -EFAULT;
37
38 dbg("%s - iflag:%x oflag:%x cflag:%x lflag:%x", __FUNCTION__,
39 t.c_iflag, t.c_oflag, t.c_cflag, t.c_lflag);
40
41 if (!(t.c_lflag & ICANON))
42 return -EINVAL;
43 }
44 return -ENOIOCTLCMD;
45}
46
24static struct usb_driver funsoft_driver = { 47static struct usb_driver funsoft_driver = {
25 .name = "funsoft", 48 .name = "funsoft",
26 .probe = usb_serial_probe, 49 .probe = usb_serial_probe,
@@ -39,6 +62,7 @@ static struct usb_serial_driver funsoft_device = {
39 .num_bulk_in = NUM_DONT_CARE, 62 .num_bulk_in = NUM_DONT_CARE,
40 .num_bulk_out = NUM_DONT_CARE, 63 .num_bulk_out = NUM_DONT_CARE,
41 .num_ports = 1, 64 .num_ports = 1,
65 .ioctl = funsoft_ioctl,
42}; 66};
43 67
44static int __init funsoft_init(void) 68static int __init funsoft_init(void)
@@ -63,3 +87,6 @@ static void __exit funsoft_exit(void)
63module_init(funsoft_init); 87module_init(funsoft_init);
64module_exit(funsoft_exit); 88module_exit(funsoft_exit);
65MODULE_LICENSE("GPL"); 89MODULE_LICENSE("GPL");
90
91module_param(debug, bool, S_IRUGO | S_IWUSR);
92MODULE_PARM_DESC(debug, "Debug enabled or not");
diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c
index 73d755df4840..5c4b06a99ac0 100644
--- a/drivers/usb/serial/kl5kusb105.c
+++ b/drivers/usb/serial/kl5kusb105.c
@@ -87,10 +87,6 @@ static int klsi_105_write_room (struct usb_serial_port *port);
87static void klsi_105_read_bulk_callback (struct urb *urb); 87static void klsi_105_read_bulk_callback (struct urb *urb);
88static void klsi_105_set_termios (struct usb_serial_port *port, 88static void klsi_105_set_termios (struct usb_serial_port *port,
89 struct ktermios *old); 89 struct ktermios *old);
90static int klsi_105_ioctl (struct usb_serial_port *port,
91 struct file * file,
92 unsigned int cmd,
93 unsigned long arg);
94static void klsi_105_throttle (struct usb_serial_port *port); 90static void klsi_105_throttle (struct usb_serial_port *port);
95static void klsi_105_unthrottle (struct usb_serial_port *port); 91static void klsi_105_unthrottle (struct usb_serial_port *port);
96/* 92/*
@@ -140,7 +136,6 @@ static struct usb_serial_driver kl5kusb105d_device = {
140 .chars_in_buffer = klsi_105_chars_in_buffer, 136 .chars_in_buffer = klsi_105_chars_in_buffer,
141 .write_room = klsi_105_write_room, 137 .write_room = klsi_105_write_room,
142 .read_bulk_callback =klsi_105_read_bulk_callback, 138 .read_bulk_callback =klsi_105_read_bulk_callback,
143 .ioctl = klsi_105_ioctl,
144 .set_termios = klsi_105_set_termios, 139 .set_termios = klsi_105_set_termios,
145 /*.break_ctl = klsi_105_break_ctl,*/ 140 /*.break_ctl = klsi_105_break_ctl,*/
146 .tiocmget = klsi_105_tiocmget, 141 .tiocmget = klsi_105_tiocmget,
@@ -899,69 +894,6 @@ static int klsi_105_tiocmset (struct usb_serial_port *port, struct file *file,
899*/ 894*/
900 return retval; 895 return retval;
901} 896}
902
903static int klsi_105_ioctl (struct usb_serial_port *port, struct file * file,
904 unsigned int cmd, unsigned long arg)
905{
906 struct klsi_105_private *priv = usb_get_serial_port_data(port);
907 void __user *user_arg = (void __user *)arg;
908
909 dbg("%scmd=0x%x", __FUNCTION__, cmd);
910
911 /* Based on code from acm.c and others */
912 switch (cmd) {
913 case TIOCMIWAIT:
914 /* wait for any of the 4 modem inputs (DCD,RI,DSR,CTS)*/
915 /* TODO */
916 dbg("%s - TIOCMIWAIT not handled", __FUNCTION__);
917 return -ENOIOCTLCMD;
918 case TIOCGICOUNT:
919 /* return count of modemline transitions */
920 /* TODO */
921 dbg("%s - TIOCGICOUNT not handled", __FUNCTION__);
922 return -ENOIOCTLCMD;
923 case TCGETS:
924 /* return current info to caller */
925 dbg("%s - TCGETS data faked/incomplete", __FUNCTION__);
926
927 if (!access_ok(VERIFY_WRITE, user_arg, sizeof(struct termios)))
928 return -EFAULT;
929
930 if (kernel_termios_to_user_termios((struct termios __user *)arg,
931 &priv->termios))
932 return -EFAULT;
933 return 0;
934 case TCSETS:
935 /* set port termios to the one given by the user */
936 dbg("%s - TCSETS not handled", __FUNCTION__);
937
938 if (!access_ok(VERIFY_READ, user_arg, sizeof(struct termios)))
939 return -EFAULT;
940
941 if (user_termios_to_kernel_termios(&priv->termios,
942 (struct termios __user *)arg))
943 return -EFAULT;
944 klsi_105_set_termios(port, &priv->termios);
945 return 0;
946 case TCSETSW: {
947 /* set port termios and try to wait for completion of last
948 * write operation */
949 /* We guess here. If there are not too many write urbs
950 * outstanding, we lie. */
951 /* what is the right way to wait here? schedule() ? */
952 /*
953 while (klsi_105_chars_in_buffer(port) > (NUM_URBS / 4 ) * URB_TRANSFER_BUFFER_SIZE)
954 schedule();
955 */
956 return -ENOIOCTLCMD;
957 }
958 default:
959 dbg("%s: arg not supported - 0x%04x", __FUNCTION__,cmd);
960 return(-ENOIOCTLCMD);
961 break;
962 }
963 return 0;
964} /* klsi_105_ioctl */
965 897
966static void klsi_105_throttle (struct usb_serial_port *port) 898static void klsi_105_throttle (struct usb_serial_port *port)
967{ 899{
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index 8cc728a49e41..83f661403ba1 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -2460,12 +2460,6 @@ static int mos7840_ioctl(struct usb_serial_port *port, struct file *file,
2460 tty_ldisc_deref(ld); 2460 tty_ldisc_deref(ld);
2461 return 0; 2461 return 0;
2462 2462
2463 case TCGETS:
2464 if (kernel_termios_to_user_termios
2465 ((struct termios __user *)argp, tty->termios))
2466 return -EFAULT;
2467 return 0;
2468
2469 case TIOCSERGETLSR: 2463 case TIOCSERGETLSR:
2470 dbg("%s (%d) TIOCSERGETLSR", __FUNCTION__, port->number); 2464 dbg("%s (%d) TIOCSERGETLSR", __FUNCTION__, port->number);
2471 return mos7840_get_lsr_info(mos7840_port, argp); 2465 return mos7840_get_lsr_info(mos7840_port, argp);
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 0ae4098718c3..819266b7e2f8 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -79,6 +79,7 @@ static int option_send_setup(struct usb_serial_port *port);
79#define OPTION_PRODUCT_COBRA 0x6500 79#define OPTION_PRODUCT_COBRA 0x6500
80#define OPTION_PRODUCT_COBRA2 0x6600 80#define OPTION_PRODUCT_COBRA2 0x6600
81#define HUAWEI_PRODUCT_E600 0x1001 81#define HUAWEI_PRODUCT_E600 0x1001
82#define HUAWEI_PRODUCT_E220 0x1003
82#define AUDIOVOX_PRODUCT_AIRCARD 0x0112 83#define AUDIOVOX_PRODUCT_AIRCARD 0x0112
83#define NOVATELWIRELESS_PRODUCT_U740 0x1400 84#define NOVATELWIRELESS_PRODUCT_U740 0x1400
84#define ANYDATA_PRODUCT_ID 0x6501 85#define ANYDATA_PRODUCT_ID 0x6501
@@ -90,6 +91,7 @@ static struct usb_device_id option_ids[] = {
90 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COBRA) }, 91 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COBRA) },
91 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COBRA2) }, 92 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COBRA2) },
92 { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E600) }, 93 { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E600) },
94 { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E220) },
93 { USB_DEVICE(AUDIOVOX_VENDOR_ID, AUDIOVOX_PRODUCT_AIRCARD) }, 95 { USB_DEVICE(AUDIOVOX_VENDOR_ID, AUDIOVOX_PRODUCT_AIRCARD) },
94 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID,NOVATELWIRELESS_PRODUCT_U740) }, 96 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID,NOVATELWIRELESS_PRODUCT_U740) },
95 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ID) }, 97 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ID) },
@@ -103,6 +105,7 @@ static struct usb_device_id option_ids1[] = {
103 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COBRA) }, 105 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COBRA) },
104 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COBRA2) }, 106 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COBRA2) },
105 { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E600) }, 107 { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E600) },
108 { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E220) },
106 { USB_DEVICE(AUDIOVOX_VENDOR_ID, AUDIOVOX_PRODUCT_AIRCARD) }, 109 { USB_DEVICE(AUDIOVOX_VENDOR_ID, AUDIOVOX_PRODUCT_AIRCARD) },
107 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID,NOVATELWIRELESS_PRODUCT_U740) }, 110 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID,NOVATELWIRELESS_PRODUCT_U740) },
108 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ID) }, 111 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ID) },
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index db8b26012c75..5fe7ff441a09 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -153,6 +153,13 @@ UNUSUAL_DEV( 0x0421, 0x042e, 0x0100, 0x0100,
153 US_SC_DEVICE, US_PR_DEVICE, NULL, 153 US_SC_DEVICE, US_PR_DEVICE, NULL,
154 US_FL_IGNORE_RESIDUE | US_FL_FIX_CAPACITY ), 154 US_FL_IGNORE_RESIDUE | US_FL_FIX_CAPACITY ),
155 155
156/* Reported by <honkkis@gmail.com> */
157UNUSUAL_DEV( 0x0421, 0x0433, 0x0100, 0x0100,
158 "Nokia",
159 "E70",
160 US_SC_DEVICE, US_PR_DEVICE, NULL,
161 US_FL_IGNORE_RESIDUE | US_FL_FIX_CAPACITY ),
162
156/* Reported by Jon Hart <Jon.Hart@web.de> */ 163/* Reported by Jon Hart <Jon.Hart@web.de> */
157UNUSUAL_DEV( 0x0421, 0x0434, 0x0100, 0x0100, 164UNUSUAL_DEV( 0x0421, 0x0434, 0x0100, 0x0100,
158 "Nokia", 165 "Nokia",
@@ -1328,6 +1335,15 @@ UNUSUAL_DEV( 0x1210, 0x0003, 0x0100, 0x0100,
1328 US_SC_DEVICE, US_PR_DEVICE, NULL, 1335 US_SC_DEVICE, US_PR_DEVICE, NULL,
1329 US_FL_IGNORE_RESIDUE ), 1336 US_FL_IGNORE_RESIDUE ),
1330 1337
1338/* This prevents the kernel from detecting the virtual cd-drive with the
1339 * Windows drivers. <johann.wilhelm@student.tugraz.at>
1340*/
1341UNUSUAL_DEV( 0x12d1, 0x1003, 0x0000, 0xffff,
1342 "HUAWEI",
1343 "E220 USB-UMTS Install",
1344 US_SC_DEVICE, US_PR_DEVICE, NULL,
1345 US_FL_IGNORE_DEVICE),
1346
1331/* Reported by Vilius Bilinkevicius <vilisas AT xxx DOT lt) */ 1347/* Reported by Vilius Bilinkevicius <vilisas AT xxx DOT lt) */
1332UNUSUAL_DEV( 0x132b, 0x000b, 0x0001, 0x0001, 1348UNUSUAL_DEV( 0x132b, 0x000b, 0x0001, 0x0001,
1333 "Minolta", 1349 "Minolta",