aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/host')
-rw-r--r--drivers/usb/host/ehci-au1xxx.c2
-rw-r--r--drivers/usb/host/ehci-dbg.c2
-rw-r--r--drivers/usb/host/ehci-hcd.c37
-rw-r--r--drivers/usb/host/ehci-hub.c7
-rw-r--r--drivers/usb/host/ehci-pci.c53
-rw-r--r--drivers/usb/host/ehci-sched.c79
-rw-r--r--drivers/usb/host/ehci.h1
-rw-r--r--drivers/usb/host/ohci-jz4740.c2
-rw-r--r--drivers/usb/host/r8a66597.h2
-rw-r--r--drivers/usb/host/xhci-hub.c7
-rw-r--r--drivers/usb/host/xhci-mem.c173
-rw-r--r--drivers/usb/host/xhci-ring.c1
-rw-r--r--drivers/usb/host/xhci.c32
-rw-r--r--drivers/usb/host/xhci.h32
14 files changed, 406 insertions, 24 deletions
diff --git a/drivers/usb/host/ehci-au1xxx.c b/drivers/usb/host/ehci-au1xxx.c
index 2baf8a849086..a869e3c103d3 100644
--- a/drivers/usb/host/ehci-au1xxx.c
+++ b/drivers/usb/host/ehci-au1xxx.c
@@ -227,8 +227,8 @@ static int ehci_hcd_au1xxx_drv_suspend(struct device *dev)
227 * mark HW unaccessible. The PM and USB cores make sure that 227 * mark HW unaccessible. The PM and USB cores make sure that
228 * the root hub is either suspended or stopped. 228 * the root hub is either suspended or stopped.
229 */ 229 */
230 spin_lock_irqsave(&ehci->lock, flags);
231 ehci_prepare_ports_for_controller_suspend(ehci, device_may_wakeup(dev)); 230 ehci_prepare_ports_for_controller_suspend(ehci, device_may_wakeup(dev));
231 spin_lock_irqsave(&ehci->lock, flags);
232 ehci_writel(ehci, 0, &ehci->regs->intr_enable); 232 ehci_writel(ehci, 0, &ehci->regs->intr_enable);
233 (void)ehci_readl(ehci, &ehci->regs->intr_enable); 233 (void)ehci_readl(ehci, &ehci->regs->intr_enable);
234 234
diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c
index 76b7fd2d838a..b349021c052b 100644
--- a/drivers/usb/host/ehci-dbg.c
+++ b/drivers/usb/host/ehci-dbg.c
@@ -1063,7 +1063,7 @@ static inline void create_debug_files (struct ehci_hcd *ehci)
1063 &debug_registers_fops)) 1063 &debug_registers_fops))
1064 goto file_error; 1064 goto file_error;
1065 1065
1066 if (!debugfs_create_file("lpm", S_IRUGO|S_IWUGO, ehci->debug_dir, bus, 1066 if (!debugfs_create_file("lpm", S_IRUGO|S_IWUSR, ehci->debug_dir, bus,
1067 &debug_lpm_fops)) 1067 &debug_lpm_fops))
1068 goto file_error; 1068 goto file_error;
1069 1069
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 34a928d3b7d2..597ed102d54f 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -114,6 +114,9 @@ MODULE_PARM_DESC(hird, "host initiated resume duration, +1 for each 75us\n");
114 114
115#define INTR_MASK (STS_IAA | STS_FATAL | STS_PCD | STS_ERR | STS_INT) 115#define INTR_MASK (STS_IAA | STS_FATAL | STS_PCD | STS_ERR | STS_INT)
116 116
117/* for ASPM quirk of ISOC on AMD SB800 */
118static struct pci_dev *amd_nb_dev;
119
117/*-------------------------------------------------------------------------*/ 120/*-------------------------------------------------------------------------*/
118 121
119#include "ehci.h" 122#include "ehci.h"
@@ -514,6 +517,11 @@ static void ehci_stop (struct usb_hcd *hcd)
514 spin_unlock_irq (&ehci->lock); 517 spin_unlock_irq (&ehci->lock);
515 ehci_mem_cleanup (ehci); 518 ehci_mem_cleanup (ehci);
516 519
520 if (amd_nb_dev) {
521 pci_dev_put(amd_nb_dev);
522 amd_nb_dev = NULL;
523 }
524
517#ifdef EHCI_STATS 525#ifdef EHCI_STATS
518 ehci_dbg (ehci, "irq normal %ld err %ld reclaim %ld (lost %ld)\n", 526 ehci_dbg (ehci, "irq normal %ld err %ld reclaim %ld (lost %ld)\n",
519 ehci->stats.normal, ehci->stats.error, ehci->stats.reclaim, 527 ehci->stats.normal, ehci->stats.error, ehci->stats.reclaim,
@@ -549,6 +557,8 @@ static int ehci_init(struct usb_hcd *hcd)
549 ehci->iaa_watchdog.function = ehci_iaa_watchdog; 557 ehci->iaa_watchdog.function = ehci_iaa_watchdog;
550 ehci->iaa_watchdog.data = (unsigned long) ehci; 558 ehci->iaa_watchdog.data = (unsigned long) ehci;
551 559
560 hcc_params = ehci_readl(ehci, &ehci->caps->hcc_params);
561
552 /* 562 /*
553 * hw default: 1K periodic list heads, one per frame. 563 * hw default: 1K periodic list heads, one per frame.
554 * periodic_size can shrink by USBCMD update if hcc_params allows. 564 * periodic_size can shrink by USBCMD update if hcc_params allows.
@@ -556,11 +566,20 @@ static int ehci_init(struct usb_hcd *hcd)
556 ehci->periodic_size = DEFAULT_I_TDPS; 566 ehci->periodic_size = DEFAULT_I_TDPS;
557 INIT_LIST_HEAD(&ehci->cached_itd_list); 567 INIT_LIST_HEAD(&ehci->cached_itd_list);
558 INIT_LIST_HEAD(&ehci->cached_sitd_list); 568 INIT_LIST_HEAD(&ehci->cached_sitd_list);
569
570 if (HCC_PGM_FRAMELISTLEN(hcc_params)) {
571 /* periodic schedule size can be smaller than default */
572 switch (EHCI_TUNE_FLS) {
573 case 0: ehci->periodic_size = 1024; break;
574 case 1: ehci->periodic_size = 512; break;
575 case 2: ehci->periodic_size = 256; break;
576 default: BUG();
577 }
578 }
559 if ((retval = ehci_mem_init(ehci, GFP_KERNEL)) < 0) 579 if ((retval = ehci_mem_init(ehci, GFP_KERNEL)) < 0)
560 return retval; 580 return retval;
561 581
562 /* controllers may cache some of the periodic schedule ... */ 582 /* controllers may cache some of the periodic schedule ... */
563 hcc_params = ehci_readl(ehci, &ehci->caps->hcc_params);
564 if (HCC_ISOC_CACHE(hcc_params)) // full frame cache 583 if (HCC_ISOC_CACHE(hcc_params)) // full frame cache
565 ehci->i_thresh = 2 + 8; 584 ehci->i_thresh = 2 + 8;
566 else // N microframes cached 585 else // N microframes cached
@@ -614,12 +633,6 @@ static int ehci_init(struct usb_hcd *hcd)
614 /* periodic schedule size can be smaller than default */ 633 /* periodic schedule size can be smaller than default */
615 temp &= ~(3 << 2); 634 temp &= ~(3 << 2);
616 temp |= (EHCI_TUNE_FLS << 2); 635 temp |= (EHCI_TUNE_FLS << 2);
617 switch (EHCI_TUNE_FLS) {
618 case 0: ehci->periodic_size = 1024; break;
619 case 1: ehci->periodic_size = 512; break;
620 case 2: ehci->periodic_size = 256; break;
621 default: BUG();
622 }
623 } 636 }
624 if (HCC_LPM(hcc_params)) { 637 if (HCC_LPM(hcc_params)) {
625 /* support link power management EHCI 1.1 addendum */ 638 /* support link power management EHCI 1.1 addendum */
@@ -1048,10 +1061,11 @@ rescan:
1048 tmp && tmp != qh; 1061 tmp && tmp != qh;
1049 tmp = tmp->qh_next.qh) 1062 tmp = tmp->qh_next.qh)
1050 continue; 1063 continue;
1051 /* periodic qh self-unlinks on empty */ 1064 /* periodic qh self-unlinks on empty, and a COMPLETING qh
1052 if (!tmp) 1065 * may already be unlinked.
1053 goto nogood; 1066 */
1054 unlink_async (ehci, qh); 1067 if (tmp)
1068 unlink_async(ehci, qh);
1055 /* FALL THROUGH */ 1069 /* FALL THROUGH */
1056 case QH_STATE_UNLINK: /* wait for hw to finish? */ 1070 case QH_STATE_UNLINK: /* wait for hw to finish? */
1057 case QH_STATE_UNLINK_WAIT: 1071 case QH_STATE_UNLINK_WAIT:
@@ -1068,7 +1082,6 @@ idle_timeout:
1068 } 1082 }
1069 /* else FALL THROUGH */ 1083 /* else FALL THROUGH */
1070 default: 1084 default:
1071nogood:
1072 /* caller was supposed to have unlinked any requests; 1085 /* caller was supposed to have unlinked any requests;
1073 * that's not our job. just leak this memory. 1086 * that's not our job. just leak this memory.
1074 */ 1087 */
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index 796ea0c8900f..8a515f0d5988 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -111,6 +111,7 @@ static void ehci_adjust_port_wakeup_flags(struct ehci_hcd *ehci,
111{ 111{
112 int port; 112 int port;
113 u32 temp; 113 u32 temp;
114 unsigned long flags;
114 115
115 /* If remote wakeup is enabled for the root hub but disabled 116 /* If remote wakeup is enabled for the root hub but disabled
116 * for the controller, we must adjust all the port wakeup flags 117 * for the controller, we must adjust all the port wakeup flags
@@ -120,6 +121,8 @@ static void ehci_adjust_port_wakeup_flags(struct ehci_hcd *ehci,
120 if (!ehci_to_hcd(ehci)->self.root_hub->do_remote_wakeup || do_wakeup) 121 if (!ehci_to_hcd(ehci)->self.root_hub->do_remote_wakeup || do_wakeup)
121 return; 122 return;
122 123
124 spin_lock_irqsave(&ehci->lock, flags);
125
123 /* clear phy low-power mode before changing wakeup flags */ 126 /* clear phy low-power mode before changing wakeup flags */
124 if (ehci->has_hostpc) { 127 if (ehci->has_hostpc) {
125 port = HCS_N_PORTS(ehci->hcs_params); 128 port = HCS_N_PORTS(ehci->hcs_params);
@@ -131,7 +134,9 @@ static void ehci_adjust_port_wakeup_flags(struct ehci_hcd *ehci,
131 temp = ehci_readl(ehci, hostpc_reg); 134 temp = ehci_readl(ehci, hostpc_reg);
132 ehci_writel(ehci, temp & ~HOSTPC_PHCD, hostpc_reg); 135 ehci_writel(ehci, temp & ~HOSTPC_PHCD, hostpc_reg);
133 } 136 }
137 spin_unlock_irqrestore(&ehci->lock, flags);
134 msleep(5); 138 msleep(5);
139 spin_lock_irqsave(&ehci->lock, flags);
135 } 140 }
136 141
137 port = HCS_N_PORTS(ehci->hcs_params); 142 port = HCS_N_PORTS(ehci->hcs_params);
@@ -170,6 +175,8 @@ static void ehci_adjust_port_wakeup_flags(struct ehci_hcd *ehci,
170 /* Does the root hub have a port wakeup pending? */ 175 /* Does the root hub have a port wakeup pending? */
171 if (!suspending && (ehci_readl(ehci, &ehci->regs->status) & STS_PCD)) 176 if (!suspending && (ehci_readl(ehci, &ehci->regs->status) & STS_PCD))
172 usb_hcd_resume_root_hub(ehci_to_hcd(ehci)); 177 usb_hcd_resume_root_hub(ehci_to_hcd(ehci));
178
179 spin_unlock_irqrestore(&ehci->lock, flags);
173} 180}
174 181
175static int ehci_bus_suspend (struct usb_hcd *hcd) 182static int ehci_bus_suspend (struct usb_hcd *hcd)
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index a1e8d273103f..566791e04e8c 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -41,6 +41,42 @@ static int ehci_pci_reinit(struct ehci_hcd *ehci, struct pci_dev *pdev)
41 return 0; 41 return 0;
42} 42}
43 43
44static int ehci_quirk_amd_hudson(struct ehci_hcd *ehci)
45{
46 struct pci_dev *amd_smbus_dev;
47 u8 rev = 0;
48
49 amd_smbus_dev = pci_get_device(PCI_VENDOR_ID_ATI, 0x4385, NULL);
50 if (amd_smbus_dev) {
51 pci_read_config_byte(amd_smbus_dev, PCI_REVISION_ID, &rev);
52 if (rev < 0x40) {
53 pci_dev_put(amd_smbus_dev);
54 amd_smbus_dev = NULL;
55 return 0;
56 }
57 } else {
58 amd_smbus_dev = pci_get_device(PCI_VENDOR_ID_AMD, 0x780b, NULL);
59 if (!amd_smbus_dev)
60 return 0;
61 pci_read_config_byte(amd_smbus_dev, PCI_REVISION_ID, &rev);
62 if (rev < 0x11 || rev > 0x18) {
63 pci_dev_put(amd_smbus_dev);
64 amd_smbus_dev = NULL;
65 return 0;
66 }
67 }
68
69 if (!amd_nb_dev)
70 amd_nb_dev = pci_get_device(PCI_VENDOR_ID_AMD, 0x1510, NULL);
71
72 ehci_info(ehci, "QUIRK: Enable exception for AMD Hudson ASPM\n");
73
74 pci_dev_put(amd_smbus_dev);
75 amd_smbus_dev = NULL;
76
77 return 1;
78}
79
44/* called during probe() after chip reset completes */ 80/* called during probe() after chip reset completes */
45static int ehci_pci_setup(struct usb_hcd *hcd) 81static int ehci_pci_setup(struct usb_hcd *hcd)
46{ 82{
@@ -99,6 +135,9 @@ static int ehci_pci_setup(struct usb_hcd *hcd)
99 /* cache this readonly data; minimize chip reads */ 135 /* cache this readonly data; minimize chip reads */
100 ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params); 136 ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params);
101 137
138 if (ehci_quirk_amd_hudson(ehci))
139 ehci->amd_l1_fix = 1;
140
102 retval = ehci_halt(ehci); 141 retval = ehci_halt(ehci);
103 if (retval) 142 if (retval)
104 return retval; 143 return retval;
@@ -148,6 +187,18 @@ static int ehci_pci_setup(struct usb_hcd *hcd)
148 if (pdev->revision < 0xa4) 187 if (pdev->revision < 0xa4)
149 ehci->no_selective_suspend = 1; 188 ehci->no_selective_suspend = 1;
150 break; 189 break;
190
191 /* MCP89 chips on the MacBookAir3,1 give EPROTO when
192 * fetching device descriptors unless LPM is disabled.
193 * There are also intermittent problems enumerating
194 * devices with PPCD enabled.
195 */
196 case 0x0d9d:
197 ehci_info(ehci, "disable lpm/ppcd for nvidia mcp89");
198 ehci->has_lpm = 0;
199 ehci->has_ppcd = 0;
200 ehci->command &= ~CMD_PPCEE;
201 break;
151 } 202 }
152 break; 203 break;
153 case PCI_VENDOR_ID_VIA: 204 case PCI_VENDOR_ID_VIA:
@@ -296,8 +347,8 @@ static int ehci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup)
296 * mark HW unaccessible. The PM and USB cores make sure that 347 * mark HW unaccessible. The PM and USB cores make sure that
297 * the root hub is either suspended or stopped. 348 * the root hub is either suspended or stopped.
298 */ 349 */
299 spin_lock_irqsave (&ehci->lock, flags);
300 ehci_prepare_ports_for_controller_suspend(ehci, do_wakeup); 350 ehci_prepare_ports_for_controller_suspend(ehci, do_wakeup);
351 spin_lock_irqsave (&ehci->lock, flags);
301 ehci_writel(ehci, 0, &ehci->regs->intr_enable); 352 ehci_writel(ehci, 0, &ehci->regs->intr_enable);
302 (void)ehci_readl(ehci, &ehci->regs->intr_enable); 353 (void)ehci_readl(ehci, &ehci->regs->intr_enable);
303 354
diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c
index a92526d6e5ae..724ba7133c4f 100644
--- a/drivers/usb/host/ehci-sched.c
+++ b/drivers/usb/host/ehci-sched.c
@@ -1583,6 +1583,63 @@ itd_link (struct ehci_hcd *ehci, unsigned frame, struct ehci_itd *itd)
1583 *hw_p = cpu_to_hc32(ehci, itd->itd_dma | Q_TYPE_ITD); 1583 *hw_p = cpu_to_hc32(ehci, itd->itd_dma | Q_TYPE_ITD);
1584} 1584}
1585 1585
1586#define AB_REG_BAR_LOW 0xe0
1587#define AB_REG_BAR_HIGH 0xe1
1588#define AB_INDX(addr) ((addr) + 0x00)
1589#define AB_DATA(addr) ((addr) + 0x04)
1590#define NB_PCIE_INDX_ADDR 0xe0
1591#define NB_PCIE_INDX_DATA 0xe4
1592#define NB_PIF0_PWRDOWN_0 0x01100012
1593#define NB_PIF0_PWRDOWN_1 0x01100013
1594
1595static void ehci_quirk_amd_L1(struct ehci_hcd *ehci, int disable)
1596{
1597 u32 addr, addr_low, addr_high, val;
1598
1599 outb_p(AB_REG_BAR_LOW, 0xcd6);
1600 addr_low = inb_p(0xcd7);
1601 outb_p(AB_REG_BAR_HIGH, 0xcd6);
1602 addr_high = inb_p(0xcd7);
1603 addr = addr_high << 8 | addr_low;
1604 outl_p(0x30, AB_INDX(addr));
1605 outl_p(0x40, AB_DATA(addr));
1606 outl_p(0x34, AB_INDX(addr));
1607 val = inl_p(AB_DATA(addr));
1608
1609 if (disable) {
1610 val &= ~0x8;
1611 val |= (1 << 4) | (1 << 9);
1612 } else {
1613 val |= 0x8;
1614 val &= ~((1 << 4) | (1 << 9));
1615 }
1616 outl_p(val, AB_DATA(addr));
1617
1618 if (amd_nb_dev) {
1619 addr = NB_PIF0_PWRDOWN_0;
1620 pci_write_config_dword(amd_nb_dev, NB_PCIE_INDX_ADDR, addr);
1621 pci_read_config_dword(amd_nb_dev, NB_PCIE_INDX_DATA, &val);
1622 if (disable)
1623 val &= ~(0x3f << 7);
1624 else
1625 val |= 0x3f << 7;
1626
1627 pci_write_config_dword(amd_nb_dev, NB_PCIE_INDX_DATA, val);
1628
1629 addr = NB_PIF0_PWRDOWN_1;
1630 pci_write_config_dword(amd_nb_dev, NB_PCIE_INDX_ADDR, addr);
1631 pci_read_config_dword(amd_nb_dev, NB_PCIE_INDX_DATA, &val);
1632 if (disable)
1633 val &= ~(0x3f << 7);
1634 else
1635 val |= 0x3f << 7;
1636
1637 pci_write_config_dword(amd_nb_dev, NB_PCIE_INDX_DATA, val);
1638 }
1639
1640 return;
1641}
1642
1586/* fit urb's itds into the selected schedule slot; activate as needed */ 1643/* fit urb's itds into the selected schedule slot; activate as needed */
1587static int 1644static int
1588itd_link_urb ( 1645itd_link_urb (
@@ -1609,6 +1666,12 @@ itd_link_urb (
1609 urb->interval, 1666 urb->interval,
1610 next_uframe >> 3, next_uframe & 0x7); 1667 next_uframe >> 3, next_uframe & 0x7);
1611 } 1668 }
1669
1670 if (ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs == 0) {
1671 if (ehci->amd_l1_fix == 1)
1672 ehci_quirk_amd_L1(ehci, 1);
1673 }
1674
1612 ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs++; 1675 ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs++;
1613 1676
1614 /* fill iTDs uframe by uframe */ 1677 /* fill iTDs uframe by uframe */
@@ -1733,6 +1796,11 @@ itd_complete (
1733 (void) disable_periodic(ehci); 1796 (void) disable_periodic(ehci);
1734 ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs--; 1797 ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs--;
1735 1798
1799 if (ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs == 0) {
1800 if (ehci->amd_l1_fix == 1)
1801 ehci_quirk_amd_L1(ehci, 0);
1802 }
1803
1736 if (unlikely(list_is_singular(&stream->td_list))) { 1804 if (unlikely(list_is_singular(&stream->td_list))) {
1737 ehci_to_hcd(ehci)->self.bandwidth_allocated 1805 ehci_to_hcd(ehci)->self.bandwidth_allocated
1738 -= stream->bandwidth; 1806 -= stream->bandwidth;
@@ -2018,6 +2086,12 @@ sitd_link_urb (
2018 (next_uframe >> 3) & (ehci->periodic_size - 1), 2086 (next_uframe >> 3) & (ehci->periodic_size - 1),
2019 stream->interval, hc32_to_cpu(ehci, stream->splits)); 2087 stream->interval, hc32_to_cpu(ehci, stream->splits));
2020 } 2088 }
2089
2090 if (ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs == 0) {
2091 if (ehci->amd_l1_fix == 1)
2092 ehci_quirk_amd_L1(ehci, 1);
2093 }
2094
2021 ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs++; 2095 ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs++;
2022 2096
2023 /* fill sITDs frame by frame */ 2097 /* fill sITDs frame by frame */
@@ -2118,6 +2192,11 @@ sitd_complete (
2118 (void) disable_periodic(ehci); 2192 (void) disable_periodic(ehci);
2119 ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs--; 2193 ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs--;
2120 2194
2195 if (ehci_to_hcd(ehci)->self.bandwidth_isoc_reqs == 0) {
2196 if (ehci->amd_l1_fix == 1)
2197 ehci_quirk_amd_L1(ehci, 0);
2198 }
2199
2121 if (list_is_singular(&stream->td_list)) { 2200 if (list_is_singular(&stream->td_list)) {
2122 ehci_to_hcd(ehci)->self.bandwidth_allocated 2201 ehci_to_hcd(ehci)->self.bandwidth_allocated
2123 -= stream->bandwidth; 2202 -= stream->bandwidth;
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index bde823f704e9..fd1c53da89e4 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -130,6 +130,7 @@ struct ehci_hcd { /* one per controller */
130 unsigned has_amcc_usb23:1; 130 unsigned has_amcc_usb23:1;
131 unsigned need_io_watchdog:1; 131 unsigned need_io_watchdog:1;
132 unsigned broken_periodic:1; 132 unsigned broken_periodic:1;
133 unsigned amd_l1_fix:1;
133 unsigned fs_i_thresh:1; /* Intel iso scheduling */ 134 unsigned fs_i_thresh:1; /* Intel iso scheduling */
134 135
135 /* required for usb32 quirk */ 136 /* required for usb32 quirk */
diff --git a/drivers/usb/host/ohci-jz4740.c b/drivers/usb/host/ohci-jz4740.c
index 10e1872f3ab9..931d588c3fb5 100644
--- a/drivers/usb/host/ohci-jz4740.c
+++ b/drivers/usb/host/ohci-jz4740.c
@@ -273,4 +273,4 @@ static struct platform_driver ohci_hcd_jz4740_driver = {
273 }, 273 },
274}; 274};
275 275
276MODULE_ALIAS("platfrom:jz4740-ohci"); 276MODULE_ALIAS("platform:jz4740-ohci");
diff --git a/drivers/usb/host/r8a66597.h b/drivers/usb/host/r8a66597.h
index 95d0f5adfdcf..25563e9a90bc 100644
--- a/drivers/usb/host/r8a66597.h
+++ b/drivers/usb/host/r8a66597.h
@@ -227,7 +227,7 @@ static inline void r8a66597_write_fifo(struct r8a66597 *r8a66597,
227 int odd = len & 0x0001; 227 int odd = len & 0x0001;
228 228
229 len = len / 2; 229 len = len / 2;
230 ioread16_rep(fifoaddr, buf, len); 230 iowrite16_rep(fifoaddr, buf, len);
231 if (unlikely(odd)) { 231 if (unlikely(odd)) {
232 buf = &buf[len]; 232 buf = &buf[len];
233 iowrite8((unsigned char)*buf, fifoaddr); 233 iowrite8((unsigned char)*buf, fifoaddr);
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index a1a7a9795536..480936a870ce 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -132,6 +132,13 @@ static u32 xhci_port_state_to_neutral(u32 state)
132static void xhci_disable_port(struct xhci_hcd *xhci, u16 wIndex, 132static void xhci_disable_port(struct xhci_hcd *xhci, u16 wIndex,
133 u32 __iomem *addr, u32 port_status) 133 u32 __iomem *addr, u32 port_status)
134{ 134{
135 /* Don't allow the USB core to disable SuperSpeed ports. */
136 if (xhci->port_array[wIndex] == 0x03) {
137 xhci_dbg(xhci, "Ignoring request to disable "
138 "SuperSpeed port.\n");
139 return;
140 }
141
135 /* Write 1 to disable the port */ 142 /* Write 1 to disable the port */
136 xhci_writel(xhci, port_status | PORT_PE, addr); 143 xhci_writel(xhci, port_status | PORT_PE, addr);
137 port_status = xhci_readl(xhci, addr); 144 port_status = xhci_readl(xhci, addr);
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 4e51343ddffc..6627a956fa8e 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -1043,7 +1043,7 @@ static inline u32 xhci_get_max_esit_payload(struct xhci_hcd *xhci,
1043 if (udev->speed == USB_SPEED_SUPER) 1043 if (udev->speed == USB_SPEED_SUPER)
1044 return ep->ss_ep_comp.wBytesPerInterval; 1044 return ep->ss_ep_comp.wBytesPerInterval;
1045 1045
1046 max_packet = ep->desc.wMaxPacketSize & 0x3ff; 1046 max_packet = GET_MAX_PACKET(ep->desc.wMaxPacketSize);
1047 max_burst = (ep->desc.wMaxPacketSize & 0x1800) >> 11; 1047 max_burst = (ep->desc.wMaxPacketSize & 0x1800) >> 11;
1048 /* A 0 in max burst means 1 transfer per ESIT */ 1048 /* A 0 in max burst means 1 transfer per ESIT */
1049 return max_packet * (max_burst + 1); 1049 return max_packet * (max_burst + 1);
@@ -1133,7 +1133,7 @@ int xhci_endpoint_init(struct xhci_hcd *xhci,
1133 /* Fall through */ 1133 /* Fall through */
1134 case USB_SPEED_FULL: 1134 case USB_SPEED_FULL:
1135 case USB_SPEED_LOW: 1135 case USB_SPEED_LOW:
1136 max_packet = ep->desc.wMaxPacketSize & 0x3ff; 1136 max_packet = GET_MAX_PACKET(ep->desc.wMaxPacketSize);
1137 ep_ctx->ep_info2 |= MAX_PACKET(max_packet); 1137 ep_ctx->ep_info2 |= MAX_PACKET(max_packet);
1138 break; 1138 break;
1139 default: 1139 default:
@@ -1441,6 +1441,13 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
1441 xhci->dcbaa = NULL; 1441 xhci->dcbaa = NULL;
1442 1442
1443 scratchpad_free(xhci); 1443 scratchpad_free(xhci);
1444
1445 xhci->num_usb2_ports = 0;
1446 xhci->num_usb3_ports = 0;
1447 kfree(xhci->usb2_ports);
1448 kfree(xhci->usb3_ports);
1449 kfree(xhci->port_array);
1450
1444 xhci->page_size = 0; 1451 xhci->page_size = 0;
1445 xhci->page_shift = 0; 1452 xhci->page_shift = 0;
1446} 1453}
@@ -1624,6 +1631,166 @@ static void xhci_set_hc_event_deq(struct xhci_hcd *xhci)
1624 &xhci->ir_set->erst_dequeue); 1631 &xhci->ir_set->erst_dequeue);
1625} 1632}
1626 1633
1634static void xhci_add_in_port(struct xhci_hcd *xhci, unsigned int num_ports,
1635 u32 __iomem *addr, u8 major_revision)
1636{
1637 u32 temp, port_offset, port_count;
1638 int i;
1639
1640 if (major_revision > 0x03) {
1641 xhci_warn(xhci, "Ignoring unknown port speed, "
1642 "Ext Cap %p, revision = 0x%x\n",
1643 addr, major_revision);
1644 /* Ignoring port protocol we can't understand. FIXME */
1645 return;
1646 }
1647
1648 /* Port offset and count in the third dword, see section 7.2 */
1649 temp = xhci_readl(xhci, addr + 2);
1650 port_offset = XHCI_EXT_PORT_OFF(temp);
1651 port_count = XHCI_EXT_PORT_COUNT(temp);
1652 xhci_dbg(xhci, "Ext Cap %p, port offset = %u, "
1653 "count = %u, revision = 0x%x\n",
1654 addr, port_offset, port_count, major_revision);
1655 /* Port count includes the current port offset */
1656 if (port_offset == 0 || (port_offset + port_count - 1) > num_ports)
1657 /* WTF? "Valid values are ‘1’ to MaxPorts" */
1658 return;
1659 port_offset--;
1660 for (i = port_offset; i < (port_offset + port_count); i++) {
1661 /* Duplicate entry. Ignore the port if the revisions differ. */
1662 if (xhci->port_array[i] != 0) {
1663 xhci_warn(xhci, "Duplicate port entry, Ext Cap %p,"
1664 " port %u\n", addr, i);
1665 xhci_warn(xhci, "Port was marked as USB %u, "
1666 "duplicated as USB %u\n",
1667 xhci->port_array[i], major_revision);
1668 /* Only adjust the roothub port counts if we haven't
1669 * found a similar duplicate.
1670 */
1671 if (xhci->port_array[i] != major_revision &&
1672 xhci->port_array[i] != (u8) -1) {
1673 if (xhci->port_array[i] == 0x03)
1674 xhci->num_usb3_ports--;
1675 else
1676 xhci->num_usb2_ports--;
1677 xhci->port_array[i] = (u8) -1;
1678 }
1679 /* FIXME: Should we disable the port? */
1680 continue;
1681 }
1682 xhci->port_array[i] = major_revision;
1683 if (major_revision == 0x03)
1684 xhci->num_usb3_ports++;
1685 else
1686 xhci->num_usb2_ports++;
1687 }
1688 /* FIXME: Should we disable ports not in the Extended Capabilities? */
1689}
1690
1691/*
1692 * Scan the Extended Capabilities for the "Supported Protocol Capabilities" that
1693 * specify what speeds each port is supposed to be. We can't count on the port
1694 * speed bits in the PORTSC register being correct until a device is connected,
1695 * but we need to set up the two fake roothubs with the correct number of USB
1696 * 3.0 and USB 2.0 ports at host controller initialization time.
1697 */
1698static int xhci_setup_port_arrays(struct xhci_hcd *xhci, gfp_t flags)
1699{
1700 u32 __iomem *addr;
1701 u32 offset;
1702 unsigned int num_ports;
1703 int i, port_index;
1704
1705 addr = &xhci->cap_regs->hcc_params;
1706 offset = XHCI_HCC_EXT_CAPS(xhci_readl(xhci, addr));
1707 if (offset == 0) {
1708 xhci_err(xhci, "No Extended Capability registers, "
1709 "unable to set up roothub.\n");
1710 return -ENODEV;
1711 }
1712
1713 num_ports = HCS_MAX_PORTS(xhci->hcs_params1);
1714 xhci->port_array = kzalloc(sizeof(*xhci->port_array)*num_ports, flags);
1715 if (!xhci->port_array)
1716 return -ENOMEM;
1717
1718 /*
1719 * For whatever reason, the first capability offset is from the
1720 * capability register base, not from the HCCPARAMS register.
1721 * See section 5.3.6 for offset calculation.
1722 */
1723 addr = &xhci->cap_regs->hc_capbase + offset;
1724 while (1) {
1725 u32 cap_id;
1726
1727 cap_id = xhci_readl(xhci, addr);
1728 if (XHCI_EXT_CAPS_ID(cap_id) == XHCI_EXT_CAPS_PROTOCOL)
1729 xhci_add_in_port(xhci, num_ports, addr,
1730 (u8) XHCI_EXT_PORT_MAJOR(cap_id));
1731 offset = XHCI_EXT_CAPS_NEXT(cap_id);
1732 if (!offset || (xhci->num_usb2_ports + xhci->num_usb3_ports)
1733 == num_ports)
1734 break;
1735 /*
1736 * Once you're into the Extended Capabilities, the offset is
1737 * always relative to the register holding the offset.
1738 */
1739 addr += offset;
1740 }
1741
1742 if (xhci->num_usb2_ports == 0 && xhci->num_usb3_ports == 0) {
1743 xhci_warn(xhci, "No ports on the roothubs?\n");
1744 return -ENODEV;
1745 }
1746 xhci_dbg(xhci, "Found %u USB 2.0 ports and %u USB 3.0 ports.\n",
1747 xhci->num_usb2_ports, xhci->num_usb3_ports);
1748 /*
1749 * Note we could have all USB 3.0 ports, or all USB 2.0 ports.
1750 * Not sure how the USB core will handle a hub with no ports...
1751 */
1752 if (xhci->num_usb2_ports) {
1753 xhci->usb2_ports = kmalloc(sizeof(*xhci->usb2_ports)*
1754 xhci->num_usb2_ports, flags);
1755 if (!xhci->usb2_ports)
1756 return -ENOMEM;
1757
1758 port_index = 0;
1759 for (i = 0; i < num_ports; i++) {
1760 if (xhci->port_array[i] == 0x03 ||
1761 xhci->port_array[i] == 0 ||
1762 xhci->port_array[i] == -1)
1763 continue;
1764
1765 xhci->usb2_ports[port_index] =
1766 &xhci->op_regs->port_status_base +
1767 NUM_PORT_REGS*i;
1768 xhci_dbg(xhci, "USB 2.0 port at index %u, "
1769 "addr = %p\n", i,
1770 xhci->usb2_ports[port_index]);
1771 port_index++;
1772 }
1773 }
1774 if (xhci->num_usb3_ports) {
1775 xhci->usb3_ports = kmalloc(sizeof(*xhci->usb3_ports)*
1776 xhci->num_usb3_ports, flags);
1777 if (!xhci->usb3_ports)
1778 return -ENOMEM;
1779
1780 port_index = 0;
1781 for (i = 0; i < num_ports; i++)
1782 if (xhci->port_array[i] == 0x03) {
1783 xhci->usb3_ports[port_index] =
1784 &xhci->op_regs->port_status_base +
1785 NUM_PORT_REGS*i;
1786 xhci_dbg(xhci, "USB 3.0 port at index %u, "
1787 "addr = %p\n", i,
1788 xhci->usb3_ports[port_index]);
1789 port_index++;
1790 }
1791 }
1792 return 0;
1793}
1627 1794
1628int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags) 1795int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
1629{ 1796{
@@ -1804,6 +1971,8 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
1804 1971
1805 if (scratchpad_alloc(xhci, flags)) 1972 if (scratchpad_alloc(xhci, flags))
1806 goto fail; 1973 goto fail;
1974 if (xhci_setup_port_arrays(xhci, flags))
1975 goto fail;
1807 1976
1808 return 0; 1977 return 0;
1809 1978
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 48e60d166ff0..e7547d8b3d67 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -2028,7 +2028,6 @@ irqreturn_t xhci_irq(struct usb_hcd *hcd)
2028 2028
2029 if (!(status & STS_EINT)) { 2029 if (!(status & STS_EINT)) {
2030 spin_unlock(&xhci->lock); 2030 spin_unlock(&xhci->lock);
2031 xhci_warn(xhci, "Spurious interrupt.\n");
2032 return IRQ_NONE; 2031 return IRQ_NONE;
2033 } 2032 }
2034 xhci_dbg(xhci, "op reg status = %08x\n", status); 2033 xhci_dbg(xhci, "op reg status = %08x\n", status);
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index d5c550ea3e68..96ef552cfeb3 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -508,9 +508,10 @@ void xhci_stop(struct usb_hcd *hcd)
508 spin_lock_irq(&xhci->lock); 508 spin_lock_irq(&xhci->lock);
509 xhci_halt(xhci); 509 xhci_halt(xhci);
510 xhci_reset(xhci); 510 xhci_reset(xhci);
511 xhci_cleanup_msix(xhci);
512 spin_unlock_irq(&xhci->lock); 511 spin_unlock_irq(&xhci->lock);
513 512
513 xhci_cleanup_msix(xhci);
514
514#ifdef CONFIG_USB_XHCI_HCD_DEBUGGING 515#ifdef CONFIG_USB_XHCI_HCD_DEBUGGING
515 /* Tell the event ring poll function not to reschedule */ 516 /* Tell the event ring poll function not to reschedule */
516 xhci->zombie = 1; 517 xhci->zombie = 1;
@@ -544,9 +545,10 @@ void xhci_shutdown(struct usb_hcd *hcd)
544 545
545 spin_lock_irq(&xhci->lock); 546 spin_lock_irq(&xhci->lock);
546 xhci_halt(xhci); 547 xhci_halt(xhci);
547 xhci_cleanup_msix(xhci);
548 spin_unlock_irq(&xhci->lock); 548 spin_unlock_irq(&xhci->lock);
549 549
550 xhci_cleanup_msix(xhci);
551
550 xhci_dbg(xhci, "xhci_shutdown completed - status = %x\n", 552 xhci_dbg(xhci, "xhci_shutdown completed - status = %x\n",
551 xhci_readl(xhci, &xhci->op_regs->status)); 553 xhci_readl(xhci, &xhci->op_regs->status));
552} 554}
@@ -1284,6 +1286,15 @@ static int xhci_configure_endpoint(struct xhci_hcd *xhci,
1284 cmd_completion = command->completion; 1286 cmd_completion = command->completion;
1285 cmd_status = &command->status; 1287 cmd_status = &command->status;
1286 command->command_trb = xhci->cmd_ring->enqueue; 1288 command->command_trb = xhci->cmd_ring->enqueue;
1289
1290 /* Enqueue pointer can be left pointing to the link TRB,
1291 * we must handle that
1292 */
1293 if ((command->command_trb->link.control & TRB_TYPE_BITMASK)
1294 == TRB_TYPE(TRB_LINK))
1295 command->command_trb =
1296 xhci->cmd_ring->enq_seg->next->trbs;
1297
1287 list_add_tail(&command->cmd_list, &virt_dev->cmd_list); 1298 list_add_tail(&command->cmd_list, &virt_dev->cmd_list);
1288 } else { 1299 } else {
1289 in_ctx = virt_dev->in_ctx; 1300 in_ctx = virt_dev->in_ctx;
@@ -1993,6 +2004,15 @@ int xhci_reset_device(struct usb_hcd *hcd, struct usb_device *udev)
1993 /* Attempt to submit the Reset Device command to the command ring */ 2004 /* Attempt to submit the Reset Device command to the command ring */
1994 spin_lock_irqsave(&xhci->lock, flags); 2005 spin_lock_irqsave(&xhci->lock, flags);
1995 reset_device_cmd->command_trb = xhci->cmd_ring->enqueue; 2006 reset_device_cmd->command_trb = xhci->cmd_ring->enqueue;
2007
2008 /* Enqueue pointer can be left pointing to the link TRB,
2009 * we must handle that
2010 */
2011 if ((reset_device_cmd->command_trb->link.control & TRB_TYPE_BITMASK)
2012 == TRB_TYPE(TRB_LINK))
2013 reset_device_cmd->command_trb =
2014 xhci->cmd_ring->enq_seg->next->trbs;
2015
1996 list_add_tail(&reset_device_cmd->cmd_list, &virt_dev->cmd_list); 2016 list_add_tail(&reset_device_cmd->cmd_list, &virt_dev->cmd_list);
1997 ret = xhci_queue_reset_device(xhci, slot_id); 2017 ret = xhci_queue_reset_device(xhci, slot_id);
1998 if (ret) { 2018 if (ret) {
@@ -2148,8 +2168,12 @@ int xhci_alloc_dev(struct usb_hcd *hcd, struct usb_device *udev)
2148 xhci_err(xhci, "Error while assigning device slot ID\n"); 2168 xhci_err(xhci, "Error while assigning device slot ID\n");
2149 return 0; 2169 return 0;
2150 } 2170 }
2151 /* xhci_alloc_virt_device() does not touch rings; no need to lock */ 2171 /* xhci_alloc_virt_device() does not touch rings; no need to lock.
2152 if (!xhci_alloc_virt_device(xhci, xhci->slot_id, udev, GFP_KERNEL)) { 2172 * Use GFP_NOIO, since this function can be called from
2173 * xhci_discover_or_reset_device(), which may be called as part of
2174 * mass storage driver error handling.
2175 */
2176 if (!xhci_alloc_virt_device(xhci, xhci->slot_id, udev, GFP_NOIO)) {
2153 /* Disable slot, if we can do it without mem alloc */ 2177 /* Disable slot, if we can do it without mem alloc */
2154 xhci_warn(xhci, "Could not allocate xHCI USB device data structures\n"); 2178 xhci_warn(xhci, "Could not allocate xHCI USB device data structures\n");
2155 spin_lock_irqsave(&xhci->lock, flags); 2179 spin_lock_irqsave(&xhci->lock, flags);
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 34a60d9f056a..404ecbce5128 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -448,6 +448,24 @@ struct xhci_doorbell_array {
448 448
449 449
450/** 450/**
451 * struct xhci_protocol_caps
452 * @revision: major revision, minor revision, capability ID,
453 * and next capability pointer.
454 * @name_string: Four ASCII characters to say which spec this xHC
455 * follows, typically "USB ".
456 * @port_info: Port offset, count, and protocol-defined information.
457 */
458struct xhci_protocol_caps {
459 u32 revision;
460 u32 name_string;
461 u32 port_info;
462};
463
464#define XHCI_EXT_PORT_MAJOR(x) (((x) >> 24) & 0xff)
465#define XHCI_EXT_PORT_OFF(x) ((x) & 0xff)
466#define XHCI_EXT_PORT_COUNT(x) (((x) >> 8) & 0xff)
467
468/**
451 * struct xhci_container_ctx 469 * struct xhci_container_ctx
452 * @type: Type of context. Used to calculated offsets to contained contexts. 470 * @type: Type of context. Used to calculated offsets to contained contexts.
453 * @size: Size of the context data 471 * @size: Size of the context data
@@ -614,6 +632,11 @@ struct xhci_ep_ctx {
614#define MAX_PACKET_MASK (0xffff << 16) 632#define MAX_PACKET_MASK (0xffff << 16)
615#define MAX_PACKET_DECODED(p) (((p) >> 16) & 0xffff) 633#define MAX_PACKET_DECODED(p) (((p) >> 16) & 0xffff)
616 634
635/* Get max packet size from ep desc. Bit 10..0 specify the max packet size.
636 * USB2.0 spec 9.6.6.
637 */
638#define GET_MAX_PACKET(p) ((p) & 0x7ff)
639
617/* tx_info bitmasks */ 640/* tx_info bitmasks */
618#define AVG_TRB_LENGTH_FOR_EP(p) ((p) & 0xffff) 641#define AVG_TRB_LENGTH_FOR_EP(p) ((p) & 0xffff)
619#define MAX_ESIT_PAYLOAD_FOR_EP(p) (((p) & 0xffff) << 16) 642#define MAX_ESIT_PAYLOAD_FOR_EP(p) (((p) & 0xffff) << 16)
@@ -1199,6 +1222,15 @@ struct xhci_hcd {
1199#define XHCI_LINK_TRB_QUIRK (1 << 0) 1222#define XHCI_LINK_TRB_QUIRK (1 << 0)
1200#define XHCI_RESET_EP_QUIRK (1 << 1) 1223#define XHCI_RESET_EP_QUIRK (1 << 1)
1201#define XHCI_NEC_HOST (1 << 2) 1224#define XHCI_NEC_HOST (1 << 2)
1225
1226 /* Is each xHCI roothub port a USB 3.0, USB 2.0, or USB 1.1 port? */
1227 u8 *port_array;
1228 /* Array of pointers to USB 3.0 PORTSC registers */
1229 u32 __iomem **usb3_ports;
1230 unsigned int num_usb3_ports;
1231 /* Array of pointers to USB 2.0 PORTSC registers */
1232 u32 __iomem **usb2_ports;
1233 unsigned int num_usb2_ports;
1202}; 1234};
1203 1235
1204/* For testing purposes */ 1236/* For testing purposes */