diff options
Diffstat (limited to 'drivers/usb/host/ehci-hcd.c')
-rw-r--r-- | drivers/usb/host/ehci-hcd.c | 64 |
1 files changed, 51 insertions, 13 deletions
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index f72ae0b6ee7f..59e81615e09c 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c | |||
@@ -95,7 +95,7 @@ static const char hcd_name [] = "ehci_hcd"; | |||
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_JIFFIES (DIV_ROUND_UP(HZ, 200) + 1) | 97 | #define EHCI_SHRINK_JIFFIES (DIV_ROUND_UP(HZ, 200) + 1) |
98 | /* 200-ms async qh unlink delay */ | 98 | /* 5-ms async qh unlink delay */ |
99 | 99 | ||
100 | /* Initial IRQ latency: faster than hw default */ | 100 | /* Initial IRQ latency: faster than hw default */ |
101 | static int log2_irq_thresh = 0; // 0 to 6 | 101 | static int log2_irq_thresh = 0; // 0 to 6 |
@@ -238,7 +238,7 @@ static int handshake_on_error_set_halt(struct ehci_hcd *ehci, void __iomem *ptr, | |||
238 | error = handshake(ehci, ptr, mask, done, usec); | 238 | error = handshake(ehci, ptr, mask, done, usec); |
239 | if (error) { | 239 | if (error) { |
240 | ehci_halt(ehci); | 240 | ehci_halt(ehci); |
241 | ehci_to_hcd(ehci)->state = HC_STATE_HALT; | 241 | ehci->rh_state = EHCI_RH_HALTED; |
242 | ehci_err(ehci, "force halt; handshake %p %08x %08x -> %d\n", | 242 | ehci_err(ehci, "force halt; handshake %p %08x %08x -> %d\n", |
243 | ptr, mask, done, error); | 243 | ptr, mask, done, error); |
244 | } | 244 | } |
@@ -278,7 +278,7 @@ static int ehci_reset (struct ehci_hcd *ehci) | |||
278 | command |= CMD_RESET; | 278 | command |= CMD_RESET; |
279 | dbg_cmd (ehci, "reset", command); | 279 | dbg_cmd (ehci, "reset", command); |
280 | ehci_writel(ehci, command, &ehci->regs->command); | 280 | ehci_writel(ehci, command, &ehci->regs->command); |
281 | ehci_to_hcd(ehci)->state = HC_STATE_HALT; | 281 | ehci->rh_state = EHCI_RH_HALTED; |
282 | ehci->next_statechange = jiffies; | 282 | ehci->next_statechange = jiffies; |
283 | retval = handshake (ehci, &ehci->regs->command, | 283 | retval = handshake (ehci, &ehci->regs->command, |
284 | CMD_RESET, 0, 250 * 1000); | 284 | CMD_RESET, 0, 250 * 1000); |
@@ -307,7 +307,7 @@ static void ehci_quiesce (struct ehci_hcd *ehci) | |||
307 | u32 temp; | 307 | u32 temp; |
308 | 308 | ||
309 | #ifdef DEBUG | 309 | #ifdef DEBUG |
310 | if (!HC_IS_RUNNING (ehci_to_hcd(ehci)->state)) | 310 | if (ehci->rh_state != EHCI_RH_RUNNING) |
311 | BUG (); | 311 | BUG (); |
312 | #endif | 312 | #endif |
313 | 313 | ||
@@ -356,7 +356,7 @@ static void ehci_iaa_watchdog(unsigned long param) | |||
356 | */ | 356 | */ |
357 | if (ehci->reclaim | 357 | if (ehci->reclaim |
358 | && !timer_pending(&ehci->iaa_watchdog) | 358 | && !timer_pending(&ehci->iaa_watchdog) |
359 | && HC_IS_RUNNING(ehci_to_hcd(ehci)->state)) { | 359 | && ehci->rh_state == EHCI_RH_RUNNING) { |
360 | u32 cmd, status; | 360 | u32 cmd, status; |
361 | 361 | ||
362 | /* If we get here, IAA is *REALLY* late. It's barely | 362 | /* If we get here, IAA is *REALLY* late. It's barely |
@@ -496,7 +496,7 @@ static void ehci_work (struct ehci_hcd *ehci) | |||
496 | * misplace IRQs, and should let us run completely without IRQs. | 496 | * misplace IRQs, and should let us run completely without IRQs. |
497 | * such lossage has been observed on both VT6202 and VT8235. | 497 | * such lossage has been observed on both VT6202 and VT8235. |
498 | */ | 498 | */ |
499 | if (HC_IS_RUNNING (ehci_to_hcd(ehci)->state) && | 499 | if (ehci->rh_state == EHCI_RH_RUNNING && |
500 | (ehci->async->qh_next.ptr != NULL || | 500 | (ehci->async->qh_next.ptr != NULL || |
501 | ehci->periodic_sched != 0)) | 501 | ehci->periodic_sched != 0)) |
502 | timer_action (ehci, TIMER_IO_WATCHDOG); | 502 | timer_action (ehci, TIMER_IO_WATCHDOG); |
@@ -516,7 +516,7 @@ static void ehci_stop (struct usb_hcd *hcd) | |||
516 | del_timer_sync(&ehci->iaa_watchdog); | 516 | del_timer_sync(&ehci->iaa_watchdog); |
517 | 517 | ||
518 | spin_lock_irq(&ehci->lock); | 518 | spin_lock_irq(&ehci->lock); |
519 | if (HC_IS_RUNNING (hcd->state)) | 519 | if (ehci->rh_state == EHCI_RH_RUNNING) |
520 | ehci_quiesce (ehci); | 520 | ehci_quiesce (ehci); |
521 | 521 | ||
522 | ehci_silence_controller(ehci); | 522 | ehci_silence_controller(ehci); |
@@ -741,7 +741,7 @@ static int ehci_run (struct usb_hcd *hcd) | |||
741 | * be started before the port switching actions could complete. | 741 | * be started before the port switching actions could complete. |
742 | */ | 742 | */ |
743 | down_write(&ehci_cf_port_reset_rwsem); | 743 | down_write(&ehci_cf_port_reset_rwsem); |
744 | hcd->state = HC_STATE_RUNNING; | 744 | ehci->rh_state = EHCI_RH_RUNNING; |
745 | ehci_writel(ehci, FLAG_CF, &ehci->regs->configured_flag); | 745 | ehci_writel(ehci, FLAG_CF, &ehci->regs->configured_flag); |
746 | ehci_readl(ehci, &ehci->regs->command); /* unblock posted writes */ | 746 | ehci_readl(ehci, &ehci->regs->command); /* unblock posted writes */ |
747 | msleep(5); | 747 | msleep(5); |
@@ -768,6 +768,35 @@ static int ehci_run (struct usb_hcd *hcd) | |||
768 | return 0; | 768 | return 0; |
769 | } | 769 | } |
770 | 770 | ||
771 | static int __maybe_unused ehci_setup (struct usb_hcd *hcd) | ||
772 | { | ||
773 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | ||
774 | int retval; | ||
775 | |||
776 | ehci->regs = (void __iomem *)ehci->caps + | ||
777 | HC_LENGTH(ehci, ehci_readl(ehci, &ehci->caps->hc_capbase)); | ||
778 | dbg_hcs_params(ehci, "reset"); | ||
779 | dbg_hcc_params(ehci, "reset"); | ||
780 | |||
781 | /* cache this readonly data; minimize chip reads */ | ||
782 | ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params); | ||
783 | |||
784 | ehci->sbrn = HCD_USB2; | ||
785 | |||
786 | retval = ehci_halt(ehci); | ||
787 | if (retval) | ||
788 | return retval; | ||
789 | |||
790 | /* data structure init */ | ||
791 | retval = ehci_init(hcd); | ||
792 | if (retval) | ||
793 | return retval; | ||
794 | |||
795 | ehci_reset(ehci); | ||
796 | |||
797 | return 0; | ||
798 | } | ||
799 | |||
771 | /*-------------------------------------------------------------------------*/ | 800 | /*-------------------------------------------------------------------------*/ |
772 | 801 | ||
773 | static irqreturn_t ehci_irq (struct usb_hcd *hcd) | 802 | static irqreturn_t ehci_irq (struct usb_hcd *hcd) |
@@ -788,7 +817,7 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd) | |||
788 | 817 | ||
789 | /* Shared IRQ? */ | 818 | /* Shared IRQ? */ |
790 | masked_status = status & INTR_MASK; | 819 | masked_status = status & INTR_MASK; |
791 | if (!masked_status || unlikely(hcd->state == HC_STATE_HALT)) { | 820 | if (!masked_status || unlikely(ehci->rh_state == EHCI_RH_HALTED)) { |
792 | spin_unlock(&ehci->lock); | 821 | spin_unlock(&ehci->lock); |
793 | return IRQ_NONE; | 822 | return IRQ_NONE; |
794 | } | 823 | } |
@@ -952,7 +981,7 @@ static int ehci_urb_enqueue ( | |||
952 | static void unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh) | 981 | static void unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh) |
953 | { | 982 | { |
954 | /* failfast */ | 983 | /* failfast */ |
955 | if (!HC_IS_RUNNING(ehci_to_hcd(ehci)->state) && ehci->reclaim) | 984 | if (ehci->rh_state != EHCI_RH_RUNNING && ehci->reclaim) |
956 | end_unlink_async(ehci); | 985 | end_unlink_async(ehci); |
957 | 986 | ||
958 | /* If the QH isn't linked then there's nothing we can do | 987 | /* If the QH isn't linked then there's nothing we can do |
@@ -1079,7 +1108,7 @@ rescan: | |||
1079 | goto idle_timeout; | 1108 | goto idle_timeout; |
1080 | } | 1109 | } |
1081 | 1110 | ||
1082 | if (!HC_IS_RUNNING (hcd->state)) | 1111 | if (ehci->rh_state != EHCI_RH_RUNNING) |
1083 | qh->qh_state = QH_STATE_IDLE; | 1112 | qh->qh_state = QH_STATE_IDLE; |
1084 | switch (qh->qh_state) { | 1113 | switch (qh->qh_state) { |
1085 | case QH_STATE_LINKED: | 1114 | case QH_STATE_LINKED: |
@@ -1166,8 +1195,7 @@ ehci_endpoint_reset(struct usb_hcd *hcd, struct usb_host_endpoint *ep) | |||
1166 | static int ehci_get_frame (struct usb_hcd *hcd) | 1195 | static int ehci_get_frame (struct usb_hcd *hcd) |
1167 | { | 1196 | { |
1168 | struct ehci_hcd *ehci = hcd_to_ehci (hcd); | 1197 | struct ehci_hcd *ehci = hcd_to_ehci (hcd); |
1169 | return (ehci_readl(ehci, &ehci->regs->frame_index) >> 3) % | 1198 | return (ehci_read_frame_index(ehci) >> 3) % ehci->periodic_size; |
1170 | ehci->periodic_size; | ||
1171 | } | 1199 | } |
1172 | 1200 | ||
1173 | /*-------------------------------------------------------------------------*/ | 1201 | /*-------------------------------------------------------------------------*/ |
@@ -1291,6 +1319,16 @@ MODULE_LICENSE ("GPL"); | |||
1291 | #define PLATFORM_DRIVER ehci_grlib_driver | 1319 | #define PLATFORM_DRIVER ehci_grlib_driver |
1292 | #endif | 1320 | #endif |
1293 | 1321 | ||
1322 | #ifdef CONFIG_USB_PXA168_EHCI | ||
1323 | #include "ehci-pxa168.c" | ||
1324 | #define PLATFORM_DRIVER ehci_pxa168_driver | ||
1325 | #endif | ||
1326 | |||
1327 | #ifdef CONFIG_NLM_XLR | ||
1328 | #include "ehci-xls.c" | ||
1329 | #define PLATFORM_DRIVER ehci_xls_driver | ||
1330 | #endif | ||
1331 | |||
1294 | #if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \ | 1332 | #if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \ |
1295 | !defined(PS3_SYSTEM_BUS_DRIVER) && !defined(OF_PLATFORM_DRIVER) && \ | 1333 | !defined(PS3_SYSTEM_BUS_DRIVER) && !defined(OF_PLATFORM_DRIVER) && \ |
1296 | !defined(XILINX_OF_PLATFORM_DRIVER) | 1334 | !defined(XILINX_OF_PLATFORM_DRIVER) |