18 #include <linux/types.h>
19 #include <linux/kernel.h>
20 #include <linux/export.h>
21 #include <linux/pci.h>
29 #include <linux/sched.h>
60 static void quirk_passive_release(
struct pci_dev *
dev)
68 pci_read_config_byte(d, 0x82, &dlc);
70 dev_info(&d->
dev,
"PIIX3: Enabling Passive Release\n");
72 pci_write_config_byte(d, 0x82, dlc);
90 dev_info(&dev->
dev,
"Activating ISA DMA hang workarounds\n");
114 pci_read_config_dword(dev, 0x40, &pmbase);
115 pmbase = pmbase & 0xff80;
131 dev_info(&dev->
dev,
"Disabling direct PCI/PCI transfers\n");
141 pci_read_config_byte(dev, 0x08, &rev);
144 dev_info(&dev->
dev,
"Chipset erratum: Disabling direct PCI/AGP transfers\n");
156 dev_info(&dev->
dev,
"Limiting direct PCI/PCI transfers\n");
176 static void quirk_vialatency(
struct pci_dev *dev)
211 pci_read_config_byte(dev, 0x76, &busarb);
216 pci_write_config_byte(dev, 0x76, busarb);
217 dev_info(&dev->
dev,
"Applying VIA southbridge workaround\n");
235 dev_info(&dev->
dev,
"Limiting direct PCI/PCI transfers\n");
244 dev_info(&dev->
dev,
"Limiting direct PCI/PCI transfers\n");
259 dev_info(&dev->
dev,
"Limiting direct PCI/PCI transfers\n");
273 dev_info(&dev->
dev,
"Limiting direct PCI/PCI transfers\n");
302 if ((r->
start & 0x3ffffff) || r->
end != r->
start + 0x3ffffff) {
321 dev_info(&dev->
dev,
"CS5536 ISA bridge bug detected "
322 "(incorrect header); workaround applied.\n");
335 res->
name = pci_name(dev);
337 res->
end = region + size - 1;
341 bus_region.start = res->
start;
342 bus_region.end = res->
end;
357 dev_info(&dev->
dev,
"ATI Northbridge, reserving I/O ports 0x3b0 to 0x3bb\n");
379 pci_read_config_word(dev, 0xE0, ®ion);
381 pci_read_config_word(dev, 0xE2, ®ion);
386 static void piix4_io_quirk(
struct pci_dev *dev,
const char *name,
unsigned int port,
unsigned int enable)
391 pci_read_config_dword(dev, port, &devres);
392 if ((devres & enable) != enable)
394 mask = (devres >> 16) & 15;
395 base = devres & 0xffff;
398 unsigned bit = size >> 1;
399 if ((bit & mask) ==
bit)
409 dev_info(&dev->
dev,
"%s PIO at %04x-%04x\n", name, base, base + size - 1);
412 static void piix4_mem_quirk(
struct pci_dev *dev,
const char *name,
unsigned int port,
unsigned int enable)
417 pci_read_config_dword(dev, port, &devres);
418 if ((devres & enable) != enable)
420 base = devres & 0xffff0000;
421 mask = (devres & 0x3f) << 16;
424 unsigned bit = size >> 1;
425 if ((bit & mask) ==
bit)
434 dev_info(&dev->
dev,
"%s MMIO at %04x-%04x\n", name, base, base + size - 1);
447 pci_read_config_dword(dev, 0x40, ®ion);
449 pci_read_config_dword(dev, 0x90, ®ion);
453 pci_read_config_dword(dev, 0x5c, &res_a);
455 piix4_io_quirk(dev,
"PIIX4 devres B", 0x60, 3 << 21);
456 piix4_io_quirk(dev,
"PIIX4 devres C", 0x64, 3 << 21);
461 if (res_a & (1 << 29)) {
462 piix4_io_quirk(dev,
"PIIX4 devres E", 0x68, 1 << 20);
463 piix4_mem_quirk(dev,
"PIIX4 devres F", 0x6c, 1 << 7);
466 if (res_a & (1 << 30)) {
467 piix4_io_quirk(dev,
"PIIX4 devres G", 0x70, 1 << 20);
468 piix4_mem_quirk(dev,
"PIIX4 devres H", 0x74, 1 << 7);
470 piix4_io_quirk(dev,
"PIIX4 devres I", 0x78, 1 << 20);
471 piix4_io_quirk(dev,
"PIIX4 devres J", 0x7c, 1 << 20);
476 #define ICH_PMBASE 0x40
477 #define ICH_ACPI_CNTL 0x44
478 #define ICH4_ACPI_EN 0x10
479 #define ICH6_ACPI_EN 0x80
480 #define ICH4_GPIOBASE 0x58
481 #define ICH4_GPIO_CNTL 0x5c
482 #define ICH4_GPIO_EN 0x10
483 #define ICH6_GPIOBASE 0x48
484 #define ICH6_GPIO_CNTL 0x4c
485 #define ICH6_GPIO_EN 0x10
507 pci_read_config_dword(dev,
ICH_PMBASE, ®ion);
511 "ICH4 ACPI/GPIO/TCO");
519 quirk_io_region(dev, region, 64,
541 pci_read_config_dword(dev,
ICH_PMBASE, ®ion);
545 "ICH6 ACPI/GPIO/TCO");
553 quirk_io_region(dev, region, 64,
558 static void __devinit ich6_lpc_generic_decode(
struct pci_dev *dev,
unsigned reg,
const char *name,
int dynsize)
563 pci_read_config_dword(dev, reg, &val);
583 dev_info(&dev->
dev,
"%s PIO at %04x-%04x\n", name, base, base+size-1);
589 ich6_lpc_acpi_gpio(dev);
592 ich6_lpc_generic_decode(dev, 0x84,
"LPC Generic IO decode 1", 0);
593 ich6_lpc_generic_decode(dev, 0x88,
"LPC Generic IO decode 2", 1);
598 static void __devinit ich7_lpc_generic_decode(
struct pci_dev *dev,
unsigned reg,
const char *name)
603 pci_read_config_dword(dev, reg, &val);
614 mask = (val >> 16) & 0xfc;
618 dev_info(&dev->
dev,
"%s PIO at %04x (mask %04x)\n", name, base, mask);
625 ich6_lpc_acpi_gpio(dev);
628 ich7_lpc_generic_decode(dev, 0x84,
"ICH7 LPC Generic IO decode 1");
629 ich7_lpc_generic_decode(dev, 0x88,
"ICH7 LPC Generic IO decode 2");
630 ich7_lpc_generic_decode(dev, 0x8c,
"ICH7 LPC Generic IO decode 3");
631 ich7_lpc_generic_decode(dev, 0x90,
"ICH7 LPC Generic IO decode 4");
656 pci_read_config_dword(dev, 0x48, ®ion);
674 quirk_vt82c586_acpi(dev);
676 pci_read_config_word(dev, 0x70, &hm);
680 pci_read_config_dword(dev, 0x90, &smb);
695 pci_read_config_word(dev, 0x88, &pm);
699 pci_read_config_word(dev, 0xd0, &smb);
715 "secondary bus fast back-to-back transfers disabled\n");
719 pci_write_config_word(pdev,
PCI_COMMAND, command & ~PCI_COMMAND_FAST_BACK);
725 #ifdef CONFIG_X86_IO_APIC
736 static void quirk_via_ioapic(
struct pci_dev *dev)
745 dev_info(&dev->
dev,
"%sbling VIA external APIC routing\n",
746 tmp == 0 ?
"Disa" :
"Ena");
749 pci_write_config_byte (dev, 0x58, tmp);
760 static void quirk_via_vt8237_bypass_apic_deassert(
struct pci_dev *dev)
763 #define BYPASS_APIC_DEASSERT 8
765 pci_read_config_byte(dev, 0x5B, &misc_control2);
766 if (!(misc_control2 & BYPASS_APIC_DEASSERT)) {
767 dev_info(&dev->
dev,
"Bypassing VIA 8237 APIC De-Assert Message\n");
768 pci_write_config_byte(dev, 0x5B, misc_control2|BYPASS_APIC_DEASSERT);
786 dev_warn(&dev->
dev,
"I/O APIC: AMD Erratum #22 may be present. In the event of instability try\n");
787 dev_warn(&dev->
dev,
" : booting with the \"noapic\" option\n");
794 if (dev->
devfn == 0 && dev->
bus->number == 0)
808 "disabling PCI-X MMRBC\n", dev->
revision);
828 pci_read_config_byte(d, 0x42, &irq);
830 if (irq && (irq != 2))
841 static int via_vlink_dev_lo = -1, via_vlink_dev_hi = 18;
843 static void quirk_via_bridge(
struct pci_dev *dev)
856 via_vlink_dev_lo = 15;
859 via_vlink_dev_lo = 16;
865 via_vlink_dev_lo = 17;
891 static void quirk_via_vlink(
struct pci_dev *dev)
896 if (via_vlink_dev_lo == -1)
902 if (!new_irq || new_irq > 15)
914 if (new_irq != irq) {
915 dev_info(&dev->
dev,
"VIA VLink IRQ fixup, from %d to %d\n",
931 pci_write_config_byte(dev, 0xfc, 0);
942 static void quirk_cardbus_legacy(
struct pci_dev *dev)
958 static void quirk_amd_ordering(
struct pci_dev *dev)
961 pci_read_config_dword(dev, 0x4C, &pcic);
964 dev_warn(&dev->
dev,
"BIOS failed to enable PCI standards compliance; fixing this error\n");
965 pci_write_config_dword(dev, 0x4C, pcic);
966 pci_read_config_dword(dev, 0x84, &pcic);
968 pci_write_config_dword(dev, 0x84, pcic);
1008 static void quirk_mediagx_master(
struct pci_dev *dev)
1011 pci_read_config_byte(dev, 0x41, ®);
1014 dev_info(&dev->
dev,
"Fixup for MediaGX/Geode Slave Disconnect Boundary (0x41=0x%02x)\n", reg);
1015 pci_write_config_byte(dev, 0x41, reg);
1026 static void quirk_disable_pxb(
struct pci_dev *pdev)
1032 pci_read_config_word(pdev, 0x40, &config);
1033 if (config & (1<<6)) {
1035 pci_write_config_word(pdev, 0x40, config);
1036 dev_info(&pdev->
dev,
"C0 revision 450NX. Disabling PCI restreaming\n");
1042 static void quirk_amd_ide_mode(
struct pci_dev *pdev)
1049 pci_read_config_byte(pdev, 0x40, &tmp);
1050 pci_write_config_byte(pdev, 0x40, tmp|1);
1051 pci_write_config_byte(pdev, 0x9, 1);
1052 pci_write_config_byte(pdev, 0xa, 6);
1053 pci_write_config_byte(pdev, 0x40, tmp);
1091 if (((prog & 1) && !(prog & 4)) || ((prog & 4) && !(prog & 1))) {
1092 dev_info(&pdev->
dev,
"IDE mode mismatch; forcing legacy mode\n");
1156 static int asus_hides_smbus;
1167 asus_hides_smbus = 1;
1174 asus_hides_smbus = 1;
1179 asus_hides_smbus = 1;
1184 asus_hides_smbus = 1;
1189 asus_hides_smbus = 1;
1196 asus_hides_smbus = 1;
1202 asus_hides_smbus = 1;
1207 asus_hides_smbus = 1;
1213 asus_hides_smbus = 1;
1220 asus_hides_smbus = 1;
1227 asus_hides_smbus = 1;
1232 asus_hides_smbus = 1;
1238 asus_hides_smbus = 1;
1244 asus_hides_smbus = 1;
1252 asus_hides_smbus = 1;
1264 asus_hides_smbus = 1;
1272 asus_hides_smbus = 1;
1291 static void asus_hides_smbus_lpc(
struct pci_dev *dev)
1295 if (
likely(!asus_hides_smbus))
1298 pci_read_config_word(dev, 0xF2, &val);
1300 pci_write_config_word(dev, 0xF2, val & (~0x8));
1301 pci_read_config_word(dev, 0xF2, &val);
1303 dev_info(&dev->
dev,
"i801 SMBus device continues to play 'hide and seek'! 0x%x\n", val);
1305 dev_info(&dev->
dev,
"Enabled i801 SMBus device\n");
1324 static void __iomem *asus_rcba_base;
1325 static void asus_hides_smbus_lpc_ich6_suspend(
struct pci_dev *dev)
1329 if (
likely(!asus_hides_smbus))
1333 pci_read_config_dword(dev, 0xF0, &rcba);
1336 if (asus_rcba_base ==
NULL)
1340 static void asus_hides_smbus_lpc_ich6_resume_early(
struct pci_dev *dev)
1344 if (
likely(!asus_hides_smbus || !asus_rcba_base))
1347 val =
readl(asus_rcba_base + 0x3418);
1348 writel(val & 0xFFFFFFF7, asus_rcba_base + 0x3418);
1351 static void asus_hides_smbus_lpc_ich6_resume(
struct pci_dev *dev)
1353 if (
likely(!asus_hides_smbus || !asus_rcba_base))
1356 asus_rcba_base =
NULL;
1357 dev_info(&dev->
dev,
"Enabled ICH6/i801 SMBus device\n");
1360 static void asus_hides_smbus_lpc_ich6(
struct pci_dev *dev)
1362 asus_hides_smbus_lpc_ich6_suspend(dev);
1363 asus_hides_smbus_lpc_ich6_resume_early(dev);
1364 asus_hides_smbus_lpc_ich6_resume(dev);
1374 static void quirk_sis_96x_smbus(
struct pci_dev *dev)
1377 pci_read_config_byte(dev, 0x77, &val);
1380 pci_write_config_byte(dev, 0x77, val & ~0x10);
1400 #define SIS_DETECT_REGISTER 0x40
1402 static void quirk_sis_503(
struct pci_dev *dev)
1410 if (((devid & 0xfff0) != 0x0960) && (devid != 0x0018)) {
1421 quirk_sis_96x_smbus(dev);
1433 static void asus_hides_ac97_lpc(
struct pci_dev *dev)
1436 int asus_hides_ac97 = 0;
1440 asus_hides_ac97 = 1;
1443 if (!asus_hides_ac97)
1446 pci_read_config_byte(dev, 0x50, &val);
1448 pci_write_config_byte(dev, 0x50, val & (~0xc0));
1449 pci_read_config_byte(dev, 0x50, &val);
1451 dev_info(&dev->
dev,
"Onboard AC97/MC97 devices continue to play 'hide and seek'! 0x%x\n", val);
1453 dev_info(&dev->
dev,
"Enabled onboard AC97/MC97 devices\n");
1459 #if defined(CONFIG_ATA) || defined(CONFIG_ATA_MODULE)
1466 static void quirk_jmicron_ata(
struct pci_dev *pdev)
1468 u32 conf1, conf5,
class;
1475 pci_read_config_dword(pdev, 0x40, &conf1);
1476 pci_read_config_dword(pdev, 0x80, &conf5);
1478 conf1 &= ~0x00CFF302;
1479 conf5 &= ~(1 << 24);
1486 conf1 |= 0x0002A100;
1499 conf1 |= 0x00C2A1B3;
1504 conf1 |= 0x00C00000;
1508 pci_write_config_dword(pdev, 0x40, conf1);
1509 pci_write_config_dword(pdev, 0x80, conf5);
1517 pdev->
class =
class >> 8;
1540 #ifdef CONFIG_X86_IO_APIC
1545 if ((pdev->
class >> 8) != 0xff00)
1556 for (i=1; i < 6; i++) {
1582 dev_warn(&dev->
dev,
"PXH quirk detected; SHPC device MSI disabled\n");
1594 static void quirk_intel_pcie_pm(
struct pci_dev * dev)
1622 #ifdef CONFIG_X86_IO_APIC
1629 static void quirk_reroute_to_boot_interrupts_intel(
struct pci_dev *dev)
1635 dev_info(&dev->
dev,
"rerouting interrupts for [%04x:%04x]\n",
1664 #define INTEL_6300_IOAPIC_ABAR 0x40
1665 #define INTEL_6300_DISABLE_BOOT_IRQ (1<<14)
1667 static void quirk_disable_intel_boot_interrupt(
struct pci_dev *dev)
1669 u16 pci_config_word;
1674 pci_read_config_word(dev, INTEL_6300_IOAPIC_ABAR, &pci_config_word);
1675 pci_config_word |= INTEL_6300_DISABLE_BOOT_IRQ;
1676 pci_write_config_word(dev, INTEL_6300_IOAPIC_ABAR, pci_config_word);
1678 dev_info(&dev->
dev,
"disabled boot interrupts on device [%04x:%04x]\n",
1687 #define BC_HT1000_FEATURE_REG 0x64
1688 #define BC_HT1000_PIC_REGS_ENABLE (1<<0)
1689 #define BC_HT1000_MAP_IDX 0xC00
1690 #define BC_HT1000_MAP_DATA 0xC01
1692 static void quirk_disable_broadcom_boot_interrupt(
struct pci_dev *dev)
1694 u32 pci_config_dword;
1700 pci_read_config_dword(dev, BC_HT1000_FEATURE_REG, &pci_config_dword);
1701 pci_write_config_dword(dev, BC_HT1000_FEATURE_REG, pci_config_dword |
1702 BC_HT1000_PIC_REGS_ENABLE);
1704 for (irq = 0x10; irq < 0x10 + 32; irq++) {
1705 outb(irq, BC_HT1000_MAP_IDX);
1706 outb(0x00, BC_HT1000_MAP_DATA);
1709 pci_write_config_dword(dev, BC_HT1000_FEATURE_REG, pci_config_dword);
1711 dev_info(&dev->
dev,
"disabled boot interrupts on device [%04x:%04x]\n",
1725 #define AMD_813X_MISC 0x40
1726 #define AMD_813X_NOIOAMODE (1<<0)
1727 #define AMD_813X_REV_B1 0x12
1728 #define AMD_813X_REV_B2 0x13
1730 static void quirk_disable_amd_813x_boot_interrupt(
struct pci_dev *dev)
1732 u32 pci_config_dword;
1736 if ((dev->
revision == AMD_813X_REV_B1) ||
1737 (dev->
revision == AMD_813X_REV_B2))
1740 pci_read_config_dword(dev, AMD_813X_MISC, &pci_config_dword);
1741 pci_config_dword &= ~AMD_813X_NOIOAMODE;
1742 pci_write_config_dword(dev, AMD_813X_MISC, pci_config_dword);
1744 dev_info(&dev->
dev,
"disabled boot interrupts on device [%04x:%04x]\n",
1752 #define AMD_8111_PCI_IRQ_ROUTING 0x56
1754 static void quirk_disable_amd_8111_boot_interrupt(
struct pci_dev *dev)
1756 u16 pci_config_word;
1761 pci_read_config_word(dev, AMD_8111_PCI_IRQ_ROUTING, &pci_config_word);
1762 if (!pci_config_word) {
1763 dev_info(&dev->
dev,
"boot interrupts on device [%04x:%04x] "
1767 pci_write_config_word(dev, AMD_8111_PCI_IRQ_ROUTING, 0);
1768 dev_info(&dev->
dev,
"disabled boot interrupts on device [%04x:%04x]\n",
1784 if (r->
start & 0x8) {
1791 quirk_tc86c001_ide);
1820 "%u serial); changing class SERIAL to OTHER "
1821 "(use parport_serial)\n",
1822 dev->
device, num_parallel, num_serial);
1824 (dev->
class & 0xff);
1841 case 0x1030 ... 0x1034:
1842 case 0x1038 ... 0x103E:
1843 case 0x1050 ... 0x1057:
1845 case 0x1064 ... 0x106B:
1846 case 0x1091 ... 0x1095:
1876 pci_read_config_word(dev, pm +
PCI_PM_CTRL, &pmcsr);
1884 dev_warn(&dev->
dev,
"Can't map e100 registers\n");
1888 cmd_hi =
readb(csr + 3);
1890 dev_warn(&dev->
dev,
"Firmware left e100 interrupts enabled; "
1931 dev_info(&dev->
dev,
"NCR 53c810 rev 1 detected; setting PCI class\n");
1942 pci_read_config_word(dev, 0x40, &en1k);
1945 dev_info(&dev->
dev,
"Enable I/O Space to 1KB granularity\n");
1955 static void quirk_nvidia_ck804_pcie_aer_ext_cap(
struct pci_dev *dev)
1958 if (pci_read_config_byte(dev, 0xf41, &b) == 0) {
1960 pci_write_config_byte(dev, 0xf41, b | 0x20);
1962 "Linking AER extended capability\n");
1967 quirk_nvidia_ck804_pcie_aer_ext_cap);
1969 quirk_nvidia_ck804_pcie_aer_ext_cap);
1971 static void __devinit quirk_via_cx700_pci_parking_caching(
struct pci_dev *dev)
1995 if (pci_read_config_byte(dev, 0x76, &b) == 0) {
1998 pci_write_config_byte(dev, 0x76, b ^ 0x40);
2001 "Disabling VIA CX700 PCI parking\n");
2005 if (pci_read_config_byte(dev, 0x72, &b) == 0) {
2008 pci_write_config_byte(dev, 0x72, 0x0);
2011 pci_write_config_byte(dev, 0x75, 0x1);
2014 pci_write_config_byte(dev, 0x77, 0x0);
2017 "Disabling VIA CX700 PCI caching\n");
2047 dev->
vpd->len = 0x80;
2053 quirk_brcm_570x_limit_vpd);
2056 quirk_brcm_570x_limit_vpd);
2059 quirk_brcm_570x_limit_vpd);
2062 quirk_brcm_570x_limit_vpd);
2065 quirk_brcm_570x_limit_vpd);
2068 quirk_brcm_570x_limit_vpd);
2070 static void quirk_brcm_5719_limit_mrrs(
struct pci_dev *dev)
2074 pci_read_config_dword(dev, 0xf4, &rev);
2077 if (rev == 0x05719000) {
2086 quirk_brcm_5719_limit_mrrs);
2098 if (pci_read_config_byte(dev, 0xF4, ®) == 0 && !(reg & 0x02)) {
2099 dev_info(&dev->
dev,
"Enabling MCH 'Overflow' Device\n");
2100 pci_write_config_byte(dev, 0xF4, reg | 0x02);
2105 quirk_unhide_mch_dev6);
2107 quirk_unhide_mch_dev6);
2109 #ifdef CONFIG_TILEPRO
2121 pci_write_config_dword(dev, 0x98, 0x1);
2128 #ifdef CONFIG_PCI_MSI
2138 dev_warn(&dev->
dev,
"MSI quirk detected; MSI disabled\n");
2153 "subordinate MSI disabled\n");
2173 if (apc_bridge->
device == 0x9602)
2174 quirk_disable_msi(apc_bridge);
2183 static int msi_ht_cap_enabled(
struct pci_dev *dev)
2188 while (pos && ttl--) {
2196 "enabled" :
"disabled");
2207 static void quirk_msi_ht_cap(
struct pci_dev *dev)
2209 if (dev->
subordinate && !msi_ht_cap_enabled(dev)) {
2211 "subordinate MSI disabled\n");
2221 static void quirk_nvidia_ck804_msi_ht_cap(
struct pci_dev *dev)
2234 if (!msi_ht_cap_enabled(dev) && !msi_ht_cap_enabled(pdev)) {
2236 "subordinate MSI disabled\n");
2242 quirk_nvidia_ck804_msi_ht_cap);
2245 static void ht_enable_msi_mapping(
struct pci_dev *dev)
2250 while (pos && ttl--) {
2266 ht_enable_msi_mapping);
2269 ht_enable_msi_mapping);
2280 (
strstr(board_name,
"P5N32-SLI PREMIUM") ||
2281 strstr(board_name,
"P5N32-E SLI"))) {
2283 "Disabling msi for MCP55 NIC on P5N32-SLI\n");
2289 nvenet_msi_disable);
2301 static void __devinit nvbridge_check_legacy_irq_routing(
struct pci_dev *dev)
2308 pci_read_config_dword(dev, 0x74, &cfg);
2310 if (cfg & ((1 << 2) | (1 << 15))) {
2312 cfg &= ~((1 << 2) | (1 << 15));
2313 pci_write_config_dword(dev, 0x74, cfg);
2319 nvbridge_check_legacy_irq_routing);
2323 nvbridge_check_legacy_irq_routing);
2325 static int ht_check_msi_mapping(
struct pci_dev *dev)
2332 while (pos && ttl--) {
2353 static int host_bridge_with_leaf(
struct pci_dev *host_bridge)
2360 dev_no = host_bridge->
devfn >> 3;
2361 for (i = dev_no + 1; i < 0x20; i++) {
2373 if (ht_check_msi_mapping(dev)) {
2384 #define PCI_HT_CAP_SLAVE_CTRL0 4
2385 #define PCI_HT_CAP_SLAVE_CTRL1 8
2387 static int is_end_of_ht_chain(
struct pci_dev *dev)
2400 ctrl_off = ((flags >> 10) & 1) ?
2401 PCI_HT_CAP_SLAVE_CTRL0 : PCI_HT_CAP_SLAVE_CTRL1;
2402 pci_read_config_word(dev, pos + ctrl_off, &ctrl);
2404 if (ctrl & (1 << 6))
2411 static void nv_ht_enable_msi_mapping(
struct pci_dev *dev)
2418 dev_no = dev->
devfn >> 3;
2419 for (i = dev_no; i >= 0; i--) {
2436 if (host_bridge == dev && is_end_of_ht_chain(host_bridge) &&
2437 host_bridge_with_leaf(host_bridge))
2441 if (msi_ht_cap_enabled(host_bridge))
2444 ht_enable_msi_mapping(dev);
2450 static void ht_disable_msi_mapping(
struct pci_dev *dev)
2455 while (pos && ttl--) {
2460 dev_info(&dev->
dev,
"Disabling HT MSI Mapping\n");
2470 static void __nv_msi_ht_cap_quirk(
struct pci_dev *dev,
int all)
2480 found = ht_check_msi_mapping(dev);
2491 if (host_bridge ==
NULL) {
2493 "nv_msi_ht_cap_quirk didn't locate host bridge\n");
2503 ht_enable_msi_mapping(dev);
2505 nv_ht_enable_msi_mapping(dev);
2515 ht_disable_msi_mapping(dev);
2521 static void nv_msi_ht_cap_quirk_all(
struct pci_dev *dev)
2523 return __nv_msi_ht_cap_quirk(dev, 1);
2526 static void nv_msi_ht_cap_quirk_leaf(
struct pci_dev *dev)
2528 return __nv_msi_ht_cap_quirk(dev, 0);
2560 quirk_msi_intx_disable_bug);
2563 quirk_msi_intx_disable_bug);
2566 quirk_msi_intx_disable_bug);
2569 quirk_msi_intx_disable_bug);
2572 quirk_msi_intx_disable_bug);
2575 quirk_msi_intx_disable_bug);
2578 quirk_msi_intx_disable_ati_bug);
2580 quirk_msi_intx_disable_ati_bug);
2582 quirk_msi_intx_disable_ati_bug);
2584 quirk_msi_intx_disable_ati_bug);
2586 quirk_msi_intx_disable_ati_bug);
2589 quirk_msi_intx_disable_bug);
2591 quirk_msi_intx_disable_bug);
2593 quirk_msi_intx_disable_bug);
2596 quirk_msi_intx_disable_bug);
2598 quirk_msi_intx_disable_bug);
2600 quirk_msi_intx_disable_bug);
2602 quirk_msi_intx_disable_bug);
2604 quirk_msi_intx_disable_bug);
2606 quirk_msi_intx_disable_bug);
2649 #ifdef CONFIG_MMC_RICOH_MMC
2650 static void ricoh_mmc_fixup_rl5c476(
struct pci_dev *dev)
2661 pci_read_config_byte(dev, 0xB7, &disable);
2665 pci_read_config_byte(dev, 0x8E, &write_enable);
2666 pci_write_config_byte(dev, 0x8E, 0xAA);
2667 pci_read_config_byte(dev, 0x8D, &write_target);
2668 pci_write_config_byte(dev, 0x8D, 0xB7);
2669 pci_write_config_byte(dev, 0xB7, disable | 0x02);
2670 pci_write_config_byte(dev, 0x8E, write_enable);
2671 pci_write_config_byte(dev, 0x8D, write_target);
2673 dev_notice(&dev->
dev,
"proprietary Ricoh MMC controller disabled (via cardbus function)\n");
2674 dev_notice(&dev->
dev,
"MMC cards are now supported by standard SDHCI controller\n");
2679 static void ricoh_mmc_fixup_r5c832(
struct pci_dev *dev)
2701 pci_write_config_byte(dev, 0xf9, 0xfc);
2702 pci_write_config_byte(dev, 0x150, 0x10);
2703 pci_write_config_byte(dev, 0xf9, 0x00);
2704 pci_write_config_byte(dev, 0xfc, 0x01);
2705 pci_write_config_byte(dev, 0xe1, 0x32);
2706 pci_write_config_byte(dev, 0xfc, 0x00);
2708 dev_notice(&dev->
dev,
"MMC controller base frequency changed to 50Mhz.\n");
2711 pci_read_config_byte(dev, 0xCB, &disable);
2716 pci_read_config_byte(dev, 0xCA, &write_enable);
2717 pci_write_config_byte(dev, 0xCA, 0x57);
2718 pci_write_config_byte(dev, 0xCB, disable | 0x02);
2719 pci_write_config_byte(dev, 0xCA, write_enable);
2721 dev_notice(&dev->
dev,
"proprietary Ricoh MMC controller disabled (via firewire function)\n");
2722 dev_notice(&dev->
dev,
"MMC cards are now supported by standard SDHCI controller\n");
2731 #ifdef CONFIG_DMAR_TABLE
2732 #define VTUNCERRMSK_REG 0x1ac
2733 #define VTD_MSK_SPEC_ERRORS (1 << 31)
2744 static void vtd_mask_spec_errors(
struct pci_dev *dev)
2748 pci_read_config_dword(dev, VTUNCERRMSK_REG, &word);
2749 pci_write_config_dword(dev, VTUNCERRMSK_REG, word | VTD_MSK_SPEC_ERRORS);
2758 dev_info(&dev->
dev,
"Setting PCI class for 816x PCIe device\n");
2797 err = pci_read_config_word(dev, 0x48, &rcc);
2799 dev_err(&dev->
dev,
"Error attempting to read the read "
2800 "completion coalescing register.\n");
2804 if (!(rcc & (1 << 10)))
2809 err = pci_write_config_word(dev, 0x48, rcc);
2811 dev_err(&dev->
dev,
"Error attempting to write the read "
2812 "completion coalescing register.\n");
2816 pr_info_once(
"Read completion coalescing disabled due to hardware "
2817 "errata relating to 256B MPS.\n");
2851 ktime_t calltime = ktime_set(0, 0);
2855 pr_debug(
"calling %pF @ %i for %s\n",
2863 static void fixup_debug_report(
struct pci_dev *dev,
ktime_t calltime,
2871 delta = ktime_sub(rettime, calltime);
2872 duration = (
unsigned long long) ktime_to_ns(delta) >> 10;
2873 pr_debug(
"pci fixup %pF returned after %lld usecs for %s\n",
2874 fn, duration, dev_name(&dev->
dev));
2890 #define I915_DEIER_REG 0x4400c
2895 dev_warn(&dev->
dev,
"igfx quirk: Can't iomap PCI device\n");
2901 dev_warn(&dev->
dev,
"BIOS left Intel GPU interrupts enabled; "
2922 quirk_broken_intx_masking);
2924 quirk_broken_intx_masking);
2931 for (; f <
end; f++)
2938 calltime = fixup_debug_start(dev, f->
hook);
2940 fixup_debug_report(dev, calltime, f->
hook);
2959 static bool pci_apply_fixup_final_quirks;
2977 if (!pci_apply_fixup_final_quirks)
3007 pci_do_fixups(dev, start, end);
3012 static int __init pci_apply_final_quirks(
void)
3022 pci_apply_fixup_final_quirks =
true;
3034 if (!tmp || cls == tmp)
3038 "using %u bytes\n", cls << 2, tmp << 2,
3039 pci_dfl_cache_line_size << 2);
3046 cls << 2, pci_dfl_cache_line_size << 2);
3060 static int reset_intel_generic_dev(
struct pci_dev *dev,
int probe)
3073 pci_write_config_byte(dev, pos + 0x4, 1);
3082 static int reset_intel_82599_sfp_virtfn(
struct pci_dev *dev,
int probe)
3099 for (i = 0; i < 4; i++) {
3101 msleep((1 << (i - 1)) * 100);
3108 dev_err(&dev->
dev,
"transaction is not cleared; "
3109 "proceeding with reset anyway\n");
3119 #include "../gpu/drm/i915/i915_reg.h"
3120 #define MSG_CTL 0x45010
3121 #define NSDE_PWR_STATE 0xd0100
3122 #define IGD_OPERATION_TIMEOUT 10000
3124 static int reset_ivb_igd(
struct pci_dev *dev,
int probe)
3133 mmio_base = pci_iomap(dev, 0, 0);
3153 if ((val & 0xb0000000) == 0)
3154 goto reset_complete;
3166 #define PCI_DEVICE_ID_INTEL_82599_SFP_VF 0x10ed
3167 #define PCI_DEVICE_ID_INTEL_IVB_M_VGA 0x0156
3168 #define PCI_DEVICE_ID_INTEL_IVB_M2_VGA 0x0166
3172 reset_intel_82599_sfp_virtfn },
3178 reset_intel_generic_dev },
3189 const struct pci_dev_reset_methods *
i;
3191 for (i = pci_dev_reset_methods; i->
reset; i++) {
3196 return i->
reset(dev, probe);
3202 static struct pci_dev *pci_func_0_dma_source(
struct pci_dev *dev)
3210 static const struct pci_dev_dma_source {
3214 } pci_dev_dma_source[] = {
3240 const struct pci_dev_dma_source *
i;
3242 for (i = pci_dev_dma_source; i->dma_source; i++) {
3243 if ((i->vendor == dev->
vendor ||
3244 i->vendor == (
u16)PCI_ANY_ID) &&
3245 (i->device == dev->
device ||
3246 i->device == (
u16)PCI_ANY_ID))
3247 return i->dma_source(dev);
3253 static const struct pci_dev_acs_enabled {
3257 } pci_dev_acs_enabled[] = {
3263 const struct pci_dev_acs_enabled *
i;
3272 for (i = pci_dev_acs_enabled; i->acs_enabled; i++) {
3273 if ((i->vendor == dev->
vendor ||
3274 i->vendor == (
u16)PCI_ANY_ID) &&
3275 (i->device == dev->
device ||
3276 i->device == (
u16)PCI_ANY_ID)) {
3277 ret = i->acs_enabled(dev, acs_flags);