diff options
Diffstat (limited to 'drivers/usb/host/ehci-hcd.c')
| -rw-r--r-- | drivers/usb/host/ehci-hcd.c | 543 |
1 files changed, 81 insertions, 462 deletions
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index f5eb9e7b5b18..af3c05eb86fc 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c | |||
| @@ -182,6 +182,9 @@ static int ehci_halt (struct ehci_hcd *ehci) | |||
| 182 | { | 182 | { |
| 183 | u32 temp = readl (&ehci->regs->status); | 183 | u32 temp = readl (&ehci->regs->status); |
| 184 | 184 | ||
| 185 | /* disable any irqs left enabled by previous code */ | ||
| 186 | writel (0, &ehci->regs->intr_enable); | ||
| 187 | |||
| 185 | if ((temp & STS_HALT) != 0) | 188 | if ((temp & STS_HALT) != 0) |
| 186 | return 0; | 189 | return 0; |
| 187 | 190 | ||
| @@ -297,50 +300,17 @@ static void ehci_watchdog (unsigned long param) | |||
| 297 | spin_unlock_irqrestore (&ehci->lock, flags); | 300 | spin_unlock_irqrestore (&ehci->lock, flags); |
| 298 | } | 301 | } |
| 299 | 302 | ||
| 300 | #ifdef CONFIG_PCI | 303 | /* Reboot notifiers kick in for silicon on any bus (not just pci, etc). |
| 301 | 304 | * This forcibly disables dma and IRQs, helping kexec and other cases | |
| 302 | /* EHCI 0.96 (and later) section 5.1 says how to kick BIOS/SMM/... | 305 | * where the next system software may expect clean state. |
| 303 | * off the controller (maybe it can boot from highspeed USB disks). | ||
| 304 | */ | 306 | */ |
| 305 | static int bios_handoff (struct ehci_hcd *ehci, int where, u32 cap) | ||
| 306 | { | ||
| 307 | struct pci_dev *pdev = to_pci_dev(ehci_to_hcd(ehci)->self.controller); | ||
| 308 | |||
| 309 | /* always say Linux will own the hardware */ | ||
| 310 | pci_write_config_byte(pdev, where + 3, 1); | ||
| 311 | |||
| 312 | /* maybe wait a while for BIOS to respond */ | ||
| 313 | if (cap & (1 << 16)) { | ||
| 314 | int msec = 5000; | ||
| 315 | |||
| 316 | do { | ||
| 317 | msleep(10); | ||
| 318 | msec -= 10; | ||
| 319 | pci_read_config_dword(pdev, where, &cap); | ||
| 320 | } while ((cap & (1 << 16)) && msec); | ||
| 321 | if (cap & (1 << 16)) { | ||
| 322 | ehci_err(ehci, "BIOS handoff failed (%d, %08x)\n", | ||
| 323 | where, cap); | ||
| 324 | // some BIOS versions seem buggy... | ||
| 325 | // return 1; | ||
| 326 | ehci_warn (ehci, "continuing after BIOS bug...\n"); | ||
| 327 | /* disable all SMIs, and clear "BIOS owns" flag */ | ||
| 328 | pci_write_config_dword(pdev, where + 4, 0); | ||
| 329 | pci_write_config_byte(pdev, where + 2, 0); | ||
| 330 | } else | ||
| 331 | ehci_dbg(ehci, "BIOS handoff succeeded\n"); | ||
| 332 | } | ||
| 333 | return 0; | ||
| 334 | } | ||
| 335 | |||
| 336 | #endif | ||
| 337 | |||
| 338 | static int | 307 | static int |
| 339 | ehci_reboot (struct notifier_block *self, unsigned long code, void *null) | 308 | ehci_reboot (struct notifier_block *self, unsigned long code, void *null) |
| 340 | { | 309 | { |
| 341 | struct ehci_hcd *ehci; | 310 | struct ehci_hcd *ehci; |
| 342 | 311 | ||
| 343 | ehci = container_of (self, struct ehci_hcd, reboot_notifier); | 312 | ehci = container_of (self, struct ehci_hcd, reboot_notifier); |
| 313 | (void) ehci_halt (ehci); | ||
| 344 | 314 | ||
| 345 | /* make BIOS/etc use companion controller during reboot */ | 315 | /* make BIOS/etc use companion controller during reboot */ |
| 346 | writel (0, &ehci->regs->configured_flag); | 316 | writel (0, &ehci->regs->configured_flag); |
| @@ -363,156 +333,90 @@ static void ehci_port_power (struct ehci_hcd *ehci, int is_on) | |||
| 363 | msleep(20); | 333 | msleep(20); |
| 364 | } | 334 | } |
| 365 | 335 | ||
| 336 | /*-------------------------------------------------------------------------*/ | ||
| 337 | |||
| 338 | /* | ||
| 339 | * ehci_work is called from some interrupts, timers, and so on. | ||
| 340 | * it calls driver completion functions, after dropping ehci->lock. | ||
| 341 | */ | ||
| 342 | static void ehci_work (struct ehci_hcd *ehci, struct pt_regs *regs) | ||
| 343 | { | ||
| 344 | timer_action_done (ehci, TIMER_IO_WATCHDOG); | ||
| 345 | if (ehci->reclaim_ready) | ||
| 346 | end_unlink_async (ehci, regs); | ||
| 347 | |||
| 348 | /* another CPU may drop ehci->lock during a schedule scan while | ||
| 349 | * it reports urb completions. this flag guards against bogus | ||
| 350 | * attempts at re-entrant schedule scanning. | ||
| 351 | */ | ||
| 352 | if (ehci->scanning) | ||
| 353 | return; | ||
| 354 | ehci->scanning = 1; | ||
| 355 | scan_async (ehci, regs); | ||
| 356 | if (ehci->next_uframe != -1) | ||
| 357 | scan_periodic (ehci, regs); | ||
| 358 | ehci->scanning = 0; | ||
| 366 | 359 | ||
| 367 | /* called by khubd or root hub init threads */ | 360 | /* the IO watchdog guards against hardware or driver bugs that |
| 361 | * misplace IRQs, and should let us run completely without IRQs. | ||
| 362 | * such lossage has been observed on both VT6202 and VT8235. | ||
| 363 | */ | ||
| 364 | if (HC_IS_RUNNING (ehci_to_hcd(ehci)->state) && | ||
| 365 | (ehci->async->qh_next.ptr != NULL || | ||
| 366 | ehci->periodic_sched != 0)) | ||
| 367 | timer_action (ehci, TIMER_IO_WATCHDOG); | ||
| 368 | } | ||
| 368 | 369 | ||
| 369 | static int ehci_hc_reset (struct usb_hcd *hcd) | 370 | static void ehci_stop (struct usb_hcd *hcd) |
| 370 | { | 371 | { |
| 371 | struct ehci_hcd *ehci = hcd_to_ehci (hcd); | 372 | struct ehci_hcd *ehci = hcd_to_ehci (hcd); |
| 372 | u32 temp; | ||
| 373 | unsigned count = 256/4; | ||
| 374 | 373 | ||
| 375 | spin_lock_init (&ehci->lock); | 374 | ehci_dbg (ehci, "stop\n"); |
| 376 | 375 | ||
| 377 | ehci->caps = hcd->regs; | 376 | /* Turn off port power on all root hub ports. */ |
| 378 | ehci->regs = hcd->regs + HC_LENGTH (readl (&ehci->caps->hc_capbase)); | 377 | ehci_port_power (ehci, 0); |
| 379 | dbg_hcs_params (ehci, "reset"); | ||
| 380 | dbg_hcc_params (ehci, "reset"); | ||
| 381 | 378 | ||
| 382 | /* cache this readonly data; minimize chip reads */ | 379 | /* no more interrupts ... */ |
| 383 | ehci->hcs_params = readl (&ehci->caps->hcs_params); | 380 | del_timer_sync (&ehci->watchdog); |
| 384 | 381 | ||
| 385 | #ifdef CONFIG_PCI | 382 | spin_lock_irq(&ehci->lock); |
| 386 | if (hcd->self.controller->bus == &pci_bus_type) { | 383 | if (HC_IS_RUNNING (hcd->state)) |
| 387 | struct pci_dev *pdev = to_pci_dev(hcd->self.controller); | 384 | ehci_quiesce (ehci); |
| 388 | 385 | ||
| 389 | switch (pdev->vendor) { | 386 | ehci_reset (ehci); |
| 390 | case PCI_VENDOR_ID_TDI: | 387 | writel (0, &ehci->regs->intr_enable); |
| 391 | if (pdev->device == PCI_DEVICE_ID_TDI_EHCI) { | 388 | spin_unlock_irq(&ehci->lock); |
| 392 | ehci->is_tdi_rh_tt = 1; | ||
| 393 | tdi_reset (ehci); | ||
| 394 | } | ||
| 395 | break; | ||
| 396 | case PCI_VENDOR_ID_AMD: | ||
| 397 | /* AMD8111 EHCI doesn't work, according to AMD errata */ | ||
| 398 | if (pdev->device == 0x7463) { | ||
| 399 | ehci_info (ehci, "ignoring AMD8111 (errata)\n"); | ||
| 400 | return -EIO; | ||
| 401 | } | ||
| 402 | break; | ||
| 403 | case PCI_VENDOR_ID_NVIDIA: | ||
| 404 | /* NVidia reports that certain chips don't handle | ||
| 405 | * QH, ITD, or SITD addresses above 2GB. (But TD, | ||
| 406 | * data buffer, and periodic schedule are normal.) | ||
| 407 | */ | ||
| 408 | switch (pdev->device) { | ||
| 409 | case 0x003c: /* MCP04 */ | ||
| 410 | case 0x005b: /* CK804 */ | ||
| 411 | case 0x00d8: /* CK8 */ | ||
| 412 | case 0x00e8: /* CK8S */ | ||
| 413 | if (pci_set_consistent_dma_mask(pdev, | ||
| 414 | DMA_31BIT_MASK) < 0) | ||
| 415 | ehci_warn (ehci, "can't enable NVidia " | ||
| 416 | "workaround for >2GB RAM\n"); | ||
| 417 | break; | ||
| 418 | } | ||
| 419 | break; | ||
| 420 | } | ||
| 421 | 389 | ||
| 422 | /* optional debug port, normally in the first BAR */ | 390 | /* let companion controllers work when we aren't */ |
| 423 | temp = pci_find_capability (pdev, 0x0a); | 391 | writel (0, &ehci->regs->configured_flag); |
| 424 | if (temp) { | 392 | unregister_reboot_notifier (&ehci->reboot_notifier); |
| 425 | pci_read_config_dword(pdev, temp, &temp); | ||
| 426 | temp >>= 16; | ||
| 427 | if ((temp & (3 << 13)) == (1 << 13)) { | ||
| 428 | temp &= 0x1fff; | ||
| 429 | ehci->debug = hcd->regs + temp; | ||
| 430 | temp = readl (&ehci->debug->control); | ||
| 431 | ehci_info (ehci, "debug port %d%s\n", | ||
| 432 | HCS_DEBUG_PORT(ehci->hcs_params), | ||
| 433 | (temp & DBGP_ENABLED) | ||
| 434 | ? " IN USE" | ||
| 435 | : ""); | ||
| 436 | if (!(temp & DBGP_ENABLED)) | ||
| 437 | ehci->debug = NULL; | ||
| 438 | } | ||
| 439 | } | ||
| 440 | 393 | ||
| 441 | temp = HCC_EXT_CAPS (readl (&ehci->caps->hcc_params)); | 394 | remove_debug_files (ehci); |
| 442 | } else | ||
| 443 | temp = 0; | ||
| 444 | |||
| 445 | /* EHCI 0.96 and later may have "extended capabilities" */ | ||
| 446 | while (temp && count--) { | ||
| 447 | u32 cap; | ||
| 448 | |||
| 449 | pci_read_config_dword (to_pci_dev(hcd->self.controller), | ||
| 450 | temp, &cap); | ||
| 451 | ehci_dbg (ehci, "capability %04x at %02x\n", cap, temp); | ||
| 452 | switch (cap & 0xff) { | ||
| 453 | case 1: /* BIOS/SMM/... handoff */ | ||
| 454 | if (bios_handoff (ehci, temp, cap) != 0) | ||
| 455 | return -EOPNOTSUPP; | ||
| 456 | break; | ||
| 457 | case 0: /* illegal reserved capability */ | ||
| 458 | ehci_warn (ehci, "illegal capability!\n"); | ||
| 459 | cap = 0; | ||
| 460 | /* FALLTHROUGH */ | ||
| 461 | default: /* unknown */ | ||
| 462 | break; | ||
| 463 | } | ||
| 464 | temp = (cap >> 8) & 0xff; | ||
| 465 | } | ||
| 466 | if (!count) { | ||
| 467 | ehci_err (ehci, "bogus capabilities ... PCI problems!\n"); | ||
| 468 | return -EIO; | ||
| 469 | } | ||
| 470 | if (ehci_is_TDI(ehci)) | ||
| 471 | ehci_reset (ehci); | ||
| 472 | #endif | ||
| 473 | 395 | ||
| 474 | ehci_port_power (ehci, 0); | 396 | /* root hub is shut down separately (first, when possible) */ |
| 397 | spin_lock_irq (&ehci->lock); | ||
| 398 | if (ehci->async) | ||
| 399 | ehci_work (ehci, NULL); | ||
| 400 | spin_unlock_irq (&ehci->lock); | ||
| 401 | ehci_mem_cleanup (ehci); | ||
| 475 | 402 | ||
| 476 | /* at least the Genesys GL880S needs fixup here */ | 403 | #ifdef EHCI_STATS |
| 477 | temp = HCS_N_CC(ehci->hcs_params) * HCS_N_PCC(ehci->hcs_params); | 404 | ehci_dbg (ehci, "irq normal %ld err %ld reclaim %ld (lost %ld)\n", |
| 478 | temp &= 0x0f; | 405 | ehci->stats.normal, ehci->stats.error, ehci->stats.reclaim, |
| 479 | if (temp && HCS_N_PORTS(ehci->hcs_params) > temp) { | 406 | ehci->stats.lost_iaa); |
| 480 | ehci_dbg (ehci, "bogus port configuration: " | 407 | ehci_dbg (ehci, "complete %ld unlink %ld\n", |
| 481 | "cc=%d x pcc=%d < ports=%d\n", | 408 | ehci->stats.complete, ehci->stats.unlink); |
| 482 | HCS_N_CC(ehci->hcs_params), | ||
| 483 | HCS_N_PCC(ehci->hcs_params), | ||
| 484 | HCS_N_PORTS(ehci->hcs_params)); | ||
| 485 | |||
| 486 | #ifdef CONFIG_PCI | ||
| 487 | if (hcd->self.controller->bus == &pci_bus_type) { | ||
| 488 | struct pci_dev *pdev; | ||
| 489 | |||
| 490 | pdev = to_pci_dev(hcd->self.controller); | ||
| 491 | switch (pdev->vendor) { | ||
| 492 | case 0x17a0: /* GENESYS */ | ||
| 493 | /* GL880S: should be PORTS=2 */ | ||
| 494 | temp |= (ehci->hcs_params & ~0xf); | ||
| 495 | ehci->hcs_params = temp; | ||
| 496 | break; | ||
| 497 | case PCI_VENDOR_ID_NVIDIA: | ||
| 498 | /* NF4: should be PCC=10 */ | ||
| 499 | break; | ||
| 500 | } | ||
| 501 | } | ||
| 502 | #endif | 409 | #endif |
| 503 | } | ||
| 504 | 410 | ||
| 505 | /* force HC to halt state */ | 411 | dbg_status (ehci, "ehci_stop completed", readl (&ehci->regs->status)); |
| 506 | return ehci_halt (ehci); | ||
| 507 | } | 412 | } |
| 508 | 413 | ||
| 509 | static int ehci_start (struct usb_hcd *hcd) | 414 | static int ehci_run (struct usb_hcd *hcd) |
| 510 | { | 415 | { |
| 511 | struct ehci_hcd *ehci = hcd_to_ehci (hcd); | 416 | struct ehci_hcd *ehci = hcd_to_ehci (hcd); |
| 512 | u32 temp; | 417 | u32 temp; |
| 513 | int retval; | 418 | int retval; |
| 514 | u32 hcc_params; | 419 | u32 hcc_params; |
| 515 | u8 sbrn = 0; | ||
| 516 | int first; | 420 | int first; |
| 517 | 421 | ||
| 518 | /* skip some things on restart paths */ | 422 | /* skip some things on restart paths */ |
| @@ -551,27 +455,6 @@ static int ehci_start (struct usb_hcd *hcd) | |||
| 551 | } | 455 | } |
| 552 | writel (ehci->periodic_dma, &ehci->regs->frame_list); | 456 | writel (ehci->periodic_dma, &ehci->regs->frame_list); |
| 553 | 457 | ||
| 554 | #ifdef CONFIG_PCI | ||
| 555 | if (hcd->self.controller->bus == &pci_bus_type) { | ||
| 556 | struct pci_dev *pdev; | ||
| 557 | u16 port_wake; | ||
| 558 | |||
| 559 | pdev = to_pci_dev(hcd->self.controller); | ||
| 560 | |||
| 561 | /* Serial Bus Release Number is at PCI 0x60 offset */ | ||
| 562 | pci_read_config_byte(pdev, 0x60, &sbrn); | ||
| 563 | |||
| 564 | /* port wake capability, reported by boot firmware */ | ||
| 565 | pci_read_config_word(pdev, 0x62, &port_wake); | ||
| 566 | hcd->can_wakeup = (port_wake & 1) != 0; | ||
| 567 | |||
| 568 | /* help hc dma work well with cachelines */ | ||
| 569 | retval = pci_set_mwi(pdev); | ||
| 570 | if (retval) | ||
| 571 | ehci_dbg(ehci, "unable to enable MWI - not fatal.\n"); | ||
| 572 | } | ||
| 573 | #endif | ||
| 574 | |||
| 575 | /* | 458 | /* |
| 576 | * dedicate a qh for the async ring head, since we couldn't unlink | 459 | * dedicate a qh for the async ring head, since we couldn't unlink |
| 577 | * a 'real' qh without stopping the async schedule [4.8]. use it | 460 | * a 'real' qh without stopping the async schedule [4.8]. use it |
| @@ -667,7 +550,7 @@ static int ehci_start (struct usb_hcd *hcd) | |||
| 667 | temp = HC_VERSION(readl (&ehci->caps->hc_capbase)); | 550 | temp = HC_VERSION(readl (&ehci->caps->hc_capbase)); |
| 668 | ehci_info (ehci, | 551 | ehci_info (ehci, |
| 669 | "USB %x.%x %s, EHCI %x.%02x, driver %s\n", | 552 | "USB %x.%x %s, EHCI %x.%02x, driver %s\n", |
| 670 | ((sbrn & 0xf0)>>4), (sbrn & 0x0f), | 553 | ((ehci->sbrn & 0xf0)>>4), (ehci->sbrn & 0x0f), |
| 671 | first ? "initialized" : "restarted", | 554 | first ? "initialized" : "restarted", |
| 672 | temp >> 8, temp & 0xff, DRIVER_VERSION); | 555 | temp >> 8, temp & 0xff, DRIVER_VERSION); |
| 673 | 556 | ||
| @@ -679,188 +562,6 @@ static int ehci_start (struct usb_hcd *hcd) | |||
| 679 | return 0; | 562 | return 0; |
| 680 | } | 563 | } |
| 681 | 564 | ||
| 682 | /* always called by thread; normally rmmod */ | ||
| 683 | |||
| 684 | static void ehci_stop (struct usb_hcd *hcd) | ||
| 685 | { | ||
| 686 | struct ehci_hcd *ehci = hcd_to_ehci (hcd); | ||
| 687 | |||
| 688 | ehci_dbg (ehci, "stop\n"); | ||
| 689 | |||
| 690 | /* Turn off port power on all root hub ports. */ | ||
| 691 | ehci_port_power (ehci, 0); | ||
| 692 | |||
| 693 | /* no more interrupts ... */ | ||
| 694 | del_timer_sync (&ehci->watchdog); | ||
| 695 | |||
| 696 | spin_lock_irq(&ehci->lock); | ||
| 697 | if (HC_IS_RUNNING (hcd->state)) | ||
| 698 | ehci_quiesce (ehci); | ||
| 699 | |||
| 700 | ehci_reset (ehci); | ||
| 701 | writel (0, &ehci->regs->intr_enable); | ||
| 702 | spin_unlock_irq(&ehci->lock); | ||
| 703 | |||
| 704 | /* let companion controllers work when we aren't */ | ||
| 705 | writel (0, &ehci->regs->configured_flag); | ||
| 706 | unregister_reboot_notifier (&ehci->reboot_notifier); | ||
| 707 | |||
| 708 | remove_debug_files (ehci); | ||
| 709 | |||
| 710 | /* root hub is shut down separately (first, when possible) */ | ||
| 711 | spin_lock_irq (&ehci->lock); | ||
| 712 | if (ehci->async) | ||
| 713 | ehci_work (ehci, NULL); | ||
| 714 | spin_unlock_irq (&ehci->lock); | ||
| 715 | ehci_mem_cleanup (ehci); | ||
| 716 | |||
| 717 | #ifdef EHCI_STATS | ||
| 718 | ehci_dbg (ehci, "irq normal %ld err %ld reclaim %ld (lost %ld)\n", | ||
| 719 | ehci->stats.normal, ehci->stats.error, ehci->stats.reclaim, | ||
| 720 | ehci->stats.lost_iaa); | ||
| 721 | ehci_dbg (ehci, "complete %ld unlink %ld\n", | ||
| 722 | ehci->stats.complete, ehci->stats.unlink); | ||
| 723 | #endif | ||
| 724 | |||
| 725 | dbg_status (ehci, "ehci_stop completed", readl (&ehci->regs->status)); | ||
| 726 | } | ||
| 727 | |||
| 728 | static int ehci_get_frame (struct usb_hcd *hcd) | ||
| 729 | { | ||
| 730 | struct ehci_hcd *ehci = hcd_to_ehci (hcd); | ||
| 731 | return (readl (&ehci->regs->frame_index) >> 3) % ehci->periodic_size; | ||
| 732 | } | ||
| 733 | |||
| 734 | /*-------------------------------------------------------------------------*/ | ||
| 735 | |||
| 736 | #ifdef CONFIG_PM | ||
| 737 | |||
| 738 | /* suspend/resume, section 4.3 */ | ||
| 739 | |||
| 740 | /* These routines rely on the bus (pci, platform, etc) | ||
| 741 | * to handle powerdown and wakeup, and currently also on | ||
| 742 | * transceivers that don't need any software attention to set up | ||
| 743 | * the right sort of wakeup. | ||
| 744 | */ | ||
| 745 | |||
| 746 | static int ehci_suspend (struct usb_hcd *hcd, pm_message_t message) | ||
| 747 | { | ||
| 748 | struct ehci_hcd *ehci = hcd_to_ehci (hcd); | ||
| 749 | |||
| 750 | if (time_before (jiffies, ehci->next_statechange)) | ||
| 751 | msleep (100); | ||
| 752 | |||
| 753 | #ifdef CONFIG_USB_SUSPEND | ||
| 754 | (void) usb_suspend_device (hcd->self.root_hub, message); | ||
| 755 | #else | ||
| 756 | usb_lock_device (hcd->self.root_hub); | ||
| 757 | (void) ehci_hub_suspend (hcd); | ||
| 758 | usb_unlock_device (hcd->self.root_hub); | ||
| 759 | #endif | ||
| 760 | |||
| 761 | // save (PCI) FLADJ in case of Vaux power loss | ||
| 762 | // ... we'd only use it to handle clock skew | ||
| 763 | |||
| 764 | return 0; | ||
| 765 | } | ||
| 766 | |||
| 767 | static int ehci_resume (struct usb_hcd *hcd) | ||
| 768 | { | ||
| 769 | struct ehci_hcd *ehci = hcd_to_ehci (hcd); | ||
| 770 | unsigned port; | ||
| 771 | struct usb_device *root = hcd->self.root_hub; | ||
| 772 | int retval = -EINVAL; | ||
| 773 | |||
| 774 | // maybe restore (PCI) FLADJ | ||
| 775 | |||
| 776 | if (time_before (jiffies, ehci->next_statechange)) | ||
| 777 | msleep (100); | ||
| 778 | |||
| 779 | /* If any port is suspended (or owned by the companion), | ||
| 780 | * we know we can/must resume the HC (and mustn't reset it). | ||
| 781 | */ | ||
| 782 | for (port = HCS_N_PORTS (ehci->hcs_params); port > 0; ) { | ||
| 783 | u32 status; | ||
| 784 | port--; | ||
| 785 | status = readl (&ehci->regs->port_status [port]); | ||
| 786 | if (!(status & PORT_POWER)) | ||
| 787 | continue; | ||
| 788 | if (status & (PORT_SUSPEND | PORT_OWNER)) { | ||
| 789 | down (&hcd->self.root_hub->serialize); | ||
| 790 | retval = ehci_hub_resume (hcd); | ||
| 791 | up (&hcd->self.root_hub->serialize); | ||
| 792 | break; | ||
| 793 | } | ||
| 794 | if (!root->children [port]) | ||
| 795 | continue; | ||
| 796 | dbg_port (ehci, __FUNCTION__, port + 1, status); | ||
| 797 | usb_set_device_state (root->children[port], | ||
| 798 | USB_STATE_NOTATTACHED); | ||
| 799 | } | ||
| 800 | |||
| 801 | /* Else reset, to cope with power loss or flush-to-storage | ||
| 802 | * style "resume" having activated BIOS during reboot. | ||
| 803 | */ | ||
| 804 | if (port == 0) { | ||
| 805 | (void) ehci_halt (ehci); | ||
| 806 | (void) ehci_reset (ehci); | ||
| 807 | (void) ehci_hc_reset (hcd); | ||
| 808 | |||
| 809 | /* emptying the schedule aborts any urbs */ | ||
| 810 | spin_lock_irq (&ehci->lock); | ||
| 811 | if (ehci->reclaim) | ||
| 812 | ehci->reclaim_ready = 1; | ||
| 813 | ehci_work (ehci, NULL); | ||
| 814 | spin_unlock_irq (&ehci->lock); | ||
| 815 | |||
| 816 | /* restart; khubd will disconnect devices */ | ||
| 817 | retval = ehci_start (hcd); | ||
| 818 | |||
| 819 | /* here we "know" root ports should always stay powered; | ||
| 820 | * but some controllers may lose all power. | ||
| 821 | */ | ||
| 822 | ehci_port_power (ehci, 1); | ||
| 823 | } | ||
| 824 | |||
| 825 | return retval; | ||
| 826 | } | ||
| 827 | |||
| 828 | #endif | ||
| 829 | |||
| 830 | /*-------------------------------------------------------------------------*/ | ||
| 831 | |||
| 832 | /* | ||
| 833 | * ehci_work is called from some interrupts, timers, and so on. | ||
| 834 | * it calls driver completion functions, after dropping ehci->lock. | ||
| 835 | */ | ||
| 836 | static void ehci_work (struct ehci_hcd *ehci, struct pt_regs *regs) | ||
| 837 | { | ||
| 838 | timer_action_done (ehci, TIMER_IO_WATCHDOG); | ||
| 839 | if (ehci->reclaim_ready) | ||
| 840 | end_unlink_async (ehci, regs); | ||
| 841 | |||
| 842 | /* another CPU may drop ehci->lock during a schedule scan while | ||
| 843 | * it reports urb completions. this flag guards against bogus | ||
| 844 | * attempts at re-entrant schedule scanning. | ||
| 845 | */ | ||
| 846 | if (ehci->scanning) | ||
| 847 | return; | ||
| 848 | ehci->scanning = 1; | ||
| 849 | scan_async (ehci, regs); | ||
| 850 | if (ehci->next_uframe != -1) | ||
| 851 | scan_periodic (ehci, regs); | ||
| 852 | ehci->scanning = 0; | ||
| 853 | |||
| 854 | /* the IO watchdog guards against hardware or driver bugs that | ||
| 855 | * misplace IRQs, and should let us run completely without IRQs. | ||
| 856 | * such lossage has been observed on both VT6202 and VT8235. | ||
| 857 | */ | ||
| 858 | if (HC_IS_RUNNING (ehci_to_hcd(ehci)->state) && | ||
| 859 | (ehci->async->qh_next.ptr != NULL || | ||
| 860 | ehci->periodic_sched != 0)) | ||
| 861 | timer_action (ehci, TIMER_IO_WATCHDOG); | ||
| 862 | } | ||
| 863 | |||
| 864 | /*-------------------------------------------------------------------------*/ | 565 | /*-------------------------------------------------------------------------*/ |
| 865 | 566 | ||
| 866 | static irqreturn_t ehci_irq (struct usb_hcd *hcd, struct pt_regs *regs) | 567 | static irqreturn_t ehci_irq (struct usb_hcd *hcd, struct pt_regs *regs) |
| @@ -1171,106 +872,24 @@ done: | |||
| 1171 | return; | 872 | return; |
| 1172 | } | 873 | } |
| 1173 | 874 | ||
| 1174 | /*-------------------------------------------------------------------------*/ | 875 | static int ehci_get_frame (struct usb_hcd *hcd) |
| 1175 | 876 | { | |
| 1176 | static const struct hc_driver ehci_driver = { | 877 | struct ehci_hcd *ehci = hcd_to_ehci (hcd); |
| 1177 | .description = hcd_name, | 878 | return (readl (&ehci->regs->frame_index) >> 3) % ehci->periodic_size; |
| 1178 | .product_desc = "EHCI Host Controller", | 879 | } |
| 1179 | .hcd_priv_size = sizeof(struct ehci_hcd), | ||
| 1180 | |||
| 1181 | /* | ||
| 1182 | * generic hardware linkage | ||
| 1183 | */ | ||
| 1184 | .irq = ehci_irq, | ||
| 1185 | .flags = HCD_MEMORY | HCD_USB2, | ||
| 1186 | |||
| 1187 | /* | ||
| 1188 | * basic lifecycle operations | ||
| 1189 | */ | ||
| 1190 | .reset = ehci_hc_reset, | ||
| 1191 | .start = ehci_start, | ||
| 1192 | #ifdef CONFIG_PM | ||
| 1193 | .suspend = ehci_suspend, | ||
| 1194 | .resume = ehci_resume, | ||
| 1195 | #endif | ||
| 1196 | .stop = ehci_stop, | ||
| 1197 | |||
| 1198 | /* | ||
| 1199 | * managing i/o requests and associated device resources | ||
| 1200 | */ | ||
| 1201 | .urb_enqueue = ehci_urb_enqueue, | ||
| 1202 | .urb_dequeue = ehci_urb_dequeue, | ||
| 1203 | .endpoint_disable = ehci_endpoint_disable, | ||
| 1204 | |||
| 1205 | /* | ||
| 1206 | * scheduling support | ||
| 1207 | */ | ||
| 1208 | .get_frame_number = ehci_get_frame, | ||
| 1209 | |||
| 1210 | /* | ||
| 1211 | * root hub support | ||
| 1212 | */ | ||
| 1213 | .hub_status_data = ehci_hub_status_data, | ||
| 1214 | .hub_control = ehci_hub_control, | ||
| 1215 | .hub_suspend = ehci_hub_suspend, | ||
| 1216 | .hub_resume = ehci_hub_resume, | ||
| 1217 | }; | ||
| 1218 | 880 | ||
| 1219 | /*-------------------------------------------------------------------------*/ | 881 | /*-------------------------------------------------------------------------*/ |
| 1220 | 882 | ||
| 1221 | /* EHCI 1.0 doesn't require PCI */ | ||
| 1222 | |||
| 1223 | #ifdef CONFIG_PCI | ||
| 1224 | |||
| 1225 | /* PCI driver selection metadata; PCI hotplugging uses this */ | ||
| 1226 | static const struct pci_device_id pci_ids [] = { { | ||
| 1227 | /* handle any USB 2.0 EHCI controller */ | ||
| 1228 | PCI_DEVICE_CLASS(((PCI_CLASS_SERIAL_USB << 8) | 0x20), ~0), | ||
| 1229 | .driver_data = (unsigned long) &ehci_driver, | ||
| 1230 | }, | ||
| 1231 | { /* end: all zeroes */ } | ||
| 1232 | }; | ||
| 1233 | MODULE_DEVICE_TABLE (pci, pci_ids); | ||
| 1234 | |||
| 1235 | /* pci driver glue; this is a "new style" PCI driver module */ | ||
| 1236 | static struct pci_driver ehci_pci_driver = { | ||
| 1237 | .name = (char *) hcd_name, | ||
| 1238 | .id_table = pci_ids, | ||
| 1239 | |||
| 1240 | .probe = usb_hcd_pci_probe, | ||
| 1241 | .remove = usb_hcd_pci_remove, | ||
| 1242 | |||
| 1243 | #ifdef CONFIG_PM | ||
| 1244 | .suspend = usb_hcd_pci_suspend, | ||
| 1245 | .resume = usb_hcd_pci_resume, | ||
| 1246 | #endif | ||
| 1247 | }; | ||
| 1248 | |||
| 1249 | #endif /* PCI */ | ||
| 1250 | |||
| 1251 | |||
| 1252 | #define DRIVER_INFO DRIVER_VERSION " " DRIVER_DESC | 883 | #define DRIVER_INFO DRIVER_VERSION " " DRIVER_DESC |
| 1253 | 884 | ||
| 1254 | MODULE_DESCRIPTION (DRIVER_INFO); | 885 | MODULE_DESCRIPTION (DRIVER_INFO); |
| 1255 | MODULE_AUTHOR (DRIVER_AUTHOR); | 886 | MODULE_AUTHOR (DRIVER_AUTHOR); |
| 1256 | MODULE_LICENSE ("GPL"); | 887 | MODULE_LICENSE ("GPL"); |
| 1257 | 888 | ||
| 1258 | static int __init init (void) | 889 | #ifdef CONFIG_PCI |
| 1259 | { | 890 | #include "ehci-pci.c" |
| 1260 | if (usb_disabled()) | 891 | #endif |
| 1261 | return -ENODEV; | ||
| 1262 | |||
| 1263 | pr_debug ("%s: block sizes: qh %Zd qtd %Zd itd %Zd sitd %Zd\n", | ||
| 1264 | hcd_name, | ||
| 1265 | sizeof (struct ehci_qh), sizeof (struct ehci_qtd), | ||
| 1266 | sizeof (struct ehci_itd), sizeof (struct ehci_sitd)); | ||
| 1267 | |||
| 1268 | return pci_register_driver (&ehci_pci_driver); | ||
| 1269 | } | ||
| 1270 | module_init (init); | ||
| 1271 | 892 | ||
| 1272 | static void __exit cleanup (void) | 893 | #if !defined(CONFIG_PCI) |
| 1273 | { | 894 | #error "missing bus glue for ehci-hcd" |
| 1274 | pci_unregister_driver (&ehci_pci_driver); | 895 | #endif |
| 1275 | } | ||
| 1276 | module_exit (cleanup); | ||
