11 #include <linux/types.h>
13 #include <linux/kernel.h>
14 #include <linux/pci.h>
17 #include <linux/export.h>
24 #define UHCI_USBLEGSUP 0xc0
26 #define UHCI_USBINTR 4
27 #define UHCI_USBLEGSUP_RWC 0x8f00
28 #define UHCI_USBLEGSUP_RO 0x5040
29 #define UHCI_USBCMD_RUN 0x0001
30 #define UHCI_USBCMD_HCRESET 0x0002
31 #define UHCI_USBCMD_EGSM 0x0008
32 #define UHCI_USBCMD_CONFIGURE 0x0040
33 #define UHCI_USBINTR_RESUME 0x0002
35 #define OHCI_CONTROL 0x04
36 #define OHCI_CMDSTATUS 0x08
37 #define OHCI_INTRSTATUS 0x0c
38 #define OHCI_INTRENABLE 0x10
39 #define OHCI_INTRDISABLE 0x14
40 #define OHCI_FMINTERVAL 0x34
41 #define OHCI_HCFS (3 << 6)
42 #define OHCI_HCR (1 << 0)
43 #define OHCI_OCR (1 << 3)
44 #define OHCI_CTRL_RWC (1 << 9)
45 #define OHCI_CTRL_IR (1 << 8)
46 #define OHCI_INTR_OC (1 << 30)
48 #define EHCI_HCC_PARAMS 0x08
50 #define EHCI_USBCMD_RUN (1 << 0)
52 #define EHCI_USBSTS_HALTED (1 << 12)
53 #define EHCI_USBINTR 8
54 #define EHCI_CONFIGFLAG 0x40
55 #define EHCI_USBLEGSUP 0
56 #define EHCI_USBLEGSUP_BIOS (1 << 16)
57 #define EHCI_USBLEGSUP_OS (1 << 24)
58 #define EHCI_USBLEGCTLSTS 4
59 #define EHCI_USBLEGCTLSTS_SOOE (1 << 13)
62 #define AB_REG_BAR_LOW 0xe0
63 #define AB_REG_BAR_HIGH 0xe1
64 #define AB_REG_BAR_SB700 0xf0
65 #define AB_INDX(addr) ((addr) + 0x00)
66 #define AB_DATA(addr) ((addr) + 0x04)
70 #define NB_PCIE_INDX_ADDR 0xe0
71 #define NB_PCIE_INDX_DATA 0xe4
72 #define PCIE_P_CNTL 0x10040
73 #define BIF_NB 0x10002
74 #define NB_PIF0_PWRDOWN_0 0x01100012
75 #define NB_PIF0_PWRDOWN_1 0x01100013
77 #define USB_INTEL_XUSB2PR 0xD0
78 #define USB_INTEL_USB2PRM 0xD4
79 #define USB_INTEL_USB3_PSSEN 0xD8
80 #define USB_INTEL_USB3PRM 0xDC
82 static struct amd_chipset_info {
98 struct amd_chipset_info info;
104 if (amd_chipset.probe_count > 0) {
105 amd_chipset.probe_count++;
106 spin_unlock_irqrestore(&amd_lock, flags);
107 return amd_chipset.probe_result;
109 memset(&info, 0,
sizeof(info));
110 spin_unlock_irqrestore(&amd_lock, flags);
113 if (info.smbus_dev) {
114 rev = info.smbus_dev->revision;
117 else if (rev >= 0x30 && rev <= 0x3b)
122 if (!info.smbus_dev) {
127 rev = info.smbus_dev->revision;
128 if (rev >= 0x11 && rev <= 0x18)
132 if (info.sb_type == 0) {
133 if (info.smbus_dev) {
135 info.smbus_dev =
NULL;
156 ret = info.probe_result = 1;
162 if (amd_chipset.probe_count > 0) {
166 amd_chipset.probe_count++;
167 ret = amd_chipset.probe_result;
169 spin_unlock_irqrestore(&amd_lock, flags);
180 spin_unlock_irqrestore(&amd_lock, flags);
197 static void usb_amd_quirk_pll(
int disable)
200 u32 bit = disable ? 0 : 1;
206 amd_chipset.isoc_reqs++;
207 if (amd_chipset.isoc_reqs > 1) {
208 spin_unlock_irqrestore(&amd_lock, flags);
212 amd_chipset.isoc_reqs--;
213 if (amd_chipset.isoc_reqs > 0) {
214 spin_unlock_irqrestore(&amd_lock, flags);
219 if (amd_chipset.sb_type == 1 || amd_chipset.sb_type == 2) {
221 addr_low =
inb_p(0xcd7);
223 addr_high =
inb_p(0xcd7);
230 }
else if (amd_chipset.sb_type == 3) {
231 pci_read_config_dword(amd_chipset.smbus_dev,
238 spin_unlock_irqrestore(&amd_lock, flags);
244 val |= (1 << 4) | (1 << 9);
247 val &= ~((1 << 4) | (1 << 9));
251 if (!amd_chipset.nb_dev) {
252 spin_unlock_irqrestore(&amd_lock, flags);
256 if (amd_chipset.nb_type == 1 || amd_chipset.nb_type == 3) {
258 pci_write_config_dword(amd_chipset.nb_dev,
260 pci_read_config_dword(amd_chipset.nb_dev,
263 val &= ~(1 | (1 << 3) | (1 << 4) | (1 << 9) | (1 << 12));
264 val |= bit | (bit << 3) | (bit << 12);
265 val |= ((!
bit) << 4) | ((!
bit) << 9);
266 pci_write_config_dword(amd_chipset.nb_dev,
270 pci_write_config_dword(amd_chipset.nb_dev,
272 pci_read_config_dword(amd_chipset.nb_dev,
277 pci_write_config_dword(amd_chipset.nb_dev,
279 }
else if (amd_chipset.nb_type == 2) {
281 pci_write_config_dword(amd_chipset.nb_dev,
283 pci_read_config_dword(amd_chipset.nb_dev,
290 pci_write_config_dword(amd_chipset.nb_dev,
294 pci_write_config_dword(amd_chipset.nb_dev,
296 pci_read_config_dword(amd_chipset.nb_dev,
303 pci_write_config_dword(amd_chipset.nb_dev,
307 spin_unlock_irqrestore(&amd_lock, flags);
313 usb_amd_quirk_pll(1);
319 usb_amd_quirk_pll(0);
330 amd_chipset.probe_count--;
331 if (amd_chipset.probe_count > 0) {
332 spin_unlock_irqrestore(&amd_lock, flags);
337 nb = amd_chipset.nb_dev;
338 smbus = amd_chipset.smbus_dev;
340 amd_chipset.nb_dev =
NULL;
341 amd_chipset.smbus_dev =
NULL;
342 amd_chipset.nb_type = 0;
343 amd_chipset.sb_type = 0;
344 amd_chipset.isoc_reqs = 0;
345 amd_chipset.probe_result = 0;
347 spin_unlock_irqrestore(&amd_lock, flags);
376 dev_warn(&pdev->
dev,
"HCRESET not completed yet!\n");
431 dev_dbg(&pdev->
dev,
"Performing full reset\n");
437 static inline int io_type_enabled(
struct pci_dev *pdev,
unsigned int mask)
443 #define pio_enabled(dev) io_type_enabled(dev, PCI_COMMAND_IO)
444 #define mmio_enabled(dev) io_type_enabled(dev, PCI_COMMAND_MEMORY)
448 unsigned long base = 0;
476 if (!mmio_resource_enabled(pdev, 0))
487 #define OHCI_CTRL_MASK (OHCI_CTRL_RWC | OHCI_CTRL_IR)
489 #define OHCI_CTRL_MASK OHCI_CTRL_RWC
495 while (wait_time > 0 &&
502 " (BIOS bug?) %08x\n",
525 for (cnt = 30; cnt > 0; --
cnt) {
565 int try_handoff = 1, tried_handoff = 0;
595 pci_write_config_byte(pdev, offset + 3, 1);
601 while ((cap & EHCI_USBLEGSUP_BIOS) && (msec > 0)) {
605 pci_read_config_dword(pdev, offset, &cap);
609 if (cap & EHCI_USBLEGSUP_BIOS) {
615 " (BIOS bug?) %08x\n", cap);
616 pci_write_config_byte(pdev, offset + 2, 0);
631 void __iomem *base, *op_reg_base;
636 if (!mmio_resource_enabled(pdev, 0))
643 cap_length =
readb(base);
644 op_reg_base = base + cap_length;
651 offset = (hcc_params >> 8) & 0xff;
652 while (offset && --count) {
653 pci_read_config_dword(pdev, offset, &cap);
655 switch (cap & 0xff) {
657 ehci_bios_handoff(pdev, op_reg_base, cap, offset);
662 dev_warn(&pdev->
dev,
"EHCI: unrecognized capability "
663 "%02x\n", cap & 0xff);
665 offset = (cap >> 8) & 0xff;
668 dev_printk(
KERN_DEBUG, &pdev->
dev,
"EHCI: capability loop?\n");
685 if ((val == ~(
u32)0) || (val & EHCI_USBSTS_HALTED)) {
688 }
while (wait_time > 0);
710 int wait_usec,
int delay_usec)
720 wait_usec -= delay_usec;
721 }
while (wait_usec > 0);
725 #define PCI_DEVICE_ID_INTEL_LYNX_POINT_XHCI 0x8C31
777 "CONFIG_USB_XHCI_HCD is turned off, "
778 "defaulting to EHCI.\n");
780 "USB 3.0 devices will work at USB 2.0 speeds.\n");
790 dev_dbg(&xhci_pdev->
dev,
"Configurable ports to enable SuperSpeed: 0x%x\n",
802 dev_dbg(&xhci_pdev->
dev,
"USB 3.0 ports that are now enabled "
803 "under xHCI: 0x%x\n", ports_available);
812 dev_dbg(&xhci_pdev->
dev,
"Configurable USB 2.0 ports to hand over to xCHI: 0x%x\n",
824 dev_dbg(&xhci_pdev->
dev,
"USB 2.0 ports that are now switched over "
825 "to xHCI: 0x%x\n", ports_available);
853 if (!mmio_resource_enabled(pdev, 0))
866 if ((ext_cap_offset +
sizeof(val)) > len) {
869 "xHCI controller failing to respond");
877 val =
readl(base + ext_cap_offset);
880 ext_cap_offset = xhci_find_next_cap_offset(base, ext_cap_offset);
888 timeout =
handshake(base + ext_cap_offset, XHCI_HC_BIOS_OWNED,
894 " (BIOS bug ?) %08x\n", val);
895 writel(val & ~XHCI_HC_BIOS_OWNED, base + ext_cap_offset);
922 "xHCI HW not ready after 5 sec (HC bug?) "
923 "status = 0x%x\n", val);
937 "xHCI HW did not halt within %d usec "
949 if (pdev->
vendor == 0x184e)
959 "BIOS handoff failed.\n");
963 quirk_usb_handoff_uhci(pdev);
965 quirk_usb_handoff_ohci(pdev);
967 quirk_usb_disable_ehci(pdev);
969 quirk_usb_handoff_xhci(pdev);