diff options
Diffstat (limited to 'drivers/usb/host')
-rw-r--r-- | drivers/usb/host/ehci-hcd.c | 21 | ||||
-rw-r--r-- | drivers/usb/host/ehci-hub.c | 78 | ||||
-rw-r--r-- | drivers/usb/host/ehci-msm.c | 20 | ||||
-rw-r--r-- | drivers/usb/host/ehci-q.c | 85 | ||||
-rw-r--r-- | drivers/usb/host/ehci-s5p.c | 95 | ||||
-rw-r--r-- | drivers/usb/host/ehci-sched.c | 17 | ||||
-rw-r--r-- | drivers/usb/host/ehci-sysfs.c | 190 | ||||
-rw-r--r-- | drivers/usb/host/ehci.h | 6 | ||||
-rw-r--r-- | drivers/usb/host/ohci-sh.c | 2 | ||||
-rw-r--r-- | drivers/usb/host/pci-quirks.c | 56 | ||||
-rw-r--r-- | drivers/usb/host/r8a66597-hcd.c | 6 | ||||
-rw-r--r-- | drivers/usb/host/r8a66597.h | 38 | ||||
-rw-r--r-- | drivers/usb/host/xhci-dbg.c | 22 | ||||
-rw-r--r-- | drivers/usb/host/xhci-mem.c | 26 | ||||
-rw-r--r-- | drivers/usb/host/xhci-ring.c | 42 | ||||
-rw-r--r-- | drivers/usb/host/xhci.c | 10 | ||||
-rw-r--r-- | drivers/usb/host/xhci.h | 7 |
17 files changed, 481 insertions, 240 deletions
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index f8030ee928e..f72ae0b6ee7 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c | |||
@@ -94,7 +94,8 @@ static const char hcd_name [] = "ehci_hcd"; | |||
94 | #define EHCI_IAA_MSECS 10 /* arbitrary */ | 94 | #define EHCI_IAA_MSECS 10 /* arbitrary */ |
95 | #define EHCI_IO_JIFFIES (HZ/10) /* io watchdog > irq_thresh */ | 95 | #define EHCI_IO_JIFFIES (HZ/10) /* io watchdog > irq_thresh */ |
96 | #define EHCI_ASYNC_JIFFIES (HZ/20) /* async idle timeout */ | 96 | #define EHCI_ASYNC_JIFFIES (HZ/20) /* async idle timeout */ |
97 | #define EHCI_SHRINK_FRAMES 5 /* async qh unlink delay */ | 97 | #define EHCI_SHRINK_JIFFIES (DIV_ROUND_UP(HZ, 200) + 1) |
98 | /* 200-ms async qh unlink delay */ | ||
98 | 99 | ||
99 | /* Initial IRQ latency: faster than hw default */ | 100 | /* Initial IRQ latency: faster than hw default */ |
100 | static int log2_irq_thresh = 0; // 0 to 6 | 101 | static int log2_irq_thresh = 0; // 0 to 6 |
@@ -114,7 +115,7 @@ MODULE_PARM_DESC (ignore_oc, "ignore bogus hardware overcurrent indications"); | |||
114 | /* for link power management(LPM) feature */ | 115 | /* for link power management(LPM) feature */ |
115 | static unsigned int hird; | 116 | static unsigned int hird; |
116 | module_param(hird, int, S_IRUGO); | 117 | module_param(hird, int, S_IRUGO); |
117 | MODULE_PARM_DESC(hird, "host initiated resume duration, +1 for each 75us\n"); | 118 | MODULE_PARM_DESC(hird, "host initiated resume duration, +1 for each 75us"); |
118 | 119 | ||
119 | #define INTR_MASK (STS_IAA | STS_FATAL | STS_PCD | STS_ERR | STS_INT) | 120 | #define INTR_MASK (STS_IAA | STS_FATAL | STS_PCD | STS_ERR | STS_INT) |
120 | 121 | ||
@@ -152,10 +153,7 @@ timer_action(struct ehci_hcd *ehci, enum ehci_timer_action action) | |||
152 | break; | 153 | break; |
153 | /* case TIMER_ASYNC_SHRINK: */ | 154 | /* case TIMER_ASYNC_SHRINK: */ |
154 | default: | 155 | default: |
155 | /* add a jiffie since we synch against the | 156 | t = EHCI_SHRINK_JIFFIES; |
156 | * 8 KHz uframe counter. | ||
157 | */ | ||
158 | t = DIV_ROUND_UP(EHCI_SHRINK_FRAMES * HZ, 1000) + 1; | ||
159 | break; | 157 | break; |
160 | } | 158 | } |
161 | mod_timer(&ehci->watchdog, t + jiffies); | 159 | mod_timer(&ehci->watchdog, t + jiffies); |
@@ -340,6 +338,7 @@ static void ehci_work(struct ehci_hcd *ehci); | |||
340 | #include "ehci-mem.c" | 338 | #include "ehci-mem.c" |
341 | #include "ehci-q.c" | 339 | #include "ehci-q.c" |
342 | #include "ehci-sched.c" | 340 | #include "ehci-sched.c" |
341 | #include "ehci-sysfs.c" | ||
343 | 342 | ||
344 | /*-------------------------------------------------------------------------*/ | 343 | /*-------------------------------------------------------------------------*/ |
345 | 344 | ||
@@ -524,7 +523,7 @@ static void ehci_stop (struct usb_hcd *hcd) | |||
524 | ehci_reset (ehci); | 523 | ehci_reset (ehci); |
525 | spin_unlock_irq(&ehci->lock); | 524 | spin_unlock_irq(&ehci->lock); |
526 | 525 | ||
527 | remove_companion_file(ehci); | 526 | remove_sysfs_files(ehci); |
528 | remove_debug_files (ehci); | 527 | remove_debug_files (ehci); |
529 | 528 | ||
530 | /* root hub is shut down separately (first, when possible) */ | 529 | /* root hub is shut down separately (first, when possible) */ |
@@ -575,6 +574,12 @@ static int ehci_init(struct usb_hcd *hcd) | |||
575 | hcc_params = ehci_readl(ehci, &ehci->caps->hcc_params); | 574 | hcc_params = ehci_readl(ehci, &ehci->caps->hcc_params); |
576 | 575 | ||
577 | /* | 576 | /* |
577 | * by default set standard 80% (== 100 usec/uframe) max periodic | ||
578 | * bandwidth as required by USB 2.0 | ||
579 | */ | ||
580 | ehci->uframe_periodic_max = 100; | ||
581 | |||
582 | /* | ||
578 | * hw default: 1K periodic list heads, one per frame. | 583 | * hw default: 1K periodic list heads, one per frame. |
579 | * periodic_size can shrink by USBCMD update if hcc_params allows. | 584 | * periodic_size can shrink by USBCMD update if hcc_params allows. |
580 | */ | 585 | */ |
@@ -758,7 +763,7 @@ static int ehci_run (struct usb_hcd *hcd) | |||
758 | * since the class device isn't created that early. | 763 | * since the class device isn't created that early. |
759 | */ | 764 | */ |
760 | create_debug_files(ehci); | 765 | create_debug_files(ehci); |
761 | create_companion_file(ehci); | 766 | create_sysfs_files(ehci); |
762 | 767 | ||
763 | return 0; | 768 | return 0; |
764 | } | 769 | } |
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c index ea6184bf48d..bf2c8f65e1a 100644 --- a/drivers/usb/host/ehci-hub.c +++ b/drivers/usb/host/ehci-hub.c | |||
@@ -471,29 +471,6 @@ static int ehci_bus_resume (struct usb_hcd *hcd) | |||
471 | 471 | ||
472 | /*-------------------------------------------------------------------------*/ | 472 | /*-------------------------------------------------------------------------*/ |
473 | 473 | ||
474 | /* Display the ports dedicated to the companion controller */ | ||
475 | static ssize_t show_companion(struct device *dev, | ||
476 | struct device_attribute *attr, | ||
477 | char *buf) | ||
478 | { | ||
479 | struct ehci_hcd *ehci; | ||
480 | int nports, index, n; | ||
481 | int count = PAGE_SIZE; | ||
482 | char *ptr = buf; | ||
483 | |||
484 | ehci = hcd_to_ehci(bus_to_hcd(dev_get_drvdata(dev))); | ||
485 | nports = HCS_N_PORTS(ehci->hcs_params); | ||
486 | |||
487 | for (index = 0; index < nports; ++index) { | ||
488 | if (test_bit(index, &ehci->companion_ports)) { | ||
489 | n = scnprintf(ptr, count, "%d\n", index + 1); | ||
490 | ptr += n; | ||
491 | count -= n; | ||
492 | } | ||
493 | } | ||
494 | return ptr - buf; | ||
495 | } | ||
496 | |||
497 | /* | 474 | /* |
498 | * Sets the owner of a port | 475 | * Sets the owner of a port |
499 | */ | 476 | */ |
@@ -528,58 +505,6 @@ static void set_owner(struct ehci_hcd *ehci, int portnum, int new_owner) | |||
528 | } | 505 | } |
529 | } | 506 | } |
530 | 507 | ||
531 | /* | ||
532 | * Dedicate or undedicate a port to the companion controller. | ||
533 | * Syntax is "[-]portnum", where a leading '-' sign means | ||
534 | * return control of the port to the EHCI controller. | ||
535 | */ | ||
536 | static ssize_t store_companion(struct device *dev, | ||
537 | struct device_attribute *attr, | ||
538 | const char *buf, size_t count) | ||
539 | { | ||
540 | struct ehci_hcd *ehci; | ||
541 | int portnum, new_owner; | ||
542 | |||
543 | ehci = hcd_to_ehci(bus_to_hcd(dev_get_drvdata(dev))); | ||
544 | new_owner = PORT_OWNER; /* Owned by companion */ | ||
545 | if (sscanf(buf, "%d", &portnum) != 1) | ||
546 | return -EINVAL; | ||
547 | if (portnum < 0) { | ||
548 | portnum = - portnum; | ||
549 | new_owner = 0; /* Owned by EHCI */ | ||
550 | } | ||
551 | if (portnum <= 0 || portnum > HCS_N_PORTS(ehci->hcs_params)) | ||
552 | return -ENOENT; | ||
553 | portnum--; | ||
554 | if (new_owner) | ||
555 | set_bit(portnum, &ehci->companion_ports); | ||
556 | else | ||
557 | clear_bit(portnum, &ehci->companion_ports); | ||
558 | set_owner(ehci, portnum, new_owner); | ||
559 | return count; | ||
560 | } | ||
561 | static DEVICE_ATTR(companion, 0644, show_companion, store_companion); | ||
562 | |||
563 | static inline int create_companion_file(struct ehci_hcd *ehci) | ||
564 | { | ||
565 | int i = 0; | ||
566 | |||
567 | /* with integrated TT there is no companion! */ | ||
568 | if (!ehci_is_TDI(ehci)) | ||
569 | i = device_create_file(ehci_to_hcd(ehci)->self.controller, | ||
570 | &dev_attr_companion); | ||
571 | return i; | ||
572 | } | ||
573 | |||
574 | static inline void remove_companion_file(struct ehci_hcd *ehci) | ||
575 | { | ||
576 | /* with integrated TT there is no companion! */ | ||
577 | if (!ehci_is_TDI(ehci)) | ||
578 | device_remove_file(ehci_to_hcd(ehci)->self.controller, | ||
579 | &dev_attr_companion); | ||
580 | } | ||
581 | |||
582 | |||
583 | /*-------------------------------------------------------------------------*/ | 508 | /*-------------------------------------------------------------------------*/ |
584 | 509 | ||
585 | static int check_reset_complete ( | 510 | static int check_reset_complete ( |
@@ -891,10 +816,11 @@ static int ehci_hub_control ( | |||
891 | * power switching; they're allowed to just limit the | 816 | * power switching; they're allowed to just limit the |
892 | * current. khubd will turn the power back on. | 817 | * current. khubd will turn the power back on. |
893 | */ | 818 | */ |
894 | if (HCS_PPC (ehci->hcs_params)){ | 819 | if ((temp & PORT_OC) && HCS_PPC(ehci->hcs_params)) { |
895 | ehci_writel(ehci, | 820 | ehci_writel(ehci, |
896 | temp & ~(PORT_RWC_BITS | PORT_POWER), | 821 | temp & ~(PORT_RWC_BITS | PORT_POWER), |
897 | status_reg); | 822 | status_reg); |
823 | temp = ehci_readl(ehci, status_reg); | ||
898 | } | 824 | } |
899 | } | 825 | } |
900 | 826 | ||
diff --git a/drivers/usb/host/ehci-msm.c b/drivers/usb/host/ehci-msm.c index b5a0bf649c9..592d5f76803 100644 --- a/drivers/usb/host/ehci-msm.c +++ b/drivers/usb/host/ehci-msm.c | |||
@@ -40,27 +40,9 @@ static int ehci_msm_reset(struct usb_hcd *hcd) | |||
40 | int retval; | 40 | int retval; |
41 | 41 | ||
42 | ehci->caps = USB_CAPLENGTH; | 42 | ehci->caps = USB_CAPLENGTH; |
43 | ehci->regs = USB_CAPLENGTH + | ||
44 | HC_LENGTH(ehci, ehci_readl(ehci, &ehci->caps->hc_capbase)); | ||
45 | dbg_hcs_params(ehci, "reset"); | ||
46 | dbg_hcc_params(ehci, "reset"); | ||
47 | |||
48 | /* cache the data to minimize the chip reads*/ | ||
49 | ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params); | ||
50 | |||
51 | hcd->has_tt = 1; | 43 | hcd->has_tt = 1; |
52 | ehci->sbrn = HCD_USB2; | ||
53 | |||
54 | retval = ehci_halt(ehci); | ||
55 | if (retval) | ||
56 | return retval; | ||
57 | |||
58 | /* data structure init */ | ||
59 | retval = ehci_init(hcd); | ||
60 | if (retval) | ||
61 | return retval; | ||
62 | 44 | ||
63 | retval = ehci_reset(ehci); | 45 | retval = ehci_setup(hcd); |
64 | if (retval) | 46 | if (retval) |
65 | return retval; | 47 | return retval; |
66 | 48 | ||
diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c index 5d6bc624c96..0917e3a3246 100644 --- a/drivers/usb/host/ehci-q.c +++ b/drivers/usb/host/ehci-q.c | |||
@@ -103,7 +103,7 @@ qh_update (struct ehci_hcd *ehci, struct ehci_qh *qh, struct ehci_qtd *qtd) | |||
103 | if (!(hw->hw_info1 & cpu_to_hc32(ehci, 1 << 14))) { | 103 | if (!(hw->hw_info1 & cpu_to_hc32(ehci, 1 << 14))) { |
104 | unsigned is_out, epnum; | 104 | unsigned is_out, epnum; |
105 | 105 | ||
106 | is_out = !(qtd->hw_token & cpu_to_hc32(ehci, 1 << 8)); | 106 | is_out = qh->is_out; |
107 | epnum = (hc32_to_cpup(ehci, &hw->hw_info1) >> 8) & 0x0f; | 107 | epnum = (hc32_to_cpup(ehci, &hw->hw_info1) >> 8) & 0x0f; |
108 | if (unlikely (!usb_gettoggle (qh->dev, epnum, is_out))) { | 108 | if (unlikely (!usb_gettoggle (qh->dev, epnum, is_out))) { |
109 | hw->hw_token &= ~cpu_to_hc32(ehci, QTD_TOGGLE); | 109 | hw->hw_token &= ~cpu_to_hc32(ehci, QTD_TOGGLE); |
@@ -946,6 +946,7 @@ done: | |||
946 | hw = qh->hw; | 946 | hw = qh->hw; |
947 | hw->hw_info1 = cpu_to_hc32(ehci, info1); | 947 | hw->hw_info1 = cpu_to_hc32(ehci, info1); |
948 | hw->hw_info2 = cpu_to_hc32(ehci, info2); | 948 | hw->hw_info2 = cpu_to_hc32(ehci, info2); |
949 | qh->is_out = !is_input; | ||
949 | usb_settoggle (urb->dev, usb_pipeendpoint (urb->pipe), !is_input, 1); | 950 | usb_settoggle (urb->dev, usb_pipeendpoint (urb->pipe), !is_input, 1); |
950 | qh_refresh (ehci, qh); | 951 | qh_refresh (ehci, qh); |
951 | return qh; | 952 | return qh; |
@@ -1231,6 +1232,8 @@ static void start_unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh) | |||
1231 | 1232 | ||
1232 | prev->hw->hw_next = qh->hw->hw_next; | 1233 | prev->hw->hw_next = qh->hw->hw_next; |
1233 | prev->qh_next = qh->qh_next; | 1234 | prev->qh_next = qh->qh_next; |
1235 | if (ehci->qh_scan_next == qh) | ||
1236 | ehci->qh_scan_next = qh->qh_next.qh; | ||
1234 | wmb (); | 1237 | wmb (); |
1235 | 1238 | ||
1236 | /* If the controller isn't running, we don't have to wait for it */ | 1239 | /* If the controller isn't running, we don't have to wait for it */ |
@@ -1256,53 +1259,49 @@ static void scan_async (struct ehci_hcd *ehci) | |||
1256 | struct ehci_qh *qh; | 1259 | struct ehci_qh *qh; |
1257 | enum ehci_timer_action action = TIMER_IO_WATCHDOG; | 1260 | enum ehci_timer_action action = TIMER_IO_WATCHDOG; |
1258 | 1261 | ||
1259 | ehci->stamp = ehci_readl(ehci, &ehci->regs->frame_index); | ||
1260 | timer_action_done (ehci, TIMER_ASYNC_SHRINK); | 1262 | timer_action_done (ehci, TIMER_ASYNC_SHRINK); |
1261 | rescan: | ||
1262 | stopped = !HC_IS_RUNNING(ehci_to_hcd(ehci)->state); | 1263 | stopped = !HC_IS_RUNNING(ehci_to_hcd(ehci)->state); |
1263 | qh = ehci->async->qh_next.qh; | ||
1264 | if (likely (qh != NULL)) { | ||
1265 | do { | ||
1266 | /* clean any finished work for this qh */ | ||
1267 | if (!list_empty(&qh->qtd_list) && (stopped || | ||
1268 | qh->stamp != ehci->stamp)) { | ||
1269 | int temp; | ||
1270 | |||
1271 | /* unlinks could happen here; completion | ||
1272 | * reporting drops the lock. rescan using | ||
1273 | * the latest schedule, but don't rescan | ||
1274 | * qhs we already finished (no looping) | ||
1275 | * unless the controller is stopped. | ||
1276 | */ | ||
1277 | qh = qh_get (qh); | ||
1278 | qh->stamp = ehci->stamp; | ||
1279 | temp = qh_completions (ehci, qh); | ||
1280 | if (qh->needs_rescan) | ||
1281 | unlink_async(ehci, qh); | ||
1282 | qh_put (qh); | ||
1283 | if (temp != 0) { | ||
1284 | goto rescan; | ||
1285 | } | ||
1286 | } | ||
1287 | 1264 | ||
1288 | /* unlink idle entries, reducing DMA usage as well | 1265 | ehci->qh_scan_next = ehci->async->qh_next.qh; |
1289 | * as HCD schedule-scanning costs. delay for any qh | 1266 | while (ehci->qh_scan_next) { |
1290 | * we just scanned, there's a not-unusual case that it | 1267 | qh = ehci->qh_scan_next; |
1291 | * doesn't stay idle for long. | 1268 | ehci->qh_scan_next = qh->qh_next.qh; |
1292 | * (plus, avoids some kind of re-activation race.) | 1269 | rescan: |
1270 | /* clean any finished work for this qh */ | ||
1271 | if (!list_empty(&qh->qtd_list)) { | ||
1272 | int temp; | ||
1273 | |||
1274 | /* | ||
1275 | * Unlinks could happen here; completion reporting | ||
1276 | * drops the lock. That's why ehci->qh_scan_next | ||
1277 | * always holds the next qh to scan; if the next qh | ||
1278 | * gets unlinked then ehci->qh_scan_next is adjusted | ||
1279 | * in start_unlink_async(). | ||
1293 | */ | 1280 | */ |
1294 | if (list_empty(&qh->qtd_list) | 1281 | qh = qh_get(qh); |
1295 | && qh->qh_state == QH_STATE_LINKED) { | 1282 | temp = qh_completions(ehci, qh); |
1296 | if (!ehci->reclaim && (stopped || | 1283 | if (qh->needs_rescan) |
1297 | ((ehci->stamp - qh->stamp) & 0x1fff) | 1284 | unlink_async(ehci, qh); |
1298 | >= EHCI_SHRINK_FRAMES * 8)) | 1285 | qh->unlink_time = jiffies + EHCI_SHRINK_JIFFIES; |
1299 | start_unlink_async(ehci, qh); | 1286 | qh_put(qh); |
1300 | else | 1287 | if (temp != 0) |
1301 | action = TIMER_ASYNC_SHRINK; | 1288 | goto rescan; |
1302 | } | 1289 | } |
1303 | 1290 | ||
1304 | qh = qh->qh_next.qh; | 1291 | /* unlink idle entries, reducing DMA usage as well |
1305 | } while (qh); | 1292 | * as HCD schedule-scanning costs. delay for any qh |
1293 | * we just scanned, there's a not-unusual case that it | ||
1294 | * doesn't stay idle for long. | ||
1295 | * (plus, avoids some kind of re-activation race.) | ||
1296 | */ | ||
1297 | if (list_empty(&qh->qtd_list) | ||
1298 | && qh->qh_state == QH_STATE_LINKED) { | ||
1299 | if (!ehci->reclaim && (stopped || | ||
1300 | time_after_eq(jiffies, qh->unlink_time))) | ||
1301 | start_unlink_async(ehci, qh); | ||
1302 | else | ||
1303 | action = TIMER_ASYNC_SHRINK; | ||
1304 | } | ||
1306 | } | 1305 | } |
1307 | if (action == TIMER_ASYNC_SHRINK) | 1306 | if (action == TIMER_ASYNC_SHRINK) |
1308 | timer_action (ehci, TIMER_ASYNC_SHRINK); | 1307 | timer_action (ehci, TIMER_ASYNC_SHRINK); |
diff --git a/drivers/usb/host/ehci-s5p.c b/drivers/usb/host/ehci-s5p.c index e3374c8f7b3..b3958b3d316 100644 --- a/drivers/usb/host/ehci-s5p.c +++ b/drivers/usb/host/ehci-s5p.c | |||
@@ -189,6 +189,100 @@ static void s5p_ehci_shutdown(struct platform_device *pdev) | |||
189 | hcd->driver->shutdown(hcd); | 189 | hcd->driver->shutdown(hcd); |
190 | } | 190 | } |
191 | 191 | ||
192 | #ifdef CONFIG_PM | ||
193 | static int s5p_ehci_suspend(struct device *dev) | ||
194 | { | ||
195 | struct s5p_ehci_hcd *s5p_ehci = dev_get_drvdata(dev); | ||
196 | struct usb_hcd *hcd = s5p_ehci->hcd; | ||
197 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | ||
198 | struct platform_device *pdev = to_platform_device(dev); | ||
199 | struct s5p_ehci_platdata *pdata = pdev->dev.platform_data; | ||
200 | unsigned long flags; | ||
201 | int rc = 0; | ||
202 | |||
203 | if (time_before(jiffies, ehci->next_statechange)) | ||
204 | msleep(20); | ||
205 | |||
206 | /* | ||
207 | * Root hub was already suspended. Disable irq emission and | ||
208 | * mark HW unaccessible. The PM and USB cores make sure that | ||
209 | * the root hub is either suspended or stopped. | ||
210 | */ | ||
211 | ehci_prepare_ports_for_controller_suspend(ehci, device_may_wakeup(dev)); | ||
212 | spin_lock_irqsave(&ehci->lock, flags); | ||
213 | ehci_writel(ehci, 0, &ehci->regs->intr_enable); | ||
214 | (void)ehci_readl(ehci, &ehci->regs->intr_enable); | ||
215 | |||
216 | clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | ||
217 | spin_unlock_irqrestore(&ehci->lock, flags); | ||
218 | |||
219 | if (pdata && pdata->phy_exit) | ||
220 | pdata->phy_exit(pdev, S5P_USB_PHY_HOST); | ||
221 | |||
222 | return rc; | ||
223 | } | ||
224 | |||
225 | static int s5p_ehci_resume(struct device *dev) | ||
226 | { | ||
227 | struct s5p_ehci_hcd *s5p_ehci = dev_get_drvdata(dev); | ||
228 | struct usb_hcd *hcd = s5p_ehci->hcd; | ||
229 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | ||
230 | struct platform_device *pdev = to_platform_device(dev); | ||
231 | struct s5p_ehci_platdata *pdata = pdev->dev.platform_data; | ||
232 | |||
233 | if (pdata && pdata->phy_init) | ||
234 | pdata->phy_init(pdev, S5P_USB_PHY_HOST); | ||
235 | |||
236 | if (time_before(jiffies, ehci->next_statechange)) | ||
237 | msleep(100); | ||
238 | |||
239 | /* Mark hardware accessible again as we are out of D3 state by now */ | ||
240 | set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | ||
241 | |||
242 | if (ehci_readl(ehci, &ehci->regs->configured_flag) == FLAG_CF) { | ||
243 | int mask = INTR_MASK; | ||
244 | |||
245 | ehci_prepare_ports_for_controller_resume(ehci); | ||
246 | if (!hcd->self.root_hub->do_remote_wakeup) | ||
247 | mask &= ~STS_PCD; | ||
248 | ehci_writel(ehci, mask, &ehci->regs->intr_enable); | ||
249 | ehci_readl(ehci, &ehci->regs->intr_enable); | ||
250 | return 0; | ||
251 | } | ||
252 | |||
253 | usb_root_hub_lost_power(hcd->self.root_hub); | ||
254 | |||
255 | (void) ehci_halt(ehci); | ||
256 | (void) ehci_reset(ehci); | ||
257 | |||
258 | /* emptying the schedule aborts any urbs */ | ||
259 | spin_lock_irq(&ehci->lock); | ||
260 | if (ehci->reclaim) | ||
261 | end_unlink_async(ehci); | ||
262 | ehci_work(ehci); | ||
263 | spin_unlock_irq(&ehci->lock); | ||
264 | |||
265 | ehci_writel(ehci, ehci->command, &ehci->regs->command); | ||
266 | ehci_writel(ehci, FLAG_CF, &ehci->regs->configured_flag); | ||
267 | ehci_readl(ehci, &ehci->regs->command); /* unblock posted writes */ | ||
268 | |||
269 | /* here we "know" root ports should always stay powered */ | ||
270 | ehci_port_power(ehci, 1); | ||
271 | |||
272 | hcd->state = HC_STATE_SUSPENDED; | ||
273 | |||
274 | return 0; | ||
275 | } | ||
276 | #else | ||
277 | #define s5p_ehci_suspend NULL | ||
278 | #define s5p_ehci_resume NULL | ||
279 | #endif | ||
280 | |||
281 | static const struct dev_pm_ops s5p_ehci_pm_ops = { | ||
282 | .suspend = s5p_ehci_suspend, | ||
283 | .resume = s5p_ehci_resume, | ||
284 | }; | ||
285 | |||
192 | static struct platform_driver s5p_ehci_driver = { | 286 | static struct platform_driver s5p_ehci_driver = { |
193 | .probe = s5p_ehci_probe, | 287 | .probe = s5p_ehci_probe, |
194 | .remove = __devexit_p(s5p_ehci_remove), | 288 | .remove = __devexit_p(s5p_ehci_remove), |
@@ -196,6 +290,7 @@ static struct platform_driver s5p_ehci_driver = { | |||
196 | .driver = { | 290 | .driver = { |
197 | .name = "s5p-ehci", | 291 | .name = "s5p-ehci", |
198 | .owner = THIS_MODULE, | 292 | .owner = THIS_MODULE, |
293 | .pm = &s5p_ehci_pm_ops, | ||
199 | } | 294 | } |
200 | }; | 295 | }; |
201 | 296 | ||
diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c index 6c9fbe352f7..2abf8543f08 100644 --- a/drivers/usb/host/ehci-sched.c +++ b/drivers/usb/host/ehci-sched.c | |||
@@ -172,7 +172,7 @@ periodic_usecs (struct ehci_hcd *ehci, unsigned frame, unsigned uframe) | |||
172 | } | 172 | } |
173 | } | 173 | } |
174 | #ifdef DEBUG | 174 | #ifdef DEBUG |
175 | if (usecs > 100) | 175 | if (usecs > ehci->uframe_periodic_max) |
176 | ehci_err (ehci, "uframe %d sched overrun: %d usecs\n", | 176 | ehci_err (ehci, "uframe %d sched overrun: %d usecs\n", |
177 | frame * 8 + uframe, usecs); | 177 | frame * 8 + uframe, usecs); |
178 | #endif | 178 | #endif |
@@ -709,11 +709,8 @@ static int check_period ( | |||
709 | if (uframe >= 8) | 709 | if (uframe >= 8) |
710 | return 0; | 710 | return 0; |
711 | 711 | ||
712 | /* | 712 | /* convert "usecs we need" to "max already claimed" */ |
713 | * 80% periodic == 100 usec/uframe available | 713 | usecs = ehci->uframe_periodic_max - usecs; |
714 | * convert "usecs we need" to "max already claimed" | ||
715 | */ | ||
716 | usecs = 100 - usecs; | ||
717 | 714 | ||
718 | /* we "know" 2 and 4 uframe intervals were rejected; so | 715 | /* we "know" 2 and 4 uframe intervals were rejected; so |
719 | * for period 0, check _every_ microframe in the schedule. | 716 | * for period 0, check _every_ microframe in the schedule. |
@@ -1286,9 +1283,9 @@ itd_slot_ok ( | |||
1286 | { | 1283 | { |
1287 | uframe %= period; | 1284 | uframe %= period; |
1288 | do { | 1285 | do { |
1289 | /* can't commit more than 80% periodic == 100 usec */ | 1286 | /* can't commit more than uframe_periodic_max usec */ |
1290 | if (periodic_usecs (ehci, uframe >> 3, uframe & 0x7) | 1287 | if (periodic_usecs (ehci, uframe >> 3, uframe & 0x7) |
1291 | > (100 - usecs)) | 1288 | > (ehci->uframe_periodic_max - usecs)) |
1292 | return 0; | 1289 | return 0; |
1293 | 1290 | ||
1294 | /* we know urb->interval is 2^N uframes */ | 1291 | /* we know urb->interval is 2^N uframes */ |
@@ -1345,7 +1342,7 @@ sitd_slot_ok ( | |||
1345 | #endif | 1342 | #endif |
1346 | 1343 | ||
1347 | /* check starts (OUT uses more than one) */ | 1344 | /* check starts (OUT uses more than one) */ |
1348 | max_used = 100 - stream->usecs; | 1345 | max_used = ehci->uframe_periodic_max - stream->usecs; |
1349 | for (tmp = stream->raw_mask & 0xff; tmp; tmp >>= 1, uf++) { | 1346 | for (tmp = stream->raw_mask & 0xff; tmp; tmp >>= 1, uf++) { |
1350 | if (periodic_usecs (ehci, frame, uf) > max_used) | 1347 | if (periodic_usecs (ehci, frame, uf) > max_used) |
1351 | return 0; | 1348 | return 0; |
@@ -1354,7 +1351,7 @@ sitd_slot_ok ( | |||
1354 | /* for IN, check CSPLIT */ | 1351 | /* for IN, check CSPLIT */ |
1355 | if (stream->c_usecs) { | 1352 | if (stream->c_usecs) { |
1356 | uf = uframe & 7; | 1353 | uf = uframe & 7; |
1357 | max_used = 100 - stream->c_usecs; | 1354 | max_used = ehci->uframe_periodic_max - stream->c_usecs; |
1358 | do { | 1355 | do { |
1359 | tmp = 1 << uf; | 1356 | tmp = 1 << uf; |
1360 | tmp <<= 8; | 1357 | tmp <<= 8; |
diff --git a/drivers/usb/host/ehci-sysfs.c b/drivers/usb/host/ehci-sysfs.c new file mode 100644 index 00000000000..14ced00ba22 --- /dev/null +++ b/drivers/usb/host/ehci-sysfs.c | |||
@@ -0,0 +1,190 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007 by Alan Stern | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify it | ||
5 | * under the terms of the GNU General Public License as published by the | ||
6 | * Free Software Foundation; either version 2 of the License, or (at your | ||
7 | * option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, but | ||
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
11 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
12 | * for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the Free Software Foundation, | ||
16 | * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
17 | */ | ||
18 | |||
19 | /* this file is part of ehci-hcd.c */ | ||
20 | |||
21 | |||
22 | /* Display the ports dedicated to the companion controller */ | ||
23 | static ssize_t show_companion(struct device *dev, | ||
24 | struct device_attribute *attr, | ||
25 | char *buf) | ||
26 | { | ||
27 | struct ehci_hcd *ehci; | ||
28 | int nports, index, n; | ||
29 | int count = PAGE_SIZE; | ||
30 | char *ptr = buf; | ||
31 | |||
32 | ehci = hcd_to_ehci(bus_to_hcd(dev_get_drvdata(dev))); | ||
33 | nports = HCS_N_PORTS(ehci->hcs_params); | ||
34 | |||
35 | for (index = 0; index < nports; ++index) { | ||
36 | if (test_bit(index, &ehci->companion_ports)) { | ||
37 | n = scnprintf(ptr, count, "%d\n", index + 1); | ||
38 | ptr += n; | ||
39 | count -= n; | ||
40 | } | ||
41 | } | ||
42 | return ptr - buf; | ||
43 | } | ||
44 | |||
45 | /* | ||
46 | * Dedicate or undedicate a port to the companion controller. | ||
47 | * Syntax is "[-]portnum", where a leading '-' sign means | ||
48 | * return control of the port to the EHCI controller. | ||
49 | */ | ||
50 | static ssize_t store_companion(struct device *dev, | ||
51 | struct device_attribute *attr, | ||
52 | const char *buf, size_t count) | ||
53 | { | ||
54 | struct ehci_hcd *ehci; | ||
55 | int portnum, new_owner; | ||
56 | |||
57 | ehci = hcd_to_ehci(bus_to_hcd(dev_get_drvdata(dev))); | ||
58 | new_owner = PORT_OWNER; /* Owned by companion */ | ||
59 | if (sscanf(buf, "%d", &portnum) != 1) | ||
60 | return -EINVAL; | ||
61 | if (portnum < 0) { | ||
62 | portnum = - portnum; | ||
63 | new_owner = 0; /* Owned by EHCI */ | ||
64 | } | ||
65 | if (portnum <= 0 || portnum > HCS_N_PORTS(ehci->hcs_params)) | ||
66 | return -ENOENT; | ||
67 | portnum--; | ||
68 | if (new_owner) | ||
69 | set_bit(portnum, &ehci->companion_ports); | ||
70 | else | ||
71 | clear_bit(portnum, &ehci->companion_ports); | ||
72 | set_owner(ehci, portnum, new_owner); | ||
73 | return count; | ||
74 | } | ||
75 | static DEVICE_ATTR(companion, 0644, show_companion, store_companion); | ||
76 | |||
77 | |||
78 | /* | ||
79 | * Display / Set uframe_periodic_max | ||
80 | */ | ||
81 | static ssize_t show_uframe_periodic_max(struct device *dev, | ||
82 | struct device_attribute *attr, | ||
83 | char *buf) | ||
84 | { | ||
85 | struct ehci_hcd *ehci; | ||
86 | int n; | ||
87 | |||
88 | ehci = hcd_to_ehci(bus_to_hcd(dev_get_drvdata(dev))); | ||
89 | n = scnprintf(buf, PAGE_SIZE, "%d\n", ehci->uframe_periodic_max); | ||
90 | return n; | ||
91 | } | ||
92 | |||
93 | |||
94 | static ssize_t store_uframe_periodic_max(struct device *dev, | ||
95 | struct device_attribute *attr, | ||
96 | const char *buf, size_t count) | ||
97 | { | ||
98 | struct ehci_hcd *ehci; | ||
99 | unsigned uframe_periodic_max; | ||
100 | unsigned frame, uframe; | ||
101 | unsigned short allocated_max; | ||
102 | unsigned long flags; | ||
103 | ssize_t ret; | ||
104 | |||
105 | ehci = hcd_to_ehci(bus_to_hcd(dev_get_drvdata(dev))); | ||
106 | if (kstrtouint(buf, 0, &uframe_periodic_max) < 0) | ||
107 | return -EINVAL; | ||
108 | |||
109 | if (uframe_periodic_max < 100 || uframe_periodic_max >= 125) { | ||
110 | ehci_info(ehci, "rejecting invalid request for " | ||
111 | "uframe_periodic_max=%u\n", uframe_periodic_max); | ||
112 | return -EINVAL; | ||
113 | } | ||
114 | |||
115 | ret = -EINVAL; | ||
116 | |||
117 | /* | ||
118 | * lock, so that our checking does not race with possible periodic | ||
119 | * bandwidth allocation through submitting new urbs. | ||
120 | */ | ||
121 | spin_lock_irqsave (&ehci->lock, flags); | ||
122 | |||
123 | /* | ||
124 | * for request to decrease max periodic bandwidth, we have to check | ||
125 | * every microframe in the schedule to see whether the decrease is | ||
126 | * possible. | ||
127 | */ | ||
128 | if (uframe_periodic_max < ehci->uframe_periodic_max) { | ||
129 | allocated_max = 0; | ||
130 | |||
131 | for (frame = 0; frame < ehci->periodic_size; ++frame) | ||
132 | for (uframe = 0; uframe < 7; ++uframe) | ||
133 | allocated_max = max(allocated_max, | ||
134 | periodic_usecs (ehci, frame, uframe)); | ||
135 | |||
136 | if (allocated_max > uframe_periodic_max) { | ||
137 | ehci_info(ehci, | ||
138 | "cannot decrease uframe_periodic_max becase " | ||
139 | "periodic bandwidth is already allocated " | ||
140 | "(%u > %u)\n", | ||
141 | allocated_max, uframe_periodic_max); | ||
142 | goto out_unlock; | ||
143 | } | ||
144 | } | ||
145 | |||
146 | /* increasing is always ok */ | ||
147 | |||
148 | ehci_info(ehci, "setting max periodic bandwidth to %u%% " | ||
149 | "(== %u usec/uframe)\n", | ||
150 | 100*uframe_periodic_max/125, uframe_periodic_max); | ||
151 | |||
152 | if (uframe_periodic_max != 100) | ||
153 | ehci_warn(ehci, "max periodic bandwidth set is non-standard\n"); | ||
154 | |||
155 | ehci->uframe_periodic_max = uframe_periodic_max; | ||
156 | ret = count; | ||
157 | |||
158 | out_unlock: | ||
159 | spin_unlock_irqrestore (&ehci->lock, flags); | ||
160 | return ret; | ||
161 | } | ||
162 | static DEVICE_ATTR(uframe_periodic_max, 0644, show_uframe_periodic_max, store_uframe_periodic_max); | ||
163 | |||
164 | |||
165 | static inline int create_sysfs_files(struct ehci_hcd *ehci) | ||
166 | { | ||
167 | struct device *controller = ehci_to_hcd(ehci)->self.controller; | ||
168 | int i = 0; | ||
169 | |||
170 | /* with integrated TT there is no companion! */ | ||
171 | if (!ehci_is_TDI(ehci)) | ||
172 | i = device_create_file(controller, &dev_attr_companion); | ||
173 | if (i) | ||
174 | goto out; | ||
175 | |||
176 | i = device_create_file(controller, &dev_attr_uframe_periodic_max); | ||
177 | out: | ||
178 | return i; | ||
179 | } | ||
180 | |||
181 | static inline void remove_sysfs_files(struct ehci_hcd *ehci) | ||
182 | { | ||
183 | struct device *controller = ehci_to_hcd(ehci)->self.controller; | ||
184 | |||
185 | /* with integrated TT there is no companion! */ | ||
186 | if (!ehci_is_TDI(ehci)) | ||
187 | device_remove_file(controller, &dev_attr_companion); | ||
188 | |||
189 | device_remove_file(controller, &dev_attr_uframe_periodic_max); | ||
190 | } | ||
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index bd6ff489baf..cc7d337ec35 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h | |||
@@ -75,6 +75,7 @@ struct ehci_hcd { /* one per controller */ | |||
75 | struct ehci_qh *async; | 75 | struct ehci_qh *async; |
76 | struct ehci_qh *dummy; /* For AMD quirk use */ | 76 | struct ehci_qh *dummy; /* For AMD quirk use */ |
77 | struct ehci_qh *reclaim; | 77 | struct ehci_qh *reclaim; |
78 | struct ehci_qh *qh_scan_next; | ||
78 | unsigned scanning : 1; | 79 | unsigned scanning : 1; |
79 | 80 | ||
80 | /* periodic schedule support */ | 81 | /* periodic schedule support */ |
@@ -87,6 +88,8 @@ struct ehci_hcd { /* one per controller */ | |||
87 | union ehci_shadow *pshadow; /* mirror hw periodic table */ | 88 | union ehci_shadow *pshadow; /* mirror hw periodic table */ |
88 | int next_uframe; /* scan periodic, start here */ | 89 | int next_uframe; /* scan periodic, start here */ |
89 | unsigned periodic_sched; /* periodic activity count */ | 90 | unsigned periodic_sched; /* periodic activity count */ |
91 | unsigned uframe_periodic_max; /* max periodic time per uframe */ | ||
92 | |||
90 | 93 | ||
91 | /* list of itds & sitds completed while clock_frame was still active */ | 94 | /* list of itds & sitds completed while clock_frame was still active */ |
92 | struct list_head cached_itd_list; | 95 | struct list_head cached_itd_list; |
@@ -117,7 +120,6 @@ struct ehci_hcd { /* one per controller */ | |||
117 | struct timer_list iaa_watchdog; | 120 | struct timer_list iaa_watchdog; |
118 | struct timer_list watchdog; | 121 | struct timer_list watchdog; |
119 | unsigned long actions; | 122 | unsigned long actions; |
120 | unsigned stamp; | ||
121 | unsigned periodic_stamp; | 123 | unsigned periodic_stamp; |
122 | unsigned random_frame; | 124 | unsigned random_frame; |
123 | unsigned long next_statechange; | 125 | unsigned long next_statechange; |
@@ -343,6 +345,7 @@ struct ehci_qh { | |||
343 | struct ehci_qh *reclaim; /* next to reclaim */ | 345 | struct ehci_qh *reclaim; /* next to reclaim */ |
344 | 346 | ||
345 | struct ehci_hcd *ehci; | 347 | struct ehci_hcd *ehci; |
348 | unsigned long unlink_time; | ||
346 | 349 | ||
347 | /* | 350 | /* |
348 | * Do NOT use atomic operations for QH refcounting. On some CPUs | 351 | * Do NOT use atomic operations for QH refcounting. On some CPUs |
@@ -374,6 +377,7 @@ struct ehci_qh { | |||
374 | #define NO_FRAME ((unsigned short)~0) /* pick new start */ | 377 | #define NO_FRAME ((unsigned short)~0) /* pick new start */ |
375 | 378 | ||
376 | struct usb_device *dev; /* access to TT */ | 379 | struct usb_device *dev; /* access to TT */ |
380 | unsigned is_out:1; /* bulk or intr OUT */ | ||
377 | unsigned clearing_tt:1; /* Clear-TT-Buf in progress */ | 381 | unsigned clearing_tt:1; /* Clear-TT-Buf in progress */ |
378 | }; | 382 | }; |
379 | 383 | ||
diff --git a/drivers/usb/host/ohci-sh.c b/drivers/usb/host/ohci-sh.c index f47867ff78c..14cecb52a9f 100644 --- a/drivers/usb/host/ohci-sh.c +++ b/drivers/usb/host/ohci-sh.c | |||
@@ -3,7 +3,7 @@ | |||
3 | * | 3 | * |
4 | * Copyright (C) 2008 Renesas Solutions Corp. | 4 | * Copyright (C) 2008 Renesas Solutions Corp. |
5 | * | 5 | * |
6 | * Author : Yoshihiro Shimoda <shimoda.yoshihiro@renesas.com> | 6 | * Author : Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> |
7 | * | 7 | * |
8 | * This program is free software; you can redistribute it and/or modify | 8 | * This program is free software; you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by | 9 | * it under the terms of the GNU General Public License as published by |
diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c index fd930618c28..a9d315906e3 100644 --- a/drivers/usb/host/pci-quirks.c +++ b/drivers/usb/host/pci-quirks.c | |||
@@ -35,6 +35,8 @@ | |||
35 | #define OHCI_INTRSTATUS 0x0c | 35 | #define OHCI_INTRSTATUS 0x0c |
36 | #define OHCI_INTRENABLE 0x10 | 36 | #define OHCI_INTRENABLE 0x10 |
37 | #define OHCI_INTRDISABLE 0x14 | 37 | #define OHCI_INTRDISABLE 0x14 |
38 | #define OHCI_FMINTERVAL 0x34 | ||
39 | #define OHCI_HCR (1 << 0) /* host controller reset */ | ||
38 | #define OHCI_OCR (1 << 3) /* ownership change request */ | 40 | #define OHCI_OCR (1 << 3) /* ownership change request */ |
39 | #define OHCI_CTRL_RWC (1 << 9) /* remote wakeup connected */ | 41 | #define OHCI_CTRL_RWC (1 << 9) /* remote wakeup connected */ |
40 | #define OHCI_CTRL_IR (1 << 8) /* interrupt routing */ | 42 | #define OHCI_CTRL_IR (1 << 8) /* interrupt routing */ |
@@ -497,6 +499,32 @@ static void __devinit quirk_usb_handoff_ohci(struct pci_dev *pdev) | |||
497 | 499 | ||
498 | /* reset controller, preserving RWC (and possibly IR) */ | 500 | /* reset controller, preserving RWC (and possibly IR) */ |
499 | writel(control & OHCI_CTRL_MASK, base + OHCI_CONTROL); | 501 | writel(control & OHCI_CTRL_MASK, base + OHCI_CONTROL); |
502 | readl(base + OHCI_CONTROL); | ||
503 | |||
504 | /* Some NVIDIA controllers stop working if kept in RESET for too long */ | ||
505 | if (pdev->vendor == PCI_VENDOR_ID_NVIDIA) { | ||
506 | u32 fminterval; | ||
507 | int cnt; | ||
508 | |||
509 | /* drive reset for at least 50 ms (7.1.7.5) */ | ||
510 | msleep(50); | ||
511 | |||
512 | /* software reset of the controller, preserving HcFmInterval */ | ||
513 | fminterval = readl(base + OHCI_FMINTERVAL); | ||
514 | writel(OHCI_HCR, base + OHCI_CMDSTATUS); | ||
515 | |||
516 | /* reset requires max 10 us delay */ | ||
517 | for (cnt = 30; cnt > 0; --cnt) { /* ... allow extra time */ | ||
518 | if ((readl(base + OHCI_CMDSTATUS) & OHCI_HCR) == 0) | ||
519 | break; | ||
520 | udelay(1); | ||
521 | } | ||
522 | writel(fminterval, base + OHCI_FMINTERVAL); | ||
523 | |||
524 | /* Now we're in the SUSPEND state with all devices reset | ||
525 | * and wakeups and interrupts disabled | ||
526 | */ | ||
527 | } | ||
500 | 528 | ||
501 | /* | 529 | /* |
502 | * disable interrupts | 530 | * disable interrupts |
@@ -507,20 +535,34 @@ static void __devinit quirk_usb_handoff_ohci(struct pci_dev *pdev) | |||
507 | iounmap(base); | 535 | iounmap(base); |
508 | } | 536 | } |
509 | 537 | ||
538 | static const struct dmi_system_id __initconst ehci_dmi_nohandoff_table[] = { | ||
539 | { | ||
540 | /* Pegatron Lucid (ExoPC) */ | ||
541 | .matches = { | ||
542 | DMI_MATCH(DMI_BOARD_NAME, "EXOPG06411"), | ||
543 | DMI_MATCH(DMI_BIOS_VERSION, "Lucid-CE-133"), | ||
544 | }, | ||
545 | }, | ||
546 | { | ||
547 | /* Pegatron Lucid (Ordissimo AIRIS) */ | ||
548 | .matches = { | ||
549 | DMI_MATCH(DMI_BOARD_NAME, "M11JB"), | ||
550 | DMI_MATCH(DMI_BIOS_VERSION, "Lucid-GE-133"), | ||
551 | }, | ||
552 | }, | ||
553 | { } | ||
554 | }; | ||
555 | |||
510 | static void __devinit ehci_bios_handoff(struct pci_dev *pdev, | 556 | static void __devinit ehci_bios_handoff(struct pci_dev *pdev, |
511 | void __iomem *op_reg_base, | 557 | void __iomem *op_reg_base, |
512 | u32 cap, u8 offset) | 558 | u32 cap, u8 offset) |
513 | { | 559 | { |
514 | int try_handoff = 1, tried_handoff = 0; | 560 | int try_handoff = 1, tried_handoff = 0; |
515 | 561 | ||
516 | /* The Pegatron Lucid (ExoPC) tablet sporadically waits for 90 | 562 | /* The Pegatron Lucid tablet sporadically waits for 98 seconds trying |
517 | * seconds trying the handoff on its unused controller. Skip | 563 | * the handoff on its unused controller. Skip it. */ |
518 | * it. */ | ||
519 | if (pdev->vendor == 0x8086 && pdev->device == 0x283a) { | 564 | if (pdev->vendor == 0x8086 && pdev->device == 0x283a) { |
520 | const char *dmi_bn = dmi_get_system_info(DMI_BOARD_NAME); | 565 | if (dmi_check_system(ehci_dmi_nohandoff_table)) |
521 | const char *dmi_bv = dmi_get_system_info(DMI_BIOS_VERSION); | ||
522 | if (dmi_bn && !strcmp(dmi_bn, "EXOPG06411") && | ||
523 | dmi_bv && !strcmp(dmi_bv, "Lucid-CE-133")) | ||
524 | try_handoff = 0; | 566 | try_handoff = 0; |
525 | } | 567 | } |
526 | 568 | ||
diff --git a/drivers/usb/host/r8a66597-hcd.c b/drivers/usb/host/r8a66597-hcd.c index 4586369dda0..40a0d8b03ad 100644 --- a/drivers/usb/host/r8a66597-hcd.c +++ b/drivers/usb/host/r8a66597-hcd.c | |||
@@ -6,7 +6,7 @@ | |||
6 | * Portions Copyright (C) 2004-2005 David Brownell | 6 | * Portions Copyright (C) 2004-2005 David Brownell |
7 | * Portions Copyright (C) 1999 Roman Weissgaerber | 7 | * Portions Copyright (C) 1999 Roman Weissgaerber |
8 | * | 8 | * |
9 | * Author : Yoshihiro Shimoda <shimoda.yoshihiro@renesas.com> | 9 | * Author : Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> |
10 | * | 10 | * |
11 | * This program is free software; you can redistribute it and/or modify | 11 | * This program is free software; you can redistribute it and/or modify |
12 | * it under the terms of the GNU General Public License as published by | 12 | * it under the terms of the GNU General Public License as published by |
@@ -1438,7 +1438,7 @@ static void packet_write(struct r8a66597 *r8a66597, u16 pipenum) | |||
1438 | if (pipenum > 0) | 1438 | if (pipenum > 0) |
1439 | r8a66597_write(r8a66597, ~(1 << pipenum), BEMPSTS); | 1439 | r8a66597_write(r8a66597, ~(1 << pipenum), BEMPSTS); |
1440 | if (urb->transfer_buffer) { | 1440 | if (urb->transfer_buffer) { |
1441 | r8a66597_write_fifo(r8a66597, td->pipe->fifoaddr, buf, size); | 1441 | r8a66597_write_fifo(r8a66597, td->pipe, buf, size); |
1442 | if (!usb_pipebulk(urb->pipe) || td->maxpacket != size) | 1442 | if (!usb_pipebulk(urb->pipe) || td->maxpacket != size) |
1443 | r8a66597_write(r8a66597, BVAL, td->pipe->fifoctr); | 1443 | r8a66597_write(r8a66597, BVAL, td->pipe->fifoctr); |
1444 | } | 1444 | } |
@@ -2306,7 +2306,7 @@ static int r8a66597_bus_resume(struct usb_hcd *hcd) | |||
2306 | 2306 | ||
2307 | dbg("resume port = %d", port); | 2307 | dbg("resume port = %d", port); |
2308 | rh->port &= ~USB_PORT_STAT_SUSPEND; | 2308 | rh->port &= ~USB_PORT_STAT_SUSPEND; |
2309 | rh->port |= USB_PORT_STAT_C_SUSPEND < 16; | 2309 | rh->port |= USB_PORT_STAT_C_SUSPEND << 16; |
2310 | r8a66597_mdfy(r8a66597, RESUME, RESUME | UACT, dvstctr_reg); | 2310 | r8a66597_mdfy(r8a66597, RESUME, RESUME | UACT, dvstctr_reg); |
2311 | msleep(50); | 2311 | msleep(50); |
2312 | r8a66597_mdfy(r8a66597, UACT, RESUME | UACT, dvstctr_reg); | 2312 | r8a66597_mdfy(r8a66597, UACT, RESUME | UACT, dvstctr_reg); |
diff --git a/drivers/usb/host/r8a66597.h b/drivers/usb/host/r8a66597.h index 25563e9a90b..f28782d20ee 100644 --- a/drivers/usb/host/r8a66597.h +++ b/drivers/usb/host/r8a66597.h | |||
@@ -201,11 +201,26 @@ static inline void r8a66597_write(struct r8a66597 *r8a66597, u16 val, | |||
201 | iowrite16(val, r8a66597->reg + offset); | 201 | iowrite16(val, r8a66597->reg + offset); |
202 | } | 202 | } |
203 | 203 | ||
204 | static inline void r8a66597_mdfy(struct r8a66597 *r8a66597, | ||
205 | u16 val, u16 pat, unsigned long offset) | ||
206 | { | ||
207 | u16 tmp; | ||
208 | tmp = r8a66597_read(r8a66597, offset); | ||
209 | tmp = tmp & (~pat); | ||
210 | tmp = tmp | val; | ||
211 | r8a66597_write(r8a66597, tmp, offset); | ||
212 | } | ||
213 | |||
214 | #define r8a66597_bclr(r8a66597, val, offset) \ | ||
215 | r8a66597_mdfy(r8a66597, 0, val, offset) | ||
216 | #define r8a66597_bset(r8a66597, val, offset) \ | ||
217 | r8a66597_mdfy(r8a66597, val, 0, offset) | ||
218 | |||
204 | static inline void r8a66597_write_fifo(struct r8a66597 *r8a66597, | 219 | static inline void r8a66597_write_fifo(struct r8a66597 *r8a66597, |
205 | unsigned long offset, u16 *buf, | 220 | struct r8a66597_pipe *pipe, u16 *buf, |
206 | int len) | 221 | int len) |
207 | { | 222 | { |
208 | void __iomem *fifoaddr = r8a66597->reg + offset; | 223 | void __iomem *fifoaddr = r8a66597->reg + pipe->fifoaddr; |
209 | unsigned long count; | 224 | unsigned long count; |
210 | unsigned char *pb; | 225 | unsigned char *pb; |
211 | int i; | 226 | int i; |
@@ -230,26 +245,15 @@ static inline void r8a66597_write_fifo(struct r8a66597 *r8a66597, | |||
230 | iowrite16_rep(fifoaddr, buf, len); | 245 | iowrite16_rep(fifoaddr, buf, len); |
231 | if (unlikely(odd)) { | 246 | if (unlikely(odd)) { |
232 | buf = &buf[len]; | 247 | buf = &buf[len]; |
248 | if (r8a66597->pdata->wr0_shorted_to_wr1) | ||
249 | r8a66597_bclr(r8a66597, MBW_16, pipe->fifosel); | ||
233 | iowrite8((unsigned char)*buf, fifoaddr); | 250 | iowrite8((unsigned char)*buf, fifoaddr); |
251 | if (r8a66597->pdata->wr0_shorted_to_wr1) | ||
252 | r8a66597_bset(r8a66597, MBW_16, pipe->fifosel); | ||
234 | } | 253 | } |
235 | } | 254 | } |
236 | } | 255 | } |
237 | 256 | ||
238 | static inline void r8a66597_mdfy(struct r8a66597 *r8a66597, | ||
239 | u16 val, u16 pat, unsigned long offset) | ||
240 | { | ||
241 | u16 tmp; | ||
242 | tmp = r8a66597_read(r8a66597, offset); | ||
243 | tmp = tmp & (~pat); | ||
244 | tmp = tmp | val; | ||
245 | r8a66597_write(r8a66597, tmp, offset); | ||
246 | } | ||
247 | |||
248 | #define r8a66597_bclr(r8a66597, val, offset) \ | ||
249 | r8a66597_mdfy(r8a66597, 0, val, offset) | ||
250 | #define r8a66597_bset(r8a66597, val, offset) \ | ||
251 | r8a66597_mdfy(r8a66597, val, 0, offset) | ||
252 | |||
253 | static inline unsigned long get_syscfg_reg(int port) | 257 | static inline unsigned long get_syscfg_reg(int port) |
254 | { | 258 | { |
255 | return port == 0 ? SYSCFG0 : SYSCFG1; | 259 | return port == 0 ? SYSCFG0 : SYSCFG1; |
diff --git a/drivers/usb/host/xhci-dbg.c b/drivers/usb/host/xhci-dbg.c index 1f50b4468e8..e9b0f043455 100644 --- a/drivers/usb/host/xhci-dbg.c +++ b/drivers/usb/host/xhci-dbg.c | |||
@@ -266,11 +266,11 @@ void xhci_debug_trb(struct xhci_hcd *xhci, union xhci_trb *trb) | |||
266 | xhci_dbg(xhci, "Interrupter target = 0x%x\n", | 266 | xhci_dbg(xhci, "Interrupter target = 0x%x\n", |
267 | GET_INTR_TARGET(le32_to_cpu(trb->link.intr_target))); | 267 | GET_INTR_TARGET(le32_to_cpu(trb->link.intr_target))); |
268 | xhci_dbg(xhci, "Cycle bit = %u\n", | 268 | xhci_dbg(xhci, "Cycle bit = %u\n", |
269 | (unsigned int) (le32_to_cpu(trb->link.control) & TRB_CYCLE)); | 269 | le32_to_cpu(trb->link.control) & TRB_CYCLE); |
270 | xhci_dbg(xhci, "Toggle cycle bit = %u\n", | 270 | xhci_dbg(xhci, "Toggle cycle bit = %u\n", |
271 | (unsigned int) (le32_to_cpu(trb->link.control) & LINK_TOGGLE)); | 271 | le32_to_cpu(trb->link.control) & LINK_TOGGLE); |
272 | xhci_dbg(xhci, "No Snoop bit = %u\n", | 272 | xhci_dbg(xhci, "No Snoop bit = %u\n", |
273 | (unsigned int) (le32_to_cpu(trb->link.control) & TRB_NO_SNOOP)); | 273 | le32_to_cpu(trb->link.control) & TRB_NO_SNOOP); |
274 | break; | 274 | break; |
275 | case TRB_TYPE(TRB_TRANSFER): | 275 | case TRB_TYPE(TRB_TRANSFER): |
276 | address = le64_to_cpu(trb->trans_event.buffer); | 276 | address = le64_to_cpu(trb->trans_event.buffer); |
@@ -284,9 +284,9 @@ void xhci_debug_trb(struct xhci_hcd *xhci, union xhci_trb *trb) | |||
284 | address = le64_to_cpu(trb->event_cmd.cmd_trb); | 284 | address = le64_to_cpu(trb->event_cmd.cmd_trb); |
285 | xhci_dbg(xhci, "Command TRB pointer = %llu\n", address); | 285 | xhci_dbg(xhci, "Command TRB pointer = %llu\n", address); |
286 | xhci_dbg(xhci, "Completion status = %u\n", | 286 | xhci_dbg(xhci, "Completion status = %u\n", |
287 | (unsigned int) GET_COMP_CODE(le32_to_cpu(trb->event_cmd.status))); | 287 | GET_COMP_CODE(le32_to_cpu(trb->event_cmd.status))); |
288 | xhci_dbg(xhci, "Flags = 0x%x\n", | 288 | xhci_dbg(xhci, "Flags = 0x%x\n", |
289 | (unsigned int) le32_to_cpu(trb->event_cmd.flags)); | 289 | le32_to_cpu(trb->event_cmd.flags)); |
290 | break; | 290 | break; |
291 | default: | 291 | default: |
292 | xhci_dbg(xhci, "Unknown TRB with TRB type ID %u\n", | 292 | xhci_dbg(xhci, "Unknown TRB with TRB type ID %u\n", |
@@ -318,10 +318,10 @@ void xhci_debug_segment(struct xhci_hcd *xhci, struct xhci_segment *seg) | |||
318 | for (i = 0; i < TRBS_PER_SEGMENT; ++i) { | 318 | for (i = 0; i < TRBS_PER_SEGMENT; ++i) { |
319 | trb = &seg->trbs[i]; | 319 | trb = &seg->trbs[i]; |
320 | xhci_dbg(xhci, "@%016llx %08x %08x %08x %08x\n", addr, | 320 | xhci_dbg(xhci, "@%016llx %08x %08x %08x %08x\n", addr, |
321 | (u32)lower_32_bits(le64_to_cpu(trb->link.segment_ptr)), | 321 | lower_32_bits(le64_to_cpu(trb->link.segment_ptr)), |
322 | (u32)upper_32_bits(le64_to_cpu(trb->link.segment_ptr)), | 322 | upper_32_bits(le64_to_cpu(trb->link.segment_ptr)), |
323 | (unsigned int) le32_to_cpu(trb->link.intr_target), | 323 | le32_to_cpu(trb->link.intr_target), |
324 | (unsigned int) le32_to_cpu(trb->link.control)); | 324 | le32_to_cpu(trb->link.control)); |
325 | addr += sizeof(*trb); | 325 | addr += sizeof(*trb); |
326 | } | 326 | } |
327 | } | 327 | } |
@@ -402,8 +402,8 @@ void xhci_dbg_erst(struct xhci_hcd *xhci, struct xhci_erst *erst) | |||
402 | addr, | 402 | addr, |
403 | lower_32_bits(le64_to_cpu(entry->seg_addr)), | 403 | lower_32_bits(le64_to_cpu(entry->seg_addr)), |
404 | upper_32_bits(le64_to_cpu(entry->seg_addr)), | 404 | upper_32_bits(le64_to_cpu(entry->seg_addr)), |
405 | (unsigned int) le32_to_cpu(entry->seg_size), | 405 | le32_to_cpu(entry->seg_size), |
406 | (unsigned int) le32_to_cpu(entry->rsvd)); | 406 | le32_to_cpu(entry->rsvd)); |
407 | addr += sizeof(*entry); | 407 | addr += sizeof(*entry); |
408 | } | 408 | } |
409 | } | 409 | } |
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index fcb7f7efc86..d446886b22b 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c | |||
@@ -89,8 +89,8 @@ static void xhci_link_segments(struct xhci_hcd *xhci, struct xhci_segment *prev, | |||
89 | return; | 89 | return; |
90 | prev->next = next; | 90 | prev->next = next; |
91 | if (link_trbs) { | 91 | if (link_trbs) { |
92 | prev->trbs[TRBS_PER_SEGMENT-1].link. | 92 | prev->trbs[TRBS_PER_SEGMENT-1].link.segment_ptr = |
93 | segment_ptr = cpu_to_le64(next->dma); | 93 | cpu_to_le64(next->dma); |
94 | 94 | ||
95 | /* Set the last TRB in the segment to have a TRB type ID of Link TRB */ | 95 | /* Set the last TRB in the segment to have a TRB type ID of Link TRB */ |
96 | val = le32_to_cpu(prev->trbs[TRBS_PER_SEGMENT-1].link.control); | 96 | val = le32_to_cpu(prev->trbs[TRBS_PER_SEGMENT-1].link.control); |
@@ -187,8 +187,8 @@ static struct xhci_ring *xhci_ring_alloc(struct xhci_hcd *xhci, | |||
187 | 187 | ||
188 | if (link_trbs) { | 188 | if (link_trbs) { |
189 | /* See section 4.9.2.1 and 6.4.4.1 */ | 189 | /* See section 4.9.2.1 and 6.4.4.1 */ |
190 | prev->trbs[TRBS_PER_SEGMENT-1].link. | 190 | prev->trbs[TRBS_PER_SEGMENT-1].link.control |= |
191 | control |= cpu_to_le32(LINK_TOGGLE); | 191 | cpu_to_le32(LINK_TOGGLE); |
192 | xhci_dbg(xhci, "Wrote link toggle flag to" | 192 | xhci_dbg(xhci, "Wrote link toggle flag to" |
193 | " segment %p (virtual), 0x%llx (DMA)\n", | 193 | " segment %p (virtual), 0x%llx (DMA)\n", |
194 | prev, (unsigned long long)prev->dma); | 194 | prev, (unsigned long long)prev->dma); |
@@ -549,8 +549,8 @@ struct xhci_stream_info *xhci_alloc_stream_info(struct xhci_hcd *xhci, | |||
549 | addr = cur_ring->first_seg->dma | | 549 | addr = cur_ring->first_seg->dma | |
550 | SCT_FOR_CTX(SCT_PRI_TR) | | 550 | SCT_FOR_CTX(SCT_PRI_TR) | |
551 | cur_ring->cycle_state; | 551 | cur_ring->cycle_state; |
552 | stream_info->stream_ctx_array[cur_stream]. | 552 | stream_info->stream_ctx_array[cur_stream].stream_ring = |
553 | stream_ring = cpu_to_le64(addr); | 553 | cpu_to_le64(addr); |
554 | xhci_dbg(xhci, "Setting stream %d ring ptr to 0x%08llx\n", | 554 | xhci_dbg(xhci, "Setting stream %d ring ptr to 0x%08llx\n", |
555 | cur_stream, (unsigned long long) addr); | 555 | cur_stream, (unsigned long long) addr); |
556 | 556 | ||
@@ -786,7 +786,7 @@ int xhci_alloc_virt_device(struct xhci_hcd *xhci, int slot_id, | |||
786 | xhci_dbg(xhci, "Set slot id %d dcbaa entry %p to 0x%llx\n", | 786 | xhci_dbg(xhci, "Set slot id %d dcbaa entry %p to 0x%llx\n", |
787 | slot_id, | 787 | slot_id, |
788 | &xhci->dcbaa->dev_context_ptrs[slot_id], | 788 | &xhci->dcbaa->dev_context_ptrs[slot_id], |
789 | (unsigned long long) le64_to_cpu(xhci->dcbaa->dev_context_ptrs[slot_id])); | 789 | le64_to_cpu(xhci->dcbaa->dev_context_ptrs[slot_id])); |
790 | 790 | ||
791 | return 1; | 791 | return 1; |
792 | fail: | 792 | fail: |
@@ -890,19 +890,19 @@ int xhci_setup_addressable_virt_dev(struct xhci_hcd *xhci, struct usb_device *ud | |||
890 | ctrl_ctx->add_flags = cpu_to_le32(SLOT_FLAG | EP0_FLAG); | 890 | ctrl_ctx->add_flags = cpu_to_le32(SLOT_FLAG | EP0_FLAG); |
891 | 891 | ||
892 | /* 3) Only the control endpoint is valid - one endpoint context */ | 892 | /* 3) Only the control endpoint is valid - one endpoint context */ |
893 | slot_ctx->dev_info |= cpu_to_le32(LAST_CTX(1) | (u32) udev->route); | 893 | slot_ctx->dev_info |= cpu_to_le32(LAST_CTX(1) | udev->route); |
894 | switch (udev->speed) { | 894 | switch (udev->speed) { |
895 | case USB_SPEED_SUPER: | 895 | case USB_SPEED_SUPER: |
896 | slot_ctx->dev_info |= cpu_to_le32((u32) SLOT_SPEED_SS); | 896 | slot_ctx->dev_info |= cpu_to_le32(SLOT_SPEED_SS); |
897 | break; | 897 | break; |
898 | case USB_SPEED_HIGH: | 898 | case USB_SPEED_HIGH: |
899 | slot_ctx->dev_info |= cpu_to_le32((u32) SLOT_SPEED_HS); | 899 | slot_ctx->dev_info |= cpu_to_le32(SLOT_SPEED_HS); |
900 | break; | 900 | break; |
901 | case USB_SPEED_FULL: | 901 | case USB_SPEED_FULL: |
902 | slot_ctx->dev_info |= cpu_to_le32((u32) SLOT_SPEED_FS); | 902 | slot_ctx->dev_info |= cpu_to_le32(SLOT_SPEED_FS); |
903 | break; | 903 | break; |
904 | case USB_SPEED_LOW: | 904 | case USB_SPEED_LOW: |
905 | slot_ctx->dev_info |= cpu_to_le32((u32) SLOT_SPEED_LS); | 905 | slot_ctx->dev_info |= cpu_to_le32(SLOT_SPEED_LS); |
906 | break; | 906 | break; |
907 | case USB_SPEED_WIRELESS: | 907 | case USB_SPEED_WIRELESS: |
908 | xhci_dbg(xhci, "FIXME xHCI doesn't support wireless speeds\n"); | 908 | xhci_dbg(xhci, "FIXME xHCI doesn't support wireless speeds\n"); |
@@ -916,7 +916,7 @@ int xhci_setup_addressable_virt_dev(struct xhci_hcd *xhci, struct usb_device *ud | |||
916 | port_num = xhci_find_real_port_number(xhci, udev); | 916 | port_num = xhci_find_real_port_number(xhci, udev); |
917 | if (!port_num) | 917 | if (!port_num) |
918 | return -EINVAL; | 918 | return -EINVAL; |
919 | slot_ctx->dev_info2 |= cpu_to_le32((u32) ROOT_HUB_PORT(port_num)); | 919 | slot_ctx->dev_info2 |= cpu_to_le32(ROOT_HUB_PORT(port_num)); |
920 | /* Set the port number in the virtual_device to the faked port number */ | 920 | /* Set the port number in the virtual_device to the faked port number */ |
921 | for (top_dev = udev; top_dev->parent && top_dev->parent->parent; | 921 | for (top_dev = udev; top_dev->parent && top_dev->parent->parent; |
922 | top_dev = top_dev->parent) | 922 | top_dev = top_dev->parent) |
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 70cacbbe7fb..7113d16e2d3 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c | |||
@@ -113,15 +113,13 @@ static int last_trb(struct xhci_hcd *xhci, struct xhci_ring *ring, | |||
113 | if (ring == xhci->event_ring) | 113 | if (ring == xhci->event_ring) |
114 | return trb == &seg->trbs[TRBS_PER_SEGMENT]; | 114 | return trb == &seg->trbs[TRBS_PER_SEGMENT]; |
115 | else | 115 | else |
116 | return (le32_to_cpu(trb->link.control) & TRB_TYPE_BITMASK) | 116 | return TRB_TYPE_LINK_LE32(trb->link.control); |
117 | == TRB_TYPE(TRB_LINK); | ||
118 | } | 117 | } |
119 | 118 | ||
120 | static int enqueue_is_link_trb(struct xhci_ring *ring) | 119 | static int enqueue_is_link_trb(struct xhci_ring *ring) |
121 | { | 120 | { |
122 | struct xhci_link_trb *link = &ring->enqueue->link; | 121 | struct xhci_link_trb *link = &ring->enqueue->link; |
123 | return ((le32_to_cpu(link->control) & TRB_TYPE_BITMASK) == | 122 | return TRB_TYPE_LINK_LE32(link->control); |
124 | TRB_TYPE(TRB_LINK)); | ||
125 | } | 123 | } |
126 | 124 | ||
127 | /* Updates trb to point to the next TRB in the ring, and updates seg if the next | 125 | /* Updates trb to point to the next TRB in the ring, and updates seg if the next |
@@ -372,7 +370,7 @@ static struct xhci_segment *find_trb_seg( | |||
372 | while (cur_seg->trbs > trb || | 370 | while (cur_seg->trbs > trb || |
373 | &cur_seg->trbs[TRBS_PER_SEGMENT - 1] < trb) { | 371 | &cur_seg->trbs[TRBS_PER_SEGMENT - 1] < trb) { |
374 | generic_trb = &cur_seg->trbs[TRBS_PER_SEGMENT - 1].generic; | 372 | generic_trb = &cur_seg->trbs[TRBS_PER_SEGMENT - 1].generic; |
375 | if (le32_to_cpu(generic_trb->field[3]) & LINK_TOGGLE) | 373 | if (generic_trb->field[3] & cpu_to_le32(LINK_TOGGLE)) |
376 | *cycle_state ^= 0x1; | 374 | *cycle_state ^= 0x1; |
377 | cur_seg = cur_seg->next; | 375 | cur_seg = cur_seg->next; |
378 | if (cur_seg == start_seg) | 376 | if (cur_seg == start_seg) |
@@ -489,8 +487,8 @@ void xhci_find_new_dequeue_state(struct xhci_hcd *xhci, | |||
489 | } | 487 | } |
490 | 488 | ||
491 | trb = &state->new_deq_ptr->generic; | 489 | trb = &state->new_deq_ptr->generic; |
492 | if ((le32_to_cpu(trb->field[3]) & TRB_TYPE_BITMASK) == | 490 | if (TRB_TYPE_LINK_LE32(trb->field[3]) && |
493 | TRB_TYPE(TRB_LINK) && (le32_to_cpu(trb->field[3]) & LINK_TOGGLE)) | 491 | (trb->field[3] & cpu_to_le32(LINK_TOGGLE))) |
494 | state->new_cycle_state ^= 0x1; | 492 | state->new_cycle_state ^= 0x1; |
495 | next_trb(xhci, ep_ring, &state->new_deq_seg, &state->new_deq_ptr); | 493 | next_trb(xhci, ep_ring, &state->new_deq_seg, &state->new_deq_ptr); |
496 | 494 | ||
@@ -525,8 +523,7 @@ static void td_to_noop(struct xhci_hcd *xhci, struct xhci_ring *ep_ring, | |||
525 | for (cur_seg = cur_td->start_seg, cur_trb = cur_td->first_trb; | 523 | for (cur_seg = cur_td->start_seg, cur_trb = cur_td->first_trb; |
526 | true; | 524 | true; |
527 | next_trb(xhci, ep_ring, &cur_seg, &cur_trb)) { | 525 | next_trb(xhci, ep_ring, &cur_seg, &cur_trb)) { |
528 | if ((le32_to_cpu(cur_trb->generic.field[3]) & TRB_TYPE_BITMASK) | 526 | if (TRB_TYPE_LINK_LE32(cur_trb->generic.field[3])) { |
529 | == TRB_TYPE(TRB_LINK)) { | ||
530 | /* Unchain any chained Link TRBs, but | 527 | /* Unchain any chained Link TRBs, but |
531 | * leave the pointers intact. | 528 | * leave the pointers intact. |
532 | */ | 529 | */ |
@@ -1000,7 +997,7 @@ static void handle_reset_ep_completion(struct xhci_hcd *xhci, | |||
1000 | * but we don't care. | 997 | * but we don't care. |
1001 | */ | 998 | */ |
1002 | xhci_dbg(xhci, "Ignoring reset ep completion code of %u\n", | 999 | xhci_dbg(xhci, "Ignoring reset ep completion code of %u\n", |
1003 | (unsigned int) GET_COMP_CODE(le32_to_cpu(event->status))); | 1000 | GET_COMP_CODE(le32_to_cpu(event->status))); |
1004 | 1001 | ||
1005 | /* HW with the reset endpoint quirk needs to have a configure endpoint | 1002 | /* HW with the reset endpoint quirk needs to have a configure endpoint |
1006 | * command complete before the endpoint can be used. Queue that here | 1003 | * command complete before the endpoint can be used. Queue that here |
@@ -1458,7 +1455,8 @@ static int xhci_requires_manual_halt_cleanup(struct xhci_hcd *xhci, | |||
1458 | * endpoint anyway. Check if a babble halted the | 1455 | * endpoint anyway. Check if a babble halted the |
1459 | * endpoint. | 1456 | * endpoint. |
1460 | */ | 1457 | */ |
1461 | if ((le32_to_cpu(ep_ctx->ep_info) & EP_STATE_MASK) == EP_STATE_HALTED) | 1458 | if ((ep_ctx->ep_info & cpu_to_le32(EP_STATE_MASK)) == |
1459 | cpu_to_le32(EP_STATE_HALTED)) | ||
1462 | return 1; | 1460 | return 1; |
1463 | 1461 | ||
1464 | return 0; | 1462 | return 0; |
@@ -1753,10 +1751,8 @@ static int process_isoc_td(struct xhci_hcd *xhci, struct xhci_td *td, | |||
1753 | for (cur_trb = ep_ring->dequeue, | 1751 | for (cur_trb = ep_ring->dequeue, |
1754 | cur_seg = ep_ring->deq_seg; cur_trb != event_trb; | 1752 | cur_seg = ep_ring->deq_seg; cur_trb != event_trb; |
1755 | next_trb(xhci, ep_ring, &cur_seg, &cur_trb)) { | 1753 | next_trb(xhci, ep_ring, &cur_seg, &cur_trb)) { |
1756 | if ((le32_to_cpu(cur_trb->generic.field[3]) & | 1754 | if (!TRB_TYPE_NOOP_LE32(cur_trb->generic.field[3]) && |
1757 | TRB_TYPE_BITMASK) != TRB_TYPE(TRB_TR_NOOP) && | 1755 | !TRB_TYPE_LINK_LE32(cur_trb->generic.field[3])) |
1758 | (le32_to_cpu(cur_trb->generic.field[3]) & | ||
1759 | TRB_TYPE_BITMASK) != TRB_TYPE(TRB_LINK)) | ||
1760 | len += TRB_LEN(le32_to_cpu(cur_trb->generic.field[2])); | 1756 | len += TRB_LEN(le32_to_cpu(cur_trb->generic.field[2])); |
1761 | } | 1757 | } |
1762 | len += TRB_LEN(le32_to_cpu(cur_trb->generic.field[2])) - | 1758 | len += TRB_LEN(le32_to_cpu(cur_trb->generic.field[2])) - |
@@ -1885,10 +1881,8 @@ static int process_bulk_intr_td(struct xhci_hcd *xhci, struct xhci_td *td, | |||
1885 | for (cur_trb = ep_ring->dequeue, cur_seg = ep_ring->deq_seg; | 1881 | for (cur_trb = ep_ring->dequeue, cur_seg = ep_ring->deq_seg; |
1886 | cur_trb != event_trb; | 1882 | cur_trb != event_trb; |
1887 | next_trb(xhci, ep_ring, &cur_seg, &cur_trb)) { | 1883 | next_trb(xhci, ep_ring, &cur_seg, &cur_trb)) { |
1888 | if ((le32_to_cpu(cur_trb->generic.field[3]) & | 1884 | if (!TRB_TYPE_NOOP_LE32(cur_trb->generic.field[3]) && |
1889 | TRB_TYPE_BITMASK) != TRB_TYPE(TRB_TR_NOOP) && | 1885 | !TRB_TYPE_LINK_LE32(cur_trb->generic.field[3])) |
1890 | (le32_to_cpu(cur_trb->generic.field[3]) & | ||
1891 | TRB_TYPE_BITMASK) != TRB_TYPE(TRB_LINK)) | ||
1892 | td->urb->actual_length += | 1886 | td->urb->actual_length += |
1893 | TRB_LEN(le32_to_cpu(cur_trb->generic.field[2])); | 1887 | TRB_LEN(le32_to_cpu(cur_trb->generic.field[2])); |
1894 | } | 1888 | } |
@@ -2047,8 +2041,8 @@ static int handle_tx_event(struct xhci_hcd *xhci, | |||
2047 | TRB_TO_SLOT_ID(le32_to_cpu(event->flags)), | 2041 | TRB_TO_SLOT_ID(le32_to_cpu(event->flags)), |
2048 | ep_index); | 2042 | ep_index); |
2049 | xhci_dbg(xhci, "Event TRB with TRB type ID %u\n", | 2043 | xhci_dbg(xhci, "Event TRB with TRB type ID %u\n", |
2050 | (unsigned int) (le32_to_cpu(event->flags) | 2044 | (le32_to_cpu(event->flags) & |
2051 | & TRB_TYPE_BITMASK)>>10); | 2045 | TRB_TYPE_BITMASK)>>10); |
2052 | xhci_print_trb_offsets(xhci, (union xhci_trb *) event); | 2046 | xhci_print_trb_offsets(xhci, (union xhci_trb *) event); |
2053 | if (ep->skip) { | 2047 | if (ep->skip) { |
2054 | ep->skip = false; | 2048 | ep->skip = false; |
@@ -2119,9 +2113,7 @@ static int handle_tx_event(struct xhci_hcd *xhci, | |||
2119 | * corresponding TD has been cancelled. Just ignore | 2113 | * corresponding TD has been cancelled. Just ignore |
2120 | * the TD. | 2114 | * the TD. |
2121 | */ | 2115 | */ |
2122 | if ((le32_to_cpu(event_trb->generic.field[3]) | 2116 | if (TRB_TYPE_NOOP_LE32(event_trb->generic.field[3])) { |
2123 | & TRB_TYPE_BITMASK) | ||
2124 | == TRB_TYPE(TRB_TR_NOOP)) { | ||
2125 | xhci_dbg(xhci, | 2117 | xhci_dbg(xhci, |
2126 | "event_trb is a no-op TRB. Skip it\n"); | 2118 | "event_trb is a no-op TRB. Skip it\n"); |
2127 | goto cleanup; | 2119 | goto cleanup; |
@@ -2452,7 +2444,7 @@ static int prepare_ring(struct xhci_hcd *xhci, struct xhci_ring *ep_ring, | |||
2452 | next->link.control |= cpu_to_le32(TRB_CHAIN); | 2444 | next->link.control |= cpu_to_le32(TRB_CHAIN); |
2453 | 2445 | ||
2454 | wmb(); | 2446 | wmb(); |
2455 | next->link.control ^= cpu_to_le32((u32) TRB_CYCLE); | 2447 | next->link.control ^= cpu_to_le32(TRB_CYCLE); |
2456 | 2448 | ||
2457 | /* Toggle the cycle bit after the last ring segment. */ | 2449 | /* Toggle the cycle bit after the last ring segment. */ |
2458 | if (last_trb_on_last_seg(xhci, ring, ring->enq_seg, next)) { | 2450 | if (last_trb_on_last_seg(xhci, ring, ring->enq_seg, next)) { |
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index f5fe1ac301a..763f484bc09 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c | |||
@@ -1342,8 +1342,8 @@ int xhci_drop_endpoint(struct usb_hcd *hcd, struct usb_device *udev, | |||
1342 | /* If the HC already knows the endpoint is disabled, | 1342 | /* If the HC already knows the endpoint is disabled, |
1343 | * or the HCD has noted it is disabled, ignore this request | 1343 | * or the HCD has noted it is disabled, ignore this request |
1344 | */ | 1344 | */ |
1345 | if ((le32_to_cpu(ep_ctx->ep_info) & EP_STATE_MASK) == | 1345 | if (((ep_ctx->ep_info & cpu_to_le32(EP_STATE_MASK)) == |
1346 | EP_STATE_DISABLED || | 1346 | cpu_to_le32(EP_STATE_DISABLED)) || |
1347 | le32_to_cpu(ctrl_ctx->drop_flags) & | 1347 | le32_to_cpu(ctrl_ctx->drop_flags) & |
1348 | xhci_get_endpoint_flag(&ep->desc)) { | 1348 | xhci_get_endpoint_flag(&ep->desc)) { |
1349 | xhci_warn(xhci, "xHCI %s called with disabled ep %p\n", | 1349 | xhci_warn(xhci, "xHCI %s called with disabled ep %p\n", |
@@ -1758,8 +1758,7 @@ static int xhci_configure_endpoint(struct xhci_hcd *xhci, | |||
1758 | /* Enqueue pointer can be left pointing to the link TRB, | 1758 | /* Enqueue pointer can be left pointing to the link TRB, |
1759 | * we must handle that | 1759 | * we must handle that |
1760 | */ | 1760 | */ |
1761 | if ((le32_to_cpu(command->command_trb->link.control) | 1761 | if (TRB_TYPE_LINK_LE32(command->command_trb->link.control)) |
1762 | & TRB_TYPE_BITMASK) == TRB_TYPE(TRB_LINK)) | ||
1763 | command->command_trb = | 1762 | command->command_trb = |
1764 | xhci->cmd_ring->enq_seg->next->trbs; | 1763 | xhci->cmd_ring->enq_seg->next->trbs; |
1765 | 1764 | ||
@@ -2559,8 +2558,7 @@ int xhci_discover_or_reset_device(struct usb_hcd *hcd, struct usb_device *udev) | |||
2559 | /* Enqueue pointer can be left pointing to the link TRB, | 2558 | /* Enqueue pointer can be left pointing to the link TRB, |
2560 | * we must handle that | 2559 | * we must handle that |
2561 | */ | 2560 | */ |
2562 | if ((le32_to_cpu(reset_device_cmd->command_trb->link.control) | 2561 | if (TRB_TYPE_LINK_LE32(reset_device_cmd->command_trb->link.control)) |
2563 | & TRB_TYPE_BITMASK) == TRB_TYPE(TRB_LINK)) | ||
2564 | reset_device_cmd->command_trb = | 2562 | reset_device_cmd->command_trb = |
2565 | xhci->cmd_ring->enq_seg->next->trbs; | 2563 | xhci->cmd_ring->enq_seg->next->trbs; |
2566 | 2564 | ||
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index d8bbf5ccb10..cae8e23308b 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h | |||
@@ -1072,6 +1072,13 @@ union xhci_trb { | |||
1072 | /* Get NEC firmware revision. */ | 1072 | /* Get NEC firmware revision. */ |
1073 | #define TRB_NEC_GET_FW 49 | 1073 | #define TRB_NEC_GET_FW 49 |
1074 | 1074 | ||
1075 | #define TRB_TYPE_LINK(x) (((x) & TRB_TYPE_BITMASK) == TRB_TYPE(TRB_LINK)) | ||
1076 | /* Above, but for __le32 types -- can avoid work by swapping constants: */ | ||
1077 | #define TRB_TYPE_LINK_LE32(x) (((x) & cpu_to_le32(TRB_TYPE_BITMASK)) == \ | ||
1078 | cpu_to_le32(TRB_TYPE(TRB_LINK))) | ||
1079 | #define TRB_TYPE_NOOP_LE32(x) (((x) & cpu_to_le32(TRB_TYPE_BITMASK)) == \ | ||
1080 | cpu_to_le32(TRB_TYPE(TRB_TR_NOOP))) | ||
1081 | |||
1075 | #define NEC_FW_MINOR(p) (((p) >> 0) & 0xff) | 1082 | #define NEC_FW_MINOR(p) (((p) >> 0) & 0xff) |
1076 | #define NEC_FW_MAJOR(p) (((p) >> 8) & 0xff) | 1083 | #define NEC_FW_MAJOR(p) (((p) >> 8) & 0xff) |
1077 | 1084 | ||