diff options
Diffstat (limited to 'drivers/usb/host/ehci-hcd.c')
-rw-r--r-- | drivers/usb/host/ehci-hcd.c | 512 |
1 files changed, 226 insertions, 286 deletions
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 1d9401e0990..b05c6865b61 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c | |||
@@ -30,8 +30,7 @@ | |||
30 | #include <linux/vmalloc.h> | 30 | #include <linux/vmalloc.h> |
31 | #include <linux/errno.h> | 31 | #include <linux/errno.h> |
32 | #include <linux/init.h> | 32 | #include <linux/init.h> |
33 | #include <linux/timer.h> | 33 | #include <linux/hrtimer.h> |
34 | #include <linux/ktime.h> | ||
35 | #include <linux/list.h> | 34 | #include <linux/list.h> |
36 | #include <linux/interrupt.h> | 35 | #include <linux/interrupt.h> |
37 | #include <linux/usb.h> | 36 | #include <linux/usb.h> |
@@ -94,12 +93,6 @@ static const char hcd_name [] = "ehci_hcd"; | |||
94 | */ | 93 | */ |
95 | #define EHCI_TUNE_FLS 1 /* (medium) 512-frame schedule */ | 94 | #define EHCI_TUNE_FLS 1 /* (medium) 512-frame schedule */ |
96 | 95 | ||
97 | #define EHCI_IAA_MSECS 10 /* arbitrary */ | ||
98 | #define EHCI_IO_JIFFIES (HZ/10) /* io watchdog > irq_thresh */ | ||
99 | #define EHCI_ASYNC_JIFFIES (HZ/20) /* async idle timeout */ | ||
100 | #define EHCI_SHRINK_JIFFIES (DIV_ROUND_UP(HZ, 200) + 1) | ||
101 | /* 5-ms async qh unlink delay */ | ||
102 | |||
103 | /* Initial IRQ latency: faster than hw default */ | 96 | /* Initial IRQ latency: faster than hw default */ |
104 | static int log2_irq_thresh = 0; // 0 to 6 | 97 | static int log2_irq_thresh = 0; // 0 to 6 |
105 | module_param (log2_irq_thresh, int, S_IRUGO); | 98 | module_param (log2_irq_thresh, int, S_IRUGO); |
@@ -130,41 +123,6 @@ MODULE_PARM_DESC(hird, "host initiated resume duration, +1 for each 75us"); | |||
130 | 123 | ||
131 | /*-------------------------------------------------------------------------*/ | 124 | /*-------------------------------------------------------------------------*/ |
132 | 125 | ||
133 | static void | ||
134 | timer_action(struct ehci_hcd *ehci, enum ehci_timer_action action) | ||
135 | { | ||
136 | /* Don't override timeouts which shrink or (later) disable | ||
137 | * the async ring; just the I/O watchdog. Note that if a | ||
138 | * SHRINK were pending, OFF would never be requested. | ||
139 | */ | ||
140 | if (timer_pending(&ehci->watchdog) | ||
141 | && ((BIT(TIMER_ASYNC_SHRINK) | BIT(TIMER_ASYNC_OFF)) | ||
142 | & ehci->actions)) | ||
143 | return; | ||
144 | |||
145 | if (!test_and_set_bit(action, &ehci->actions)) { | ||
146 | unsigned long t; | ||
147 | |||
148 | switch (action) { | ||
149 | case TIMER_IO_WATCHDOG: | ||
150 | if (!ehci->need_io_watchdog) | ||
151 | return; | ||
152 | t = EHCI_IO_JIFFIES; | ||
153 | break; | ||
154 | case TIMER_ASYNC_OFF: | ||
155 | t = EHCI_ASYNC_JIFFIES; | ||
156 | break; | ||
157 | /* case TIMER_ASYNC_SHRINK: */ | ||
158 | default: | ||
159 | t = EHCI_SHRINK_JIFFIES; | ||
160 | break; | ||
161 | } | ||
162 | mod_timer(&ehci->watchdog, t + jiffies); | ||
163 | } | ||
164 | } | ||
165 | |||
166 | /*-------------------------------------------------------------------------*/ | ||
167 | |||
168 | /* | 126 | /* |
169 | * handshake - spin reading hc until handshake completes or fails | 127 | * handshake - spin reading hc until handshake completes or fails |
170 | * @ptr: address of hc register to be read | 128 | * @ptr: address of hc register to be read |
@@ -203,29 +161,30 @@ static int handshake (struct ehci_hcd *ehci, void __iomem *ptr, | |||
203 | /* check TDI/ARC silicon is in host mode */ | 161 | /* check TDI/ARC silicon is in host mode */ |
204 | static int tdi_in_host_mode (struct ehci_hcd *ehci) | 162 | static int tdi_in_host_mode (struct ehci_hcd *ehci) |
205 | { | 163 | { |
206 | u32 __iomem *reg_ptr; | ||
207 | u32 tmp; | 164 | u32 tmp; |
208 | 165 | ||
209 | reg_ptr = (u32 __iomem *)(((u8 __iomem *)ehci->regs) + USBMODE); | 166 | tmp = ehci_readl(ehci, &ehci->regs->usbmode); |
210 | tmp = ehci_readl(ehci, reg_ptr); | ||
211 | return (tmp & 3) == USBMODE_CM_HC; | 167 | return (tmp & 3) == USBMODE_CM_HC; |
212 | } | 168 | } |
213 | 169 | ||
214 | /* force HC to halt state from unknown (EHCI spec section 2.3) */ | 170 | /* |
171 | * Force HC to halt state from unknown (EHCI spec section 2.3). | ||
172 | * Must be called with interrupts enabled and the lock not held. | ||
173 | */ | ||
215 | static int ehci_halt (struct ehci_hcd *ehci) | 174 | static int ehci_halt (struct ehci_hcd *ehci) |
216 | { | 175 | { |
217 | u32 temp = ehci_readl(ehci, &ehci->regs->status); | 176 | u32 temp; |
177 | |||
178 | spin_lock_irq(&ehci->lock); | ||
218 | 179 | ||
219 | /* disable any irqs left enabled by previous code */ | 180 | /* disable any irqs left enabled by previous code */ |
220 | ehci_writel(ehci, 0, &ehci->regs->intr_enable); | 181 | ehci_writel(ehci, 0, &ehci->regs->intr_enable); |
221 | 182 | ||
222 | if (ehci_is_TDI(ehci) && tdi_in_host_mode(ehci) == 0) { | 183 | if (ehci_is_TDI(ehci) && !tdi_in_host_mode(ehci)) { |
184 | spin_unlock_irq(&ehci->lock); | ||
223 | return 0; | 185 | return 0; |
224 | } | 186 | } |
225 | 187 | ||
226 | if ((temp & STS_HALT) != 0) | ||
227 | return 0; | ||
228 | |||
229 | /* | 188 | /* |
230 | * This routine gets called during probe before ehci->command | 189 | * This routine gets called during probe before ehci->command |
231 | * has been initialized, so we can't rely on its value. | 190 | * has been initialized, so we can't rely on its value. |
@@ -234,80 +193,20 @@ static int ehci_halt (struct ehci_hcd *ehci) | |||
234 | temp = ehci_readl(ehci, &ehci->regs->command); | 193 | temp = ehci_readl(ehci, &ehci->regs->command); |
235 | temp &= ~(CMD_RUN | CMD_IAAD); | 194 | temp &= ~(CMD_RUN | CMD_IAAD); |
236 | ehci_writel(ehci, temp, &ehci->regs->command); | 195 | ehci_writel(ehci, temp, &ehci->regs->command); |
237 | return handshake (ehci, &ehci->regs->status, | ||
238 | STS_HALT, STS_HALT, 16 * 125); | ||
239 | } | ||
240 | |||
241 | #if defined(CONFIG_USB_SUSPEND) && defined(CONFIG_PPC_PS3) | ||
242 | |||
243 | /* | ||
244 | * The EHCI controller of the Cell Super Companion Chip used in the | ||
245 | * PS3 will stop the root hub after all root hub ports are suspended. | ||
246 | * When in this condition handshake will return -ETIMEDOUT. The | ||
247 | * STS_HLT bit will not be set, so inspection of the frame index is | ||
248 | * used here to test for the condition. If the condition is found | ||
249 | * return success to allow the USB suspend to complete. | ||
250 | */ | ||
251 | |||
252 | static int handshake_for_broken_root_hub(struct ehci_hcd *ehci, | ||
253 | void __iomem *ptr, u32 mask, u32 done, | ||
254 | int usec) | ||
255 | { | ||
256 | unsigned int old_index; | ||
257 | int error; | ||
258 | |||
259 | if (!firmware_has_feature(FW_FEATURE_PS3_LV1)) | ||
260 | return -ETIMEDOUT; | ||
261 | |||
262 | old_index = ehci_read_frame_index(ehci); | ||
263 | |||
264 | error = handshake(ehci, ptr, mask, done, usec); | ||
265 | |||
266 | if (error == -ETIMEDOUT && ehci_read_frame_index(ehci) == old_index) | ||
267 | return 0; | ||
268 | |||
269 | return error; | ||
270 | } | ||
271 | |||
272 | #else | ||
273 | |||
274 | static int handshake_for_broken_root_hub(struct ehci_hcd *ehci, | ||
275 | void __iomem *ptr, u32 mask, u32 done, | ||
276 | int usec) | ||
277 | { | ||
278 | return -ETIMEDOUT; | ||
279 | } | ||
280 | |||
281 | #endif | ||
282 | 196 | ||
283 | static int handshake_on_error_set_halt(struct ehci_hcd *ehci, void __iomem *ptr, | 197 | spin_unlock_irq(&ehci->lock); |
284 | u32 mask, u32 done, int usec) | 198 | synchronize_irq(ehci_to_hcd(ehci)->irq); |
285 | { | ||
286 | int error; | ||
287 | |||
288 | error = handshake(ehci, ptr, mask, done, usec); | ||
289 | if (error == -ETIMEDOUT) | ||
290 | error = handshake_for_broken_root_hub(ehci, ptr, mask, done, | ||
291 | usec); | ||
292 | |||
293 | if (error) { | ||
294 | ehci_halt(ehci); | ||
295 | ehci->rh_state = EHCI_RH_HALTED; | ||
296 | ehci_err(ehci, "force halt; handshake %p %08x %08x -> %d\n", | ||
297 | ptr, mask, done, error); | ||
298 | } | ||
299 | 199 | ||
300 | return error; | 200 | return handshake(ehci, &ehci->regs->status, |
201 | STS_HALT, STS_HALT, 16 * 125); | ||
301 | } | 202 | } |
302 | 203 | ||
303 | /* put TDI/ARC silicon into EHCI mode */ | 204 | /* put TDI/ARC silicon into EHCI mode */ |
304 | static void tdi_reset (struct ehci_hcd *ehci) | 205 | static void tdi_reset (struct ehci_hcd *ehci) |
305 | { | 206 | { |
306 | u32 __iomem *reg_ptr; | ||
307 | u32 tmp; | 207 | u32 tmp; |
308 | 208 | ||
309 | reg_ptr = (u32 __iomem *)(((u8 __iomem *)ehci->regs) + USBMODE); | 209 | tmp = ehci_readl(ehci, &ehci->regs->usbmode); |
310 | tmp = ehci_readl(ehci, reg_ptr); | ||
311 | tmp |= USBMODE_CM_HC; | 210 | tmp |= USBMODE_CM_HC; |
312 | /* The default byte access to MMR space is LE after | 211 | /* The default byte access to MMR space is LE after |
313 | * controller reset. Set the required endian mode | 212 | * controller reset. Set the required endian mode |
@@ -315,10 +214,13 @@ static void tdi_reset (struct ehci_hcd *ehci) | |||
315 | */ | 214 | */ |
316 | if (ehci_big_endian_mmio(ehci)) | 215 | if (ehci_big_endian_mmio(ehci)) |
317 | tmp |= USBMODE_BE; | 216 | tmp |= USBMODE_BE; |
318 | ehci_writel(ehci, tmp, reg_ptr); | 217 | ehci_writel(ehci, tmp, &ehci->regs->usbmode); |
319 | } | 218 | } |
320 | 219 | ||
321 | /* reset a non-running (STS_HALT == 1) controller */ | 220 | /* |
221 | * Reset a non-running (STS_HALT == 1) controller. | ||
222 | * Must be called with interrupts enabled and the lock not held. | ||
223 | */ | ||
322 | static int ehci_reset (struct ehci_hcd *ehci) | 224 | static int ehci_reset (struct ehci_hcd *ehci) |
323 | { | 225 | { |
324 | int retval; | 226 | int retval; |
@@ -339,9 +241,8 @@ static int ehci_reset (struct ehci_hcd *ehci) | |||
339 | 241 | ||
340 | if (ehci->has_hostpc) { | 242 | if (ehci->has_hostpc) { |
341 | ehci_writel(ehci, USBMODE_EX_HC | USBMODE_EX_VBPS, | 243 | ehci_writel(ehci, USBMODE_EX_HC | USBMODE_EX_VBPS, |
342 | (u32 __iomem *)(((u8 *)ehci->regs) + USBMODE_EX)); | 244 | &ehci->regs->usbmode_ex); |
343 | ehci_writel(ehci, TXFIFO_DEFAULT, | 245 | ehci_writel(ehci, TXFIFO_DEFAULT, &ehci->regs->txfill_tuning); |
344 | (u32 __iomem *)(((u8 *)ehci->regs) + TXFILLTUNING)); | ||
345 | } | 246 | } |
346 | if (retval) | 247 | if (retval) |
347 | return retval; | 248 | return retval; |
@@ -357,36 +258,40 @@ static int ehci_reset (struct ehci_hcd *ehci) | |||
357 | return retval; | 258 | return retval; |
358 | } | 259 | } |
359 | 260 | ||
360 | /* idle the controller (from running) */ | 261 | /* |
262 | * Idle the controller (turn off the schedules). | ||
263 | * Must be called with interrupts enabled and the lock not held. | ||
264 | */ | ||
361 | static void ehci_quiesce (struct ehci_hcd *ehci) | 265 | static void ehci_quiesce (struct ehci_hcd *ehci) |
362 | { | 266 | { |
363 | u32 temp; | 267 | u32 temp; |
364 | 268 | ||
365 | #ifdef DEBUG | ||
366 | if (ehci->rh_state != EHCI_RH_RUNNING) | 269 | if (ehci->rh_state != EHCI_RH_RUNNING) |
367 | BUG (); | 270 | return; |
368 | #endif | ||
369 | 271 | ||
370 | /* wait for any schedule enables/disables to take effect */ | 272 | /* wait for any schedule enables/disables to take effect */ |
371 | temp = (ehci->command << 10) & (STS_ASS | STS_PSS); | 273 | temp = (ehci->command << 10) & (STS_ASS | STS_PSS); |
372 | if (handshake_on_error_set_halt(ehci, &ehci->regs->status, | 274 | handshake(ehci, &ehci->regs->status, STS_ASS | STS_PSS, temp, 16 * 125); |
373 | STS_ASS | STS_PSS, temp, 16 * 125)) | ||
374 | return; | ||
375 | 275 | ||
376 | /* then disable anything that's still active */ | 276 | /* then disable anything that's still active */ |
277 | spin_lock_irq(&ehci->lock); | ||
377 | ehci->command &= ~(CMD_ASE | CMD_PSE); | 278 | ehci->command &= ~(CMD_ASE | CMD_PSE); |
378 | ehci_writel(ehci, ehci->command, &ehci->regs->command); | 279 | ehci_writel(ehci, ehci->command, &ehci->regs->command); |
280 | spin_unlock_irq(&ehci->lock); | ||
379 | 281 | ||
380 | /* hardware can take 16 microframes to turn off ... */ | 282 | /* hardware can take 16 microframes to turn off ... */ |
381 | handshake_on_error_set_halt(ehci, &ehci->regs->status, | 283 | handshake(ehci, &ehci->regs->status, STS_ASS | STS_PSS, 0, 16 * 125); |
382 | STS_ASS | STS_PSS, 0, 16 * 125); | ||
383 | } | 284 | } |
384 | 285 | ||
385 | /*-------------------------------------------------------------------------*/ | 286 | /*-------------------------------------------------------------------------*/ |
386 | 287 | ||
387 | static void end_unlink_async(struct ehci_hcd *ehci); | 288 | static void end_unlink_async(struct ehci_hcd *ehci); |
289 | static void unlink_empty_async(struct ehci_hcd *ehci); | ||
388 | static void ehci_work(struct ehci_hcd *ehci); | 290 | static void ehci_work(struct ehci_hcd *ehci); |
291 | static void start_unlink_intr(struct ehci_hcd *ehci, struct ehci_qh *qh); | ||
292 | static void end_unlink_intr(struct ehci_hcd *ehci, struct ehci_qh *qh); | ||
389 | 293 | ||
294 | #include "ehci-timer.c" | ||
390 | #include "ehci-hub.c" | 295 | #include "ehci-hub.c" |
391 | #include "ehci-lpm.c" | 296 | #include "ehci-lpm.c" |
392 | #include "ehci-mem.c" | 297 | #include "ehci-mem.c" |
@@ -396,68 +301,6 @@ static void ehci_work(struct ehci_hcd *ehci); | |||
396 | 301 | ||
397 | /*-------------------------------------------------------------------------*/ | 302 | /*-------------------------------------------------------------------------*/ |
398 | 303 | ||
399 | static void ehci_iaa_watchdog(unsigned long param) | ||
400 | { | ||
401 | struct ehci_hcd *ehci = (struct ehci_hcd *) param; | ||
402 | unsigned long flags; | ||
403 | |||
404 | spin_lock_irqsave (&ehci->lock, flags); | ||
405 | |||
406 | /* Lost IAA irqs wedge things badly; seen first with a vt8235. | ||
407 | * So we need this watchdog, but must protect it against both | ||
408 | * (a) SMP races against real IAA firing and retriggering, and | ||
409 | * (b) clean HC shutdown, when IAA watchdog was pending. | ||
410 | */ | ||
411 | if (ehci->reclaim | ||
412 | && !timer_pending(&ehci->iaa_watchdog) | ||
413 | && ehci->rh_state == EHCI_RH_RUNNING) { | ||
414 | u32 cmd, status; | ||
415 | |||
416 | /* If we get here, IAA is *REALLY* late. It's barely | ||
417 | * conceivable that the system is so busy that CMD_IAAD | ||
418 | * is still legitimately set, so let's be sure it's | ||
419 | * clear before we read STS_IAA. (The HC should clear | ||
420 | * CMD_IAAD when it sets STS_IAA.) | ||
421 | */ | ||
422 | cmd = ehci_readl(ehci, &ehci->regs->command); | ||
423 | |||
424 | /* If IAA is set here it either legitimately triggered | ||
425 | * before we cleared IAAD above (but _way_ late, so we'll | ||
426 | * still count it as lost) ... or a silicon erratum: | ||
427 | * - VIA seems to set IAA without triggering the IRQ; | ||
428 | * - IAAD potentially cleared without setting IAA. | ||
429 | */ | ||
430 | status = ehci_readl(ehci, &ehci->regs->status); | ||
431 | if ((status & STS_IAA) || !(cmd & CMD_IAAD)) { | ||
432 | COUNT (ehci->stats.lost_iaa); | ||
433 | ehci_writel(ehci, STS_IAA, &ehci->regs->status); | ||
434 | } | ||
435 | |||
436 | ehci_vdbg(ehci, "IAA watchdog: status %x cmd %x\n", | ||
437 | status, cmd); | ||
438 | end_unlink_async(ehci); | ||
439 | } | ||
440 | |||
441 | spin_unlock_irqrestore(&ehci->lock, flags); | ||
442 | } | ||
443 | |||
444 | static void ehci_watchdog(unsigned long param) | ||
445 | { | ||
446 | struct ehci_hcd *ehci = (struct ehci_hcd *) param; | ||
447 | unsigned long flags; | ||
448 | |||
449 | spin_lock_irqsave(&ehci->lock, flags); | ||
450 | |||
451 | /* stop async processing after it's idled a bit */ | ||
452 | if (test_bit (TIMER_ASYNC_OFF, &ehci->actions)) | ||
453 | start_unlink_async (ehci, ehci->async); | ||
454 | |||
455 | /* ehci could run by timer, without IRQs ... */ | ||
456 | ehci_work (ehci); | ||
457 | |||
458 | spin_unlock_irqrestore (&ehci->lock, flags); | ||
459 | } | ||
460 | |||
461 | /* On some systems, leaving remote wakeup enabled prevents system shutdown. | 304 | /* On some systems, leaving remote wakeup enabled prevents system shutdown. |
462 | * The firmware seems to think that powering off is a wakeup event! | 305 | * The firmware seems to think that powering off is a wakeup event! |
463 | * This routine turns off remote wakeup and everything else, on all ports. | 306 | * This routine turns off remote wakeup and everything else, on all ports. |
@@ -473,11 +316,14 @@ static void ehci_turn_off_all_ports(struct ehci_hcd *ehci) | |||
473 | 316 | ||
474 | /* | 317 | /* |
475 | * Halt HC, turn off all ports, and let the BIOS use the companion controllers. | 318 | * Halt HC, turn off all ports, and let the BIOS use the companion controllers. |
476 | * Should be called with ehci->lock held. | 319 | * Must be called with interrupts enabled and the lock not held. |
477 | */ | 320 | */ |
478 | static void ehci_silence_controller(struct ehci_hcd *ehci) | 321 | static void ehci_silence_controller(struct ehci_hcd *ehci) |
479 | { | 322 | { |
480 | ehci_halt(ehci); | 323 | ehci_halt(ehci); |
324 | |||
325 | spin_lock_irq(&ehci->lock); | ||
326 | ehci->rh_state = EHCI_RH_HALTED; | ||
481 | ehci_turn_off_all_ports(ehci); | 327 | ehci_turn_off_all_ports(ehci); |
482 | 328 | ||
483 | /* make BIOS/etc use companion controller during reboot */ | 329 | /* make BIOS/etc use companion controller during reboot */ |
@@ -485,6 +331,7 @@ static void ehci_silence_controller(struct ehci_hcd *ehci) | |||
485 | 331 | ||
486 | /* unblock posted writes */ | 332 | /* unblock posted writes */ |
487 | ehci_readl(ehci, &ehci->regs->configured_flag); | 333 | ehci_readl(ehci, &ehci->regs->configured_flag); |
334 | spin_unlock_irq(&ehci->lock); | ||
488 | } | 335 | } |
489 | 336 | ||
490 | /* ehci_shutdown kick in for silicon on any bus (not just pci, etc). | 337 | /* ehci_shutdown kick in for silicon on any bus (not just pci, etc). |
@@ -495,12 +342,15 @@ static void ehci_shutdown(struct usb_hcd *hcd) | |||
495 | { | 342 | { |
496 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | 343 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
497 | 344 | ||
498 | del_timer_sync(&ehci->watchdog); | ||
499 | del_timer_sync(&ehci->iaa_watchdog); | ||
500 | |||
501 | spin_lock_irq(&ehci->lock); | 345 | spin_lock_irq(&ehci->lock); |
502 | ehci_silence_controller(ehci); | 346 | ehci->shutdown = true; |
347 | ehci->rh_state = EHCI_RH_STOPPING; | ||
348 | ehci->enabled_hrtimer_events = 0; | ||
503 | spin_unlock_irq(&ehci->lock); | 349 | spin_unlock_irq(&ehci->lock); |
350 | |||
351 | ehci_silence_controller(ehci); | ||
352 | |||
353 | hrtimer_cancel(&ehci->hrtimer); | ||
504 | } | 354 | } |
505 | 355 | ||
506 | static void ehci_port_power (struct ehci_hcd *ehci, int is_on) | 356 | static void ehci_port_power (struct ehci_hcd *ehci, int is_on) |
@@ -529,28 +379,33 @@ static void ehci_port_power (struct ehci_hcd *ehci, int is_on) | |||
529 | */ | 379 | */ |
530 | static void ehci_work (struct ehci_hcd *ehci) | 380 | static void ehci_work (struct ehci_hcd *ehci) |
531 | { | 381 | { |
532 | timer_action_done (ehci, TIMER_IO_WATCHDOG); | ||
533 | |||
534 | /* another CPU may drop ehci->lock during a schedule scan while | 382 | /* another CPU may drop ehci->lock during a schedule scan while |
535 | * it reports urb completions. this flag guards against bogus | 383 | * it reports urb completions. this flag guards against bogus |
536 | * attempts at re-entrant schedule scanning. | 384 | * attempts at re-entrant schedule scanning. |
537 | */ | 385 | */ |
538 | if (ehci->scanning) | 386 | if (ehci->scanning) { |
387 | ehci->need_rescan = true; | ||
539 | return; | 388 | return; |
540 | ehci->scanning = 1; | 389 | } |
541 | scan_async (ehci); | 390 | ehci->scanning = true; |
542 | if (ehci->next_uframe != -1) | 391 | |
543 | scan_periodic (ehci); | 392 | rescan: |
544 | ehci->scanning = 0; | 393 | ehci->need_rescan = false; |
394 | if (ehci->async_count) | ||
395 | scan_async(ehci); | ||
396 | if (ehci->intr_count > 0) | ||
397 | scan_intr(ehci); | ||
398 | if (ehci->isoc_count > 0) | ||
399 | scan_isoc(ehci); | ||
400 | if (ehci->need_rescan) | ||
401 | goto rescan; | ||
402 | ehci->scanning = false; | ||
545 | 403 | ||
546 | /* the IO watchdog guards against hardware or driver bugs that | 404 | /* the IO watchdog guards against hardware or driver bugs that |
547 | * misplace IRQs, and should let us run completely without IRQs. | 405 | * misplace IRQs, and should let us run completely without IRQs. |
548 | * such lossage has been observed on both VT6202 and VT8235. | 406 | * such lossage has been observed on both VT6202 and VT8235. |
549 | */ | 407 | */ |
550 | if (ehci->rh_state == EHCI_RH_RUNNING && | 408 | turn_on_io_watchdog(ehci); |
551 | (ehci->async->qh_next.ptr != NULL || | ||
552 | ehci->periodic_sched != 0)) | ||
553 | timer_action (ehci, TIMER_IO_WATCHDOG); | ||
554 | } | 409 | } |
555 | 410 | ||
556 | /* | 411 | /* |
@@ -563,24 +418,22 @@ static void ehci_stop (struct usb_hcd *hcd) | |||
563 | ehci_dbg (ehci, "stop\n"); | 418 | ehci_dbg (ehci, "stop\n"); |
564 | 419 | ||
565 | /* no more interrupts ... */ | 420 | /* no more interrupts ... */ |
566 | del_timer_sync (&ehci->watchdog); | ||
567 | del_timer_sync(&ehci->iaa_watchdog); | ||
568 | 421 | ||
569 | spin_lock_irq(&ehci->lock); | 422 | spin_lock_irq(&ehci->lock); |
570 | if (ehci->rh_state == EHCI_RH_RUNNING) | 423 | ehci->enabled_hrtimer_events = 0; |
571 | ehci_quiesce (ehci); | 424 | spin_unlock_irq(&ehci->lock); |
572 | 425 | ||
426 | ehci_quiesce(ehci); | ||
573 | ehci_silence_controller(ehci); | 427 | ehci_silence_controller(ehci); |
574 | ehci_reset (ehci); | 428 | ehci_reset (ehci); |
575 | spin_unlock_irq(&ehci->lock); | ||
576 | 429 | ||
430 | hrtimer_cancel(&ehci->hrtimer); | ||
577 | remove_sysfs_files(ehci); | 431 | remove_sysfs_files(ehci); |
578 | remove_debug_files (ehci); | 432 | remove_debug_files (ehci); |
579 | 433 | ||
580 | /* root hub is shut down separately (first, when possible) */ | 434 | /* root hub is shut down separately (first, when possible) */ |
581 | spin_lock_irq (&ehci->lock); | 435 | spin_lock_irq (&ehci->lock); |
582 | if (ehci->async) | 436 | end_free_itds(ehci); |
583 | ehci_work (ehci); | ||
584 | spin_unlock_irq (&ehci->lock); | 437 | spin_unlock_irq (&ehci->lock); |
585 | ehci_mem_cleanup (ehci); | 438 | ehci_mem_cleanup (ehci); |
586 | 439 | ||
@@ -588,8 +441,8 @@ static void ehci_stop (struct usb_hcd *hcd) | |||
588 | usb_amd_dev_put(); | 441 | usb_amd_dev_put(); |
589 | 442 | ||
590 | #ifdef EHCI_STATS | 443 | #ifdef EHCI_STATS |
591 | ehci_dbg (ehci, "irq normal %ld err %ld reclaim %ld (lost %ld)\n", | 444 | ehci_dbg(ehci, "irq normal %ld err %ld iaa %ld (lost %ld)\n", |
592 | ehci->stats.normal, ehci->stats.error, ehci->stats.reclaim, | 445 | ehci->stats.normal, ehci->stats.error, ehci->stats.iaa, |
593 | ehci->stats.lost_iaa); | 446 | ehci->stats.lost_iaa); |
594 | ehci_dbg (ehci, "complete %ld unlink %ld\n", | 447 | ehci_dbg (ehci, "complete %ld unlink %ld\n", |
595 | ehci->stats.complete, ehci->stats.unlink); | 448 | ehci->stats.complete, ehci->stats.unlink); |
@@ -614,13 +467,10 @@ static int ehci_init(struct usb_hcd *hcd) | |||
614 | * keep io watchdog by default, those good HCDs could turn off it later | 467 | * keep io watchdog by default, those good HCDs could turn off it later |
615 | */ | 468 | */ |
616 | ehci->need_io_watchdog = 1; | 469 | ehci->need_io_watchdog = 1; |
617 | init_timer(&ehci->watchdog); | ||
618 | ehci->watchdog.function = ehci_watchdog; | ||
619 | ehci->watchdog.data = (unsigned long) ehci; | ||
620 | 470 | ||
621 | init_timer(&ehci->iaa_watchdog); | 471 | hrtimer_init(&ehci->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS); |
622 | ehci->iaa_watchdog.function = ehci_iaa_watchdog; | 472 | ehci->hrtimer.function = ehci_hrtimer_func; |
623 | ehci->iaa_watchdog.data = (unsigned long) ehci; | 473 | ehci->next_hrtimer_event = EHCI_HRTIMER_NO_EVENT; |
624 | 474 | ||
625 | hcc_params = ehci_readl(ehci, &ehci->caps->hcc_params); | 475 | hcc_params = ehci_readl(ehci, &ehci->caps->hcc_params); |
626 | 476 | ||
@@ -635,6 +485,7 @@ static int ehci_init(struct usb_hcd *hcd) | |||
635 | * periodic_size can shrink by USBCMD update if hcc_params allows. | 485 | * periodic_size can shrink by USBCMD update if hcc_params allows. |
636 | */ | 486 | */ |
637 | ehci->periodic_size = DEFAULT_I_TDPS; | 487 | ehci->periodic_size = DEFAULT_I_TDPS; |
488 | INIT_LIST_HEAD(&ehci->intr_qh_list); | ||
638 | INIT_LIST_HEAD(&ehci->cached_itd_list); | 489 | INIT_LIST_HEAD(&ehci->cached_itd_list); |
639 | INIT_LIST_HEAD(&ehci->cached_sitd_list); | 490 | INIT_LIST_HEAD(&ehci->cached_sitd_list); |
640 | 491 | ||
@@ -656,10 +507,6 @@ static int ehci_init(struct usb_hcd *hcd) | |||
656 | else // N microframes cached | 507 | else // N microframes cached |
657 | ehci->i_thresh = 2 + HCC_ISOC_THRES(hcc_params); | 508 | ehci->i_thresh = 2 + HCC_ISOC_THRES(hcc_params); |
658 | 509 | ||
659 | ehci->reclaim = NULL; | ||
660 | ehci->next_uframe = -1; | ||
661 | ehci->clock_frame = -1; | ||
662 | |||
663 | /* | 510 | /* |
664 | * dedicate a qh for the async ring head, since we couldn't unlink | 511 | * dedicate a qh for the async ring head, since we couldn't unlink |
665 | * a 'real' qh without stopping the async schedule [4.8]. use it | 512 | * a 'real' qh without stopping the async schedule [4.8]. use it |
@@ -672,7 +519,7 @@ static int ehci_init(struct usb_hcd *hcd) | |||
672 | hw->hw_next = QH_NEXT(ehci, ehci->async->qh_dma); | 519 | hw->hw_next = QH_NEXT(ehci, ehci->async->qh_dma); |
673 | hw->hw_info1 = cpu_to_hc32(ehci, QH_HEAD); | 520 | hw->hw_info1 = cpu_to_hc32(ehci, QH_HEAD); |
674 | #if defined(CONFIG_PPC_PS3) | 521 | #if defined(CONFIG_PPC_PS3) |
675 | hw->hw_info1 |= cpu_to_hc32(ehci, (1 << 7)); /* I = 1 */ | 522 | hw->hw_info1 |= cpu_to_hc32(ehci, QH_INACTIVATE); |
676 | #endif | 523 | #endif |
677 | hw->hw_token = cpu_to_hc32(ehci, QTD_STS_HALT); | 524 | hw->hw_token = cpu_to_hc32(ehci, QTD_STS_HALT); |
678 | hw->hw_qtd_next = EHCI_LIST_END(ehci); | 525 | hw->hw_qtd_next = EHCI_LIST_END(ehci); |
@@ -813,7 +660,7 @@ static int ehci_run (struct usb_hcd *hcd) | |||
813 | return 0; | 660 | return 0; |
814 | } | 661 | } |
815 | 662 | ||
816 | static int __maybe_unused ehci_setup (struct usb_hcd *hcd) | 663 | static int ehci_setup(struct usb_hcd *hcd) |
817 | { | 664 | { |
818 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | 665 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
819 | int retval; | 666 | int retval; |
@@ -828,15 +675,18 @@ static int __maybe_unused ehci_setup (struct usb_hcd *hcd) | |||
828 | 675 | ||
829 | ehci->sbrn = HCD_USB2; | 676 | ehci->sbrn = HCD_USB2; |
830 | 677 | ||
831 | retval = ehci_halt(ehci); | 678 | /* data structure init */ |
679 | retval = ehci_init(hcd); | ||
832 | if (retval) | 680 | if (retval) |
833 | return retval; | 681 | return retval; |
834 | 682 | ||
835 | /* data structure init */ | 683 | retval = ehci_halt(ehci); |
836 | retval = ehci_init(hcd); | ||
837 | if (retval) | 684 | if (retval) |
838 | return retval; | 685 | return retval; |
839 | 686 | ||
687 | if (ehci_is_TDI(ehci)) | ||
688 | tdi_reset(ehci); | ||
689 | |||
840 | ehci_reset(ehci); | 690 | ehci_reset(ehci); |
841 | 691 | ||
842 | return 0; | 692 | return 0; |
@@ -895,14 +745,28 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd) | |||
895 | 745 | ||
896 | /* complete the unlinking of some qh [4.15.2.3] */ | 746 | /* complete the unlinking of some qh [4.15.2.3] */ |
897 | if (status & STS_IAA) { | 747 | if (status & STS_IAA) { |
748 | |||
749 | /* Turn off the IAA watchdog */ | ||
750 | ehci->enabled_hrtimer_events &= ~BIT(EHCI_HRTIMER_IAA_WATCHDOG); | ||
751 | |||
752 | /* | ||
753 | * Mild optimization: Allow another IAAD to reset the | ||
754 | * hrtimer, if one occurs before the next expiration. | ||
755 | * In theory we could always cancel the hrtimer, but | ||
756 | * tests show that about half the time it will be reset | ||
757 | * for some other event anyway. | ||
758 | */ | ||
759 | if (ehci->next_hrtimer_event == EHCI_HRTIMER_IAA_WATCHDOG) | ||
760 | ++ehci->next_hrtimer_event; | ||
761 | |||
898 | /* guard against (alleged) silicon errata */ | 762 | /* guard against (alleged) silicon errata */ |
899 | if (cmd & CMD_IAAD) | 763 | if (cmd & CMD_IAAD) |
900 | ehci_dbg(ehci, "IAA with IAAD still set?\n"); | 764 | ehci_dbg(ehci, "IAA with IAAD still set?\n"); |
901 | if (ehci->reclaim) { | 765 | if (ehci->async_iaa) { |
902 | COUNT(ehci->stats.reclaim); | 766 | COUNT(ehci->stats.iaa); |
903 | end_unlink_async(ehci); | 767 | end_unlink_async(ehci); |
904 | } else | 768 | } else |
905 | ehci_dbg(ehci, "IAA with nothing to reclaim?\n"); | 769 | ehci_dbg(ehci, "IAA with nothing unlinked?\n"); |
906 | } | 770 | } |
907 | 771 | ||
908 | /* remote wakeup [4.3.1] */ | 772 | /* remote wakeup [4.3.1] */ |
@@ -956,15 +820,19 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd) | |||
956 | ehci_err(ehci, "fatal error\n"); | 820 | ehci_err(ehci, "fatal error\n"); |
957 | dbg_cmd(ehci, "fatal", cmd); | 821 | dbg_cmd(ehci, "fatal", cmd); |
958 | dbg_status(ehci, "fatal", status); | 822 | dbg_status(ehci, "fatal", status); |
959 | ehci_halt(ehci); | ||
960 | dead: | 823 | dead: |
961 | ehci_reset(ehci); | ||
962 | ehci_writel(ehci, 0, &ehci->regs->configured_flag); | ||
963 | usb_hc_died(hcd); | 824 | usb_hc_died(hcd); |
964 | /* generic layer kills/unlinks all urbs, then | 825 | |
965 | * uses ehci_stop to clean up the rest | 826 | /* Don't let the controller do anything more */ |
966 | */ | 827 | ehci->shutdown = true; |
967 | bh = 1; | 828 | ehci->rh_state = EHCI_RH_STOPPING; |
829 | ehci->command &= ~(CMD_RUN | CMD_ASE | CMD_PSE); | ||
830 | ehci_writel(ehci, ehci->command, &ehci->regs->command); | ||
831 | ehci_writel(ehci, 0, &ehci->regs->intr_enable); | ||
832 | ehci_handle_controller_death(ehci); | ||
833 | |||
834 | /* Handle completions when the controller stops */ | ||
835 | bh = 0; | ||
968 | } | 836 | } |
969 | 837 | ||
970 | if (bh) | 838 | if (bh) |
@@ -1026,38 +894,6 @@ static int ehci_urb_enqueue ( | |||
1026 | } | 894 | } |
1027 | } | 895 | } |
1028 | 896 | ||
1029 | static void unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh) | ||
1030 | { | ||
1031 | /* failfast */ | ||
1032 | if (ehci->rh_state != EHCI_RH_RUNNING && ehci->reclaim) | ||
1033 | end_unlink_async(ehci); | ||
1034 | |||
1035 | /* If the QH isn't linked then there's nothing we can do | ||
1036 | * unless we were called during a giveback, in which case | ||
1037 | * qh_completions() has to deal with it. | ||
1038 | */ | ||
1039 | if (qh->qh_state != QH_STATE_LINKED) { | ||
1040 | if (qh->qh_state == QH_STATE_COMPLETING) | ||
1041 | qh->needs_rescan = 1; | ||
1042 | return; | ||
1043 | } | ||
1044 | |||
1045 | /* defer till later if busy */ | ||
1046 | if (ehci->reclaim) { | ||
1047 | struct ehci_qh *last; | ||
1048 | |||
1049 | for (last = ehci->reclaim; | ||
1050 | last->reclaim; | ||
1051 | last = last->reclaim) | ||
1052 | continue; | ||
1053 | qh->qh_state = QH_STATE_UNLINK_WAIT; | ||
1054 | last->reclaim = qh; | ||
1055 | |||
1056 | /* start IAA cycle */ | ||
1057 | } else | ||
1058 | start_unlink_async (ehci, qh); | ||
1059 | } | ||
1060 | |||
1061 | /* remove from hardware lists | 897 | /* remove from hardware lists |
1062 | * completions normally happen asynchronously | 898 | * completions normally happen asynchronously |
1063 | */ | 899 | */ |
@@ -1084,7 +920,7 @@ static int ehci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) | |||
1084 | switch (qh->qh_state) { | 920 | switch (qh->qh_state) { |
1085 | case QH_STATE_LINKED: | 921 | case QH_STATE_LINKED: |
1086 | case QH_STATE_COMPLETING: | 922 | case QH_STATE_COMPLETING: |
1087 | unlink_async(ehci, qh); | 923 | start_unlink_async(ehci, qh); |
1088 | break; | 924 | break; |
1089 | case QH_STATE_UNLINK: | 925 | case QH_STATE_UNLINK: |
1090 | case QH_STATE_UNLINK_WAIT: | 926 | case QH_STATE_UNLINK_WAIT: |
@@ -1104,7 +940,7 @@ static int ehci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) | |||
1104 | switch (qh->qh_state) { | 940 | switch (qh->qh_state) { |
1105 | case QH_STATE_LINKED: | 941 | case QH_STATE_LINKED: |
1106 | case QH_STATE_COMPLETING: | 942 | case QH_STATE_COMPLETING: |
1107 | intr_deschedule (ehci, qh); | 943 | start_unlink_intr(ehci, qh); |
1108 | break; | 944 | break; |
1109 | case QH_STATE_IDLE: | 945 | case QH_STATE_IDLE: |
1110 | qh_completions (ehci, qh); | 946 | qh_completions (ehci, qh); |
@@ -1152,11 +988,17 @@ rescan: | |||
1152 | * accelerate iso completions ... so spin a while. | 988 | * accelerate iso completions ... so spin a while. |
1153 | */ | 989 | */ |
1154 | if (qh->hw == NULL) { | 990 | if (qh->hw == NULL) { |
1155 | ehci_vdbg (ehci, "iso delay\n"); | 991 | struct ehci_iso_stream *stream = ep->hcpriv; |
1156 | goto idle_timeout; | 992 | |
993 | if (!list_empty(&stream->td_list)) | ||
994 | goto idle_timeout; | ||
995 | |||
996 | /* BUG_ON(!list_empty(&stream->free_list)); */ | ||
997 | kfree(stream); | ||
998 | goto done; | ||
1157 | } | 999 | } |
1158 | 1000 | ||
1159 | if (ehci->rh_state != EHCI_RH_RUNNING) | 1001 | if (ehci->rh_state < EHCI_RH_RUNNING) |
1160 | qh->qh_state = QH_STATE_IDLE; | 1002 | qh->qh_state = QH_STATE_IDLE; |
1161 | switch (qh->qh_state) { | 1003 | switch (qh->qh_state) { |
1162 | case QH_STATE_LINKED: | 1004 | case QH_STATE_LINKED: |
@@ -1169,7 +1011,7 @@ rescan: | |||
1169 | * may already be unlinked. | 1011 | * may already be unlinked. |
1170 | */ | 1012 | */ |
1171 | if (tmp) | 1013 | if (tmp) |
1172 | unlink_async(ehci, qh); | 1014 | start_unlink_async(ehci, qh); |
1173 | /* FALL THROUGH */ | 1015 | /* FALL THROUGH */ |
1174 | case QH_STATE_UNLINK: /* wait for hw to finish? */ | 1016 | case QH_STATE_UNLINK: /* wait for hw to finish? */ |
1175 | case QH_STATE_UNLINK_WAIT: | 1017 | case QH_STATE_UNLINK_WAIT: |
@@ -1181,7 +1023,7 @@ idle_timeout: | |||
1181 | if (qh->clearing_tt) | 1023 | if (qh->clearing_tt) |
1182 | goto idle_timeout; | 1024 | goto idle_timeout; |
1183 | if (list_empty (&qh->qtd_list)) { | 1025 | if (list_empty (&qh->qtd_list)) { |
1184 | qh_put (qh); | 1026 | qh_destroy(ehci, qh); |
1185 | break; | 1027 | break; |
1186 | } | 1028 | } |
1187 | /* else FALL THROUGH */ | 1029 | /* else FALL THROUGH */ |
@@ -1194,8 +1036,8 @@ idle_timeout: | |||
1194 | list_empty (&qh->qtd_list) ? "" : "(has tds)"); | 1036 | list_empty (&qh->qtd_list) ? "" : "(has tds)"); |
1195 | break; | 1037 | break; |
1196 | } | 1038 | } |
1039 | done: | ||
1197 | ep->hcpriv = NULL; | 1040 | ep->hcpriv = NULL; |
1198 | done: | ||
1199 | spin_unlock_irqrestore (&ehci->lock, flags); | 1041 | spin_unlock_irqrestore (&ehci->lock, flags); |
1200 | } | 1042 | } |
1201 | 1043 | ||
@@ -1232,9 +1074,9 @@ ehci_endpoint_reset(struct usb_hcd *hcd, struct usb_host_endpoint *ep) | |||
1232 | * re-linking will call qh_refresh(). | 1074 | * re-linking will call qh_refresh(). |
1233 | */ | 1075 | */ |
1234 | if (eptype == USB_ENDPOINT_XFER_BULK) | 1076 | if (eptype == USB_ENDPOINT_XFER_BULK) |
1235 | unlink_async(ehci, qh); | 1077 | start_unlink_async(ehci, qh); |
1236 | else | 1078 | else |
1237 | intr_deschedule(ehci, qh); | 1079 | start_unlink_intr(ehci, qh); |
1238 | } | 1080 | } |
1239 | } | 1081 | } |
1240 | spin_unlock_irqrestore(&ehci->lock, flags); | 1082 | spin_unlock_irqrestore(&ehci->lock, flags); |
@@ -1247,6 +1089,104 @@ static int ehci_get_frame (struct usb_hcd *hcd) | |||
1247 | } | 1089 | } |
1248 | 1090 | ||
1249 | /*-------------------------------------------------------------------------*/ | 1091 | /*-------------------------------------------------------------------------*/ |
1092 | |||
1093 | #ifdef CONFIG_PM | ||
1094 | |||
1095 | /* suspend/resume, section 4.3 */ | ||
1096 | |||
1097 | /* These routines handle the generic parts of controller suspend/resume */ | ||
1098 | |||
1099 | static int __maybe_unused ehci_suspend(struct usb_hcd *hcd, bool do_wakeup) | ||
1100 | { | ||
1101 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | ||
1102 | |||
1103 | if (time_before(jiffies, ehci->next_statechange)) | ||
1104 | msleep(10); | ||
1105 | |||
1106 | /* | ||
1107 | * Root hub was already suspended. Disable IRQ emission and | ||
1108 | * mark HW unaccessible. The PM and USB cores make sure that | ||
1109 | * the root hub is either suspended or stopped. | ||
1110 | */ | ||
1111 | ehci_prepare_ports_for_controller_suspend(ehci, do_wakeup); | ||
1112 | |||
1113 | spin_lock_irq(&ehci->lock); | ||
1114 | ehci_writel(ehci, 0, &ehci->regs->intr_enable); | ||
1115 | (void) ehci_readl(ehci, &ehci->regs->intr_enable); | ||
1116 | |||
1117 | clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | ||
1118 | spin_unlock_irq(&ehci->lock); | ||
1119 | |||
1120 | return 0; | ||
1121 | } | ||
1122 | |||
1123 | /* Returns 0 if power was preserved, 1 if power was lost */ | ||
1124 | static int __maybe_unused ehci_resume(struct usb_hcd *hcd, bool hibernated) | ||
1125 | { | ||
1126 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | ||
1127 | |||
1128 | if (time_before(jiffies, ehci->next_statechange)) | ||
1129 | msleep(100); | ||
1130 | |||
1131 | /* Mark hardware accessible again as we are back to full power by now */ | ||
1132 | set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | ||
1133 | |||
1134 | if (ehci->shutdown) | ||
1135 | return 0; /* Controller is dead */ | ||
1136 | |||
1137 | /* | ||
1138 | * If CF is still set and we aren't resuming from hibernation | ||
1139 | * then we maintained suspend power. | ||
1140 | * Just undo the effect of ehci_suspend(). | ||
1141 | */ | ||
1142 | if (ehci_readl(ehci, &ehci->regs->configured_flag) == FLAG_CF && | ||
1143 | !hibernated) { | ||
1144 | int mask = INTR_MASK; | ||
1145 | |||
1146 | ehci_prepare_ports_for_controller_resume(ehci); | ||
1147 | |||
1148 | spin_lock_irq(&ehci->lock); | ||
1149 | if (ehci->shutdown) | ||
1150 | goto skip; | ||
1151 | |||
1152 | if (!hcd->self.root_hub->do_remote_wakeup) | ||
1153 | mask &= ~STS_PCD; | ||
1154 | ehci_writel(ehci, mask, &ehci->regs->intr_enable); | ||
1155 | ehci_readl(ehci, &ehci->regs->intr_enable); | ||
1156 | skip: | ||
1157 | spin_unlock_irq(&ehci->lock); | ||
1158 | return 0; | ||
1159 | } | ||
1160 | |||
1161 | /* | ||
1162 | * Else reset, to cope with power loss or resume from hibernation | ||
1163 | * having let the firmware kick in during reboot. | ||
1164 | */ | ||
1165 | usb_root_hub_lost_power(hcd->self.root_hub); | ||
1166 | (void) ehci_halt(ehci); | ||
1167 | (void) ehci_reset(ehci); | ||
1168 | |||
1169 | spin_lock_irq(&ehci->lock); | ||
1170 | if (ehci->shutdown) | ||
1171 | goto skip; | ||
1172 | |||
1173 | ehci_writel(ehci, ehci->command, &ehci->regs->command); | ||
1174 | ehci_writel(ehci, FLAG_CF, &ehci->regs->configured_flag); | ||
1175 | ehci_readl(ehci, &ehci->regs->command); /* unblock posted writes */ | ||
1176 | |||
1177 | ehci->rh_state = EHCI_RH_SUSPENDED; | ||
1178 | spin_unlock_irq(&ehci->lock); | ||
1179 | |||
1180 | /* here we "know" root ports should always stay powered */ | ||
1181 | ehci_port_power(ehci, 1); | ||
1182 | |||
1183 | return 1; | ||
1184 | } | ||
1185 | |||
1186 | #endif | ||
1187 | |||
1188 | /*-------------------------------------------------------------------------*/ | ||
1189 | |||
1250 | /* | 1190 | /* |
1251 | * The EHCI in ChipIdea HDRC cannot be a separate module or device, | 1191 | * The EHCI in ChipIdea HDRC cannot be a separate module or device, |
1252 | * because its registers (and irq) are shared between host/gadget/otg | 1192 | * because its registers (and irq) are shared between host/gadget/otg |