aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host
diff options
context:
space:
mode:
authorDavid Vrabel <david.vrabel@csr.com>2008-10-20 11:07:19 -0400
committerDavid Vrabel <david.vrabel@csr.com>2008-10-20 11:07:19 -0400
commit61e0e79ee3c609eb34edf2fe023708cba6a79b1f (patch)
tree663deacffd4071120dc9badb70428fe5f124c7b9 /drivers/usb/host
parentc15895ef30c2c03e99802951787183039a349d32 (diff)
parent0cfd81031a26717fe14380d18275f8e217571615 (diff)
Merge branch 'master' into for-upstream
Conflicts: Documentation/ABI/testing/sysfs-bus-usb drivers/Makefile
Diffstat (limited to 'drivers/usb/host')
-rw-r--r--drivers/usb/host/ehci-dbg.c56
-rw-r--r--drivers/usb/host/ehci-hcd.c48
-rw-r--r--drivers/usb/host/ehci-hub.c27
-rw-r--r--drivers/usb/host/ehci-ixp4xx.c2
-rw-r--r--drivers/usb/host/ehci-ppc-soc.c201
-rw-r--r--drivers/usb/host/ehci.h161
-rw-r--r--drivers/usb/host/isp116x-hcd.c13
-rw-r--r--drivers/usb/host/isp1760-if.c7
-rw-r--r--drivers/usb/host/ohci-dbg.c2
-rw-r--r--drivers/usb/host/ohci-hcd.c10
-rw-r--r--drivers/usb/host/ohci-hub.c87
-rw-r--r--drivers/usb/host/ohci-omap.c18
-rw-r--r--drivers/usb/host/ohci-pnx4008.c2
-rw-r--r--drivers/usb/host/ohci-pxa27x.c259
-rw-r--r--drivers/usb/host/ohci.h8
-rw-r--r--drivers/usb/host/r8a66597-hcd.c101
-rw-r--r--drivers/usb/host/sl811-hcd.c15
-rw-r--r--drivers/usb/host/sl811_cs.c133
-rw-r--r--drivers/usb/host/uhci-hcd.c10
-rw-r--r--drivers/usb/host/uhci-q.c41
20 files changed, 537 insertions, 664 deletions
diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c
index b0f8ed5a7fb9..0cb53ca8d343 100644
--- a/drivers/usb/host/ehci-dbg.c
+++ b/drivers/usb/host/ehci-dbg.c
@@ -358,7 +358,8 @@ struct debug_buffer {
358 struct usb_bus *bus; 358 struct usb_bus *bus;
359 struct mutex mutex; /* protect filling of buffer */ 359 struct mutex mutex; /* protect filling of buffer */
360 size_t count; /* number of characters filled into buffer */ 360 size_t count; /* number of characters filled into buffer */
361 char *page; 361 char *output_buf;
362 size_t alloc_size;
362}; 363};
363 364
364#define speed_char(info1) ({ char tmp; \ 365#define speed_char(info1) ({ char tmp; \
@@ -488,8 +489,8 @@ static ssize_t fill_async_buffer(struct debug_buffer *buf)
488 489
489 hcd = bus_to_hcd(buf->bus); 490 hcd = bus_to_hcd(buf->bus);
490 ehci = hcd_to_ehci (hcd); 491 ehci = hcd_to_ehci (hcd);
491 next = buf->page; 492 next = buf->output_buf;
492 size = PAGE_SIZE; 493 size = buf->alloc_size;
493 494
494 *next = 0; 495 *next = 0;
495 496
@@ -510,7 +511,7 @@ static ssize_t fill_async_buffer(struct debug_buffer *buf)
510 } 511 }
511 spin_unlock_irqrestore (&ehci->lock, flags); 512 spin_unlock_irqrestore (&ehci->lock, flags);
512 513
513 return strlen(buf->page); 514 return strlen(buf->output_buf);
514} 515}
515 516
516#define DBG_SCHED_LIMIT 64 517#define DBG_SCHED_LIMIT 64
@@ -531,8 +532,8 @@ static ssize_t fill_periodic_buffer(struct debug_buffer *buf)
531 532
532 hcd = bus_to_hcd(buf->bus); 533 hcd = bus_to_hcd(buf->bus);
533 ehci = hcd_to_ehci (hcd); 534 ehci = hcd_to_ehci (hcd);
534 next = buf->page; 535 next = buf->output_buf;
535 size = PAGE_SIZE; 536 size = buf->alloc_size;
536 537
537 temp = scnprintf (next, size, "size = %d\n", ehci->periodic_size); 538 temp = scnprintf (next, size, "size = %d\n", ehci->periodic_size);
538 size -= temp; 539 size -= temp;
@@ -568,14 +569,16 @@ static ssize_t fill_periodic_buffer(struct debug_buffer *buf)
568 for (temp = 0; temp < seen_count; temp++) { 569 for (temp = 0; temp < seen_count; temp++) {
569 if (seen [temp].ptr != p.ptr) 570 if (seen [temp].ptr != p.ptr)
570 continue; 571 continue;
571 if (p.qh->qh_next.ptr) 572 if (p.qh->qh_next.ptr) {
572 temp = scnprintf (next, size, 573 temp = scnprintf (next, size,
573 " ..."); 574 " ...");
574 p.ptr = NULL; 575 size -= temp;
576 next += temp;
577 }
575 break; 578 break;
576 } 579 }
577 /* show more info the first time around */ 580 /* show more info the first time around */
578 if (temp == seen_count && p.ptr) { 581 if (temp == seen_count) {
579 u32 scratch = hc32_to_cpup(ehci, 582 u32 scratch = hc32_to_cpup(ehci,
580 &p.qh->hw_info1); 583 &p.qh->hw_info1);
581 struct ehci_qtd *qtd; 584 struct ehci_qtd *qtd;
@@ -649,7 +652,7 @@ static ssize_t fill_periodic_buffer(struct debug_buffer *buf)
649 spin_unlock_irqrestore (&ehci->lock, flags); 652 spin_unlock_irqrestore (&ehci->lock, flags);
650 kfree (seen); 653 kfree (seen);
651 654
652 return PAGE_SIZE - size; 655 return buf->alloc_size - size;
653} 656}
654#undef DBG_SCHED_LIMIT 657#undef DBG_SCHED_LIMIT
655 658
@@ -665,14 +668,14 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
665 668
666 hcd = bus_to_hcd(buf->bus); 669 hcd = bus_to_hcd(buf->bus);
667 ehci = hcd_to_ehci (hcd); 670 ehci = hcd_to_ehci (hcd);
668 next = buf->page; 671 next = buf->output_buf;
669 size = PAGE_SIZE; 672 size = buf->alloc_size;
670 673
671 spin_lock_irqsave (&ehci->lock, flags); 674 spin_lock_irqsave (&ehci->lock, flags);
672 675
673 if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) { 676 if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) {
674 size = scnprintf (next, size, 677 size = scnprintf (next, size,
675 "bus %s, device %s (driver " DRIVER_VERSION ")\n" 678 "bus %s, device %s\n"
676 "%s\n" 679 "%s\n"
677 "SUSPENDED (no register access)\n", 680 "SUSPENDED (no register access)\n",
678 hcd->self.controller->bus->name, 681 hcd->self.controller->bus->name,
@@ -684,7 +687,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
684 /* Capability Registers */ 687 /* Capability Registers */
685 i = HC_VERSION(ehci_readl(ehci, &ehci->caps->hc_capbase)); 688 i = HC_VERSION(ehci_readl(ehci, &ehci->caps->hc_capbase));
686 temp = scnprintf (next, size, 689 temp = scnprintf (next, size,
687 "bus %s, device %s (driver " DRIVER_VERSION ")\n" 690 "bus %s, device %s\n"
688 "%s\n" 691 "%s\n"
689 "EHCI %x.%02x, hcd state %d\n", 692 "EHCI %x.%02x, hcd state %d\n",
690 hcd->self.controller->bus->name, 693 hcd->self.controller->bus->name,
@@ -808,7 +811,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
808done: 811done:
809 spin_unlock_irqrestore (&ehci->lock, flags); 812 spin_unlock_irqrestore (&ehci->lock, flags);
810 813
811 return PAGE_SIZE - size; 814 return buf->alloc_size - size;
812} 815}
813 816
814static struct debug_buffer *alloc_buffer(struct usb_bus *bus, 817static struct debug_buffer *alloc_buffer(struct usb_bus *bus,
@@ -822,6 +825,7 @@ static struct debug_buffer *alloc_buffer(struct usb_bus *bus,
822 buf->bus = bus; 825 buf->bus = bus;
823 buf->fill_func = fill_func; 826 buf->fill_func = fill_func;
824 mutex_init(&buf->mutex); 827 mutex_init(&buf->mutex);
828 buf->alloc_size = PAGE_SIZE;
825 } 829 }
826 830
827 return buf; 831 return buf;
@@ -831,10 +835,10 @@ static int fill_buffer(struct debug_buffer *buf)
831{ 835{
832 int ret = 0; 836 int ret = 0;
833 837
834 if (!buf->page) 838 if (!buf->output_buf)
835 buf->page = (char *)get_zeroed_page(GFP_KERNEL); 839 buf->output_buf = (char *)vmalloc(buf->alloc_size);
836 840
837 if (!buf->page) { 841 if (!buf->output_buf) {
838 ret = -ENOMEM; 842 ret = -ENOMEM;
839 goto out; 843 goto out;
840 } 844 }
@@ -867,7 +871,7 @@ static ssize_t debug_output(struct file *file, char __user *user_buf,
867 mutex_unlock(&buf->mutex); 871 mutex_unlock(&buf->mutex);
868 872
869 ret = simple_read_from_buffer(user_buf, len, offset, 873 ret = simple_read_from_buffer(user_buf, len, offset,
870 buf->page, buf->count); 874 buf->output_buf, buf->count);
871 875
872out: 876out:
873 return ret; 877 return ret;
@@ -879,8 +883,8 @@ static int debug_close(struct inode *inode, struct file *file)
879 struct debug_buffer *buf = file->private_data; 883 struct debug_buffer *buf = file->private_data;
880 884
881 if (buf) { 885 if (buf) {
882 if (buf->page) 886 if (buf->output_buf)
883 free_page((unsigned long)buf->page); 887 vfree(buf->output_buf);
884 kfree(buf); 888 kfree(buf);
885 } 889 }
886 890
@@ -895,10 +899,14 @@ static int debug_async_open(struct inode *inode, struct file *file)
895 899
896static int debug_periodic_open(struct inode *inode, struct file *file) 900static int debug_periodic_open(struct inode *inode, struct file *file)
897{ 901{
898 file->private_data = alloc_buffer(inode->i_private, 902 struct debug_buffer *buf;
899 fill_periodic_buffer); 903 buf = alloc_buffer(inode->i_private, fill_periodic_buffer);
904 if (!buf)
905 return -ENOMEM;
900 906
901 return file->private_data ? 0 : -ENOMEM; 907 buf->alloc_size = (sizeof(void *) == 4 ? 6 : 8)*PAGE_SIZE;
908 file->private_data = buf;
909 return 0;
902} 910}
903 911
904static int debug_registers_open(struct inode *inode, struct file *file) 912static int debug_registers_open(struct inode *inode, struct file *file)
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 8409e0705d63..d343afacb0b0 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -24,6 +24,7 @@
24#include <linux/ioport.h> 24#include <linux/ioport.h>
25#include <linux/sched.h> 25#include <linux/sched.h>
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/vmalloc.h>
27#include <linux/errno.h> 28#include <linux/errno.h>
28#include <linux/init.h> 29#include <linux/init.h>
29#include <linux/timer.h> 30#include <linux/timer.h>
@@ -59,7 +60,6 @@
59 * providing early devices for those host controllers to talk to! 60 * providing early devices for those host controllers to talk to!
60 */ 61 */
61 62
62#define DRIVER_VERSION "10 Dec 2004"
63#define DRIVER_AUTHOR "David Brownell" 63#define DRIVER_AUTHOR "David Brownell"
64#define DRIVER_DESC "USB 2.0 'Enhanced' Host Controller (EHCI) Driver" 64#define DRIVER_DESC "USB 2.0 'Enhanced' Host Controller (EHCI) Driver"
65 65
@@ -620,9 +620,9 @@ static int ehci_run (struct usb_hcd *hcd)
620 620
621 temp = HC_VERSION(ehci_readl(ehci, &ehci->caps->hc_capbase)); 621 temp = HC_VERSION(ehci_readl(ehci, &ehci->caps->hc_capbase));
622 ehci_info (ehci, 622 ehci_info (ehci,
623 "USB %x.%x started, EHCI %x.%02x, driver %s%s\n", 623 "USB %x.%x started, EHCI %x.%02x%s\n",
624 ((ehci->sbrn & 0xf0)>>4), (ehci->sbrn & 0x0f), 624 ((ehci->sbrn & 0xf0)>>4), (ehci->sbrn & 0x0f),
625 temp >> 8, temp & 0xff, DRIVER_VERSION, 625 temp >> 8, temp & 0xff,
626 ignore_oc ? ", overcurrent ignored" : ""); 626 ignore_oc ? ", overcurrent ignored" : "");
627 627
628 ehci_writel(ehci, INTR_MASK, 628 ehci_writel(ehci, INTR_MASK,
@@ -706,7 +706,7 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd)
706 pcd_status = status; 706 pcd_status = status;
707 707
708 /* resume root hub? */ 708 /* resume root hub? */
709 if (!(ehci_readl(ehci, &ehci->regs->command) & CMD_RUN)) 709 if (!(cmd & CMD_RUN))
710 usb_hcd_resume_root_hub(hcd); 710 usb_hcd_resume_root_hub(hcd);
711 711
712 while (i--) { 712 while (i--) {
@@ -715,8 +715,11 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd)
715 715
716 if (pstatus & PORT_OWNER) 716 if (pstatus & PORT_OWNER)
717 continue; 717 continue;
718 if (!(pstatus & PORT_RESUME) 718 if (!(test_bit(i, &ehci->suspended_ports) &&
719 || ehci->reset_done [i] != 0) 719 ((pstatus & PORT_RESUME) ||
720 !(pstatus & PORT_SUSPEND)) &&
721 (pstatus & PORT_PE) &&
722 ehci->reset_done[i] == 0))
720 continue; 723 continue;
721 724
722 /* start 20 msec resume signaling from this port, 725 /* start 20 msec resume signaling from this port,
@@ -731,9 +734,8 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd)
731 734
732 /* PCI errors [4.15.2.4] */ 735 /* PCI errors [4.15.2.4] */
733 if (unlikely ((status & STS_FATAL) != 0)) { 736 if (unlikely ((status & STS_FATAL) != 0)) {
734 dbg_cmd (ehci, "fatal", ehci_readl(ehci, 737 dbg_cmd(ehci, "fatal", cmd);
735 &ehci->regs->command)); 738 dbg_status(ehci, "fatal", status);
736 dbg_status (ehci, "fatal", status);
737 if (status & STS_HALT) { 739 if (status & STS_HALT) {
738 ehci_err (ehci, "fatal error\n"); 740 ehci_err (ehci, "fatal error\n");
739dead: 741dead:
@@ -994,9 +996,7 @@ static int ehci_get_frame (struct usb_hcd *hcd)
994 996
995/*-------------------------------------------------------------------------*/ 997/*-------------------------------------------------------------------------*/
996 998
997#define DRIVER_INFO DRIVER_VERSION " " DRIVER_DESC 999MODULE_DESCRIPTION(DRIVER_DESC);
998
999MODULE_DESCRIPTION (DRIVER_INFO);
1000MODULE_AUTHOR (DRIVER_AUTHOR); 1000MODULE_AUTHOR (DRIVER_AUTHOR);
1001MODULE_LICENSE ("GPL"); 1001MODULE_LICENSE ("GPL");
1002 1002
@@ -1020,11 +1020,6 @@ MODULE_LICENSE ("GPL");
1020#define PS3_SYSTEM_BUS_DRIVER ps3_ehci_driver 1020#define PS3_SYSTEM_BUS_DRIVER ps3_ehci_driver
1021#endif 1021#endif
1022 1022
1023#if defined(CONFIG_440EPX) && !defined(CONFIG_PPC_MERGE)
1024#include "ehci-ppc-soc.c"
1025#define PLATFORM_DRIVER ehci_ppc_soc_driver
1026#endif
1027
1028#ifdef CONFIG_USB_EHCI_HCD_PPC_OF 1023#ifdef CONFIG_USB_EHCI_HCD_PPC_OF
1029#include "ehci-ppc-of.c" 1024#include "ehci-ppc-of.c"
1030#define OF_PLATFORM_DRIVER ehci_hcd_ppc_of_driver 1025#define OF_PLATFORM_DRIVER ehci_hcd_ppc_of_driver
@@ -1049,6 +1044,16 @@ static int __init ehci_hcd_init(void)
1049{ 1044{
1050 int retval = 0; 1045 int retval = 0;
1051 1046
1047 if (usb_disabled())
1048 return -ENODEV;
1049
1050 printk(KERN_INFO "%s: " DRIVER_DESC "\n", hcd_name);
1051 set_bit(USB_EHCI_LOADED, &usb_hcds_loaded);
1052 if (test_bit(USB_UHCI_LOADED, &usb_hcds_loaded) ||
1053 test_bit(USB_OHCI_LOADED, &usb_hcds_loaded))
1054 printk(KERN_WARNING "Warning! ehci_hcd should always be loaded"
1055 " before uhci_hcd and ohci_hcd, not after\n");
1056
1052 pr_debug("%s: block sizes: qh %Zd qtd %Zd itd %Zd sitd %Zd\n", 1057 pr_debug("%s: block sizes: qh %Zd qtd %Zd itd %Zd sitd %Zd\n",
1053 hcd_name, 1058 hcd_name,
1054 sizeof(struct ehci_qh), sizeof(struct ehci_qtd), 1059 sizeof(struct ehci_qh), sizeof(struct ehci_qtd),
@@ -1056,8 +1061,10 @@ static int __init ehci_hcd_init(void)
1056 1061
1057#ifdef DEBUG 1062#ifdef DEBUG
1058 ehci_debug_root = debugfs_create_dir("ehci", NULL); 1063 ehci_debug_root = debugfs_create_dir("ehci", NULL);
1059 if (!ehci_debug_root) 1064 if (!ehci_debug_root) {
1060 return -ENOENT; 1065 retval = -ENOENT;
1066 goto err_debug;
1067 }
1061#endif 1068#endif
1062 1069
1063#ifdef PLATFORM_DRIVER 1070#ifdef PLATFORM_DRIVER
@@ -1105,6 +1112,8 @@ clean0:
1105 debugfs_remove(ehci_debug_root); 1112 debugfs_remove(ehci_debug_root);
1106 ehci_debug_root = NULL; 1113 ehci_debug_root = NULL;
1107#endif 1114#endif
1115err_debug:
1116 clear_bit(USB_EHCI_LOADED, &usb_hcds_loaded);
1108 return retval; 1117 return retval;
1109} 1118}
1110module_init(ehci_hcd_init); 1119module_init(ehci_hcd_init);
@@ -1126,6 +1135,7 @@ static void __exit ehci_hcd_cleanup(void)
1126#ifdef DEBUG 1135#ifdef DEBUG
1127 debugfs_remove(ehci_debug_root); 1136 debugfs_remove(ehci_debug_root);
1128#endif 1137#endif
1138 clear_bit(USB_EHCI_LOADED, &usb_hcds_loaded);
1129} 1139}
1130module_exit(ehci_hcd_cleanup); 1140module_exit(ehci_hcd_cleanup);
1131 1141
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index 740835bb8575..218f9660d7ee 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -236,10 +236,8 @@ static int ehci_bus_resume (struct usb_hcd *hcd)
236 temp = ehci_readl(ehci, &ehci->regs->port_status [i]); 236 temp = ehci_readl(ehci, &ehci->regs->port_status [i]);
237 temp &= ~(PORT_RWC_BITS | PORT_WAKE_BITS); 237 temp &= ~(PORT_RWC_BITS | PORT_WAKE_BITS);
238 if (test_bit(i, &ehci->bus_suspended) && 238 if (test_bit(i, &ehci->bus_suspended) &&
239 (temp & PORT_SUSPEND)) { 239 (temp & PORT_SUSPEND))
240 ehci->reset_done [i] = jiffies + msecs_to_jiffies (20);
241 temp |= PORT_RESUME; 240 temp |= PORT_RESUME;
242 }
243 ehci_writel(ehci, temp, &ehci->regs->port_status [i]); 241 ehci_writel(ehci, temp, &ehci->regs->port_status [i]);
244 } 242 }
245 i = HCS_N_PORTS (ehci->hcs_params); 243 i = HCS_N_PORTS (ehci->hcs_params);
@@ -482,10 +480,9 @@ ehci_hub_status_data (struct usb_hcd *hcd, char *buf)
482 * controller by the user. 480 * controller by the user.
483 */ 481 */
484 482
485 if ((temp & mask) != 0 483 if ((temp & mask) != 0 || test_bit(i, &ehci->port_c_suspend)
486 || ((temp & PORT_RESUME) != 0 484 || (ehci->reset_done[i] && time_after_eq(
487 && time_after_eq(jiffies, 485 jiffies, ehci->reset_done[i]))) {
488 ehci->reset_done[i]))) {
489 if (i < 7) 486 if (i < 7)
490 buf [0] |= 1 << (i + 1); 487 buf [0] |= 1 << (i + 1);
491 else 488 else
@@ -688,6 +685,7 @@ static int ehci_hub_control (
688 /* resume completed? */ 685 /* resume completed? */
689 else if (time_after_eq(jiffies, 686 else if (time_after_eq(jiffies,
690 ehci->reset_done[wIndex])) { 687 ehci->reset_done[wIndex])) {
688 clear_bit(wIndex, &ehci->suspended_ports);
691 set_bit(wIndex, &ehci->port_c_suspend); 689 set_bit(wIndex, &ehci->port_c_suspend);
692 ehci->reset_done[wIndex] = 0; 690 ehci->reset_done[wIndex] = 0;
693 691
@@ -734,6 +732,9 @@ static int ehci_hub_control (
734 ehci_readl(ehci, status_reg)); 732 ehci_readl(ehci, status_reg));
735 } 733 }
736 734
735 if (!(temp & (PORT_RESUME|PORT_RESET)))
736 ehci->reset_done[wIndex] = 0;
737
737 /* transfer dedicated ports to the companion hc */ 738 /* transfer dedicated ports to the companion hc */
738 if ((temp & PORT_CONNECT) && 739 if ((temp & PORT_CONNECT) &&
739 test_bit(wIndex, &ehci->companion_ports)) { 740 test_bit(wIndex, &ehci->companion_ports)) {
@@ -757,8 +758,17 @@ static int ehci_hub_control (
757 } 758 }
758 if (temp & PORT_PE) 759 if (temp & PORT_PE)
759 status |= 1 << USB_PORT_FEAT_ENABLE; 760 status |= 1 << USB_PORT_FEAT_ENABLE;
760 if (temp & (PORT_SUSPEND|PORT_RESUME)) 761
762 /* maybe the port was unsuspended without our knowledge */
763 if (temp & (PORT_SUSPEND|PORT_RESUME)) {
761 status |= 1 << USB_PORT_FEAT_SUSPEND; 764 status |= 1 << USB_PORT_FEAT_SUSPEND;
765 } else if (test_bit(wIndex, &ehci->suspended_ports)) {
766 clear_bit(wIndex, &ehci->suspended_ports);
767 ehci->reset_done[wIndex] = 0;
768 if (temp & PORT_PE)
769 set_bit(wIndex, &ehci->port_c_suspend);
770 }
771
762 if (temp & PORT_OC) 772 if (temp & PORT_OC)
763 status |= 1 << USB_PORT_FEAT_OVER_CURRENT; 773 status |= 1 << USB_PORT_FEAT_OVER_CURRENT;
764 if (temp & PORT_RESET) 774 if (temp & PORT_RESET)
@@ -803,6 +813,7 @@ static int ehci_hub_control (
803 || (temp & PORT_RESET) != 0) 813 || (temp & PORT_RESET) != 0)
804 goto error; 814 goto error;
805 ehci_writel(ehci, temp | PORT_SUSPEND, status_reg); 815 ehci_writel(ehci, temp | PORT_SUSPEND, status_reg);
816 set_bit(wIndex, &ehci->suspended_ports);
806 break; 817 break;
807 case USB_PORT_FEAT_POWER: 818 case USB_PORT_FEAT_POWER:
808 if (HCS_PPC (ehci->hcs_params)) 819 if (HCS_PPC (ehci->hcs_params))
diff --git a/drivers/usb/host/ehci-ixp4xx.c b/drivers/usb/host/ehci-ixp4xx.c
index f9575c409124..9c32063a0c2f 100644
--- a/drivers/usb/host/ehci-ixp4xx.c
+++ b/drivers/usb/host/ehci-ixp4xx.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * IXP4XX EHCI Host Controller Driver 2 * IXP4XX EHCI Host Controller Driver
3 * 3 *
4 * Author: Vladimir Barinov <vbarinov@ru.mvista.com> 4 * Author: Vladimir Barinov <vbarinov@embeddedalley.com>
5 * 5 *
6 * Based on "ehci-fsl.c" by Randy Vinson <rvinson@mvista.com> 6 * Based on "ehci-fsl.c" by Randy Vinson <rvinson@mvista.com>
7 * 7 *
diff --git a/drivers/usb/host/ehci-ppc-soc.c b/drivers/usb/host/ehci-ppc-soc.c
deleted file mode 100644
index 529590eb4037..000000000000
--- a/drivers/usb/host/ehci-ppc-soc.c
+++ /dev/null
@@ -1,201 +0,0 @@
1/*
2 * EHCI HCD (Host Controller Driver) for USB.
3 *
4 * (C) Copyright 2006-2007 Stefan Roese <sr@denx.de>, DENX Software Engineering
5 *
6 * Bus Glue for PPC On-Chip EHCI driver
7 * Tested on AMCC 440EPx
8 *
9 * Based on "ehci-au1xxx.c" by K.Boge <karsten.boge@amd.com>
10 *
11 * This file is licenced under the GPL.
12 */
13
14#include <linux/platform_device.h>
15
16extern int usb_disabled(void);
17
18/* called during probe() after chip reset completes */
19static int ehci_ppc_soc_setup(struct usb_hcd *hcd)
20{
21 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
22 int retval;
23
24 retval = ehci_halt(ehci);
25 if (retval)
26 return retval;
27
28 retval = ehci_init(hcd);
29 if (retval)
30 return retval;
31
32 ehci->sbrn = 0x20;
33 return ehci_reset(ehci);
34}
35
36/**
37 * usb_ehci_ppc_soc_probe - initialize PPC-SoC-based HCDs
38 * Context: !in_interrupt()
39 *
40 * Allocates basic resources for this USB host controller, and
41 * then invokes the start() method for the HCD associated with it
42 * through the hotplug entry's driver_data.
43 *
44 */
45int usb_ehci_ppc_soc_probe(const struct hc_driver *driver,
46 struct usb_hcd **hcd_out,
47 struct platform_device *dev)
48{
49 int retval;
50 struct usb_hcd *hcd;
51 struct ehci_hcd *ehci;
52
53 if (dev->resource[1].flags != IORESOURCE_IRQ) {
54 pr_debug("resource[1] is not IORESOURCE_IRQ");
55 retval = -ENOMEM;
56 }
57 hcd = usb_create_hcd(driver, &dev->dev, "PPC-SOC EHCI");
58 if (!hcd)
59 return -ENOMEM;
60 hcd->rsrc_start = dev->resource[0].start;
61 hcd->rsrc_len = dev->resource[0].end - dev->resource[0].start + 1;
62
63 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
64 pr_debug("request_mem_region failed");
65 retval = -EBUSY;
66 goto err1;
67 }
68
69 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
70 if (!hcd->regs) {
71 pr_debug("ioremap failed");
72 retval = -ENOMEM;
73 goto err2;
74 }
75
76 ehci = hcd_to_ehci(hcd);
77 ehci->big_endian_mmio = 1;
78 ehci->big_endian_desc = 1;
79 ehci->caps = hcd->regs;
80 ehci->regs = hcd->regs + HC_LENGTH(ehci_readl(ehci, &ehci->caps->hc_capbase));
81
82 /* cache this readonly data; minimize chip reads */
83 ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params);
84
85#if defined(CONFIG_440EPX)
86 /*
87 * 440EPx Errata USBH_3
88 * Fix: Enable Break Memory Transfer (BMT) in INSNREG3
89 */
90 out_be32((void *)((ulong)(&ehci->regs->command) + 0x8c), (1 << 0));
91 ehci_dbg(ehci, "Break Memory Transfer (BMT) has beed enabled!\n");
92#endif
93
94 retval = usb_add_hcd(hcd, dev->resource[1].start, IRQF_DISABLED);
95 if (retval == 0)
96 return retval;
97
98 iounmap(hcd->regs);
99err2:
100 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
101err1:
102 usb_put_hcd(hcd);
103 return retval;
104}
105
106/* may be called without controller electrically present */
107/* may be called with controller, bus, and devices active */
108
109/**
110 * usb_ehci_hcd_ppc_soc_remove - shutdown processing for PPC-SoC-based HCDs
111 * @dev: USB Host Controller being removed
112 * Context: !in_interrupt()
113 *
114 * Reverses the effect of usb_ehci_hcd_ppc_soc_probe(), first invoking
115 * the HCD's stop() method. It is always called from a thread
116 * context, normally "rmmod", "apmd", or something similar.
117 *
118 */
119void usb_ehci_ppc_soc_remove(struct usb_hcd *hcd, struct platform_device *dev)
120{
121 usb_remove_hcd(hcd);
122 iounmap(hcd->regs);
123 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
124 usb_put_hcd(hcd);
125}
126
127static const struct hc_driver ehci_ppc_soc_hc_driver = {
128 .description = hcd_name,
129 .product_desc = "PPC-SOC EHCI",
130 .hcd_priv_size = sizeof(struct ehci_hcd),
131
132 /*
133 * generic hardware linkage
134 */
135 .irq = ehci_irq,
136 .flags = HCD_MEMORY | HCD_USB2,
137
138 /*
139 * basic lifecycle operations
140 */
141 .reset = ehci_ppc_soc_setup,
142 .start = ehci_run,
143 .stop = ehci_stop,
144 .shutdown = ehci_shutdown,
145
146 /*
147 * managing i/o requests and associated device resources
148 */
149 .urb_enqueue = ehci_urb_enqueue,
150 .urb_dequeue = ehci_urb_dequeue,
151 .endpoint_disable = ehci_endpoint_disable,
152
153 /*
154 * scheduling support
155 */
156 .get_frame_number = ehci_get_frame,
157
158 /*
159 * root hub support
160 */
161 .hub_status_data = ehci_hub_status_data,
162 .hub_control = ehci_hub_control,
163 .bus_suspend = ehci_bus_suspend,
164 .bus_resume = ehci_bus_resume,
165 .relinquish_port = ehci_relinquish_port,
166 .port_handed_over = ehci_port_handed_over,
167};
168
169static int ehci_hcd_ppc_soc_drv_probe(struct platform_device *pdev)
170{
171 struct usb_hcd *hcd = NULL;
172 int ret;
173
174 pr_debug("In ehci_hcd_ppc_soc_drv_probe\n");
175
176 if (usb_disabled())
177 return -ENODEV;
178
179 /* FIXME we only want one one probe() not two */
180 ret = usb_ehci_ppc_soc_probe(&ehci_ppc_soc_hc_driver, &hcd, pdev);
181 return ret;
182}
183
184static int ehci_hcd_ppc_soc_drv_remove(struct platform_device *pdev)
185{
186 struct usb_hcd *hcd = platform_get_drvdata(pdev);
187
188 /* FIXME we only want one one remove() not two */
189 usb_ehci_ppc_soc_remove(hcd, pdev);
190 return 0;
191}
192
193MODULE_ALIAS("platform:ppc-soc-ehci");
194static struct platform_driver ehci_ppc_soc_driver = {
195 .probe = ehci_hcd_ppc_soc_drv_probe,
196 .remove = ehci_hcd_ppc_soc_drv_remove,
197 .shutdown = usb_hcd_platform_shutdown,
198 .driver = {
199 .name = "ppc-soc-ehci",
200 }
201};
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index 5799298364fb..b11798d17ae5 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -99,6 +99,8 @@ struct ehci_hcd { /* one per controller */
99 owned by the companion during a bus suspend */ 99 owned by the companion during a bus suspend */
100 unsigned long port_c_suspend; /* which ports have 100 unsigned long port_c_suspend; /* which ports have
101 the change-suspend feature turned on */ 101 the change-suspend feature turned on */
102 unsigned long suspended_ports; /* which ports are
103 suspended */
102 104
103 /* per-HC memory pools (could be per-bus, but ...) */ 105 /* per-HC memory pools (could be per-bus, but ...) */
104 struct dma_pool *qh_pool; /* qh per active urb */ 106 struct dma_pool *qh_pool; /* qh per active urb */
@@ -181,14 +183,16 @@ timer_action (struct ehci_hcd *ehci, enum ehci_timer_action action)
181 * the async ring; just the I/O watchdog. Note that if a 183 * the async ring; just the I/O watchdog. Note that if a
182 * SHRINK were pending, OFF would never be requested. 184 * SHRINK were pending, OFF would never be requested.
183 */ 185 */
184 if (timer_pending(&ehci->watchdog) 186 enum ehci_timer_action oldactions = ehci->actions;
185 && ((BIT(TIMER_ASYNC_SHRINK) | BIT(TIMER_ASYNC_OFF))
186 & ehci->actions))
187 return;
188 187
189 if (!test_and_set_bit (action, &ehci->actions)) { 188 if (!test_and_set_bit (action, &ehci->actions)) {
190 unsigned long t; 189 unsigned long t;
191 190
191 if (timer_pending(&ehci->watchdog)
192 && ((BIT(TIMER_ASYNC_SHRINK) | BIT(TIMER_ASYNC_OFF))
193 & oldactions))
194 return;
195
192 switch (action) { 196 switch (action) {
193 case TIMER_IO_WATCHDOG: 197 case TIMER_IO_WATCHDOG:
194 t = EHCI_IO_JIFFIES; 198 t = EHCI_IO_JIFFIES;
@@ -204,149 +208,13 @@ timer_action (struct ehci_hcd *ehci, enum ehci_timer_action action)
204 t = DIV_ROUND_UP(EHCI_SHRINK_FRAMES * HZ, 1000) + 1; 208 t = DIV_ROUND_UP(EHCI_SHRINK_FRAMES * HZ, 1000) + 1;
205 break; 209 break;
206 } 210 }
207 mod_timer(&ehci->watchdog, t + jiffies); 211 mod_timer(&ehci->watchdog, round_jiffies(t + jiffies));
208 } 212 }
209} 213}
210 214
211/*-------------------------------------------------------------------------*/ 215/*-------------------------------------------------------------------------*/
212 216
213/* EHCI register interface, corresponds to EHCI Revision 0.95 specification */ 217#include <linux/usb/ehci_def.h>
214
215/* Section 2.2 Host Controller Capability Registers */
216struct ehci_caps {
217 /* these fields are specified as 8 and 16 bit registers,
218 * but some hosts can't perform 8 or 16 bit PCI accesses.
219 */
220 u32 hc_capbase;
221#define HC_LENGTH(p) (((p)>>00)&0x00ff) /* bits 7:0 */
222#define HC_VERSION(p) (((p)>>16)&0xffff) /* bits 31:16 */
223 u32 hcs_params; /* HCSPARAMS - offset 0x4 */
224#define HCS_DEBUG_PORT(p) (((p)>>20)&0xf) /* bits 23:20, debug port? */
225#define HCS_INDICATOR(p) ((p)&(1 << 16)) /* true: has port indicators */
226#define HCS_N_CC(p) (((p)>>12)&0xf) /* bits 15:12, #companion HCs */
227#define HCS_N_PCC(p) (((p)>>8)&0xf) /* bits 11:8, ports per CC */
228#define HCS_PORTROUTED(p) ((p)&(1 << 7)) /* true: port routing */
229#define HCS_PPC(p) ((p)&(1 << 4)) /* true: port power control */
230#define HCS_N_PORTS(p) (((p)>>0)&0xf) /* bits 3:0, ports on HC */
231
232 u32 hcc_params; /* HCCPARAMS - offset 0x8 */
233#define HCC_EXT_CAPS(p) (((p)>>8)&0xff) /* for pci extended caps */
234#define HCC_ISOC_CACHE(p) ((p)&(1 << 7)) /* true: can cache isoc frame */
235#define HCC_ISOC_THRES(p) (((p)>>4)&0x7) /* bits 6:4, uframes cached */
236#define HCC_CANPARK(p) ((p)&(1 << 2)) /* true: can park on async qh */
237#define HCC_PGM_FRAMELISTLEN(p) ((p)&(1 << 1)) /* true: periodic_size changes*/
238#define HCC_64BIT_ADDR(p) ((p)&(1)) /* true: can use 64-bit addr */
239 u8 portroute [8]; /* nibbles for routing - offset 0xC */
240} __attribute__ ((packed));
241
242
243/* Section 2.3 Host Controller Operational Registers */
244struct ehci_regs {
245
246 /* USBCMD: offset 0x00 */
247 u32 command;
248/* 23:16 is r/w intr rate, in microframes; default "8" == 1/msec */
249#define CMD_PARK (1<<11) /* enable "park" on async qh */
250#define CMD_PARK_CNT(c) (((c)>>8)&3) /* how many transfers to park for */
251#define CMD_LRESET (1<<7) /* partial reset (no ports, etc) */
252#define CMD_IAAD (1<<6) /* "doorbell" interrupt async advance */
253#define CMD_ASE (1<<5) /* async schedule enable */
254#define CMD_PSE (1<<4) /* periodic schedule enable */
255/* 3:2 is periodic frame list size */
256#define CMD_RESET (1<<1) /* reset HC not bus */
257#define CMD_RUN (1<<0) /* start/stop HC */
258
259 /* USBSTS: offset 0x04 */
260 u32 status;
261#define STS_ASS (1<<15) /* Async Schedule Status */
262#define STS_PSS (1<<14) /* Periodic Schedule Status */
263#define STS_RECL (1<<13) /* Reclamation */
264#define STS_HALT (1<<12) /* Not running (any reason) */
265/* some bits reserved */
266 /* these STS_* flags are also intr_enable bits (USBINTR) */
267#define STS_IAA (1<<5) /* Interrupted on async advance */
268#define STS_FATAL (1<<4) /* such as some PCI access errors */
269#define STS_FLR (1<<3) /* frame list rolled over */
270#define STS_PCD (1<<2) /* port change detect */
271#define STS_ERR (1<<1) /* "error" completion (overflow, ...) */
272#define STS_INT (1<<0) /* "normal" completion (short, ...) */
273
274 /* USBINTR: offset 0x08 */
275 u32 intr_enable;
276
277 /* FRINDEX: offset 0x0C */
278 u32 frame_index; /* current microframe number */
279 /* CTRLDSSEGMENT: offset 0x10 */
280 u32 segment; /* address bits 63:32 if needed */
281 /* PERIODICLISTBASE: offset 0x14 */
282 u32 frame_list; /* points to periodic list */
283 /* ASYNCLISTADDR: offset 0x18 */
284 u32 async_next; /* address of next async queue head */
285
286 u32 reserved [9];
287
288 /* CONFIGFLAG: offset 0x40 */
289 u32 configured_flag;
290#define FLAG_CF (1<<0) /* true: we'll support "high speed" */
291
292 /* PORTSC: offset 0x44 */
293 u32 port_status [0]; /* up to N_PORTS */
294/* 31:23 reserved */
295#define PORT_WKOC_E (1<<22) /* wake on overcurrent (enable) */
296#define PORT_WKDISC_E (1<<21) /* wake on disconnect (enable) */
297#define PORT_WKCONN_E (1<<20) /* wake on connect (enable) */
298/* 19:16 for port testing */
299#define PORT_LED_OFF (0<<14)
300#define PORT_LED_AMBER (1<<14)
301#define PORT_LED_GREEN (2<<14)
302#define PORT_LED_MASK (3<<14)
303#define PORT_OWNER (1<<13) /* true: companion hc owns this port */
304#define PORT_POWER (1<<12) /* true: has power (see PPC) */
305#define PORT_USB11(x) (((x)&(3<<10))==(1<<10)) /* USB 1.1 device */
306/* 11:10 for detecting lowspeed devices (reset vs release ownership) */
307/* 9 reserved */
308#define PORT_RESET (1<<8) /* reset port */
309#define PORT_SUSPEND (1<<7) /* suspend port */
310#define PORT_RESUME (1<<6) /* resume it */
311#define PORT_OCC (1<<5) /* over current change */
312#define PORT_OC (1<<4) /* over current active */
313#define PORT_PEC (1<<3) /* port enable change */
314#define PORT_PE (1<<2) /* port enable */
315#define PORT_CSC (1<<1) /* connect status change */
316#define PORT_CONNECT (1<<0) /* device connected */
317#define PORT_RWC_BITS (PORT_CSC | PORT_PEC | PORT_OCC)
318} __attribute__ ((packed));
319
320#define USBMODE 0x68 /* USB Device mode */
321#define USBMODE_SDIS (1<<3) /* Stream disable */
322#define USBMODE_BE (1<<2) /* BE/LE endianness select */
323#define USBMODE_CM_HC (3<<0) /* host controller mode */
324#define USBMODE_CM_IDLE (0<<0) /* idle state */
325
326/* Appendix C, Debug port ... intended for use with special "debug devices"
327 * that can help if there's no serial console. (nonstandard enumeration.)
328 */
329struct ehci_dbg_port {
330 u32 control;
331#define DBGP_OWNER (1<<30)
332#define DBGP_ENABLED (1<<28)
333#define DBGP_DONE (1<<16)
334#define DBGP_INUSE (1<<10)
335#define DBGP_ERRCODE(x) (((x)>>7)&0x07)
336# define DBGP_ERR_BAD 1
337# define DBGP_ERR_SIGNAL 2
338#define DBGP_ERROR (1<<6)
339#define DBGP_GO (1<<5)
340#define DBGP_OUT (1<<4)
341#define DBGP_LEN(x) (((x)>>0)&0x0f)
342 u32 pids;
343#define DBGP_PID_GET(x) (((x)>>16)&0xff)
344#define DBGP_PID_SET(data,tok) (((data)<<8)|(tok))
345 u32 data03;
346 u32 data47;
347 u32 address;
348#define DBGP_EPADDR(dev,ep) (((dev)<<8)|(ep))
349} __attribute__ ((packed));
350 218
351/*-------------------------------------------------------------------------*/ 219/*-------------------------------------------------------------------------*/
352 220
@@ -740,16 +608,7 @@ ehci_port_speed(struct ehci_hcd *ehci, unsigned int portsc)
740/* 608/*
741 * Big-endian read/write functions are arch-specific. 609 * Big-endian read/write functions are arch-specific.
742 * Other arches can be added if/when they're needed. 610 * Other arches can be added if/when they're needed.
743 *
744 * REVISIT: arch/powerpc now has readl/writel_be, so the
745 * definition below can die once the 4xx support is
746 * finally ported over.
747 */ 611 */
748#if defined(CONFIG_PPC) && !defined(CONFIG_PPC_MERGE)
749#define readl_be(addr) in_be32((__force unsigned *)addr)
750#define writel_be(val, addr) out_be32((__force unsigned *)addr, val)
751#endif
752
753#if defined(CONFIG_ARM) && defined(CONFIG_ARCH_IXP4XX) 612#if defined(CONFIG_ARM) && defined(CONFIG_ARCH_IXP4XX)
754#define readl_be(addr) __raw_readl((__force unsigned *)addr) 613#define readl_be(addr) __raw_readl((__force unsigned *)addr)
755#define writel_be(val, addr) __raw_writel(val, (__force unsigned *)addr) 614#define writel_be(val, addr) __raw_writel(val, (__force unsigned *)addr)
diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c
index ce1ca0ba0515..4dda31b26892 100644
--- a/drivers/usb/host/isp116x-hcd.c
+++ b/drivers/usb/host/isp116x-hcd.c
@@ -1562,11 +1562,12 @@ static int __devinit isp116x_probe(struct platform_device *pdev)
1562{ 1562{
1563 struct usb_hcd *hcd; 1563 struct usb_hcd *hcd;
1564 struct isp116x *isp116x; 1564 struct isp116x *isp116x;
1565 struct resource *addr, *data; 1565 struct resource *addr, *data, *ires;
1566 void __iomem *addr_reg; 1566 void __iomem *addr_reg;
1567 void __iomem *data_reg; 1567 void __iomem *data_reg;
1568 int irq; 1568 int irq;
1569 int ret = 0; 1569 int ret = 0;
1570 unsigned long irqflags;
1570 1571
1571 if (pdev->num_resources < 3) { 1572 if (pdev->num_resources < 3) {
1572 ret = -ENODEV; 1573 ret = -ENODEV;
@@ -1575,12 +1576,16 @@ static int __devinit isp116x_probe(struct platform_device *pdev)
1575 1576
1576 data = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1577 data = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1577 addr = platform_get_resource(pdev, IORESOURCE_MEM, 1); 1578 addr = platform_get_resource(pdev, IORESOURCE_MEM, 1);
1578 irq = platform_get_irq(pdev, 0); 1579 ires = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
1579 if (!addr || !data || irq < 0) { 1580
1581 if (!addr || !data || !ires) {
1580 ret = -ENODEV; 1582 ret = -ENODEV;
1581 goto err1; 1583 goto err1;
1582 } 1584 }
1583 1585
1586 irq = ires->start;
1587 irqflags = ires->flags & IRQF_TRIGGER_MASK;
1588
1584 if (pdev->dev.dma_mask) { 1589 if (pdev->dev.dma_mask) {
1585 DBG("DMA not supported\n"); 1590 DBG("DMA not supported\n");
1586 ret = -EINVAL; 1591 ret = -EINVAL;
@@ -1634,7 +1639,7 @@ static int __devinit isp116x_probe(struct platform_device *pdev)
1634 goto err6; 1639 goto err6;
1635 } 1640 }
1636 1641
1637 ret = usb_add_hcd(hcd, irq, IRQF_DISABLED); 1642 ret = usb_add_hcd(hcd, irq, irqflags | IRQF_DISABLED);
1638 if (ret) 1643 if (ret)
1639 goto err6; 1644 goto err6;
1640 1645
diff --git a/drivers/usb/host/isp1760-if.c b/drivers/usb/host/isp1760-if.c
index 051ef7b6bdc6..af849f596135 100644
--- a/drivers/usb/host/isp1760-if.c
+++ b/drivers/usb/host/isp1760-if.c
@@ -218,7 +218,7 @@ static int __devinit isp1761_pci_probe(struct pci_dev *dev,
218 * and reading back and checking the contents are same or not 218 * and reading back and checking the contents are same or not
219 */ 219 */
220 if (reg_data != 0xFACE) { 220 if (reg_data != 0xFACE) {
221 err("scratch register mismatch %x", reg_data); 221 dev_err(&dev->dev, "scratch register mismatch %x\n", reg_data);
222 goto clean; 222 goto clean;
223 } 223 }
224 224
@@ -232,9 +232,10 @@ static int __devinit isp1761_pci_probe(struct pci_dev *dev,
232 hcd = isp1760_register(pci_mem_phy0, length, dev->irq, 232 hcd = isp1760_register(pci_mem_phy0, length, dev->irq,
233 IRQF_SHARED | IRQF_DISABLED, &dev->dev, dev_name(&dev->dev), 233 IRQF_SHARED | IRQF_DISABLED, &dev->dev, dev_name(&dev->dev),
234 devflags); 234 devflags);
235 pci_set_drvdata(dev, hcd); 235 if (!IS_ERR(hcd)) {
236 if (!hcd) 236 pci_set_drvdata(dev, hcd);
237 return 0; 237 return 0;
238 }
238clean: 239clean:
239 status = -ENODEV; 240 status = -ENODEV;
240 iounmap(iobase); 241 iounmap(iobase);
diff --git a/drivers/usb/host/ohci-dbg.c b/drivers/usb/host/ohci-dbg.c
index 7cef1d2f7ccc..d3269656aa4d 100644
--- a/drivers/usb/host/ohci-dbg.c
+++ b/drivers/usb/host/ohci-dbg.c
@@ -649,7 +649,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
649 ohci_dbg_sw (ohci, &next, &size, 649 ohci_dbg_sw (ohci, &next, &size,
650 "bus %s, device %s\n" 650 "bus %s, device %s\n"
651 "%s\n" 651 "%s\n"
652 "%s version " DRIVER_VERSION "\n", 652 "%s\n",
653 hcd->self.controller->bus->name, 653 hcd->self.controller->bus->name,
654 dev_name(hcd->self.controller), 654 dev_name(hcd->self.controller),
655 hcd->product_desc, 655 hcd->product_desc,
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index 89901962cbfd..8647dab0d7f9 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -46,7 +46,6 @@
46 46
47#include "../core/hcd.h" 47#include "../core/hcd.h"
48 48
49#define DRIVER_VERSION "2006 August 04"
50#define DRIVER_AUTHOR "Roman Weissgaerber, David Brownell" 49#define DRIVER_AUTHOR "Roman Weissgaerber, David Brownell"
51#define DRIVER_DESC "USB 1.1 'Open' Host Controller (OHCI) Driver" 50#define DRIVER_DESC "USB 1.1 'Open' Host Controller (OHCI) Driver"
52 51
@@ -984,10 +983,8 @@ static int ohci_restart (struct ohci_hcd *ohci)
984 983
985/*-------------------------------------------------------------------------*/ 984/*-------------------------------------------------------------------------*/
986 985
987#define DRIVER_INFO DRIVER_VERSION " " DRIVER_DESC
988
989MODULE_AUTHOR (DRIVER_AUTHOR); 986MODULE_AUTHOR (DRIVER_AUTHOR);
990MODULE_DESCRIPTION (DRIVER_INFO); 987MODULE_DESCRIPTION(DRIVER_DESC);
991MODULE_LICENSE ("GPL"); 988MODULE_LICENSE ("GPL");
992 989
993#ifdef CONFIG_PCI 990#ifdef CONFIG_PCI
@@ -1095,9 +1092,10 @@ static int __init ohci_hcd_mod_init(void)
1095 if (usb_disabled()) 1092 if (usb_disabled())
1096 return -ENODEV; 1093 return -ENODEV;
1097 1094
1098 printk (KERN_DEBUG "%s: " DRIVER_INFO "\n", hcd_name); 1095 printk(KERN_INFO "%s: " DRIVER_DESC "\n", hcd_name);
1099 pr_debug ("%s: block sizes: ed %Zd td %Zd\n", hcd_name, 1096 pr_debug ("%s: block sizes: ed %Zd td %Zd\n", hcd_name,
1100 sizeof (struct ed), sizeof (struct td)); 1097 sizeof (struct ed), sizeof (struct td));
1098 set_bit(USB_OHCI_LOADED, &usb_hcds_loaded);
1101 1099
1102#ifdef DEBUG 1100#ifdef DEBUG
1103 ohci_debug_root = debugfs_create_dir("ohci", NULL); 1101 ohci_debug_root = debugfs_create_dir("ohci", NULL);
@@ -1184,6 +1182,7 @@ static int __init ohci_hcd_mod_init(void)
1184 error_debug: 1182 error_debug:
1185#endif 1183#endif
1186 1184
1185 clear_bit(USB_OHCI_LOADED, &usb_hcds_loaded);
1187 return retval; 1186 return retval;
1188} 1187}
1189module_init(ohci_hcd_mod_init); 1188module_init(ohci_hcd_mod_init);
@@ -1214,6 +1213,7 @@ static void __exit ohci_hcd_mod_exit(void)
1214#ifdef DEBUG 1213#ifdef DEBUG
1215 debugfs_remove(ohci_debug_root); 1214 debugfs_remove(ohci_debug_root);
1216#endif 1215#endif
1216 clear_bit(USB_OHCI_LOADED, &usb_hcds_loaded);
1217} 1217}
1218module_exit(ohci_hcd_mod_exit); 1218module_exit(ohci_hcd_mod_exit);
1219 1219
diff --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c
index 7ea9a7b31155..32bbce9718f0 100644
--- a/drivers/usb/host/ohci-hub.c
+++ b/drivers/usb/host/ohci-hub.c
@@ -359,21 +359,24 @@ static void ohci_finish_controller_resume(struct usb_hcd *hcd)
359 359
360/* Carry out polling-, autostop-, and autoresume-related state changes */ 360/* Carry out polling-, autostop-, and autoresume-related state changes */
361static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed, 361static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed,
362 int any_connected) 362 int any_connected, int rhsc_status)
363{ 363{
364 int poll_rh = 1; 364 int poll_rh = 1;
365 int rhsc; 365 int rhsc_enable;
366 366
367 rhsc = ohci_readl(ohci, &ohci->regs->intrenable) & OHCI_INTR_RHSC; 367 /* Some broken controllers never turn off RHCS in the interrupt
368 switch (ohci->hc_control & OHCI_CTRL_HCFS) { 368 * status register. For their sake we won't re-enable RHSC
369 * interrupts if the interrupt bit is already active.
370 */
371 rhsc_enable = ohci_readl(ohci, &ohci->regs->intrenable) &
372 OHCI_INTR_RHSC;
369 373
374 switch (ohci->hc_control & OHCI_CTRL_HCFS) {
370 case OHCI_USB_OPER: 375 case OHCI_USB_OPER:
371 /* If no status changes are pending, enable status-change 376 /* If no status changes are pending, enable RHSC interrupts. */
372 * interrupts. 377 if (!rhsc_enable && !rhsc_status && !changed) {
373 */ 378 rhsc_enable = OHCI_INTR_RHSC;
374 if (!rhsc && !changed) { 379 ohci_writel(ohci, rhsc_enable, &ohci->regs->intrenable);
375 rhsc = OHCI_INTR_RHSC;
376 ohci_writel(ohci, rhsc, &ohci->regs->intrenable);
377 } 380 }
378 381
379 /* Keep on polling until we know a device is connected 382 /* Keep on polling until we know a device is connected
@@ -383,7 +386,7 @@ static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed,
383 if (any_connected || 386 if (any_connected ||
384 !device_may_wakeup(&ohci_to_hcd(ohci) 387 !device_may_wakeup(&ohci_to_hcd(ohci)
385 ->self.root_hub->dev)) { 388 ->self.root_hub->dev)) {
386 if (rhsc) 389 if (rhsc_enable)
387 poll_rh = 0; 390 poll_rh = 0;
388 } else { 391 } else {
389 ohci->autostop = 1; 392 ohci->autostop = 1;
@@ -396,34 +399,45 @@ static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed,
396 ohci->autostop = 0; 399 ohci->autostop = 0;
397 ohci->next_statechange = jiffies + 400 ohci->next_statechange = jiffies +
398 STATECHANGE_DELAY; 401 STATECHANGE_DELAY;
399 } else if (rhsc && time_after_eq(jiffies, 402 } else if (time_after_eq(jiffies,
400 ohci->next_statechange) 403 ohci->next_statechange)
401 && !ohci->ed_rm_list 404 && !ohci->ed_rm_list
402 && !(ohci->hc_control & 405 && !(ohci->hc_control &
403 OHCI_SCHED_ENABLES)) { 406 OHCI_SCHED_ENABLES)) {
404 ohci_rh_suspend(ohci, 1); 407 ohci_rh_suspend(ohci, 1);
405 poll_rh = 0; 408 if (rhsc_enable)
409 poll_rh = 0;
406 } 410 }
407 } 411 }
408 break; 412 break;
409 413
410 /* if there is a port change, autostart or ask to be resumed */
411 case OHCI_USB_SUSPEND: 414 case OHCI_USB_SUSPEND:
412 case OHCI_USB_RESUME: 415 case OHCI_USB_RESUME:
416 /* if there is a port change, autostart or ask to be resumed */
413 if (changed) { 417 if (changed) {
414 if (ohci->autostop) 418 if (ohci->autostop)
415 ohci_rh_resume(ohci); 419 ohci_rh_resume(ohci);
416 else 420 else
417 usb_hcd_resume_root_hub(ohci_to_hcd(ohci)); 421 usb_hcd_resume_root_hub(ohci_to_hcd(ohci));
418 } else {
419 if (!rhsc && (ohci->autostop ||
420 ohci_to_hcd(ohci)->self.root_hub->
421 do_remote_wakeup))
422 ohci_writel(ohci, OHCI_INTR_RHSC,
423 &ohci->regs->intrenable);
424 422
425 /* everything is idle, no need for polling */ 423 /* If remote wakeup is disabled, stop polling */
424 } else if (!ohci->autostop &&
425 !ohci_to_hcd(ohci)->self.root_hub->
426 do_remote_wakeup) {
426 poll_rh = 0; 427 poll_rh = 0;
428
429 } else {
430 /* If no status changes are pending,
431 * enable RHSC interrupts
432 */
433 if (!rhsc_enable && !rhsc_status) {
434 rhsc_enable = OHCI_INTR_RHSC;
435 ohci_writel(ohci, rhsc_enable,
436 &ohci->regs->intrenable);
437 }
438 /* Keep polling until RHSC is enabled */
439 if (rhsc_enable)
440 poll_rh = 0;
427 } 441 }
428 break; 442 break;
429 } 443 }
@@ -441,18 +455,22 @@ static inline int ohci_rh_resume(struct ohci_hcd *ohci)
441 * autostop isn't used when CONFIG_PM is turned off. 455 * autostop isn't used when CONFIG_PM is turned off.
442 */ 456 */
443static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed, 457static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed,
444 int any_connected) 458 int any_connected, int rhsc_status)
445{ 459{
446 /* If RHSC is enabled, don't poll */ 460 /* If RHSC is enabled, don't poll */
447 if (ohci_readl(ohci, &ohci->regs->intrenable) & OHCI_INTR_RHSC) 461 if (ohci_readl(ohci, &ohci->regs->intrenable) & OHCI_INTR_RHSC)
448 return 0; 462 return 0;
449 463
450 /* If no status changes are pending, enable status-change interrupts */ 464 /* If status changes are pending, continue polling.
451 if (!changed) { 465 * Conversely, if no status changes are pending but the RHSC
452 ohci_writel(ohci, OHCI_INTR_RHSC, &ohci->regs->intrenable); 466 * status bit was set, then RHSC may be broken so continue polling.
453 return 0; 467 */
454 } 468 if (changed || rhsc_status)
455 return 1; 469 return 1;
470
471 /* It's safe to re-enable RHSC interrupts */
472 ohci_writel(ohci, OHCI_INTR_RHSC, &ohci->regs->intrenable);
473 return 0;
456} 474}
457 475
458#endif /* CONFIG_PM */ 476#endif /* CONFIG_PM */
@@ -467,6 +485,7 @@ ohci_hub_status_data (struct usb_hcd *hcd, char *buf)
467 struct ohci_hcd *ohci = hcd_to_ohci (hcd); 485 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
468 int i, changed = 0, length = 1; 486 int i, changed = 0, length = 1;
469 int any_connected = 0; 487 int any_connected = 0;
488 int rhsc_status;
470 unsigned long flags; 489 unsigned long flags;
471 490
472 spin_lock_irqsave (&ohci->lock, flags); 491 spin_lock_irqsave (&ohci->lock, flags);
@@ -492,12 +511,10 @@ ohci_hub_status_data (struct usb_hcd *hcd, char *buf)
492 length++; 511 length++;
493 } 512 }
494 513
495 /* Some broken controllers never turn off RHCS in the interrupt 514 /* Clear the RHSC status flag before reading the port statuses */
496 * status register. For their sake we won't re-enable RHSC 515 ohci_writel(ohci, OHCI_INTR_RHSC, &ohci->regs->intrstatus);
497 * interrupts if the flag is already set. 516 rhsc_status = ohci_readl(ohci, &ohci->regs->intrstatus) &
498 */ 517 OHCI_INTR_RHSC;
499 if (ohci_readl(ohci, &ohci->regs->intrstatus) & OHCI_INTR_RHSC)
500 changed = 1;
501 518
502 /* look at each port */ 519 /* look at each port */
503 for (i = 0; i < ohci->num_ports; i++) { 520 for (i = 0; i < ohci->num_ports; i++) {
@@ -517,7 +534,7 @@ ohci_hub_status_data (struct usb_hcd *hcd, char *buf)
517 } 534 }
518 535
519 hcd->poll_rh = ohci_root_hub_state_changes(ohci, changed, 536 hcd->poll_rh = ohci_root_hub_state_changes(ohci, changed,
520 any_connected); 537 any_connected, rhsc_status);
521 538
522done: 539done:
523 spin_unlock_irqrestore (&ohci->lock, flags); 540 spin_unlock_irqrestore (&ohci->lock, flags);
diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c
index 95b3ec89c126..91697bdb399f 100644
--- a/drivers/usb/host/ohci-omap.c
+++ b/drivers/usb/host/ohci-omap.c
@@ -231,7 +231,7 @@ static int ohci_omap_init(struct usb_hcd *hcd)
231 231
232 omap_ohci_clock_power(1); 232 omap_ohci_clock_power(1);
233 233
234 if (cpu_is_omap1510()) { 234 if (cpu_is_omap15xx()) {
235 omap_1510_local_bus_power(1); 235 omap_1510_local_bus_power(1);
236 omap_1510_local_bus_init(); 236 omap_1510_local_bus_init();
237 } 237 }
@@ -319,7 +319,7 @@ static int usb_hcd_omap_probe (const struct hc_driver *driver,
319 if (IS_ERR(usb_host_ck)) 319 if (IS_ERR(usb_host_ck))
320 return PTR_ERR(usb_host_ck); 320 return PTR_ERR(usb_host_ck);
321 321
322 if (!cpu_is_omap1510()) 322 if (!cpu_is_omap15xx())
323 usb_dc_ck = clk_get(0, "usb_dc_ck"); 323 usb_dc_ck = clk_get(0, "usb_dc_ck");
324 else 324 else
325 usb_dc_ck = clk_get(0, "lb_ck"); 325 usb_dc_ck = clk_get(0, "lb_ck");
@@ -344,7 +344,12 @@ static int usb_hcd_omap_probe (const struct hc_driver *driver,
344 goto err1; 344 goto err1;
345 } 345 }
346 346
347 hcd->regs = (void __iomem *) (int) IO_ADDRESS(hcd->rsrc_start); 347 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
348 if (!hcd->regs) {
349 dev_err(&pdev->dev, "can't ioremap OHCI HCD\n");
350 retval = -ENOMEM;
351 goto err2;
352 }
348 353
349 ohci = hcd_to_ohci(hcd); 354 ohci = hcd_to_ohci(hcd);
350 ohci_hcd_init(ohci); 355 ohci_hcd_init(ohci);
@@ -355,11 +360,11 @@ static int usb_hcd_omap_probe (const struct hc_driver *driver,
355 irq = platform_get_irq(pdev, 0); 360 irq = platform_get_irq(pdev, 0);
356 if (irq < 0) { 361 if (irq < 0) {
357 retval = -ENXIO; 362 retval = -ENXIO;
358 goto err2; 363 goto err3;
359 } 364 }
360 retval = usb_add_hcd(hcd, irq, IRQF_DISABLED); 365 retval = usb_add_hcd(hcd, irq, IRQF_DISABLED);
361 if (retval) 366 if (retval)
362 goto err2; 367 goto err3;
363 368
364 host_initialized = 1; 369 host_initialized = 1;
365 370
@@ -367,6 +372,8 @@ static int usb_hcd_omap_probe (const struct hc_driver *driver,
367 omap_ohci_clock_power(0); 372 omap_ohci_clock_power(0);
368 373
369 return 0; 374 return 0;
375err3:
376 iounmap(hcd->regs);
370err2: 377err2:
371 release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 378 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
372err1: 379err1:
@@ -401,6 +408,7 @@ usb_hcd_omap_remove (struct usb_hcd *hcd, struct platform_device *pdev)
401 } 408 }
402 if (machine_is_omap_osk()) 409 if (machine_is_omap_osk())
403 omap_free_gpio(9); 410 omap_free_gpio(9);
411 iounmap(hcd->regs);
404 release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 412 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
405 usb_put_hcd(hcd); 413 usb_put_hcd(hcd);
406 clk_put(usb_dc_ck); 414 clk_put(usb_dc_ck);
diff --git a/drivers/usb/host/ohci-pnx4008.c b/drivers/usb/host/ohci-pnx4008.c
index 658a2a978c32..e306ca6aef3d 100644
--- a/drivers/usb/host/ohci-pnx4008.c
+++ b/drivers/usb/host/ohci-pnx4008.c
@@ -331,7 +331,7 @@ static int __devinit usb_hcd_pnx4008_probe(struct platform_device *pdev)
331 331
332 int ret = 0, irq; 332 int ret = 0, irq;
333 333
334 dev_dbg(&pdev->dev, "%s: " DRIVER_INFO " (pnx4008)\n", hcd_name); 334 dev_dbg(&pdev->dev, "%s: " DRIVER_DESC " (pnx4008)\n", hcd_name);
335 if (usb_disabled()) { 335 if (usb_disabled()) {
336 err("USB is disabled"); 336 err("USB is disabled");
337 ret = -ENODEV; 337 ret = -ENODEV;
diff --git a/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c
index 7f0f35c78185..e294d430733b 100644
--- a/drivers/usb/host/ohci-pxa27x.c
+++ b/drivers/usb/host/ohci-pxa27x.c
@@ -23,17 +23,90 @@
23#include <linux/signal.h> 23#include <linux/signal.h>
24#include <linux/platform_device.h> 24#include <linux/platform_device.h>
25#include <linux/clk.h> 25#include <linux/clk.h>
26
27#include <mach/hardware.h>
28#include <mach/pxa-regs.h>
29#include <mach/pxa2xx-regs.h> /* FIXME: for PSSR */
30#include <mach/ohci.h> 26#include <mach/ohci.h>
31 27
28/*
29 * UHC: USB Host Controller (OHCI-like) register definitions
30 */
31#define UHCREV (0x0000) /* UHC HCI Spec Revision */
32#define UHCHCON (0x0004) /* UHC Host Control Register */
33#define UHCCOMS (0x0008) /* UHC Command Status Register */
34#define UHCINTS (0x000C) /* UHC Interrupt Status Register */
35#define UHCINTE (0x0010) /* UHC Interrupt Enable */
36#define UHCINTD (0x0014) /* UHC Interrupt Disable */
37#define UHCHCCA (0x0018) /* UHC Host Controller Comm. Area */
38#define UHCPCED (0x001C) /* UHC Period Current Endpt Descr */
39#define UHCCHED (0x0020) /* UHC Control Head Endpt Descr */
40#define UHCCCED (0x0024) /* UHC Control Current Endpt Descr */
41#define UHCBHED (0x0028) /* UHC Bulk Head Endpt Descr */
42#define UHCBCED (0x002C) /* UHC Bulk Current Endpt Descr */
43#define UHCDHEAD (0x0030) /* UHC Done Head */
44#define UHCFMI (0x0034) /* UHC Frame Interval */
45#define UHCFMR (0x0038) /* UHC Frame Remaining */
46#define UHCFMN (0x003C) /* UHC Frame Number */
47#define UHCPERS (0x0040) /* UHC Periodic Start */
48#define UHCLS (0x0044) /* UHC Low Speed Threshold */
49
50#define UHCRHDA (0x0048) /* UHC Root Hub Descriptor A */
51#define UHCRHDA_NOCP (1 << 12) /* No over current protection */
52#define UHCRHDA_OCPM (1 << 11) /* Over Current Protection Mode */
53#define UHCRHDA_POTPGT(x) \
54 (((x) & 0xff) << 24) /* Power On To Power Good Time */
55
56#define UHCRHDB (0x004C) /* UHC Root Hub Descriptor B */
57#define UHCRHS (0x0050) /* UHC Root Hub Status */
58#define UHCRHPS1 (0x0054) /* UHC Root Hub Port 1 Status */
59#define UHCRHPS2 (0x0058) /* UHC Root Hub Port 2 Status */
60#define UHCRHPS3 (0x005C) /* UHC Root Hub Port 3 Status */
61
62#define UHCSTAT (0x0060) /* UHC Status Register */
63#define UHCSTAT_UPS3 (1 << 16) /* USB Power Sense Port3 */
64#define UHCSTAT_SBMAI (1 << 15) /* System Bus Master Abort Interrupt*/
65#define UHCSTAT_SBTAI (1 << 14) /* System Bus Target Abort Interrupt*/
66#define UHCSTAT_UPRI (1 << 13) /* USB Port Resume Interrupt */
67#define UHCSTAT_UPS2 (1 << 12) /* USB Power Sense Port 2 */
68#define UHCSTAT_UPS1 (1 << 11) /* USB Power Sense Port 1 */
69#define UHCSTAT_HTA (1 << 10) /* HCI Target Abort */
70#define UHCSTAT_HBA (1 << 8) /* HCI Buffer Active */
71#define UHCSTAT_RWUE (1 << 7) /* HCI Remote Wake Up Event */
72
73#define UHCHR (0x0064) /* UHC Reset Register */
74#define UHCHR_SSEP3 (1 << 11) /* Sleep Standby Enable for Port3 */
75#define UHCHR_SSEP2 (1 << 10) /* Sleep Standby Enable for Port2 */
76#define UHCHR_SSEP1 (1 << 9) /* Sleep Standby Enable for Port1 */
77#define UHCHR_PCPL (1 << 7) /* Power control polarity low */
78#define UHCHR_PSPL (1 << 6) /* Power sense polarity low */
79#define UHCHR_SSE (1 << 5) /* Sleep Standby Enable */
80#define UHCHR_UIT (1 << 4) /* USB Interrupt Test */
81#define UHCHR_SSDC (1 << 3) /* Simulation Scale Down Clock */
82#define UHCHR_CGR (1 << 2) /* Clock Generation Reset */
83#define UHCHR_FHR (1 << 1) /* Force Host Controller Reset */
84#define UHCHR_FSBIR (1 << 0) /* Force System Bus Iface Reset */
85
86#define UHCHIE (0x0068) /* UHC Interrupt Enable Register*/
87#define UHCHIE_UPS3IE (1 << 14) /* Power Sense Port3 IntEn */
88#define UHCHIE_UPRIE (1 << 13) /* Port Resume IntEn */
89#define UHCHIE_UPS2IE (1 << 12) /* Power Sense Port2 IntEn */
90#define UHCHIE_UPS1IE (1 << 11) /* Power Sense Port1 IntEn */
91#define UHCHIE_TAIE (1 << 10) /* HCI Interface Transfer Abort
92 Interrupt Enable*/
93#define UHCHIE_HBAIE (1 << 8) /* HCI Buffer Active IntEn */
94#define UHCHIE_RWIE (1 << 7) /* Remote Wake-up IntEn */
95
96#define UHCHIT (0x006C) /* UHC Interrupt Test register */
97
32#define PXA_UHC_MAX_PORTNUM 3 98#define PXA_UHC_MAX_PORTNUM 3
33 99
34#define UHCRHPS(x) __REG2( 0x4C000050, (x)<<2 ) 100struct pxa27x_ohci {
101 /* must be 1st member here for hcd_to_ohci() to work */
102 struct ohci_hcd ohci;
103
104 struct device *dev;
105 struct clk *clk;
106 void __iomem *mmio_base;
107};
35 108
36static struct clk *usb_clk; 109#define to_pxa27x_ohci(hcd) (struct pxa27x_ohci *)hcd_to_ohci(hcd)
37 110
38/* 111/*
39 PMM_NPS_MODE -- PMM Non-power switching mode 112 PMM_NPS_MODE -- PMM Non-power switching mode
@@ -45,30 +118,35 @@ static struct clk *usb_clk;
45 PMM_PERPORT_MODE -- PMM per port switching mode 118 PMM_PERPORT_MODE -- PMM per port switching mode
46 Ports are powered individually. 119 Ports are powered individually.
47 */ 120 */
48static int pxa27x_ohci_select_pmm( int mode ) 121static int pxa27x_ohci_select_pmm(struct pxa27x_ohci *ohci, int mode)
49{ 122{
50 switch ( mode ) { 123 uint32_t uhcrhda = __raw_readl(ohci->mmio_base + UHCRHDA);
124 uint32_t uhcrhdb = __raw_readl(ohci->mmio_base + UHCRHDB);
125
126 switch (mode) {
51 case PMM_NPS_MODE: 127 case PMM_NPS_MODE:
52 UHCRHDA |= RH_A_NPS; 128 uhcrhda |= RH_A_NPS;
53 break; 129 break;
54 case PMM_GLOBAL_MODE: 130 case PMM_GLOBAL_MODE:
55 UHCRHDA &= ~(RH_A_NPS & RH_A_PSM); 131 uhcrhda &= ~(RH_A_NPS & RH_A_PSM);
56 break; 132 break;
57 case PMM_PERPORT_MODE: 133 case PMM_PERPORT_MODE:
58 UHCRHDA &= ~(RH_A_NPS); 134 uhcrhda &= ~(RH_A_NPS);
59 UHCRHDA |= RH_A_PSM; 135 uhcrhda |= RH_A_PSM;
60 136
61 /* Set port power control mask bits, only 3 ports. */ 137 /* Set port power control mask bits, only 3 ports. */
62 UHCRHDB |= (0x7<<17); 138 uhcrhdb |= (0x7<<17);
63 break; 139 break;
64 default: 140 default:
65 printk( KERN_ERR 141 printk( KERN_ERR
66 "Invalid mode %d, set to non-power switch mode.\n", 142 "Invalid mode %d, set to non-power switch mode.\n",
67 mode ); 143 mode );
68 144
69 UHCRHDA |= RH_A_NPS; 145 uhcrhda |= RH_A_NPS;
70 } 146 }
71 147
148 __raw_writel(uhcrhda, ohci->mmio_base + UHCRHDA);
149 __raw_writel(uhcrhdb, ohci->mmio_base + UHCRHDB);
72 return 0; 150 return 0;
73} 151}
74 152
@@ -76,57 +154,110 @@ extern int usb_disabled(void);
76 154
77/*-------------------------------------------------------------------------*/ 155/*-------------------------------------------------------------------------*/
78 156
79static int pxa27x_start_hc(struct device *dev) 157static inline void pxa27x_setup_hc(struct pxa27x_ohci *ohci,
158 struct pxaohci_platform_data *inf)
159{
160 uint32_t uhchr = __raw_readl(ohci->mmio_base + UHCHR);
161 uint32_t uhcrhda = __raw_readl(ohci->mmio_base + UHCRHDA);
162
163 if (inf->flags & ENABLE_PORT1)
164 uhchr &= ~UHCHR_SSEP1;
165
166 if (inf->flags & ENABLE_PORT2)
167 uhchr &= ~UHCHR_SSEP2;
168
169 if (inf->flags & ENABLE_PORT3)
170 uhchr &= ~UHCHR_SSEP3;
171
172 if (inf->flags & POWER_CONTROL_LOW)
173 uhchr |= UHCHR_PCPL;
174
175 if (inf->flags & POWER_SENSE_LOW)
176 uhchr |= UHCHR_PSPL;
177
178 if (inf->flags & NO_OC_PROTECTION)
179 uhcrhda |= UHCRHDA_NOCP;
180
181 if (inf->flags & OC_MODE_PERPORT)
182 uhcrhda |= UHCRHDA_OCPM;
183
184 if (inf->power_on_delay) {
185 uhcrhda &= ~UHCRHDA_POTPGT(0xff);
186 uhcrhda |= UHCRHDA_POTPGT(inf->power_on_delay / 2);
187 }
188
189 __raw_writel(uhchr, ohci->mmio_base + UHCHR);
190 __raw_writel(uhcrhda, ohci->mmio_base + UHCRHDA);
191}
192
193static inline void pxa27x_reset_hc(struct pxa27x_ohci *ohci)
194{
195 uint32_t uhchr = __raw_readl(ohci->mmio_base + UHCHR);
196
197 __raw_writel(uhchr | UHCHR_FHR, ohci->mmio_base + UHCHR);
198 udelay(11);
199 __raw_writel(uhchr & ~UHCHR_FHR, ohci->mmio_base + UHCHR);
200}
201
202#ifdef CONFIG_CPU_PXA27x
203extern void pxa27x_clear_otgph(void);
204#else
205#define pxa27x_clear_otgph() do {} while (0)
206#endif
207
208static int pxa27x_start_hc(struct pxa27x_ohci *ohci, struct device *dev)
80{ 209{
81 int retval = 0; 210 int retval = 0;
82 struct pxaohci_platform_data *inf; 211 struct pxaohci_platform_data *inf;
212 uint32_t uhchr;
83 213
84 inf = dev->platform_data; 214 inf = dev->platform_data;
85 215
86 clk_enable(usb_clk); 216 clk_enable(ohci->clk);
87 217
88 UHCHR |= UHCHR_FHR; 218 pxa27x_reset_hc(ohci);
89 udelay(11); 219
90 UHCHR &= ~UHCHR_FHR; 220 uhchr = __raw_readl(ohci->mmio_base + UHCHR) | UHCHR_FSBIR;
221 __raw_writel(uhchr, ohci->mmio_base + UHCHR);
91 222
92 UHCHR |= UHCHR_FSBIR; 223 while (__raw_readl(ohci->mmio_base + UHCHR) & UHCHR_FSBIR)
93 while (UHCHR & UHCHR_FSBIR)
94 cpu_relax(); 224 cpu_relax();
95 225
226 pxa27x_setup_hc(ohci, inf);
227
96 if (inf->init) 228 if (inf->init)
97 retval = inf->init(dev); 229 retval = inf->init(dev);
98 230
99 if (retval < 0) 231 if (retval < 0)
100 return retval; 232 return retval;
101 233
102 UHCHR &= ~UHCHR_SSE; 234 uhchr = __raw_readl(ohci->mmio_base + UHCHR) & ~UHCHR_SSE;
103 235 __raw_writel(uhchr, ohci->mmio_base + UHCHR);
104 UHCHIE = (UHCHIE_UPRIE | UHCHIE_RWIE); 236 __raw_writel(UHCHIE_UPRIE | UHCHIE_RWIE, ohci->mmio_base + UHCHIE);
105 237
106 /* Clear any OTG Pin Hold */ 238 /* Clear any OTG Pin Hold */
107 if (cpu_is_pxa27x() && (PSSR & PSSR_OTGPH)) 239 pxa27x_clear_otgph();
108 PSSR |= PSSR_OTGPH;
109
110 return 0; 240 return 0;
111} 241}
112 242
113static void pxa27x_stop_hc(struct device *dev) 243static void pxa27x_stop_hc(struct pxa27x_ohci *ohci, struct device *dev)
114{ 244{
115 struct pxaohci_platform_data *inf; 245 struct pxaohci_platform_data *inf;
246 uint32_t uhccoms;
116 247
117 inf = dev->platform_data; 248 inf = dev->platform_data;
118 249
119 if (inf->exit) 250 if (inf->exit)
120 inf->exit(dev); 251 inf->exit(dev);
121 252
122 UHCHR |= UHCHR_FHR; 253 pxa27x_reset_hc(ohci);
123 udelay(11);
124 UHCHR &= ~UHCHR_FHR;
125 254
126 UHCCOMS |= 1; 255 /* Host Controller Reset */
256 uhccoms = __raw_readl(ohci->mmio_base + UHCCOMS) | 0x01;
257 __raw_writel(uhccoms, ohci->mmio_base + UHCCOMS);
127 udelay(10); 258 udelay(10);
128 259
129 clk_disable(usb_clk); 260 clk_disable(ohci->clk);
130} 261}
131 262
132 263
@@ -147,18 +278,22 @@ static void pxa27x_stop_hc(struct device *dev)
147 */ 278 */
148int usb_hcd_pxa27x_probe (const struct hc_driver *driver, struct platform_device *pdev) 279int usb_hcd_pxa27x_probe (const struct hc_driver *driver, struct platform_device *pdev)
149{ 280{
150 int retval; 281 int retval, irq;
151 struct usb_hcd *hcd; 282 struct usb_hcd *hcd;
152 struct pxaohci_platform_data *inf; 283 struct pxaohci_platform_data *inf;
284 struct pxa27x_ohci *ohci;
285 struct resource *r;
286 struct clk *usb_clk;
153 287
154 inf = pdev->dev.platform_data; 288 inf = pdev->dev.platform_data;
155 289
156 if (!inf) 290 if (!inf)
157 return -ENODEV; 291 return -ENODEV;
158 292
159 if (pdev->resource[1].flags != IORESOURCE_IRQ) { 293 irq = platform_get_irq(pdev, 0);
160 pr_debug ("resource[1] is not IORESOURCE_IRQ"); 294 if (irq < 0) {
161 return -ENOMEM; 295 pr_err("no resource of IORESOURCE_IRQ");
296 return -ENXIO;
162 } 297 }
163 298
164 usb_clk = clk_get(&pdev->dev, "USBCLK"); 299 usb_clk = clk_get(&pdev->dev, "USBCLK");
@@ -168,8 +303,16 @@ int usb_hcd_pxa27x_probe (const struct hc_driver *driver, struct platform_device
168 hcd = usb_create_hcd (driver, &pdev->dev, "pxa27x"); 303 hcd = usb_create_hcd (driver, &pdev->dev, "pxa27x");
169 if (!hcd) 304 if (!hcd)
170 return -ENOMEM; 305 return -ENOMEM;
171 hcd->rsrc_start = pdev->resource[0].start; 306
172 hcd->rsrc_len = pdev->resource[0].end - pdev->resource[0].start + 1; 307 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
308 if (!r) {
309 pr_err("no resource of IORESOURCE_MEM");
310 retval = -ENXIO;
311 goto err1;
312 }
313
314 hcd->rsrc_start = r->start;
315 hcd->rsrc_len = resource_size(r);
173 316
174 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { 317 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
175 pr_debug("request_mem_region failed"); 318 pr_debug("request_mem_region failed");
@@ -184,24 +327,30 @@ int usb_hcd_pxa27x_probe (const struct hc_driver *driver, struct platform_device
184 goto err2; 327 goto err2;
185 } 328 }
186 329
187 if ((retval = pxa27x_start_hc(&pdev->dev)) < 0) { 330 /* initialize "struct pxa27x_ohci" */
331 ohci = (struct pxa27x_ohci *)hcd_to_ohci(hcd);
332 ohci->dev = &pdev->dev;
333 ohci->clk = usb_clk;
334 ohci->mmio_base = (void __iomem *)hcd->regs;
335
336 if ((retval = pxa27x_start_hc(ohci, &pdev->dev)) < 0) {
188 pr_debug("pxa27x_start_hc failed"); 337 pr_debug("pxa27x_start_hc failed");
189 goto err3; 338 goto err3;
190 } 339 }
191 340
192 /* Select Power Management Mode */ 341 /* Select Power Management Mode */
193 pxa27x_ohci_select_pmm(inf->port_mode); 342 pxa27x_ohci_select_pmm(ohci, inf->port_mode);
194 343
195 if (inf->power_budget) 344 if (inf->power_budget)
196 hcd->power_budget = inf->power_budget; 345 hcd->power_budget = inf->power_budget;
197 346
198 ohci_hcd_init(hcd_to_ohci(hcd)); 347 ohci_hcd_init(hcd_to_ohci(hcd));
199 348
200 retval = usb_add_hcd(hcd, pdev->resource[1].start, IRQF_DISABLED); 349 retval = usb_add_hcd(hcd, irq, IRQF_DISABLED);
201 if (retval == 0) 350 if (retval == 0)
202 return retval; 351 return retval;
203 352
204 pxa27x_stop_hc(&pdev->dev); 353 pxa27x_stop_hc(ohci, &pdev->dev);
205 err3: 354 err3:
206 iounmap(hcd->regs); 355 iounmap(hcd->regs);
207 err2: 356 err2:
@@ -228,12 +377,14 @@ int usb_hcd_pxa27x_probe (const struct hc_driver *driver, struct platform_device
228 */ 377 */
229void usb_hcd_pxa27x_remove (struct usb_hcd *hcd, struct platform_device *pdev) 378void usb_hcd_pxa27x_remove (struct usb_hcd *hcd, struct platform_device *pdev)
230{ 379{
380 struct pxa27x_ohci *ohci = to_pxa27x_ohci(hcd);
381
231 usb_remove_hcd(hcd); 382 usb_remove_hcd(hcd);
232 pxa27x_stop_hc(&pdev->dev); 383 pxa27x_stop_hc(ohci, &pdev->dev);
233 iounmap(hcd->regs); 384 iounmap(hcd->regs);
234 release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 385 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
235 usb_put_hcd(hcd); 386 usb_put_hcd(hcd);
236 clk_put(usb_clk); 387 clk_put(ohci->clk);
237} 388}
238 389
239/*-------------------------------------------------------------------------*/ 390/*-------------------------------------------------------------------------*/
@@ -266,7 +417,7 @@ ohci_pxa27x_start (struct usb_hcd *hcd)
266static const struct hc_driver ohci_pxa27x_hc_driver = { 417static const struct hc_driver ohci_pxa27x_hc_driver = {
267 .description = hcd_name, 418 .description = hcd_name,
268 .product_desc = "PXA27x OHCI", 419 .product_desc = "PXA27x OHCI",
269 .hcd_priv_size = sizeof(struct ohci_hcd), 420 .hcd_priv_size = sizeof(struct pxa27x_ohci),
270 421
271 /* 422 /*
272 * generic hardware linkage 423 * generic hardware linkage
@@ -330,13 +481,13 @@ static int ohci_hcd_pxa27x_drv_remove(struct platform_device *pdev)
330static int ohci_hcd_pxa27x_drv_suspend(struct platform_device *pdev, pm_message_t state) 481static int ohci_hcd_pxa27x_drv_suspend(struct platform_device *pdev, pm_message_t state)
331{ 482{
332 struct usb_hcd *hcd = platform_get_drvdata(pdev); 483 struct usb_hcd *hcd = platform_get_drvdata(pdev);
333 struct ohci_hcd *ohci = hcd_to_ohci(hcd); 484 struct pxa27x_ohci *ohci = to_pxa27x_ohci(hcd);
334 485
335 if (time_before(jiffies, ohci->next_statechange)) 486 if (time_before(jiffies, ohci->ohci.next_statechange))
336 msleep(5); 487 msleep(5);
337 ohci->next_statechange = jiffies; 488 ohci->ohci.next_statechange = jiffies;
338 489
339 pxa27x_stop_hc(&pdev->dev); 490 pxa27x_stop_hc(ohci, &pdev->dev);
340 hcd->state = HC_STATE_SUSPENDED; 491 hcd->state = HC_STATE_SUSPENDED;
341 492
342 return 0; 493 return 0;
@@ -345,14 +496,14 @@ static int ohci_hcd_pxa27x_drv_suspend(struct platform_device *pdev, pm_message_
345static int ohci_hcd_pxa27x_drv_resume(struct platform_device *pdev) 496static int ohci_hcd_pxa27x_drv_resume(struct platform_device *pdev)
346{ 497{
347 struct usb_hcd *hcd = platform_get_drvdata(pdev); 498 struct usb_hcd *hcd = platform_get_drvdata(pdev);
348 struct ohci_hcd *ohci = hcd_to_ohci(hcd); 499 struct pxa27x_ohci *ohci = to_pxa27x_ohci(hcd);
349 int status; 500 int status;
350 501
351 if (time_before(jiffies, ohci->next_statechange)) 502 if (time_before(jiffies, ohci->ohci.next_statechange))
352 msleep(5); 503 msleep(5);
353 ohci->next_statechange = jiffies; 504 ohci->ohci.next_statechange = jiffies;
354 505
355 if ((status = pxa27x_start_hc(&pdev->dev)) < 0) 506 if ((status = pxa27x_start_hc(ohci, &pdev->dev)) < 0)
356 return status; 507 return status;
357 508
358 ohci_finish_controller_resume(hcd); 509 ohci_finish_controller_resume(hcd);
diff --git a/drivers/usb/host/ohci.h b/drivers/usb/host/ohci.h
index faf622eafce7..222011f6172c 100644
--- a/drivers/usb/host/ohci.h
+++ b/drivers/usb/host/ohci.h
@@ -540,15 +540,7 @@ static inline struct usb_hcd *ohci_to_hcd (const struct ohci_hcd *ohci)
540 * Big-endian read/write functions are arch-specific. 540 * Big-endian read/write functions are arch-specific.
541 * Other arches can be added if/when they're needed. 541 * Other arches can be added if/when they're needed.
542 * 542 *
543 * REVISIT: arch/powerpc now has readl/writel_be, so the
544 * definition below can die once the STB04xxx support is
545 * finally ported over.
546 */ 543 */
547#if defined(CONFIG_PPC) && !defined(CONFIG_PPC_MERGE)
548#define readl_be(addr) in_be32((__force unsigned *)addr)
549#define writel_be(val, addr) out_be32((__force unsigned *)addr, val)
550#endif
551
552static inline unsigned int _ohci_readl (const struct ohci_hcd *ohci, 544static inline unsigned int _ohci_readl (const struct ohci_hcd *ohci,
553 __hc32 __iomem * regs) 545 __hc32 __iomem * regs)
554{ 546{
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c
index ea7126f99cab..c18d8790c410 100644
--- a/drivers/usb/host/r8a66597-hcd.c
+++ b/drivers/usb/host/r8a66597-hcd.c
@@ -66,7 +66,7 @@ static unsigned short endian;
66module_param(endian, ushort, 0644); 66module_param(endian, ushort, 0644);
67MODULE_PARM_DESC(endian, "data endian: big=256, little=0 (default=0)"); 67MODULE_PARM_DESC(endian, "data endian: big=256, little=0 (default=0)");
68 68
69static unsigned short irq_sense = INTL; 69static unsigned short irq_sense = 0xff;
70module_param(irq_sense, ushort, 0644); 70module_param(irq_sense, ushort, 0644);
71MODULE_PARM_DESC(irq_sense, "IRQ sense: low level=32, falling edge=0 " 71MODULE_PARM_DESC(irq_sense, "IRQ sense: low level=32, falling edge=0 "
72 "(default=32)"); 72 "(default=32)");
@@ -118,7 +118,7 @@ static int r8a66597_clock_enable(struct r8a66597 *r8a66597)
118 r8a66597_write(r8a66597, SCKE, SYSCFG0); 118 r8a66597_write(r8a66597, SCKE, SYSCFG0);
119 tmp = r8a66597_read(r8a66597, SYSCFG0); 119 tmp = r8a66597_read(r8a66597, SYSCFG0);
120 if (i++ > 1000) { 120 if (i++ > 1000) {
121 err("register access fail."); 121 printk(KERN_ERR "r8a66597: register access fail.\n");
122 return -ENXIO; 122 return -ENXIO;
123 } 123 }
124 } while ((tmp & SCKE) != SCKE); 124 } while ((tmp & SCKE) != SCKE);
@@ -128,7 +128,7 @@ static int r8a66597_clock_enable(struct r8a66597 *r8a66597)
128 r8a66597_write(r8a66597, USBE, SYSCFG0); 128 r8a66597_write(r8a66597, USBE, SYSCFG0);
129 tmp = r8a66597_read(r8a66597, SYSCFG0); 129 tmp = r8a66597_read(r8a66597, SYSCFG0);
130 if (i++ > 1000) { 130 if (i++ > 1000) {
131 err("register access fail."); 131 printk(KERN_ERR "r8a66597: register access fail.\n");
132 return -ENXIO; 132 return -ENXIO;
133 } 133 }
134 } while ((tmp & USBE) != USBE); 134 } while ((tmp & USBE) != USBE);
@@ -141,7 +141,7 @@ static int r8a66597_clock_enable(struct r8a66597 *r8a66597)
141 msleep(1); 141 msleep(1);
142 tmp = r8a66597_read(r8a66597, SYSCFG0); 142 tmp = r8a66597_read(r8a66597, SYSCFG0);
143 if (i++ > 500) { 143 if (i++ > 500) {
144 err("register access fail."); 144 printk(KERN_ERR "r8a66597: register access fail.\n");
145 return -ENXIO; 145 return -ENXIO;
146 } 146 }
147 } while ((tmp & SCKE) != SCKE); 147 } while ((tmp & SCKE) != SCKE);
@@ -265,7 +265,7 @@ static void get_port_number(char *devpath, u16 *root_port, u16 *hub_port)
265 if (root_port) { 265 if (root_port) {
266 *root_port = (devpath[0] & 0x0F) - 1; 266 *root_port = (devpath[0] & 0x0F) - 1;
267 if (*root_port >= R8A66597_MAX_ROOT_HUB) 267 if (*root_port >= R8A66597_MAX_ROOT_HUB)
268 err("illegal root port number"); 268 printk(KERN_ERR "r8a66597: Illegal root port number.\n");
269 } 269 }
270 if (hub_port) 270 if (hub_port)
271 *hub_port = devpath[2] & 0x0F; 271 *hub_port = devpath[2] & 0x0F;
@@ -286,7 +286,7 @@ static u16 get_r8a66597_usb_speed(enum usb_device_speed speed)
286 usbspd = HSMODE; 286 usbspd = HSMODE;
287 break; 287 break;
288 default: 288 default:
289 err("unknown speed"); 289 printk(KERN_ERR "r8a66597: unknown speed\n");
290 break; 290 break;
291 } 291 }
292 292
@@ -385,7 +385,7 @@ static u8 alloc_usb_address(struct r8a66597 *r8a66597, struct urb *urb)
385 struct r8a66597_device *dev; 385 struct r8a66597_device *dev;
386 386
387 if (is_hub_limit(urb->dev->devpath)) { 387 if (is_hub_limit(urb->dev->devpath)) {
388 err("Externel hub limit reached."); 388 dev_err(&urb->dev->dev, "External hub limit reached.\n");
389 return 0; 389 return 0;
390 } 390 }
391 391
@@ -406,8 +406,9 @@ static u8 alloc_usb_address(struct r8a66597 *r8a66597, struct urb *urb)
406 return addr; 406 return addr;
407 } 407 }
408 408
409 err("cannot communicate with a USB device more than 10.(%x)", 409 dev_err(&urb->dev->dev,
410 r8a66597->address_map); 410 "cannot communicate with a USB device more than 10.(%x)\n",
411 r8a66597->address_map);
411 412
412 return 0; 413 return 0;
413} 414}
@@ -447,7 +448,8 @@ static void r8a66597_reg_wait(struct r8a66597 *r8a66597, unsigned long reg,
447 do { 448 do {
448 tmp = r8a66597_read(r8a66597, reg); 449 tmp = r8a66597_read(r8a66597, reg);
449 if (i++ > 1000000) { 450 if (i++ > 1000000) {
450 err("register%lx, loop %x is timeout", reg, loop); 451 printk(KERN_ERR "r8a66597: register%lx, loop %x "
452 "is timeout\n", reg, loop);
451 break; 453 break;
452 } 454 }
453 ndelay(1); 455 ndelay(1);
@@ -675,7 +677,7 @@ static u16 get_empty_pipenum(struct r8a66597 *r8a66597,
675 array[i++] = 1; 677 array[i++] = 1;
676 break; 678 break;
677 default: 679 default:
678 err("Illegal type"); 680 printk(KERN_ERR "r8a66597: Illegal type\n");
679 return 0; 681 return 0;
680 } 682 }
681 683
@@ -705,7 +707,7 @@ static u16 get_r8a66597_type(__u8 type)
705 r8a66597_type = R8A66597_ISO; 707 r8a66597_type = R8A66597_ISO;
706 break; 708 break;
707 default: 709 default:
708 err("Illegal type"); 710 printk(KERN_ERR "r8a66597: Illegal type\n");
709 r8a66597_type = 0x0000; 711 r8a66597_type = 0x0000;
710 break; 712 break;
711 } 713 }
@@ -724,7 +726,7 @@ static u16 get_bufnum(u16 pipenum)
724 else if (check_interrupt(pipenum)) 726 else if (check_interrupt(pipenum))
725 bufnum = 4 + (pipenum - 6); 727 bufnum = 4 + (pipenum - 6);
726 else 728 else
727 err("Illegal pipenum (%d)", pipenum); 729 printk(KERN_ERR "r8a66597: Illegal pipenum (%d)\n", pipenum);
728 730
729 return bufnum; 731 return bufnum;
730} 732}
@@ -740,7 +742,7 @@ static u16 get_buf_bsize(u16 pipenum)
740 else if (check_interrupt(pipenum)) 742 else if (check_interrupt(pipenum))
741 buf_bsize = 0; 743 buf_bsize = 0;
742 else 744 else
743 err("Illegal pipenum (%d)", pipenum); 745 printk(KERN_ERR "r8a66597: Illegal pipenum (%d)\n", pipenum);
744 746
745 return buf_bsize; 747 return buf_bsize;
746} 748}
@@ -760,10 +762,12 @@ static void enable_r8a66597_pipe_dma(struct r8a66597 *r8a66597,
760 if ((r8a66597->dma_map & (1 << i)) != 0) 762 if ((r8a66597->dma_map & (1 << i)) != 0)
761 continue; 763 continue;
762 764
763 info("address %d, EndpointAddress 0x%02x use DMA FIFO", 765 dev_info(&dev->udev->dev,
764 usb_pipedevice(urb->pipe), 766 "address %d, EndpointAddress 0x%02x use "
765 info->dir_in ? USB_ENDPOINT_DIR_MASK + info->epnum 767 "DMA FIFO\n", usb_pipedevice(urb->pipe),
766 : info->epnum); 768 info->dir_in ?
769 USB_ENDPOINT_DIR_MASK + info->epnum
770 : info->epnum);
767 771
768 r8a66597->dma_map |= 1 << i; 772 r8a66597->dma_map |= 1 << i;
769 dev->dma_map |= 1 << i; 773 dev->dma_map |= 1 << i;
@@ -1187,7 +1191,7 @@ static int start_transfer(struct r8a66597 *r8a66597, struct r8a66597_td *td)
1187 prepare_status_packet(r8a66597, td); 1191 prepare_status_packet(r8a66597, td);
1188 break; 1192 break;
1189 default: 1193 default:
1190 err("invalid type."); 1194 printk(KERN_ERR "r8a66597: invalid type.\n");
1191 break; 1195 break;
1192 } 1196 }
1193 1197
@@ -1295,7 +1299,7 @@ static void packet_read(struct r8a66597 *r8a66597, u16 pipenum)
1295 if (unlikely((tmp & FRDY) == 0)) { 1299 if (unlikely((tmp & FRDY) == 0)) {
1296 pipe_stop(r8a66597, td->pipe); 1300 pipe_stop(r8a66597, td->pipe);
1297 pipe_irq_disable(r8a66597, pipenum); 1301 pipe_irq_disable(r8a66597, pipenum);
1298 err("in fifo not ready (%d)", pipenum); 1302 printk(KERN_ERR "r8a66597: in fifo not ready (%d)\n", pipenum);
1299 finish_request(r8a66597, td, pipenum, td->urb, -EPIPE); 1303 finish_request(r8a66597, td, pipenum, td->urb, -EPIPE);
1300 return; 1304 return;
1301 } 1305 }
@@ -1370,7 +1374,7 @@ static void packet_write(struct r8a66597 *r8a66597, u16 pipenum)
1370 if (unlikely((tmp & FRDY) == 0)) { 1374 if (unlikely((tmp & FRDY) == 0)) {
1371 pipe_stop(r8a66597, td->pipe); 1375 pipe_stop(r8a66597, td->pipe);
1372 pipe_irq_disable(r8a66597, pipenum); 1376 pipe_irq_disable(r8a66597, pipenum);
1373 err("out write fifo not ready. (%d)", pipenum); 1377 printk(KERN_ERR "r8a66597: out fifo not ready (%d)\n", pipenum);
1374 finish_request(r8a66597, td, pipenum, urb, -EPIPE); 1378 finish_request(r8a66597, td, pipenum, urb, -EPIPE);
1375 return; 1379 return;
1376 } 1380 }
@@ -2005,7 +2009,7 @@ static struct r8a66597_device *get_r8a66597_device(struct r8a66597 *r8a66597,
2005 return dev; 2009 return dev;
2006 } 2010 }
2007 2011
2008 err("get_r8a66597_device fail.(%d)\n", addr); 2012 printk(KERN_ERR "r8a66597: get_r8a66597_device fail.(%d)\n", addr);
2009 return NULL; 2013 return NULL;
2010} 2014}
2011 2015
@@ -2263,7 +2267,7 @@ static int __init_or_module r8a66597_remove(struct platform_device *pdev)
2263#define resource_len(r) (((r)->end - (r)->start) + 1) 2267#define resource_len(r) (((r)->end - (r)->start) + 1)
2264static int __init r8a66597_probe(struct platform_device *pdev) 2268static int __init r8a66597_probe(struct platform_device *pdev)
2265{ 2269{
2266 struct resource *res = NULL; 2270 struct resource *res = NULL, *ires;
2267 int irq = -1; 2271 int irq = -1;
2268 void __iomem *reg = NULL; 2272 void __iomem *reg = NULL;
2269 struct usb_hcd *hcd = NULL; 2273 struct usb_hcd *hcd = NULL;
@@ -2274,7 +2278,7 @@ static int __init r8a66597_probe(struct platform_device *pdev)
2274 2278
2275 if (pdev->dev.dma_mask) { 2279 if (pdev->dev.dma_mask) {
2276 ret = -EINVAL; 2280 ret = -EINVAL;
2277 err("dma not support"); 2281 dev_err(&pdev->dev, "dma not supported\n");
2278 goto clean_up; 2282 goto clean_up;
2279 } 2283 }
2280 2284
@@ -2282,21 +2286,25 @@ static int __init r8a66597_probe(struct platform_device *pdev)
2282 (char *)hcd_name); 2286 (char *)hcd_name);
2283 if (!res) { 2287 if (!res) {
2284 ret = -ENODEV; 2288 ret = -ENODEV;
2285 err("platform_get_resource_byname error."); 2289 dev_err(&pdev->dev, "platform_get_resource_byname error.\n");
2286 goto clean_up; 2290 goto clean_up;
2287 } 2291 }
2288 2292
2289 irq = platform_get_irq(pdev, 0); 2293 ires = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
2290 if (irq < 0) { 2294 if (!ires) {
2291 ret = -ENODEV; 2295 ret = -ENODEV;
2292 err("platform_get_irq error."); 2296 dev_err(&pdev->dev,
2297 "platform_get_resource IORESOURCE_IRQ error.\n");
2293 goto clean_up; 2298 goto clean_up;
2294 } 2299 }
2295 2300
2301 irq = ires->start;
2302 irq_trigger = ires->flags & IRQF_TRIGGER_MASK;
2303
2296 reg = ioremap(res->start, resource_len(res)); 2304 reg = ioremap(res->start, resource_len(res));
2297 if (reg == NULL) { 2305 if (reg == NULL) {
2298 ret = -ENOMEM; 2306 ret = -ENOMEM;
2299 err("ioremap error."); 2307 dev_err(&pdev->dev, "ioremap error.\n");
2300 goto clean_up; 2308 goto clean_up;
2301 } 2309 }
2302 2310
@@ -2304,7 +2312,7 @@ static int __init r8a66597_probe(struct platform_device *pdev)
2304 hcd = usb_create_hcd(&r8a66597_hc_driver, &pdev->dev, (char *)hcd_name); 2312 hcd = usb_create_hcd(&r8a66597_hc_driver, &pdev->dev, (char *)hcd_name);
2305 if (!hcd) { 2313 if (!hcd) {
2306 ret = -ENOMEM; 2314 ret = -ENOMEM;
2307 err("Failed to create hcd"); 2315 dev_err(&pdev->dev, "Failed to create hcd\n");
2308 goto clean_up; 2316 goto clean_up;
2309 } 2317 }
2310 r8a66597 = hcd_to_r8a66597(hcd); 2318 r8a66597 = hcd_to_r8a66597(hcd);
@@ -2329,13 +2337,33 @@ static int __init r8a66597_probe(struct platform_device *pdev)
2329 INIT_LIST_HEAD(&r8a66597->child_device); 2337 INIT_LIST_HEAD(&r8a66597->child_device);
2330 2338
2331 hcd->rsrc_start = res->start; 2339 hcd->rsrc_start = res->start;
2332 if (irq_sense == INTL) 2340
2333 irq_trigger = IRQF_TRIGGER_LOW; 2341 /* irq_sense setting on cmdline takes precedence over resource
2334 else 2342 * settings, so the introduction of irqflags in IRQ resourse
2335 irq_trigger = IRQF_TRIGGER_FALLING; 2343 * won't disturb existing setups */
2344 switch (irq_sense) {
2345 case INTL:
2346 irq_trigger = IRQF_TRIGGER_LOW;
2347 break;
2348 case 0:
2349 irq_trigger = IRQF_TRIGGER_FALLING;
2350 break;
2351 case 0xff:
2352 if (irq_trigger)
2353 irq_sense = (irq_trigger & IRQF_TRIGGER_LOW) ?
2354 INTL : 0;
2355 else {
2356 irq_sense = INTL;
2357 irq_trigger = IRQF_TRIGGER_LOW;
2358 }
2359 break;
2360 default:
2361 dev_err(&pdev->dev, "Unknown irq_sense value.\n");
2362 }
2363
2336 ret = usb_add_hcd(hcd, irq, IRQF_DISABLED | irq_trigger); 2364 ret = usb_add_hcd(hcd, irq, IRQF_DISABLED | irq_trigger);
2337 if (ret != 0) { 2365 if (ret != 0) {
2338 err("Failed to add hcd"); 2366 dev_err(&pdev->dev, "Failed to add hcd\n");
2339 goto clean_up; 2367 goto clean_up;
2340 } 2368 }
2341 2369
@@ -2364,7 +2392,8 @@ static int __init r8a66597_init(void)
2364 if (usb_disabled()) 2392 if (usb_disabled())
2365 return -ENODEV; 2393 return -ENODEV;
2366 2394
2367 info("driver %s, %s", hcd_name, DRIVER_VERSION); 2395 printk(KERN_INFO KBUILD_MODNAME ": driver %s, %s\n", hcd_name,
2396 DRIVER_VERSION);
2368 return platform_driver_register(&r8a66597_driver); 2397 return platform_driver_register(&r8a66597_driver);
2369} 2398}
2370module_init(r8a66597_init); 2399module_init(r8a66597_init);
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c
index 8a74bbb57d08..e106e9d48d4a 100644
--- a/drivers/usb/host/sl811-hcd.c
+++ b/drivers/usb/host/sl811-hcd.c
@@ -1620,22 +1620,26 @@ sl811h_probe(struct platform_device *dev)
1620{ 1620{
1621 struct usb_hcd *hcd; 1621 struct usb_hcd *hcd;
1622 struct sl811 *sl811; 1622 struct sl811 *sl811;
1623 struct resource *addr, *data; 1623 struct resource *addr, *data, *ires;
1624 int irq; 1624 int irq;
1625 void __iomem *addr_reg; 1625 void __iomem *addr_reg;
1626 void __iomem *data_reg; 1626 void __iomem *data_reg;
1627 int retval; 1627 int retval;
1628 u8 tmp, ioaddr = 0; 1628 u8 tmp, ioaddr = 0;
1629 unsigned long irqflags;
1629 1630
1630 /* basic sanity checks first. board-specific init logic should 1631 /* basic sanity checks first. board-specific init logic should
1631 * have initialized these three resources and probably board 1632 * have initialized these three resources and probably board
1632 * specific platform_data. we don't probe for IRQs, and do only 1633 * specific platform_data. we don't probe for IRQs, and do only
1633 * minimal sanity checking. 1634 * minimal sanity checking.
1634 */ 1635 */
1635 irq = platform_get_irq(dev, 0); 1636 ires = platform_get_resource(dev, IORESOURCE_IRQ, 0);
1636 if (dev->num_resources < 3 || irq < 0) 1637 if (dev->num_resources < 3 || !ires)
1637 return -ENODEV; 1638 return -ENODEV;
1638 1639
1640 irq = ires->start;
1641 irqflags = ires->flags & IRQF_TRIGGER_MASK;
1642
1639 /* refuse to confuse usbcore */ 1643 /* refuse to confuse usbcore */
1640 if (dev->dev.dma_mask) { 1644 if (dev->dev.dma_mask) {
1641 DBG("no we won't dma\n"); 1645 DBG("no we won't dma\n");
@@ -1717,8 +1721,11 @@ sl811h_probe(struct platform_device *dev)
1717 * triggers (e.g. most ARM CPUs). Initial driver stress testing 1721 * triggers (e.g. most ARM CPUs). Initial driver stress testing
1718 * was on a system with single edge triggering, so most sorts of 1722 * was on a system with single edge triggering, so most sorts of
1719 * triggering arrangement should work. 1723 * triggering arrangement should work.
1724 *
1725 * Use resource IRQ flags if set by platform device setup.
1720 */ 1726 */
1721 retval = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED); 1727 irqflags |= IRQF_SHARED;
1728 retval = usb_add_hcd(hcd, irq, IRQF_DISABLED | irqflags);
1722 if (retval != 0) 1729 if (retval != 0)
1723 goto err6; 1730 goto err6;
1724 1731
diff --git a/drivers/usb/host/sl811_cs.c b/drivers/usb/host/sl811_cs.c
index 5da63f535005..516848dd9b48 100644
--- a/drivers/usb/host/sl811_cs.c
+++ b/drivers/usb/host/sl811_cs.c
@@ -112,7 +112,8 @@ static struct platform_device platform_dev = {
112 .num_resources = ARRAY_SIZE(resources), 112 .num_resources = ARRAY_SIZE(resources),
113}; 113};
114 114
115static int sl811_hc_init(struct device *parent, ioaddr_t base_addr, int irq) 115static int sl811_hc_init(struct device *parent, resource_size_t base_addr,
116 int irq)
116{ 117{
117 if (platform_dev.dev.parent) 118 if (platform_dev.dev.parent)
118 return -EBUSY; 119 return -EBUSY;
@@ -155,97 +156,72 @@ static void sl811_cs_release(struct pcmcia_device * link)
155 platform_device_unregister(&platform_dev); 156 platform_device_unregister(&platform_dev);
156} 157}
157 158
159static int sl811_cs_config_check(struct pcmcia_device *p_dev,
160 cistpl_cftable_entry_t *cfg,
161 cistpl_cftable_entry_t *dflt,
162 unsigned int vcc,
163 void *priv_data)
164{
165 if (cfg->index == 0)
166 return -ENODEV;
167
168 /* Use power settings for Vcc and Vpp if present */
169 /* Note that the CIS values need to be rescaled */
170 if (cfg->vcc.present & (1<<CISTPL_POWER_VNOM)) {
171 if (cfg->vcc.param[CISTPL_POWER_VNOM]/10000 != vcc)
172 return -ENODEV;
173 } else if (dflt->vcc.present & (1<<CISTPL_POWER_VNOM)) {
174 if (dflt->vcc.param[CISTPL_POWER_VNOM]/10000 != vcc)
175 return -ENODEV;
176 }
177
178 if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM))
179 p_dev->conf.Vpp =
180 cfg->vpp1.param[CISTPL_POWER_VNOM]/10000;
181 else if (dflt->vpp1.present & (1<<CISTPL_POWER_VNOM))
182 p_dev->conf.Vpp =
183 dflt->vpp1.param[CISTPL_POWER_VNOM]/10000;
184
185 /* we need an interrupt */
186 if (cfg->irq.IRQInfo1 || dflt->irq.IRQInfo1)
187 p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
188
189 /* IO window settings */
190 p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0;
191 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
192 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
193
194 p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
195 p_dev->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK;
196 p_dev->io.BasePort1 = io->win[0].base;
197 p_dev->io.NumPorts1 = io->win[0].len;
198
199 return pcmcia_request_io(p_dev, &p_dev->io);
200 }
201 pcmcia_disable_device(p_dev);
202 return -ENODEV;
203}
204
205
158static int sl811_cs_config(struct pcmcia_device *link) 206static int sl811_cs_config(struct pcmcia_device *link)
159{ 207{
160 struct device *parent = &handle_to_dev(link); 208 struct device *parent = &handle_to_dev(link);
161 local_info_t *dev = link->priv; 209 local_info_t *dev = link->priv;
162 tuple_t tuple;
163 cisparse_t parse;
164 int last_fn, last_ret; 210 int last_fn, last_ret;
165 u_char buf[64];
166 config_info_t conf;
167 cistpl_cftable_entry_t dflt = { 0 };
168 211
169 DBG(0, "sl811_cs_config(0x%p)\n", link); 212 DBG(0, "sl811_cs_config(0x%p)\n", link);
170 213
171 /* Look up the current Vcc */ 214 if (pcmcia_loop_config(link, sl811_cs_config_check, NULL))
172 CS_CHECK(GetConfigurationInfo, 215 goto failed;
173 pcmcia_get_configuration_info(link, &conf));
174
175 tuple.Attributes = 0;
176 tuple.TupleData = buf;
177 tuple.TupleDataMax = sizeof(buf);
178 tuple.TupleOffset = 0;
179 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
180 CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple));
181 while (1) {
182 cistpl_cftable_entry_t *cfg = &(parse.cftable_entry);
183
184 if (pcmcia_get_tuple_data(link, &tuple) != 0
185 || pcmcia_parse_tuple(link, &tuple, &parse)
186 != 0)
187 goto next_entry;
188
189 if (cfg->flags & CISTPL_CFTABLE_DEFAULT) {
190 dflt = *cfg;
191 }
192
193 if (cfg->index == 0)
194 goto next_entry;
195
196 link->conf.ConfigIndex = cfg->index;
197
198 /* Use power settings for Vcc and Vpp if present */
199 /* Note that the CIS values need to be rescaled */
200 if (cfg->vcc.present & (1<<CISTPL_POWER_VNOM)) {
201 if (cfg->vcc.param[CISTPL_POWER_VNOM]/10000
202 != conf.Vcc)
203 goto next_entry;
204 } else if (dflt.vcc.present & (1<<CISTPL_POWER_VNOM)) {
205 if (dflt.vcc.param[CISTPL_POWER_VNOM]/10000
206 != conf.Vcc)
207 goto next_entry;
208 }
209
210 if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM))
211 link->conf.Vpp =
212 cfg->vpp1.param[CISTPL_POWER_VNOM]/10000;
213 else if (dflt.vpp1.present & (1<<CISTPL_POWER_VNOM))
214 link->conf.Vpp =
215 dflt.vpp1.param[CISTPL_POWER_VNOM]/10000;
216
217 /* we need an interrupt */
218 if (cfg->irq.IRQInfo1 || dflt.irq.IRQInfo1)
219 link->conf.Attributes |= CONF_ENABLE_IRQ;
220
221 /* IO window settings */
222 link->io.NumPorts1 = link->io.NumPorts2 = 0;
223 if ((cfg->io.nwin > 0) || (dflt.io.nwin > 0)) {
224 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt.io;
225
226 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
227 link->io.IOAddrLines = io->flags & CISTPL_IO_LINES_MASK;
228 link->io.BasePort1 = io->win[0].base;
229 link->io.NumPorts1 = io->win[0].len;
230
231 if (pcmcia_request_io(link, &link->io) != 0)
232 goto next_entry;
233 }
234 break;
235
236next_entry:
237 pcmcia_disable_device(link);
238 last_ret = pcmcia_get_next_tuple(link, &tuple);
239 }
240 216
241 /* require an IRQ and two registers */ 217 /* require an IRQ and two registers */
242 if (!link->io.NumPorts1 || link->io.NumPorts1 < 2) 218 if (!link->io.NumPorts1 || link->io.NumPorts1 < 2)
243 goto cs_failed; 219 goto failed;
244 if (link->conf.Attributes & CONF_ENABLE_IRQ) 220 if (link->conf.Attributes & CONF_ENABLE_IRQ)
245 CS_CHECK(RequestIRQ, 221 CS_CHECK(RequestIRQ,
246 pcmcia_request_irq(link, &link->irq)); 222 pcmcia_request_irq(link, &link->irq));
247 else 223 else
248 goto cs_failed; 224 goto failed;
249 225
250 CS_CHECK(RequestConfiguration, 226 CS_CHECK(RequestConfiguration,
251 pcmcia_request_configuration(link, &link->conf)); 227 pcmcia_request_configuration(link, &link->conf));
@@ -266,8 +242,9 @@ next_entry:
266 if (sl811_hc_init(parent, link->io.BasePort1, link->irq.AssignedIRQ) 242 if (sl811_hc_init(parent, link->io.BasePort1, link->irq.AssignedIRQ)
267 < 0) { 243 < 0) {
268cs_failed: 244cs_failed:
269 printk("sl811_cs_config failed\n");
270 cs_error(link, last_fn, last_ret); 245 cs_error(link, last_fn, last_ret);
246failed:
247 printk(KERN_WARNING "sl811_cs_config failed\n");
271 sl811_cs_release(link); 248 sl811_cs_release(link);
272 return -ENODEV; 249 return -ENODEV;
273 } 250 }
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
index 3a7bfe7a8874..cf5e4cf7ea42 100644
--- a/drivers/usb/host/uhci-hcd.c
+++ b/drivers/usb/host/uhci-hcd.c
@@ -53,7 +53,6 @@
53/* 53/*
54 * Version Information 54 * Version Information
55 */ 55 */
56#define DRIVER_VERSION "v3.0"
57#define DRIVER_AUTHOR "Linus 'Frodo Rabbit' Torvalds, Johannes Erdfelt, \ 56#define DRIVER_AUTHOR "Linus 'Frodo Rabbit' Torvalds, Johannes Erdfelt, \
58Randy Dunlap, Georg Acher, Deti Fliegl, Thomas Sailer, Roman Weissgaerber, \ 57Randy Dunlap, Georg Acher, Deti Fliegl, Thomas Sailer, Roman Weissgaerber, \
59Alan Stern" 58Alan Stern"
@@ -951,12 +950,13 @@ static int __init uhci_hcd_init(void)
951{ 950{
952 int retval = -ENOMEM; 951 int retval = -ENOMEM;
953 952
954 printk(KERN_INFO DRIVER_DESC " " DRIVER_VERSION "%s\n",
955 ignore_oc ? ", overcurrent ignored" : "");
956
957 if (usb_disabled()) 953 if (usb_disabled())
958 return -ENODEV; 954 return -ENODEV;
959 955
956 printk(KERN_INFO "uhci_hcd: " DRIVER_DESC "%s\n",
957 ignore_oc ? ", overcurrent ignored" : "");
958 set_bit(USB_UHCI_LOADED, &usb_hcds_loaded);
959
960 if (DEBUG_CONFIGURED) { 960 if (DEBUG_CONFIGURED) {
961 errbuf = kmalloc(ERRBUF_LEN, GFP_KERNEL); 961 errbuf = kmalloc(ERRBUF_LEN, GFP_KERNEL);
962 if (!errbuf) 962 if (!errbuf)
@@ -988,6 +988,7 @@ debug_failed:
988 988
989errbuf_failed: 989errbuf_failed:
990 990
991 clear_bit(USB_UHCI_LOADED, &usb_hcds_loaded);
991 return retval; 992 return retval;
992} 993}
993 994
@@ -997,6 +998,7 @@ static void __exit uhci_hcd_cleanup(void)
997 kmem_cache_destroy(uhci_up_cachep); 998 kmem_cache_destroy(uhci_up_cachep);
998 debugfs_remove(uhci_debugfs_root); 999 debugfs_remove(uhci_debugfs_root);
999 kfree(errbuf); 1000 kfree(errbuf);
1001 clear_bit(USB_UHCI_LOADED, &usb_hcds_loaded);
1000} 1002}
1001 1003
1002module_init(uhci_hcd_init); 1004module_init(uhci_hcd_init);
diff --git a/drivers/usb/host/uhci-q.c b/drivers/usb/host/uhci-q.c
index db645936eedd..5631d89c8730 100644
--- a/drivers/usb/host/uhci-q.c
+++ b/drivers/usb/host/uhci-q.c
@@ -123,14 +123,10 @@ static struct uhci_td *uhci_alloc_td(struct uhci_hcd *uhci)
123 123
124static void uhci_free_td(struct uhci_hcd *uhci, struct uhci_td *td) 124static void uhci_free_td(struct uhci_hcd *uhci, struct uhci_td *td)
125{ 125{
126 if (!list_empty(&td->list)) { 126 if (!list_empty(&td->list))
127 dev_warn(uhci_dev(uhci), "td %p still in list!\n", td); 127 dev_WARN(uhci_dev(uhci), "td %p still in list!\n", td);
128 WARN_ON(1); 128 if (!list_empty(&td->fl_list))
129 } 129 dev_WARN(uhci_dev(uhci), "td %p still in fl_list!\n", td);
130 if (!list_empty(&td->fl_list)) {
131 dev_warn(uhci_dev(uhci), "td %p still in fl_list!\n", td);
132 WARN_ON(1);
133 }
134 130
135 dma_pool_free(uhci->td_pool, td, td->dma_handle); 131 dma_pool_free(uhci->td_pool, td, td->dma_handle);
136} 132}
@@ -295,10 +291,8 @@ static struct uhci_qh *uhci_alloc_qh(struct uhci_hcd *uhci,
295static void uhci_free_qh(struct uhci_hcd *uhci, struct uhci_qh *qh) 291static void uhci_free_qh(struct uhci_hcd *uhci, struct uhci_qh *qh)
296{ 292{
297 WARN_ON(qh->state != QH_STATE_IDLE && qh->udev); 293 WARN_ON(qh->state != QH_STATE_IDLE && qh->udev);
298 if (!list_empty(&qh->queue)) { 294 if (!list_empty(&qh->queue))
299 dev_warn(uhci_dev(uhci), "qh %p list not empty!\n", qh); 295 dev_WARN(uhci_dev(uhci), "qh %p list not empty!\n", qh);
300 WARN_ON(1);
301 }
302 296
303 list_del(&qh->node); 297 list_del(&qh->node);
304 if (qh->udev) { 298 if (qh->udev) {
@@ -746,11 +740,9 @@ static void uhci_free_urb_priv(struct uhci_hcd *uhci,
746{ 740{
747 struct uhci_td *td, *tmp; 741 struct uhci_td *td, *tmp;
748 742
749 if (!list_empty(&urbp->node)) { 743 if (!list_empty(&urbp->node))
750 dev_warn(uhci_dev(uhci), "urb %p still on QH's list!\n", 744 dev_WARN(uhci_dev(uhci), "urb %p still on QH's list!\n",
751 urbp->urb); 745 urbp->urb);
752 WARN_ON(1);
753 }
754 746
755 list_for_each_entry_safe(td, tmp, &urbp->td_list, list) { 747 list_for_each_entry_safe(td, tmp, &urbp->td_list, list) {
756 uhci_remove_td_from_urbp(td); 748 uhci_remove_td_from_urbp(td);
@@ -1073,13 +1065,18 @@ static int uhci_submit_interrupt(struct uhci_hcd *uhci, struct urb *urb,
1073 } 1065 }
1074 if (exponent < 0) 1066 if (exponent < 0)
1075 return -EINVAL; 1067 return -EINVAL;
1076 qh->period = 1 << exponent;
1077 qh->skel = SKEL_INDEX(exponent);
1078 1068
1079 /* For now, interrupt phase is fixed by the layout 1069 /* If the slot is full, try a lower period */
1080 * of the QH lists. */ 1070 do {
1081 qh->phase = (qh->period / 2) & (MAX_PHASE - 1); 1071 qh->period = 1 << exponent;
1082 ret = uhci_check_bandwidth(uhci, qh); 1072 qh->skel = SKEL_INDEX(exponent);
1073
1074 /* For now, interrupt phase is fixed by the layout
1075 * of the QH lists.
1076 */
1077 qh->phase = (qh->period / 2) & (MAX_PHASE - 1);
1078 ret = uhci_check_bandwidth(uhci, qh);
1079 } while (ret != 0 && --exponent >= 0);
1083 if (ret) 1080 if (ret)
1084 return ret; 1081 return ret;
1085 } else if (qh->period > urb->interval) 1082 } else if (qh->period > urb->interval)