diff options
Diffstat (limited to 'drivers/usb/host/pci-quirks.c')
-rw-r--r-- | drivers/usb/host/pci-quirks.c | 42 |
1 files changed, 35 insertions, 7 deletions
diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c index c5e9e4a76f14..966d1484ee79 100644 --- a/drivers/usb/host/pci-quirks.c +++ b/drivers/usb/host/pci-quirks.c | |||
@@ -75,7 +75,9 @@ | |||
75 | #define NB_PIF0_PWRDOWN_1 0x01100013 | 75 | #define NB_PIF0_PWRDOWN_1 0x01100013 |
76 | 76 | ||
77 | #define USB_INTEL_XUSB2PR 0xD0 | 77 | #define USB_INTEL_XUSB2PR 0xD0 |
78 | #define USB_INTEL_USB2PRM 0xD4 | ||
78 | #define USB_INTEL_USB3_PSSEN 0xD8 | 79 | #define USB_INTEL_USB3_PSSEN 0xD8 |
80 | #define USB_INTEL_USB3PRM 0xDC | ||
79 | 81 | ||
80 | static struct amd_chipset_info { | 82 | static struct amd_chipset_info { |
81 | struct pci_dev *nb_dev; | 83 | struct pci_dev *nb_dev; |
@@ -772,10 +774,18 @@ void usb_enable_xhci_ports(struct pci_dev *xhci_pdev) | |||
772 | return; | 774 | return; |
773 | } | 775 | } |
774 | 776 | ||
775 | ports_available = 0xffffffff; | 777 | /* Read USB3PRM, the USB 3.0 Port Routing Mask Register |
778 | * Indicate the ports that can be changed from OS. | ||
779 | */ | ||
780 | pci_read_config_dword(xhci_pdev, USB_INTEL_USB3PRM, | ||
781 | &ports_available); | ||
782 | |||
783 | dev_dbg(&xhci_pdev->dev, "Configurable ports to enable SuperSpeed: 0x%x\n", | ||
784 | ports_available); | ||
785 | |||
776 | /* Write USB3_PSSEN, the USB 3.0 Port SuperSpeed Enable | 786 | /* Write USB3_PSSEN, the USB 3.0 Port SuperSpeed Enable |
777 | * Register, to turn on SuperSpeed terminations for all | 787 | * Register, to turn on SuperSpeed terminations for the |
778 | * available ports. | 788 | * switchable ports. |
779 | */ | 789 | */ |
780 | pci_write_config_dword(xhci_pdev, USB_INTEL_USB3_PSSEN, | 790 | pci_write_config_dword(xhci_pdev, USB_INTEL_USB3_PSSEN, |
781 | cpu_to_le32(ports_available)); | 791 | cpu_to_le32(ports_available)); |
@@ -785,7 +795,16 @@ void usb_enable_xhci_ports(struct pci_dev *xhci_pdev) | |||
785 | dev_dbg(&xhci_pdev->dev, "USB 3.0 ports that are now enabled " | 795 | dev_dbg(&xhci_pdev->dev, "USB 3.0 ports that are now enabled " |
786 | "under xHCI: 0x%x\n", ports_available); | 796 | "under xHCI: 0x%x\n", ports_available); |
787 | 797 | ||
788 | ports_available = 0xffffffff; | 798 | /* Read XUSB2PRM, xHCI USB 2.0 Port Routing Mask Register |
799 | * Indicate the USB 2.0 ports to be controlled by the xHCI host. | ||
800 | */ | ||
801 | |||
802 | pci_read_config_dword(xhci_pdev, USB_INTEL_USB2PRM, | ||
803 | &ports_available); | ||
804 | |||
805 | dev_dbg(&xhci_pdev->dev, "Configurable USB 2.0 ports to hand over to xCHI: 0x%x\n", | ||
806 | ports_available); | ||
807 | |||
789 | /* Write XUSB2PR, the xHC USB 2.0 Port Routing Register, to | 808 | /* Write XUSB2PR, the xHC USB 2.0 Port Routing Register, to |
790 | * switch the USB 2.0 power and data lines over to the xHCI | 809 | * switch the USB 2.0 power and data lines over to the xHCI |
791 | * host. | 810 | * host. |
@@ -822,12 +841,12 @@ static void __devinit quirk_usb_handoff_xhci(struct pci_dev *pdev) | |||
822 | void __iomem *op_reg_base; | 841 | void __iomem *op_reg_base; |
823 | u32 val; | 842 | u32 val; |
824 | int timeout; | 843 | int timeout; |
844 | int len = pci_resource_len(pdev, 0); | ||
825 | 845 | ||
826 | if (!mmio_resource_enabled(pdev, 0)) | 846 | if (!mmio_resource_enabled(pdev, 0)) |
827 | return; | 847 | return; |
828 | 848 | ||
829 | base = ioremap_nocache(pci_resource_start(pdev, 0), | 849 | base = ioremap_nocache(pci_resource_start(pdev, 0), len); |
830 | pci_resource_len(pdev, 0)); | ||
831 | if (base == NULL) | 850 | if (base == NULL) |
832 | return; | 851 | return; |
833 | 852 | ||
@@ -837,9 +856,17 @@ static void __devinit quirk_usb_handoff_xhci(struct pci_dev *pdev) | |||
837 | */ | 856 | */ |
838 | ext_cap_offset = xhci_find_next_cap_offset(base, XHCI_HCC_PARAMS_OFFSET); | 857 | ext_cap_offset = xhci_find_next_cap_offset(base, XHCI_HCC_PARAMS_OFFSET); |
839 | do { | 858 | do { |
859 | if ((ext_cap_offset + sizeof(val)) > len) { | ||
860 | /* We're reading garbage from the controller */ | ||
861 | dev_warn(&pdev->dev, | ||
862 | "xHCI controller failing to respond"); | ||
863 | return; | ||
864 | } | ||
865 | |||
840 | if (!ext_cap_offset) | 866 | if (!ext_cap_offset) |
841 | /* We've reached the end of the extended capabilities */ | 867 | /* We've reached the end of the extended capabilities */ |
842 | goto hc_init; | 868 | goto hc_init; |
869 | |||
843 | val = readl(base + ext_cap_offset); | 870 | val = readl(base + ext_cap_offset); |
844 | if (XHCI_EXT_CAPS_ID(val) == XHCI_EXT_CAPS_LEGACY) | 871 | if (XHCI_EXT_CAPS_ID(val) == XHCI_EXT_CAPS_LEGACY) |
845 | break; | 872 | break; |
@@ -870,9 +897,10 @@ static void __devinit quirk_usb_handoff_xhci(struct pci_dev *pdev) | |||
870 | /* Disable any BIOS SMIs and clear all SMI events*/ | 897 | /* Disable any BIOS SMIs and clear all SMI events*/ |
871 | writel(val, base + ext_cap_offset + XHCI_LEGACY_CONTROL_OFFSET); | 898 | writel(val, base + ext_cap_offset + XHCI_LEGACY_CONTROL_OFFSET); |
872 | 899 | ||
900 | hc_init: | ||
873 | if (usb_is_intel_switchable_xhci(pdev)) | 901 | if (usb_is_intel_switchable_xhci(pdev)) |
874 | usb_enable_xhci_ports(pdev); | 902 | usb_enable_xhci_ports(pdev); |
875 | hc_init: | 903 | |
876 | op_reg_base = base + XHCI_HC_LENGTH(readl(base)); | 904 | op_reg_base = base + XHCI_HC_LENGTH(readl(base)); |
877 | 905 | ||
878 | /* Wait for the host controller to be ready before writing any | 906 | /* Wait for the host controller to be ready before writing any |