diff options
Diffstat (limited to 'drivers/usb/host')
-rw-r--r-- | drivers/usb/host/ehci-hcd.c | 16 | ||||
-rw-r--r-- | drivers/usb/host/ehci-hub.c | 104 | ||||
-rw-r--r-- | drivers/usb/host/ehci-pci.c | 40 | ||||
-rw-r--r-- | drivers/usb/host/ehci.h | 1 | ||||
-rw-r--r-- | drivers/usb/host/ohci-hcd.c | 10 | ||||
-rw-r--r-- | drivers/usb/host/ohci-hub.c | 172 | ||||
-rw-r--r-- | drivers/usb/host/u132-hcd.c | 8 |
7 files changed, 205 insertions, 146 deletions
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 9030994aba98..025d33313681 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c | |||
@@ -126,6 +126,11 @@ static unsigned park = 0; | |||
126 | module_param (park, uint, S_IRUGO); | 126 | module_param (park, uint, S_IRUGO); |
127 | MODULE_PARM_DESC (park, "park setting; 1-3 back-to-back async packets"); | 127 | MODULE_PARM_DESC (park, "park setting; 1-3 back-to-back async packets"); |
128 | 128 | ||
129 | /* for flakey hardware, ignore overcurrent indicators */ | ||
130 | static int ignore_oc = 0; | ||
131 | module_param (ignore_oc, bool, S_IRUGO); | ||
132 | MODULE_PARM_DESC (ignore_oc, "ignore bogus hardware overcurrent indications"); | ||
133 | |||
129 | #define INTR_MASK (STS_IAA | STS_FATAL | STS_PCD | STS_ERR | STS_INT) | 134 | #define INTR_MASK (STS_IAA | STS_FATAL | STS_PCD | STS_ERR | STS_INT) |
130 | 135 | ||
131 | /*-------------------------------------------------------------------------*/ | 136 | /*-------------------------------------------------------------------------*/ |
@@ -541,9 +546,10 @@ static int ehci_run (struct usb_hcd *hcd) | |||
541 | 546 | ||
542 | temp = HC_VERSION(readl (&ehci->caps->hc_capbase)); | 547 | temp = HC_VERSION(readl (&ehci->caps->hc_capbase)); |
543 | ehci_info (ehci, | 548 | ehci_info (ehci, |
544 | "USB %x.%x started, EHCI %x.%02x, driver %s\n", | 549 | "USB %x.%x started, EHCI %x.%02x, driver %s%s\n", |
545 | ((ehci->sbrn & 0xf0)>>4), (ehci->sbrn & 0x0f), | 550 | ((ehci->sbrn & 0xf0)>>4), (ehci->sbrn & 0x0f), |
546 | temp >> 8, temp & 0xff, DRIVER_VERSION); | 551 | temp >> 8, temp & 0xff, DRIVER_VERSION, |
552 | ignore_oc ? ", overcurrent ignored" : ""); | ||
547 | 553 | ||
548 | writel (INTR_MASK, &ehci->regs->intr_enable); /* Turn On Interrupts */ | 554 | writel (INTR_MASK, &ehci->regs->intr_enable); /* Turn On Interrupts */ |
549 | 555 | ||
@@ -613,9 +619,8 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd) | |||
613 | unsigned i = HCS_N_PORTS (ehci->hcs_params); | 619 | unsigned i = HCS_N_PORTS (ehci->hcs_params); |
614 | 620 | ||
615 | /* resume root hub? */ | 621 | /* resume root hub? */ |
616 | status = readl (&ehci->regs->command); | 622 | if (!(readl(&ehci->regs->command) & CMD_RUN)) |
617 | if (!(status & CMD_RUN)) | 623 | usb_hcd_resume_root_hub(hcd); |
618 | writel (status | CMD_RUN, &ehci->regs->command); | ||
619 | 624 | ||
620 | while (i--) { | 625 | while (i--) { |
621 | int pstatus = readl (&ehci->regs->port_status [i]); | 626 | int pstatus = readl (&ehci->regs->port_status [i]); |
@@ -632,7 +637,6 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd) | |||
632 | */ | 637 | */ |
633 | ehci->reset_done [i] = jiffies + msecs_to_jiffies (20); | 638 | ehci->reset_done [i] = jiffies + msecs_to_jiffies (20); |
634 | ehci_dbg (ehci, "port %d remote wakeup\n", i + 1); | 639 | ehci_dbg (ehci, "port %d remote wakeup\n", i + 1); |
635 | usb_hcd_resume_root_hub(hcd); | ||
636 | } | 640 | } |
637 | } | 641 | } |
638 | 642 | ||
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c index 1b20722c102b..bfe5f307cba6 100644 --- a/drivers/usb/host/ehci-hub.c +++ b/drivers/usb/host/ehci-hub.c | |||
@@ -34,6 +34,7 @@ static int ehci_bus_suspend (struct usb_hcd *hcd) | |||
34 | { | 34 | { |
35 | struct ehci_hcd *ehci = hcd_to_ehci (hcd); | 35 | struct ehci_hcd *ehci = hcd_to_ehci (hcd); |
36 | int port; | 36 | int port; |
37 | int mask; | ||
37 | 38 | ||
38 | if (time_before (jiffies, ehci->next_statechange)) | 39 | if (time_before (jiffies, ehci->next_statechange)) |
39 | msleep(5); | 40 | msleep(5); |
@@ -51,14 +52,25 @@ static int ehci_bus_suspend (struct usb_hcd *hcd) | |||
51 | ehci->reclaim_ready = 1; | 52 | ehci->reclaim_ready = 1; |
52 | ehci_work(ehci); | 53 | ehci_work(ehci); |
53 | 54 | ||
54 | /* suspend any active/unsuspended ports, maybe allow wakeup */ | 55 | /* Unlike other USB host controller types, EHCI doesn't have |
56 | * any notion of "global" or bus-wide suspend. The driver has | ||
57 | * to manually suspend all the active unsuspended ports, and | ||
58 | * then manually resume them in the bus_resume() routine. | ||
59 | */ | ||
60 | ehci->bus_suspended = 0; | ||
55 | while (port--) { | 61 | while (port--) { |
56 | u32 __iomem *reg = &ehci->regs->port_status [port]; | 62 | u32 __iomem *reg = &ehci->regs->port_status [port]; |
57 | u32 t1 = readl (reg) & ~PORT_RWC_BITS; | 63 | u32 t1 = readl (reg) & ~PORT_RWC_BITS; |
58 | u32 t2 = t1; | 64 | u32 t2 = t1; |
59 | 65 | ||
60 | if ((t1 & PORT_PE) && !(t1 & PORT_OWNER)) | 66 | /* keep track of which ports we suspend */ |
67 | if ((t1 & PORT_PE) && !(t1 & PORT_OWNER) && | ||
68 | !(t1 & PORT_SUSPEND)) { | ||
61 | t2 |= PORT_SUSPEND; | 69 | t2 |= PORT_SUSPEND; |
70 | set_bit(port, &ehci->bus_suspended); | ||
71 | } | ||
72 | |||
73 | /* enable remote wakeup on all ports */ | ||
62 | if (device_may_wakeup(&hcd->self.root_hub->dev)) | 74 | if (device_may_wakeup(&hcd->self.root_hub->dev)) |
63 | t2 |= PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E; | 75 | t2 |= PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E; |
64 | else | 76 | else |
@@ -76,6 +88,13 @@ static int ehci_bus_suspend (struct usb_hcd *hcd) | |||
76 | ehci_halt (ehci); | 88 | ehci_halt (ehci); |
77 | hcd->state = HC_STATE_SUSPENDED; | 89 | hcd->state = HC_STATE_SUSPENDED; |
78 | 90 | ||
91 | /* allow remote wakeup */ | ||
92 | mask = INTR_MASK; | ||
93 | if (!device_may_wakeup(&hcd->self.root_hub->dev)) | ||
94 | mask &= ~STS_PCD; | ||
95 | writel(mask, &ehci->regs->intr_enable); | ||
96 | readl(&ehci->regs->intr_enable); | ||
97 | |||
79 | ehci->next_statechange = jiffies + msecs_to_jiffies(10); | 98 | ehci->next_statechange = jiffies + msecs_to_jiffies(10); |
80 | spin_unlock_irq (&ehci->lock); | 99 | spin_unlock_irq (&ehci->lock); |
81 | return 0; | 100 | return 0; |
@@ -88,7 +107,6 @@ static int ehci_bus_resume (struct usb_hcd *hcd) | |||
88 | struct ehci_hcd *ehci = hcd_to_ehci (hcd); | 107 | struct ehci_hcd *ehci = hcd_to_ehci (hcd); |
89 | u32 temp; | 108 | u32 temp; |
90 | int i; | 109 | int i; |
91 | int intr_enable; | ||
92 | 110 | ||
93 | if (time_before (jiffies, ehci->next_statechange)) | 111 | if (time_before (jiffies, ehci->next_statechange)) |
94 | msleep(5); | 112 | msleep(5); |
@@ -100,31 +118,30 @@ static int ehci_bus_resume (struct usb_hcd *hcd) | |||
100 | * the last user of the controller, not reset/pm hardware keeping | 118 | * the last user of the controller, not reset/pm hardware keeping |
101 | * state we gave to it. | 119 | * state we gave to it. |
102 | */ | 120 | */ |
121 | temp = readl(&ehci->regs->intr_enable); | ||
122 | ehci_dbg(ehci, "resume root hub%s\n", temp ? "" : " after power loss"); | ||
103 | 123 | ||
104 | /* re-init operational registers in case we lost power */ | 124 | /* at least some APM implementations will try to deliver |
105 | if (readl (&ehci->regs->intr_enable) == 0) { | 125 | * IRQs right away, so delay them until we're ready. |
106 | /* at least some APM implementations will try to deliver | 126 | */ |
107 | * IRQs right away, so delay them until we're ready. | 127 | writel(0, &ehci->regs->intr_enable); |
108 | */ | 128 | |
109 | intr_enable = 1; | 129 | /* re-init operational registers */ |
110 | writel (0, &ehci->regs->segment); | 130 | writel(0, &ehci->regs->segment); |
111 | writel (ehci->periodic_dma, &ehci->regs->frame_list); | 131 | writel(ehci->periodic_dma, &ehci->regs->frame_list); |
112 | writel ((u32)ehci->async->qh_dma, &ehci->regs->async_next); | 132 | writel((u32) ehci->async->qh_dma, &ehci->regs->async_next); |
113 | } else | ||
114 | intr_enable = 0; | ||
115 | ehci_dbg(ehci, "resume root hub%s\n", | ||
116 | intr_enable ? " after power loss" : ""); | ||
117 | 133 | ||
118 | /* restore CMD_RUN, framelist size, and irq threshold */ | 134 | /* restore CMD_RUN, framelist size, and irq threshold */ |
119 | writel (ehci->command, &ehci->regs->command); | 135 | writel (ehci->command, &ehci->regs->command); |
120 | 136 | ||
121 | /* take ports out of suspend */ | 137 | /* manually resume the ports we suspended during bus_suspend() */ |
122 | i = HCS_N_PORTS (ehci->hcs_params); | 138 | i = HCS_N_PORTS (ehci->hcs_params); |
123 | while (i--) { | 139 | while (i--) { |
124 | temp = readl (&ehci->regs->port_status [i]); | 140 | temp = readl (&ehci->regs->port_status [i]); |
125 | temp &= ~(PORT_RWC_BITS | 141 | temp &= ~(PORT_RWC_BITS |
126 | | PORT_WKOC_E | PORT_WKDISC_E | PORT_WKCONN_E); | 142 | | PORT_WKOC_E | PORT_WKDISC_E | PORT_WKCONN_E); |
127 | if (temp & PORT_SUSPEND) { | 143 | if (test_bit(i, &ehci->bus_suspended) && |
144 | (temp & PORT_SUSPEND)) { | ||
128 | ehci->reset_done [i] = jiffies + msecs_to_jiffies (20); | 145 | ehci->reset_done [i] = jiffies + msecs_to_jiffies (20); |
129 | temp |= PORT_RESUME; | 146 | temp |= PORT_RESUME; |
130 | } | 147 | } |
@@ -134,11 +151,12 @@ static int ehci_bus_resume (struct usb_hcd *hcd) | |||
134 | mdelay (20); | 151 | mdelay (20); |
135 | while (i--) { | 152 | while (i--) { |
136 | temp = readl (&ehci->regs->port_status [i]); | 153 | temp = readl (&ehci->regs->port_status [i]); |
137 | if ((temp & PORT_SUSPEND) == 0) | 154 | if (test_bit(i, &ehci->bus_suspended) && |
138 | continue; | 155 | (temp & PORT_SUSPEND)) { |
139 | temp &= ~(PORT_RWC_BITS | PORT_RESUME); | 156 | temp &= ~(PORT_RWC_BITS | PORT_RESUME); |
140 | writel (temp, &ehci->regs->port_status [i]); | 157 | writel (temp, &ehci->regs->port_status [i]); |
141 | ehci_vdbg (ehci, "resumed port %d\n", i + 1); | 158 | ehci_vdbg (ehci, "resumed port %d\n", i + 1); |
159 | } | ||
142 | } | 160 | } |
143 | (void) readl (&ehci->regs->command); | 161 | (void) readl (&ehci->regs->command); |
144 | 162 | ||
@@ -157,8 +175,7 @@ static int ehci_bus_resume (struct usb_hcd *hcd) | |||
157 | hcd->state = HC_STATE_RUNNING; | 175 | hcd->state = HC_STATE_RUNNING; |
158 | 176 | ||
159 | /* Now we can safely re-enable irqs */ | 177 | /* Now we can safely re-enable irqs */ |
160 | if (intr_enable) | 178 | writel(INTR_MASK, &ehci->regs->intr_enable); |
161 | writel (INTR_MASK, &ehci->regs->intr_enable); | ||
162 | 179 | ||
163 | spin_unlock_irq (&ehci->lock); | 180 | spin_unlock_irq (&ehci->lock); |
164 | return 0; | 181 | return 0; |
@@ -218,6 +235,7 @@ ehci_hub_status_data (struct usb_hcd *hcd, char *buf) | |||
218 | { | 235 | { |
219 | struct ehci_hcd *ehci = hcd_to_ehci (hcd); | 236 | struct ehci_hcd *ehci = hcd_to_ehci (hcd); |
220 | u32 temp, status = 0; | 237 | u32 temp, status = 0; |
238 | u32 mask; | ||
221 | int ports, i, retval = 1; | 239 | int ports, i, retval = 1; |
222 | unsigned long flags; | 240 | unsigned long flags; |
223 | 241 | ||
@@ -233,6 +251,18 @@ ehci_hub_status_data (struct usb_hcd *hcd, char *buf) | |||
233 | retval++; | 251 | retval++; |
234 | } | 252 | } |
235 | 253 | ||
254 | /* Some boards (mostly VIA?) report bogus overcurrent indications, | ||
255 | * causing massive log spam unless we completely ignore them. It | ||
256 | * may be relevant that VIA VT8235 controlers, where PORT_POWER is | ||
257 | * always set, seem to clear PORT_OCC and PORT_CSC when writing to | ||
258 | * PORT_POWER; that's surprising, but maybe within-spec. | ||
259 | */ | ||
260 | if (!ignore_oc) | ||
261 | mask = PORT_CSC | PORT_PEC | PORT_OCC; | ||
262 | else | ||
263 | mask = PORT_CSC | PORT_PEC; | ||
264 | // PORT_RESUME from hardware ~= PORT_STAT_C_SUSPEND | ||
265 | |||
236 | /* no hub change reports (bit 0) for now (power, ...) */ | 266 | /* no hub change reports (bit 0) for now (power, ...) */ |
237 | 267 | ||
238 | /* port N changes (bit N)? */ | 268 | /* port N changes (bit N)? */ |
@@ -250,8 +280,7 @@ ehci_hub_status_data (struct usb_hcd *hcd, char *buf) | |||
250 | } | 280 | } |
251 | if (!(temp & PORT_CONNECT)) | 281 | if (!(temp & PORT_CONNECT)) |
252 | ehci->reset_done [i] = 0; | 282 | ehci->reset_done [i] = 0; |
253 | if ((temp & (PORT_CSC | PORT_PEC | PORT_OCC)) != 0 | 283 | if ((temp & mask) != 0 |
254 | // PORT_STAT_C_SUSPEND? | ||
255 | || ((temp & PORT_RESUME) != 0 | 284 | || ((temp & PORT_RESUME) != 0 |
256 | && time_after (jiffies, | 285 | && time_after (jiffies, |
257 | ehci->reset_done [i]))) { | 286 | ehci->reset_done [i]))) { |
@@ -319,6 +348,7 @@ static int ehci_hub_control ( | |||
319 | u32 temp, status; | 348 | u32 temp, status; |
320 | unsigned long flags; | 349 | unsigned long flags; |
321 | int retval = 0; | 350 | int retval = 0; |
351 | unsigned selector; | ||
322 | 352 | ||
323 | /* | 353 | /* |
324 | * FIXME: support SetPortFeatures USB_PORT_FEAT_INDICATOR. | 354 | * FIXME: support SetPortFeatures USB_PORT_FEAT_INDICATOR. |
@@ -417,7 +447,7 @@ static int ehci_hub_control ( | |||
417 | status |= 1 << USB_PORT_FEAT_C_CONNECTION; | 447 | status |= 1 << USB_PORT_FEAT_C_CONNECTION; |
418 | if (temp & PORT_PEC) | 448 | if (temp & PORT_PEC) |
419 | status |= 1 << USB_PORT_FEAT_C_ENABLE; | 449 | status |= 1 << USB_PORT_FEAT_C_ENABLE; |
420 | if (temp & PORT_OCC) | 450 | if ((temp & PORT_OCC) && !ignore_oc) |
421 | status |= 1 << USB_PORT_FEAT_C_OVER_CURRENT; | 451 | status |= 1 << USB_PORT_FEAT_C_OVER_CURRENT; |
422 | 452 | ||
423 | /* whoever resumes must GetPortStatus to complete it!! */ | 453 | /* whoever resumes must GetPortStatus to complete it!! */ |
@@ -506,6 +536,8 @@ static int ehci_hub_control ( | |||
506 | } | 536 | } |
507 | break; | 537 | break; |
508 | case SetPortFeature: | 538 | case SetPortFeature: |
539 | selector = wIndex >> 8; | ||
540 | wIndex &= 0xff; | ||
509 | if (!wIndex || wIndex > ports) | 541 | if (!wIndex || wIndex > ports) |
510 | goto error; | 542 | goto error; |
511 | wIndex--; | 543 | wIndex--; |
@@ -559,6 +591,22 @@ static int ehci_hub_control ( | |||
559 | } | 591 | } |
560 | writel (temp, &ehci->regs->port_status [wIndex]); | 592 | writel (temp, &ehci->regs->port_status [wIndex]); |
561 | break; | 593 | break; |
594 | |||
595 | /* For downstream facing ports (these): one hub port is put | ||
596 | * into test mode according to USB2 11.24.2.13, then the hub | ||
597 | * must be reset (which for root hub now means rmmod+modprobe, | ||
598 | * or else system reboot). See EHCI 2.3.9 and 4.14 for info | ||
599 | * about the EHCI-specific stuff. | ||
600 | */ | ||
601 | case USB_PORT_FEAT_TEST: | ||
602 | if (!selector || selector > 5) | ||
603 | goto error; | ||
604 | ehci_quiesce(ehci); | ||
605 | ehci_halt(ehci); | ||
606 | temp |= selector << 16; | ||
607 | writel (temp, &ehci->regs->port_status [wIndex]); | ||
608 | break; | ||
609 | |||
562 | default: | 610 | default: |
563 | goto error; | 611 | goto error; |
564 | } | 612 | } |
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c index e51c1ed81ac4..4bc7970ba3ef 100644 --- a/drivers/usb/host/ehci-pci.c +++ b/drivers/usb/host/ehci-pci.c | |||
@@ -257,9 +257,7 @@ static int ehci_pci_suspend(struct usb_hcd *hcd, pm_message_t message) | |||
257 | static int ehci_pci_resume(struct usb_hcd *hcd) | 257 | static int ehci_pci_resume(struct usb_hcd *hcd) |
258 | { | 258 | { |
259 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | 259 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
260 | unsigned port; | ||
261 | struct pci_dev *pdev = to_pci_dev(hcd->self.controller); | 260 | struct pci_dev *pdev = to_pci_dev(hcd->self.controller); |
262 | int retval = -EINVAL; | ||
263 | 261 | ||
264 | // maybe restore FLADJ | 262 | // maybe restore FLADJ |
265 | 263 | ||
@@ -269,27 +267,19 @@ static int ehci_pci_resume(struct usb_hcd *hcd) | |||
269 | /* Mark hardware accessible again as we are out of D3 state by now */ | 267 | /* Mark hardware accessible again as we are out of D3 state by now */ |
270 | set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | 268 | set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); |
271 | 269 | ||
272 | /* If CF is clear, we lost PCI Vaux power and need to restart. */ | 270 | /* If CF is still set, we maintained PCI Vaux power. |
273 | if (readl(&ehci->regs->configured_flag) != FLAG_CF) | 271 | * Just undo the effect of ehci_pci_suspend(). |
274 | goto restart; | ||
275 | |||
276 | /* If any port is suspended (or owned by the companion), | ||
277 | * we know we can/must resume the HC (and mustn't reset it). | ||
278 | * We just defer that to the root hub code. | ||
279 | */ | 272 | */ |
280 | for (port = HCS_N_PORTS(ehci->hcs_params); port > 0; ) { | 273 | if (readl(&ehci->regs->configured_flag) == FLAG_CF) { |
281 | u32 status; | 274 | int mask = INTR_MASK; |
282 | port--; | 275 | |
283 | status = readl(&ehci->regs->port_status [port]); | 276 | if (!device_may_wakeup(&hcd->self.root_hub->dev)) |
284 | if (!(status & PORT_POWER)) | 277 | mask &= ~STS_PCD; |
285 | continue; | 278 | writel(mask, &ehci->regs->intr_enable); |
286 | if (status & (PORT_SUSPEND | PORT_RESUME | PORT_OWNER)) { | 279 | readl(&ehci->regs->intr_enable); |
287 | usb_hcd_resume_root_hub(hcd); | 280 | return 0; |
288 | return 0; | ||
289 | } | ||
290 | } | 281 | } |
291 | 282 | ||
292 | restart: | ||
293 | ehci_dbg(ehci, "lost power, restarting\n"); | 283 | ehci_dbg(ehci, "lost power, restarting\n"); |
294 | usb_root_hub_lost_power(hcd->self.root_hub); | 284 | usb_root_hub_lost_power(hcd->self.root_hub); |
295 | 285 | ||
@@ -307,13 +297,15 @@ restart: | |||
307 | ehci_work(ehci); | 297 | ehci_work(ehci); |
308 | spin_unlock_irq(&ehci->lock); | 298 | spin_unlock_irq(&ehci->lock); |
309 | 299 | ||
310 | /* restart; khubd will disconnect devices */ | ||
311 | retval = ehci_run(hcd); | ||
312 | |||
313 | /* here we "know" root ports should always stay powered */ | 300 | /* here we "know" root ports should always stay powered */ |
314 | ehci_port_power(ehci, 1); | 301 | ehci_port_power(ehci, 1); |
315 | 302 | ||
316 | return retval; | 303 | writel(ehci->command, &ehci->regs->command); |
304 | writel(FLAG_CF, &ehci->regs->configured_flag); | ||
305 | readl(&ehci->regs->command); /* unblock posted writes */ | ||
306 | |||
307 | hcd->state = HC_STATE_SUSPENDED; | ||
308 | return 0; | ||
317 | } | 309 | } |
318 | #endif | 310 | #endif |
319 | 311 | ||
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h index bbc3082a73d7..74dbc6c8228f 100644 --- a/drivers/usb/host/ehci.h +++ b/drivers/usb/host/ehci.h | |||
@@ -74,6 +74,7 @@ struct ehci_hcd { /* one per controller */ | |||
74 | 74 | ||
75 | /* per root hub port */ | 75 | /* per root hub port */ |
76 | unsigned long reset_done [EHCI_MAX_ROOT_PORTS]; | 76 | unsigned long reset_done [EHCI_MAX_ROOT_PORTS]; |
77 | unsigned long bus_suspended; | ||
77 | 78 | ||
78 | /* per-HC memory pools (could be per-bus, but ...) */ | 79 | /* per-HC memory pools (could be per-bus, but ...) */ |
79 | struct dma_pool *qh_pool; /* qh per active urb */ | 80 | struct dma_pool *qh_pool; /* qh per active urb */ |
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index ea4714e557e4..a95275a401b1 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c | |||
@@ -729,6 +729,16 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd) | |||
729 | ohci->next_statechange = jiffies + STATECHANGE_DELAY; | 729 | ohci->next_statechange = jiffies + STATECHANGE_DELAY; |
730 | ohci_writel(ohci, OHCI_INTR_RD | OHCI_INTR_RHSC, | 730 | ohci_writel(ohci, OHCI_INTR_RD | OHCI_INTR_RHSC, |
731 | ®s->intrstatus); | 731 | ®s->intrstatus); |
732 | |||
733 | /* NOTE: Vendors didn't always make the same implementation | ||
734 | * choices for RHSC. Many followed the spec; RHSC triggers | ||
735 | * on an edge, like setting and maybe clearing a port status | ||
736 | * change bit. With others it's level-triggered, active | ||
737 | * until khubd clears all the port status change bits. We'll | ||
738 | * always disable it here and rely on polling until khubd | ||
739 | * re-enables it. | ||
740 | */ | ||
741 | ohci_writel(ohci, OHCI_INTR_RHSC, ®s->intrdisable); | ||
732 | usb_hcd_poll_rh_status(hcd); | 742 | usb_hcd_poll_rh_status(hcd); |
733 | } | 743 | } |
734 | 744 | ||
diff --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c index 6995ea36f2e8..2441642cb7b4 100644 --- a/drivers/usb/host/ohci-hub.c +++ b/drivers/usb/host/ohci-hub.c | |||
@@ -41,7 +41,11 @@ static void ohci_rhsc_enable (struct usb_hcd *hcd) | |||
41 | { | 41 | { |
42 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); | 42 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); |
43 | 43 | ||
44 | ohci_writel (ohci, OHCI_INTR_RHSC, &ohci->regs->intrenable); | 44 | spin_lock_irq(&ohci->lock); |
45 | if (!ohci->autostop) | ||
46 | del_timer(&hcd->rh_timer); /* Prevent next poll */ | ||
47 | ohci_writel(ohci, OHCI_INTR_RHSC, &ohci->regs->intrenable); | ||
48 | spin_unlock_irq(&ohci->lock); | ||
45 | } | 49 | } |
46 | 50 | ||
47 | #define OHCI_SCHED_ENABLES \ | 51 | #define OHCI_SCHED_ENABLES \ |
@@ -50,6 +54,9 @@ static void ohci_rhsc_enable (struct usb_hcd *hcd) | |||
50 | static void dl_done_list (struct ohci_hcd *); | 54 | static void dl_done_list (struct ohci_hcd *); |
51 | static void finish_unlinks (struct ohci_hcd *, u16); | 55 | static void finish_unlinks (struct ohci_hcd *, u16); |
52 | 56 | ||
57 | #ifdef CONFIG_PM | ||
58 | static int ohci_restart(struct ohci_hcd *ohci); | ||
59 | |||
53 | static int ohci_rh_suspend (struct ohci_hcd *ohci, int autostop) | 60 | static int ohci_rh_suspend (struct ohci_hcd *ohci, int autostop) |
54 | __releases(ohci->lock) | 61 | __releases(ohci->lock) |
55 | __acquires(ohci->lock) | 62 | __acquires(ohci->lock) |
@@ -132,8 +139,6 @@ static inline struct ed *find_head (struct ed *ed) | |||
132 | return ed; | 139 | return ed; |
133 | } | 140 | } |
134 | 141 | ||
135 | static int ohci_restart (struct ohci_hcd *ohci); | ||
136 | |||
137 | /* caller has locked the root hub */ | 142 | /* caller has locked the root hub */ |
138 | static int ohci_rh_resume (struct ohci_hcd *ohci) | 143 | static int ohci_rh_resume (struct ohci_hcd *ohci) |
139 | __releases(ohci->lock) | 144 | __releases(ohci->lock) |
@@ -169,7 +174,7 @@ __acquires(ohci->lock) | |||
169 | break; | 174 | break; |
170 | case OHCI_USB_RESUME: | 175 | case OHCI_USB_RESUME: |
171 | /* HCFS changes sometime after INTR_RD */ | 176 | /* HCFS changes sometime after INTR_RD */ |
172 | ohci_info(ohci, "%swakeup\n", | 177 | ohci_dbg(ohci, "%swakeup root hub\n", |
173 | autostopped ? "auto-" : ""); | 178 | autostopped ? "auto-" : ""); |
174 | break; | 179 | break; |
175 | case OHCI_USB_OPER: | 180 | case OHCI_USB_OPER: |
@@ -181,7 +186,6 @@ __acquires(ohci->lock) | |||
181 | ohci_dbg (ohci, "lost power\n"); | 186 | ohci_dbg (ohci, "lost power\n"); |
182 | status = -EBUSY; | 187 | status = -EBUSY; |
183 | } | 188 | } |
184 | #ifdef CONFIG_PM | ||
185 | if (status == -EBUSY) { | 189 | if (status == -EBUSY) { |
186 | if (!autostopped) { | 190 | if (!autostopped) { |
187 | spin_unlock_irq (&ohci->lock); | 191 | spin_unlock_irq (&ohci->lock); |
@@ -191,25 +195,12 @@ __acquires(ohci->lock) | |||
191 | } | 195 | } |
192 | return status; | 196 | return status; |
193 | } | 197 | } |
194 | #endif | ||
195 | if (status != -EINPROGRESS) | 198 | if (status != -EINPROGRESS) |
196 | return status; | 199 | return status; |
197 | if (autostopped) | 200 | if (autostopped) |
198 | goto skip_resume; | 201 | goto skip_resume; |
199 | spin_unlock_irq (&ohci->lock); | 202 | spin_unlock_irq (&ohci->lock); |
200 | 203 | ||
201 | temp = ohci->num_ports; | ||
202 | while (temp--) { | ||
203 | u32 stat = ohci_readl (ohci, | ||
204 | &ohci->regs->roothub.portstatus [temp]); | ||
205 | |||
206 | /* force global, not selective, resume */ | ||
207 | if (!(stat & RH_PS_PSS)) | ||
208 | continue; | ||
209 | ohci_writel (ohci, RH_PS_POCI, | ||
210 | &ohci->regs->roothub.portstatus [temp]); | ||
211 | } | ||
212 | |||
213 | /* Some controllers (lucent erratum) need extra-long delays */ | 204 | /* Some controllers (lucent erratum) need extra-long delays */ |
214 | msleep (20 /* usb 11.5.1.10 */ + 12 /* 32 msec counter */ + 1); | 205 | msleep (20 /* usb 11.5.1.10 */ + 12 /* 32 msec counter */ + 1); |
215 | 206 | ||
@@ -217,6 +208,7 @@ __acquires(ohci->lock) | |||
217 | temp &= OHCI_CTRL_HCFS; | 208 | temp &= OHCI_CTRL_HCFS; |
218 | if (temp != OHCI_USB_RESUME) { | 209 | if (temp != OHCI_USB_RESUME) { |
219 | ohci_err (ohci, "controller won't resume\n"); | 210 | ohci_err (ohci, "controller won't resume\n"); |
211 | spin_lock_irq(&ohci->lock); | ||
220 | return -EBUSY; | 212 | return -EBUSY; |
221 | } | 213 | } |
222 | 214 | ||
@@ -296,8 +288,6 @@ skip_resume: | |||
296 | return 0; | 288 | return 0; |
297 | } | 289 | } |
298 | 290 | ||
299 | #ifdef CONFIG_PM | ||
300 | |||
301 | static int ohci_bus_suspend (struct usb_hcd *hcd) | 291 | static int ohci_bus_suspend (struct usb_hcd *hcd) |
302 | { | 292 | { |
303 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); | 293 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); |
@@ -335,6 +325,83 @@ static int ohci_bus_resume (struct usb_hcd *hcd) | |||
335 | return rc; | 325 | return rc; |
336 | } | 326 | } |
337 | 327 | ||
328 | /* Carry out polling-, autostop-, and autoresume-related state changes */ | ||
329 | static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed, | ||
330 | int any_connected) | ||
331 | { | ||
332 | int poll_rh = 1; | ||
333 | |||
334 | switch (ohci->hc_control & OHCI_CTRL_HCFS) { | ||
335 | |||
336 | case OHCI_USB_OPER: | ||
337 | /* keep on polling until we know a device is connected | ||
338 | * and RHSC is enabled */ | ||
339 | if (!ohci->autostop) { | ||
340 | if (any_connected || | ||
341 | !device_may_wakeup(&ohci_to_hcd(ohci) | ||
342 | ->self.root_hub->dev)) { | ||
343 | if (ohci_readl(ohci, &ohci->regs->intrenable) & | ||
344 | OHCI_INTR_RHSC) | ||
345 | poll_rh = 0; | ||
346 | } else { | ||
347 | ohci->autostop = 1; | ||
348 | ohci->next_statechange = jiffies + HZ; | ||
349 | } | ||
350 | |||
351 | /* if no devices have been attached for one second, autostop */ | ||
352 | } else { | ||
353 | if (changed || any_connected) { | ||
354 | ohci->autostop = 0; | ||
355 | ohci->next_statechange = jiffies + | ||
356 | STATECHANGE_DELAY; | ||
357 | } else if (time_after_eq(jiffies, | ||
358 | ohci->next_statechange) | ||
359 | && !ohci->ed_rm_list | ||
360 | && !(ohci->hc_control & | ||
361 | OHCI_SCHED_ENABLES)) { | ||
362 | ohci_rh_suspend(ohci, 1); | ||
363 | } | ||
364 | } | ||
365 | break; | ||
366 | |||
367 | /* if there is a port change, autostart or ask to be resumed */ | ||
368 | case OHCI_USB_SUSPEND: | ||
369 | case OHCI_USB_RESUME: | ||
370 | if (changed) { | ||
371 | if (ohci->autostop) | ||
372 | ohci_rh_resume(ohci); | ||
373 | else | ||
374 | usb_hcd_resume_root_hub(ohci_to_hcd(ohci)); | ||
375 | } else { | ||
376 | /* everything is idle, no need for polling */ | ||
377 | poll_rh = 0; | ||
378 | } | ||
379 | break; | ||
380 | } | ||
381 | return poll_rh; | ||
382 | } | ||
383 | |||
384 | #else /* CONFIG_PM */ | ||
385 | |||
386 | static inline int ohci_rh_resume(struct ohci_hcd *ohci) | ||
387 | { | ||
388 | return 0; | ||
389 | } | ||
390 | |||
391 | /* Carry out polling-related state changes. | ||
392 | * autostop isn't used when CONFIG_PM is turned off. | ||
393 | */ | ||
394 | static int ohci_root_hub_state_changes(struct ohci_hcd *ohci, int changed, | ||
395 | int any_connected) | ||
396 | { | ||
397 | int poll_rh = 1; | ||
398 | |||
399 | /* keep on polling until RHSC is enabled */ | ||
400 | if (ohci_readl(ohci, &ohci->regs->intrenable) & OHCI_INTR_RHSC) | ||
401 | poll_rh = 0; | ||
402 | return poll_rh; | ||
403 | } | ||
404 | |||
338 | #endif /* CONFIG_PM */ | 405 | #endif /* CONFIG_PM */ |
339 | 406 | ||
340 | /*-------------------------------------------------------------------------*/ | 407 | /*-------------------------------------------------------------------------*/ |
@@ -346,7 +413,7 @@ ohci_hub_status_data (struct usb_hcd *hcd, char *buf) | |||
346 | { | 413 | { |
347 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); | 414 | struct ohci_hcd *ohci = hcd_to_ohci (hcd); |
348 | int i, changed = 0, length = 1; | 415 | int i, changed = 0, length = 1; |
349 | int any_connected = 0, rhsc_enabled = 1; | 416 | int any_connected = 0; |
350 | unsigned long flags; | 417 | unsigned long flags; |
351 | 418 | ||
352 | spin_lock_irqsave (&ohci->lock, flags); | 419 | spin_lock_irqsave (&ohci->lock, flags); |
@@ -387,67 +454,8 @@ ohci_hub_status_data (struct usb_hcd *hcd, char *buf) | |||
387 | } | 454 | } |
388 | } | 455 | } |
389 | 456 | ||
390 | /* NOTE: vendors didn't always make the same implementation | 457 | hcd->poll_rh = ohci_root_hub_state_changes(ohci, changed, |
391 | * choices for RHSC. Sometimes it triggers on an edge (like | 458 | any_connected); |
392 | * setting and maybe clearing a port status change bit); and | ||
393 | * it's level-triggered on other silicon, active until khubd | ||
394 | * clears all active port status change bits. If it's still | ||
395 | * set (level-triggered) we must disable it and rely on | ||
396 | * polling until khubd re-enables it. | ||
397 | */ | ||
398 | if (ohci_readl (ohci, &ohci->regs->intrstatus) & OHCI_INTR_RHSC) { | ||
399 | ohci_writel (ohci, OHCI_INTR_RHSC, &ohci->regs->intrdisable); | ||
400 | (void) ohci_readl (ohci, &ohci->regs->intrdisable); | ||
401 | rhsc_enabled = 0; | ||
402 | } | ||
403 | hcd->poll_rh = 1; | ||
404 | |||
405 | /* carry out appropriate state changes */ | ||
406 | switch (ohci->hc_control & OHCI_CTRL_HCFS) { | ||
407 | |||
408 | case OHCI_USB_OPER: | ||
409 | /* keep on polling until we know a device is connected | ||
410 | * and RHSC is enabled */ | ||
411 | if (!ohci->autostop) { | ||
412 | if (any_connected) { | ||
413 | if (rhsc_enabled) | ||
414 | hcd->poll_rh = 0; | ||
415 | } else { | ||
416 | ohci->autostop = 1; | ||
417 | ohci->next_statechange = jiffies + HZ; | ||
418 | } | ||
419 | |||
420 | /* if no devices have been attached for one second, autostop */ | ||
421 | } else { | ||
422 | if (changed || any_connected) { | ||
423 | ohci->autostop = 0; | ||
424 | ohci->next_statechange = jiffies + | ||
425 | STATECHANGE_DELAY; | ||
426 | } else if (device_may_wakeup(&hcd->self.root_hub->dev) | ||
427 | && time_after_eq(jiffies, | ||
428 | ohci->next_statechange) | ||
429 | && !ohci->ed_rm_list | ||
430 | && !(ohci->hc_control & | ||
431 | OHCI_SCHED_ENABLES)) { | ||
432 | ohci_rh_suspend (ohci, 1); | ||
433 | } | ||
434 | } | ||
435 | break; | ||
436 | |||
437 | /* if there is a port change, autostart or ask to be resumed */ | ||
438 | case OHCI_USB_SUSPEND: | ||
439 | case OHCI_USB_RESUME: | ||
440 | if (changed) { | ||
441 | if (ohci->autostop) | ||
442 | ohci_rh_resume (ohci); | ||
443 | else | ||
444 | usb_hcd_resume_root_hub (hcd); | ||
445 | } else { | ||
446 | /* everything is idle, no need for polling */ | ||
447 | hcd->poll_rh = 0; | ||
448 | } | ||
449 | break; | ||
450 | } | ||
451 | 459 | ||
452 | done: | 460 | done: |
453 | spin_unlock_irqrestore (&ohci->lock, flags); | 461 | spin_unlock_irqrestore (&ohci->lock, flags); |
diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c index a00d1595656c..ef54e310bfc4 100644 --- a/drivers/usb/host/u132-hcd.c +++ b/drivers/usb/host/u132-hcd.c | |||
@@ -71,7 +71,7 @@ static int distrust_firmware = 1; | |||
71 | module_param(distrust_firmware, bool, 0); | 71 | module_param(distrust_firmware, bool, 0); |
72 | MODULE_PARM_DESC(distrust_firmware, "true to distrust firmware power/overcurren" | 72 | MODULE_PARM_DESC(distrust_firmware, "true to distrust firmware power/overcurren" |
73 | "t setup"); | 73 | "t setup"); |
74 | DECLARE_WAIT_QUEUE_HEAD(u132_hcd_wait); | 74 | static DECLARE_WAIT_QUEUE_HEAD(u132_hcd_wait); |
75 | /* | 75 | /* |
76 | * u132_module_lock exists to protect access to global variables | 76 | * u132_module_lock exists to protect access to global variables |
77 | * | 77 | * |
@@ -205,11 +205,7 @@ struct u132 { | |||
205 | struct u132_port port[MAX_U132_PORTS]; | 205 | struct u132_port port[MAX_U132_PORTS]; |
206 | struct u132_endp *endp[MAX_U132_ENDPS]; | 206 | struct u132_endp *endp[MAX_U132_ENDPS]; |
207 | }; | 207 | }; |
208 | int usb_ftdi_elan_read_reg(struct platform_device *pdev, u32 *data); | 208 | |
209 | int usb_ftdi_elan_read_pcimem(struct platform_device *pdev, u8 addressofs, | ||
210 | u8 width, u32 *data); | ||
211 | int usb_ftdi_elan_write_pcimem(struct platform_device *pdev, u8 addressofs, | ||
212 | u8 width, u32 data); | ||
213 | /* | 209 | /* |
214 | * these cannot be inlines because we need the structure offset!! | 210 | * these cannot be inlines because we need the structure offset!! |
215 | * Does anyone have a better way????? | 211 | * Does anyone have a better way????? |