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