aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host/uhci-hcd.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/host/uhci-hcd.c')
-rw-r--r--drivers/usb/host/uhci-hcd.c87
1 files changed, 47 insertions, 40 deletions
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
index 6637e52736dd..f52d04db28f4 100644
--- a/drivers/usb/host/uhci-hcd.c
+++ b/drivers/usb/host/uhci-hcd.c
@@ -140,7 +140,7 @@ static void finish_reset(struct uhci_hcd *uhci)
140 uhci->rh_state = UHCI_RH_RESET; 140 uhci->rh_state = UHCI_RH_RESET;
141 uhci->is_stopped = UHCI_IS_STOPPED; 141 uhci->is_stopped = UHCI_IS_STOPPED;
142 uhci_to_hcd(uhci)->state = HC_STATE_HALT; 142 uhci_to_hcd(uhci)->state = HC_STATE_HALT;
143 uhci_to_hcd(uhci)->poll_rh = 0; 143 clear_bit(HCD_FLAG_POLL_RH, &uhci_to_hcd(uhci)->flags);
144 144
145 uhci->dead = 0; /* Full reset resurrects the controller */ 145 uhci->dead = 0; /* Full reset resurrects the controller */
146} 146}
@@ -176,6 +176,8 @@ static void check_and_reset_hc(struct uhci_hcd *uhci)
176 */ 176 */
177static void configure_hc(struct uhci_hcd *uhci) 177static void configure_hc(struct uhci_hcd *uhci)
178{ 178{
179 struct pci_dev *pdev = to_pci_dev(uhci_dev(uhci));
180
179 /* Set the frame length to the default: 1 ms exactly */ 181 /* Set the frame length to the default: 1 ms exactly */
180 outb(USBSOF_DEFAULT, uhci->io_addr + USBSOF); 182 outb(USBSOF_DEFAULT, uhci->io_addr + USBSOF);
181 183
@@ -191,8 +193,11 @@ static void configure_hc(struct uhci_hcd *uhci)
191 mb(); 193 mb();
192 194
193 /* Enable PIRQ */ 195 /* Enable PIRQ */
194 pci_write_config_word(to_pci_dev(uhci_dev(uhci)), USBLEGSUP, 196 pci_write_config_word(pdev, USBLEGSUP, USBLEGSUP_DEFAULT);
195 USBLEGSUP_DEFAULT); 197
198 /* Disable platform-specific non-PME# wakeup */
199 if (pdev->vendor == PCI_VENDOR_ID_INTEL)
200 pci_write_config_byte(pdev, USBRES_INTEL, 0);
196} 201}
197 202
198 203
@@ -344,7 +349,10 @@ __acquires(uhci->lock)
344 /* If interrupts don't work and remote wakeup is enabled then 349 /* If interrupts don't work and remote wakeup is enabled then
345 * the suspended root hub needs to be polled. 350 * the suspended root hub needs to be polled.
346 */ 351 */
347 uhci_to_hcd(uhci)->poll_rh = (!int_enable && wakeup_enable); 352 if (!int_enable && wakeup_enable)
353 set_bit(HCD_FLAG_POLL_RH, &uhci_to_hcd(uhci)->flags);
354 else
355 clear_bit(HCD_FLAG_POLL_RH, &uhci_to_hcd(uhci)->flags);
348 356
349 uhci_scan_schedule(uhci); 357 uhci_scan_schedule(uhci);
350 uhci_fsbr_off(uhci); 358 uhci_fsbr_off(uhci);
@@ -363,7 +371,7 @@ static void start_rh(struct uhci_hcd *uhci)
363 uhci->io_addr + USBINTR); 371 uhci->io_addr + USBINTR);
364 mb(); 372 mb();
365 uhci->rh_state = UHCI_RH_RUNNING; 373 uhci->rh_state = UHCI_RH_RUNNING;
366 uhci_to_hcd(uhci)->poll_rh = 1; 374 set_bit(HCD_FLAG_POLL_RH, &uhci_to_hcd(uhci)->flags);
367} 375}
368 376
369static void wakeup_rh(struct uhci_hcd *uhci) 377static void wakeup_rh(struct uhci_hcd *uhci)
@@ -589,7 +597,7 @@ static int uhci_start(struct usb_hcd *hcd)
589 struct uhci_hcd *uhci = hcd_to_uhci(hcd); 597 struct uhci_hcd *uhci = hcd_to_uhci(hcd);
590 int retval = -EBUSY; 598 int retval = -EBUSY;
591 int i; 599 int i;
592 struct dentry *dentry; 600 struct dentry __maybe_unused *dentry;
593 601
594 hcd->uses_new_polling = 1; 602 hcd->uses_new_polling = 1;
595 603
@@ -599,18 +607,16 @@ static int uhci_start(struct usb_hcd *hcd)
599 INIT_LIST_HEAD(&uhci->idle_qh_list); 607 INIT_LIST_HEAD(&uhci->idle_qh_list);
600 init_waitqueue_head(&uhci->waitqh); 608 init_waitqueue_head(&uhci->waitqh);
601 609
602 if (DEBUG_CONFIGURED) { 610#ifdef UHCI_DEBUG_OPS
603 dentry = debugfs_create_file(hcd->self.bus_name, 611 dentry = debugfs_create_file(hcd->self.bus_name,
604 S_IFREG|S_IRUGO|S_IWUSR, uhci_debugfs_root, 612 S_IFREG|S_IRUGO|S_IWUSR, uhci_debugfs_root,
605 uhci, &uhci_debug_operations); 613 uhci, &uhci_debug_operations);
606 if (!dentry) { 614 if (!dentry) {
607 dev_err(uhci_dev(uhci), "couldn't create uhci " 615 dev_err(uhci_dev(uhci), "couldn't create uhci debugfs entry\n");
608 "debugfs entry\n"); 616 return -ENOMEM;
609 retval = -ENOMEM;
610 goto err_create_debug_entry;
611 }
612 uhci->dentry = dentry;
613 } 617 }
618 uhci->dentry = dentry;
619#endif
614 620
615 uhci->frame = dma_alloc_coherent(uhci_dev(uhci), 621 uhci->frame = dma_alloc_coherent(uhci_dev(uhci),
616 UHCI_NUMFRAMES * sizeof(*uhci->frame), 622 UHCI_NUMFRAMES * sizeof(*uhci->frame),
@@ -691,7 +697,9 @@ static int uhci_start(struct usb_hcd *hcd)
691 697
692 configure_hc(uhci); 698 configure_hc(uhci);
693 uhci->is_initialized = 1; 699 uhci->is_initialized = 1;
700 spin_lock_irq(&uhci->lock);
694 start_rh(uhci); 701 start_rh(uhci);
702 spin_unlock_irq(&uhci->lock);
695 return 0; 703 return 0;
696 704
697/* 705/*
@@ -722,7 +730,6 @@ err_alloc_frame_cpu:
722err_alloc_frame: 730err_alloc_frame:
723 debugfs_remove(uhci->dentry); 731 debugfs_remove(uhci->dentry);
724 732
725err_create_debug_entry:
726 return retval; 733 return retval;
727} 734}
728 735
@@ -731,7 +738,7 @@ static void uhci_stop(struct usb_hcd *hcd)
731 struct uhci_hcd *uhci = hcd_to_uhci(hcd); 738 struct uhci_hcd *uhci = hcd_to_uhci(hcd);
732 739
733 spin_lock_irq(&uhci->lock); 740 spin_lock_irq(&uhci->lock);
734 if (test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags) && !uhci->dead) 741 if (HCD_HW_ACCESSIBLE(hcd) && !uhci->dead)
735 uhci_hc_died(uhci); 742 uhci_hc_died(uhci);
736 uhci_scan_schedule(uhci); 743 uhci_scan_schedule(uhci);
737 spin_unlock_irq(&uhci->lock); 744 spin_unlock_irq(&uhci->lock);
@@ -748,7 +755,7 @@ static int uhci_rh_suspend(struct usb_hcd *hcd)
748 int rc = 0; 755 int rc = 0;
749 756
750 spin_lock_irq(&uhci->lock); 757 spin_lock_irq(&uhci->lock);
751 if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) 758 if (!HCD_HW_ACCESSIBLE(hcd))
752 rc = -ESHUTDOWN; 759 rc = -ESHUTDOWN;
753 else if (uhci->dead) 760 else if (uhci->dead)
754 ; /* Dead controllers tell no tales */ 761 ; /* Dead controllers tell no tales */
@@ -775,7 +782,7 @@ static int uhci_rh_resume(struct usb_hcd *hcd)
775 int rc = 0; 782 int rc = 0;
776 783
777 spin_lock_irq(&uhci->lock); 784 spin_lock_irq(&uhci->lock);
778 if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) 785 if (!HCD_HW_ACCESSIBLE(hcd))
779 rc = -ESHUTDOWN; 786 rc = -ESHUTDOWN;
780 else if (!uhci->dead) 787 else if (!uhci->dead)
781 wakeup_rh(uhci); 788 wakeup_rh(uhci);
@@ -783,15 +790,16 @@ static int uhci_rh_resume(struct usb_hcd *hcd)
783 return rc; 790 return rc;
784} 791}
785 792
786static int uhci_pci_suspend(struct usb_hcd *hcd) 793static int uhci_pci_suspend(struct usb_hcd *hcd, bool do_wakeup)
787{ 794{
788 struct uhci_hcd *uhci = hcd_to_uhci(hcd); 795 struct uhci_hcd *uhci = hcd_to_uhci(hcd);
796 struct pci_dev *pdev = to_pci_dev(uhci_dev(uhci));
789 int rc = 0; 797 int rc = 0;
790 798
791 dev_dbg(uhci_dev(uhci), "%s\n", __func__); 799 dev_dbg(uhci_dev(uhci), "%s\n", __func__);
792 800
793 spin_lock_irq(&uhci->lock); 801 spin_lock_irq(&uhci->lock);
794 if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags) || uhci->dead) 802 if (!HCD_HW_ACCESSIBLE(hcd) || uhci->dead)
795 goto done_okay; /* Already suspended or dead */ 803 goto done_okay; /* Already suspended or dead */
796 804
797 if (uhci->rh_state > UHCI_RH_SUSPENDED) { 805 if (uhci->rh_state > UHCI_RH_SUSPENDED) {
@@ -803,11 +811,15 @@ static int uhci_pci_suspend(struct usb_hcd *hcd)
803 /* All PCI host controllers are required to disable IRQ generation 811 /* All PCI host controllers are required to disable IRQ generation
804 * at the source, so we must turn off PIRQ. 812 * at the source, so we must turn off PIRQ.
805 */ 813 */
806 pci_write_config_word(to_pci_dev(uhci_dev(uhci)), USBLEGSUP, 0); 814 pci_write_config_word(pdev, USBLEGSUP, 0);
807 mb(); 815 clear_bit(HCD_FLAG_POLL_RH, &hcd->flags);
808 hcd->poll_rh = 0; 816
809 817 /* Enable platform-specific non-PME# wakeup */
810 /* FIXME: Enable non-PME# remote wakeup? */ 818 if (do_wakeup) {
819 if (pdev->vendor == PCI_VENDOR_ID_INTEL)
820 pci_write_config_byte(pdev, USBRES_INTEL,
821 USBPORT1EN | USBPORT2EN);
822 }
811 823
812done_okay: 824done_okay:
813 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); 825 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
@@ -826,7 +838,6 @@ static int uhci_pci_resume(struct usb_hcd *hcd, bool hibernated)
826 * even if the controller was dead. 838 * even if the controller was dead.
827 */ 839 */
828 set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); 840 set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
829 mb();
830 841
831 spin_lock_irq(&uhci->lock); 842 spin_lock_irq(&uhci->lock);
832 843
@@ -834,8 +845,6 @@ static int uhci_pci_resume(struct usb_hcd *hcd, bool hibernated)
834 if (hibernated) 845 if (hibernated)
835 uhci_hc_died(uhci); 846 uhci_hc_died(uhci);
836 847
837 /* FIXME: Disable non-PME# remote wakeup? */
838
839 /* The firmware or a boot kernel may have changed the controller 848 /* The firmware or a boot kernel may have changed the controller
840 * settings during a system wakeup. Check it and reconfigure 849 * settings during a system wakeup. Check it and reconfigure
841 * to avoid problems. 850 * to avoid problems.
@@ -845,22 +854,20 @@ static int uhci_pci_resume(struct usb_hcd *hcd, bool hibernated)
845 /* If the controller was dead before, it's back alive now */ 854 /* If the controller was dead before, it's back alive now */
846 configure_hc(uhci); 855 configure_hc(uhci);
847 856
848 if (uhci->rh_state == UHCI_RH_RESET) { 857 /* Tell the core if the controller had to be reset */
849 858 if (uhci->rh_state == UHCI_RH_RESET)
850 /* The controller had to be reset */
851 usb_root_hub_lost_power(hcd->self.root_hub); 859 usb_root_hub_lost_power(hcd->self.root_hub);
852 suspend_rh(uhci, UHCI_RH_SUSPENDED);
853 }
854 860
855 spin_unlock_irq(&uhci->lock); 861 spin_unlock_irq(&uhci->lock);
856 862
857 /* If interrupts don't work and remote wakeup is enabled then 863 /* If interrupts don't work and remote wakeup is enabled then
858 * the suspended root hub needs to be polled. 864 * the suspended root hub needs to be polled.
859 */ 865 */
860 if (!uhci->RD_enable && hcd->self.root_hub->do_remote_wakeup) { 866 if (!uhci->RD_enable && hcd->self.root_hub->do_remote_wakeup)
861 hcd->poll_rh = 1; 867 set_bit(HCD_FLAG_POLL_RH, &hcd->flags);
862 usb_hcd_poll_rh_status(hcd); 868
863 } 869 /* Does the root hub have a port wakeup pending? */
870 usb_hcd_poll_rh_status(hcd);
864 return 0; 871 return 0;
865} 872}
866#endif 873#endif