diff options
Diffstat (limited to 'drivers/usb/host/ehci-hcd.c')
-rw-r--r-- | drivers/usb/host/ehci-hcd.c | 89 |
1 files changed, 55 insertions, 34 deletions
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 11c627ce6022..9835e0713943 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c | |||
@@ -30,7 +30,6 @@ | |||
30 | #include <linux/timer.h> | 30 | #include <linux/timer.h> |
31 | #include <linux/list.h> | 31 | #include <linux/list.h> |
32 | #include <linux/interrupt.h> | 32 | #include <linux/interrupt.h> |
33 | #include <linux/reboot.h> | ||
34 | #include <linux/usb.h> | 33 | #include <linux/usb.h> |
35 | #include <linux/moduleparam.h> | 34 | #include <linux/moduleparam.h> |
36 | #include <linux/dma-mapping.h> | 35 | #include <linux/dma-mapping.h> |
@@ -127,6 +126,8 @@ timer_action(struct ehci_hcd *ehci, enum ehci_timer_action action) | |||
127 | 126 | ||
128 | switch (action) { | 127 | switch (action) { |
129 | case TIMER_IO_WATCHDOG: | 128 | case TIMER_IO_WATCHDOG: |
129 | if (!ehci->need_io_watchdog) | ||
130 | return; | ||
130 | t = EHCI_IO_JIFFIES; | 131 | t = EHCI_IO_JIFFIES; |
131 | break; | 132 | break; |
132 | case TIMER_ASYNC_OFF: | 133 | case TIMER_ASYNC_OFF: |
@@ -239,6 +240,11 @@ static int ehci_reset (struct ehci_hcd *ehci) | |||
239 | int retval; | 240 | int retval; |
240 | u32 command = ehci_readl(ehci, &ehci->regs->command); | 241 | u32 command = ehci_readl(ehci, &ehci->regs->command); |
241 | 242 | ||
243 | /* If the EHCI debug controller is active, special care must be | ||
244 | * taken before and after a host controller reset */ | ||
245 | if (ehci->debug && !dbgp_reset_prep()) | ||
246 | ehci->debug = NULL; | ||
247 | |||
242 | command |= CMD_RESET; | 248 | command |= CMD_RESET; |
243 | dbg_cmd (ehci, "reset", command); | 249 | dbg_cmd (ehci, "reset", command); |
244 | ehci_writel(ehci, command, &ehci->regs->command); | 250 | ehci_writel(ehci, command, &ehci->regs->command); |
@@ -247,12 +253,21 @@ static int ehci_reset (struct ehci_hcd *ehci) | |||
247 | retval = handshake (ehci, &ehci->regs->command, | 253 | retval = handshake (ehci, &ehci->regs->command, |
248 | CMD_RESET, 0, 250 * 1000); | 254 | CMD_RESET, 0, 250 * 1000); |
249 | 255 | ||
256 | if (ehci->has_hostpc) { | ||
257 | ehci_writel(ehci, USBMODE_EX_HC | USBMODE_EX_VBPS, | ||
258 | (u32 __iomem *)(((u8 *)ehci->regs) + USBMODE_EX)); | ||
259 | ehci_writel(ehci, TXFIFO_DEFAULT, | ||
260 | (u32 __iomem *)(((u8 *)ehci->regs) + TXFILLTUNING)); | ||
261 | } | ||
250 | if (retval) | 262 | if (retval) |
251 | return retval; | 263 | return retval; |
252 | 264 | ||
253 | if (ehci_is_TDI(ehci)) | 265 | if (ehci_is_TDI(ehci)) |
254 | tdi_reset (ehci); | 266 | tdi_reset (ehci); |
255 | 267 | ||
268 | if (ehci->debug) | ||
269 | dbgp_external_startup(); | ||
270 | |||
256 | return retval; | 271 | return retval; |
257 | } | 272 | } |
258 | 273 | ||
@@ -505,9 +520,14 @@ static int ehci_init(struct usb_hcd *hcd) | |||
505 | u32 temp; | 520 | u32 temp; |
506 | int retval; | 521 | int retval; |
507 | u32 hcc_params; | 522 | u32 hcc_params; |
523 | struct ehci_qh_hw *hw; | ||
508 | 524 | ||
509 | spin_lock_init(&ehci->lock); | 525 | spin_lock_init(&ehci->lock); |
510 | 526 | ||
527 | /* | ||
528 | * keep io watchdog by default, those good HCDs could turn off it later | ||
529 | */ | ||
530 | ehci->need_io_watchdog = 1; | ||
511 | init_timer(&ehci->watchdog); | 531 | init_timer(&ehci->watchdog); |
512 | ehci->watchdog.function = ehci_watchdog; | 532 | ehci->watchdog.function = ehci_watchdog; |
513 | ehci->watchdog.data = (unsigned long) ehci; | 533 | ehci->watchdog.data = (unsigned long) ehci; |
@@ -544,12 +564,13 @@ static int ehci_init(struct usb_hcd *hcd) | |||
544 | * from automatically advancing to the next td after short reads. | 564 | * from automatically advancing to the next td after short reads. |
545 | */ | 565 | */ |
546 | ehci->async->qh_next.qh = NULL; | 566 | ehci->async->qh_next.qh = NULL; |
547 | ehci->async->hw_next = QH_NEXT(ehci, ehci->async->qh_dma); | 567 | hw = ehci->async->hw; |
548 | ehci->async->hw_info1 = cpu_to_hc32(ehci, QH_HEAD); | 568 | hw->hw_next = QH_NEXT(ehci, ehci->async->qh_dma); |
549 | ehci->async->hw_token = cpu_to_hc32(ehci, QTD_STS_HALT); | 569 | hw->hw_info1 = cpu_to_hc32(ehci, QH_HEAD); |
550 | ehci->async->hw_qtd_next = EHCI_LIST_END(ehci); | 570 | hw->hw_token = cpu_to_hc32(ehci, QTD_STS_HALT); |
571 | hw->hw_qtd_next = EHCI_LIST_END(ehci); | ||
551 | ehci->async->qh_state = QH_STATE_LINKED; | 572 | ehci->async->qh_state = QH_STATE_LINKED; |
552 | ehci->async->hw_alt_next = QTD_NEXT(ehci, ehci->async->dummy->qtd_dma); | 573 | hw->hw_alt_next = QTD_NEXT(ehci, ehci->async->dummy->qtd_dma); |
553 | 574 | ||
554 | /* clear interrupt enables, set irq latency */ | 575 | /* clear interrupt enables, set irq latency */ |
555 | if (log2_irq_thresh < 0 || log2_irq_thresh > 6) | 576 | if (log2_irq_thresh < 0 || log2_irq_thresh > 6) |
@@ -850,12 +871,18 @@ static void unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh) | |||
850 | if (!HC_IS_RUNNING(ehci_to_hcd(ehci)->state) && ehci->reclaim) | 871 | if (!HC_IS_RUNNING(ehci_to_hcd(ehci)->state) && ehci->reclaim) |
851 | end_unlink_async(ehci); | 872 | end_unlink_async(ehci); |
852 | 873 | ||
853 | /* if it's not linked then there's nothing to do */ | 874 | /* If the QH isn't linked then there's nothing we can do |
854 | if (qh->qh_state != QH_STATE_LINKED) | 875 | * unless we were called during a giveback, in which case |
855 | ; | 876 | * qh_completions() has to deal with it. |
877 | */ | ||
878 | if (qh->qh_state != QH_STATE_LINKED) { | ||
879 | if (qh->qh_state == QH_STATE_COMPLETING) | ||
880 | qh->needs_rescan = 1; | ||
881 | return; | ||
882 | } | ||
856 | 883 | ||
857 | /* defer till later if busy */ | 884 | /* defer till later if busy */ |
858 | else if (ehci->reclaim) { | 885 | if (ehci->reclaim) { |
859 | struct ehci_qh *last; | 886 | struct ehci_qh *last; |
860 | 887 | ||
861 | for (last = ehci->reclaim; | 888 | for (last = ehci->reclaim; |
@@ -915,8 +942,9 @@ static int ehci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) | |||
915 | break; | 942 | break; |
916 | switch (qh->qh_state) { | 943 | switch (qh->qh_state) { |
917 | case QH_STATE_LINKED: | 944 | case QH_STATE_LINKED: |
945 | case QH_STATE_COMPLETING: | ||
918 | intr_deschedule (ehci, qh); | 946 | intr_deschedule (ehci, qh); |
919 | /* FALL THROUGH */ | 947 | break; |
920 | case QH_STATE_IDLE: | 948 | case QH_STATE_IDLE: |
921 | qh_completions (ehci, qh); | 949 | qh_completions (ehci, qh); |
922 | break; | 950 | break; |
@@ -925,23 +953,6 @@ static int ehci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) | |||
925 | qh, qh->qh_state); | 953 | qh, qh->qh_state); |
926 | goto done; | 954 | goto done; |
927 | } | 955 | } |
928 | |||
929 | /* reschedule QH iff another request is queued */ | ||
930 | if (!list_empty (&qh->qtd_list) | ||
931 | && HC_IS_RUNNING (hcd->state)) { | ||
932 | rc = qh_schedule(ehci, qh); | ||
933 | |||
934 | /* An error here likely indicates handshake failure | ||
935 | * or no space left in the schedule. Neither fault | ||
936 | * should happen often ... | ||
937 | * | ||
938 | * FIXME kill the now-dysfunctional queued urbs | ||
939 | */ | ||
940 | if (rc != 0) | ||
941 | ehci_err(ehci, | ||
942 | "can't reschedule qh %p, err %d", | ||
943 | qh, rc); | ||
944 | } | ||
945 | break; | 956 | break; |
946 | 957 | ||
947 | case PIPE_ISOCHRONOUS: | 958 | case PIPE_ISOCHRONOUS: |
@@ -979,7 +990,7 @@ rescan: | |||
979 | /* endpoints can be iso streams. for now, we don't | 990 | /* endpoints can be iso streams. for now, we don't |
980 | * accelerate iso completions ... so spin a while. | 991 | * accelerate iso completions ... so spin a while. |
981 | */ | 992 | */ |
982 | if (qh->hw_info1 == 0) { | 993 | if (qh->hw->hw_info1 == 0) { |
983 | ehci_vdbg (ehci, "iso delay\n"); | 994 | ehci_vdbg (ehci, "iso delay\n"); |
984 | goto idle_timeout; | 995 | goto idle_timeout; |
985 | } | 996 | } |
@@ -988,6 +999,7 @@ rescan: | |||
988 | qh->qh_state = QH_STATE_IDLE; | 999 | qh->qh_state = QH_STATE_IDLE; |
989 | switch (qh->qh_state) { | 1000 | switch (qh->qh_state) { |
990 | case QH_STATE_LINKED: | 1001 | case QH_STATE_LINKED: |
1002 | case QH_STATE_COMPLETING: | ||
991 | for (tmp = ehci->async->qh_next.qh; | 1003 | for (tmp = ehci->async->qh_next.qh; |
992 | tmp && tmp != qh; | 1004 | tmp && tmp != qh; |
993 | tmp = tmp->qh_next.qh) | 1005 | tmp = tmp->qh_next.qh) |
@@ -1052,18 +1064,17 @@ ehci_endpoint_reset(struct usb_hcd *hcd, struct usb_host_endpoint *ep) | |||
1052 | usb_settoggle(qh->dev, epnum, is_out, 0); | 1064 | usb_settoggle(qh->dev, epnum, is_out, 0); |
1053 | if (!list_empty(&qh->qtd_list)) { | 1065 | if (!list_empty(&qh->qtd_list)) { |
1054 | WARN_ONCE(1, "clear_halt for a busy endpoint\n"); | 1066 | WARN_ONCE(1, "clear_halt for a busy endpoint\n"); |
1055 | } else if (qh->qh_state == QH_STATE_LINKED) { | 1067 | } else if (qh->qh_state == QH_STATE_LINKED || |
1068 | qh->qh_state == QH_STATE_COMPLETING) { | ||
1056 | 1069 | ||
1057 | /* The toggle value in the QH can't be updated | 1070 | /* The toggle value in the QH can't be updated |
1058 | * while the QH is active. Unlink it now; | 1071 | * while the QH is active. Unlink it now; |
1059 | * re-linking will call qh_refresh(). | 1072 | * re-linking will call qh_refresh(). |
1060 | */ | 1073 | */ |
1061 | if (eptype == USB_ENDPOINT_XFER_BULK) { | 1074 | if (eptype == USB_ENDPOINT_XFER_BULK) |
1062 | unlink_async(ehci, qh); | 1075 | unlink_async(ehci, qh); |
1063 | } else { | 1076 | else |
1064 | intr_deschedule(ehci, qh); | 1077 | intr_deschedule(ehci, qh); |
1065 | (void) qh_schedule(ehci, qh); | ||
1066 | } | ||
1067 | } | 1078 | } |
1068 | } | 1079 | } |
1069 | spin_unlock_irqrestore(&ehci->lock, flags); | 1080 | spin_unlock_irqrestore(&ehci->lock, flags); |
@@ -1117,6 +1128,16 @@ MODULE_LICENSE ("GPL"); | |||
1117 | #define PLATFORM_DRIVER ixp4xx_ehci_driver | 1128 | #define PLATFORM_DRIVER ixp4xx_ehci_driver |
1118 | #endif | 1129 | #endif |
1119 | 1130 | ||
1131 | #ifdef CONFIG_USB_W90X900_EHCI | ||
1132 | #include "ehci-w90x900.c" | ||
1133 | #define PLATFORM_DRIVER ehci_hcd_w90x900_driver | ||
1134 | #endif | ||
1135 | |||
1136 | #ifdef CONFIG_ARCH_AT91 | ||
1137 | #include "ehci-atmel.c" | ||
1138 | #define PLATFORM_DRIVER ehci_atmel_driver | ||
1139 | #endif | ||
1140 | |||
1120 | #if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \ | 1141 | #if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \ |
1121 | !defined(PS3_SYSTEM_BUS_DRIVER) && !defined(OF_PLATFORM_DRIVER) | 1142 | !defined(PS3_SYSTEM_BUS_DRIVER) && !defined(OF_PLATFORM_DRIVER) |
1122 | #error "missing bus glue for ehci-hcd" | 1143 | #error "missing bus glue for ehci-hcd" |