18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * This file contains work-arounds for many known PCI hardware bugs. 48c2ecf20Sopenharmony_ci * Devices present only on certain architectures (host bridges et cetera) 58c2ecf20Sopenharmony_ci * should be handled in arch-specific code. 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Note: any quirks for hotpluggable devices must _NOT_ be declared __init. 88c2ecf20Sopenharmony_ci * 98c2ecf20Sopenharmony_ci * Copyright (c) 1999 Martin Mares <mj@ucw.cz> 108c2ecf20Sopenharmony_ci * 118c2ecf20Sopenharmony_ci * Init/reset quirks for USB host controllers should be in the USB quirks 128c2ecf20Sopenharmony_ci * file, where their drivers can use them. 138c2ecf20Sopenharmony_ci */ 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#include <linux/types.h> 168c2ecf20Sopenharmony_ci#include <linux/kernel.h> 178c2ecf20Sopenharmony_ci#include <linux/export.h> 188c2ecf20Sopenharmony_ci#include <linux/pci.h> 198c2ecf20Sopenharmony_ci#include <linux/init.h> 208c2ecf20Sopenharmony_ci#include <linux/delay.h> 218c2ecf20Sopenharmony_ci#include <linux/acpi.h> 228c2ecf20Sopenharmony_ci#include <linux/dmi.h> 238c2ecf20Sopenharmony_ci#include <linux/ioport.h> 248c2ecf20Sopenharmony_ci#include <linux/sched.h> 258c2ecf20Sopenharmony_ci#include <linux/ktime.h> 268c2ecf20Sopenharmony_ci#include <linux/mm.h> 278c2ecf20Sopenharmony_ci#include <linux/nvme.h> 288c2ecf20Sopenharmony_ci#include <linux/platform_data/x86/apple.h> 298c2ecf20Sopenharmony_ci#include <linux/pm_runtime.h> 308c2ecf20Sopenharmony_ci#include <linux/suspend.h> 318c2ecf20Sopenharmony_ci#include <linux/switchtec.h> 328c2ecf20Sopenharmony_ci#include <linux/vgaarb.h> 338c2ecf20Sopenharmony_ci#include <asm/dma.h> /* isa_dma_bridge_buggy */ 348c2ecf20Sopenharmony_ci#include "pci.h" 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_cistatic ktime_t fixup_debug_start(struct pci_dev *dev, 378c2ecf20Sopenharmony_ci void (*fn)(struct pci_dev *dev)) 388c2ecf20Sopenharmony_ci{ 398c2ecf20Sopenharmony_ci if (initcall_debug) 408c2ecf20Sopenharmony_ci pci_info(dev, "calling %pS @ %i\n", fn, task_pid_nr(current)); 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci return ktime_get(); 438c2ecf20Sopenharmony_ci} 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_cistatic void fixup_debug_report(struct pci_dev *dev, ktime_t calltime, 468c2ecf20Sopenharmony_ci void (*fn)(struct pci_dev *dev)) 478c2ecf20Sopenharmony_ci{ 488c2ecf20Sopenharmony_ci ktime_t delta, rettime; 498c2ecf20Sopenharmony_ci unsigned long long duration; 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci rettime = ktime_get(); 528c2ecf20Sopenharmony_ci delta = ktime_sub(rettime, calltime); 538c2ecf20Sopenharmony_ci duration = (unsigned long long) ktime_to_ns(delta) >> 10; 548c2ecf20Sopenharmony_ci if (initcall_debug || duration > 10000) 558c2ecf20Sopenharmony_ci pci_info(dev, "%pS took %lld usecs\n", fn, duration); 568c2ecf20Sopenharmony_ci} 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_cistatic void pci_do_fixups(struct pci_dev *dev, struct pci_fixup *f, 598c2ecf20Sopenharmony_ci struct pci_fixup *end) 608c2ecf20Sopenharmony_ci{ 618c2ecf20Sopenharmony_ci ktime_t calltime; 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci for (; f < end; f++) 648c2ecf20Sopenharmony_ci if ((f->class == (u32) (dev->class >> f->class_shift) || 658c2ecf20Sopenharmony_ci f->class == (u32) PCI_ANY_ID) && 668c2ecf20Sopenharmony_ci (f->vendor == dev->vendor || 678c2ecf20Sopenharmony_ci f->vendor == (u16) PCI_ANY_ID) && 688c2ecf20Sopenharmony_ci (f->device == dev->device || 698c2ecf20Sopenharmony_ci f->device == (u16) PCI_ANY_ID)) { 708c2ecf20Sopenharmony_ci void (*hook)(struct pci_dev *dev); 718c2ecf20Sopenharmony_ci#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS 728c2ecf20Sopenharmony_ci hook = offset_to_ptr(&f->hook_offset); 738c2ecf20Sopenharmony_ci#else 748c2ecf20Sopenharmony_ci hook = f->hook; 758c2ecf20Sopenharmony_ci#endif 768c2ecf20Sopenharmony_ci calltime = fixup_debug_start(dev, hook); 778c2ecf20Sopenharmony_ci hook(dev); 788c2ecf20Sopenharmony_ci fixup_debug_report(dev, calltime, hook); 798c2ecf20Sopenharmony_ci } 808c2ecf20Sopenharmony_ci} 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ciextern struct pci_fixup __start_pci_fixups_early[]; 838c2ecf20Sopenharmony_ciextern struct pci_fixup __end_pci_fixups_early[]; 848c2ecf20Sopenharmony_ciextern struct pci_fixup __start_pci_fixups_header[]; 858c2ecf20Sopenharmony_ciextern struct pci_fixup __end_pci_fixups_header[]; 868c2ecf20Sopenharmony_ciextern struct pci_fixup __start_pci_fixups_final[]; 878c2ecf20Sopenharmony_ciextern struct pci_fixup __end_pci_fixups_final[]; 888c2ecf20Sopenharmony_ciextern struct pci_fixup __start_pci_fixups_enable[]; 898c2ecf20Sopenharmony_ciextern struct pci_fixup __end_pci_fixups_enable[]; 908c2ecf20Sopenharmony_ciextern struct pci_fixup __start_pci_fixups_resume[]; 918c2ecf20Sopenharmony_ciextern struct pci_fixup __end_pci_fixups_resume[]; 928c2ecf20Sopenharmony_ciextern struct pci_fixup __start_pci_fixups_resume_early[]; 938c2ecf20Sopenharmony_ciextern struct pci_fixup __end_pci_fixups_resume_early[]; 948c2ecf20Sopenharmony_ciextern struct pci_fixup __start_pci_fixups_suspend[]; 958c2ecf20Sopenharmony_ciextern struct pci_fixup __end_pci_fixups_suspend[]; 968c2ecf20Sopenharmony_ciextern struct pci_fixup __start_pci_fixups_suspend_late[]; 978c2ecf20Sopenharmony_ciextern struct pci_fixup __end_pci_fixups_suspend_late[]; 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_cistatic bool pci_apply_fixup_final_quirks; 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_civoid pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev) 1028c2ecf20Sopenharmony_ci{ 1038c2ecf20Sopenharmony_ci struct pci_fixup *start, *end; 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_ci switch (pass) { 1068c2ecf20Sopenharmony_ci case pci_fixup_early: 1078c2ecf20Sopenharmony_ci start = __start_pci_fixups_early; 1088c2ecf20Sopenharmony_ci end = __end_pci_fixups_early; 1098c2ecf20Sopenharmony_ci break; 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci case pci_fixup_header: 1128c2ecf20Sopenharmony_ci start = __start_pci_fixups_header; 1138c2ecf20Sopenharmony_ci end = __end_pci_fixups_header; 1148c2ecf20Sopenharmony_ci break; 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ci case pci_fixup_final: 1178c2ecf20Sopenharmony_ci if (!pci_apply_fixup_final_quirks) 1188c2ecf20Sopenharmony_ci return; 1198c2ecf20Sopenharmony_ci start = __start_pci_fixups_final; 1208c2ecf20Sopenharmony_ci end = __end_pci_fixups_final; 1218c2ecf20Sopenharmony_ci break; 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_ci case pci_fixup_enable: 1248c2ecf20Sopenharmony_ci start = __start_pci_fixups_enable; 1258c2ecf20Sopenharmony_ci end = __end_pci_fixups_enable; 1268c2ecf20Sopenharmony_ci break; 1278c2ecf20Sopenharmony_ci 1288c2ecf20Sopenharmony_ci case pci_fixup_resume: 1298c2ecf20Sopenharmony_ci start = __start_pci_fixups_resume; 1308c2ecf20Sopenharmony_ci end = __end_pci_fixups_resume; 1318c2ecf20Sopenharmony_ci break; 1328c2ecf20Sopenharmony_ci 1338c2ecf20Sopenharmony_ci case pci_fixup_resume_early: 1348c2ecf20Sopenharmony_ci start = __start_pci_fixups_resume_early; 1358c2ecf20Sopenharmony_ci end = __end_pci_fixups_resume_early; 1368c2ecf20Sopenharmony_ci break; 1378c2ecf20Sopenharmony_ci 1388c2ecf20Sopenharmony_ci case pci_fixup_suspend: 1398c2ecf20Sopenharmony_ci start = __start_pci_fixups_suspend; 1408c2ecf20Sopenharmony_ci end = __end_pci_fixups_suspend; 1418c2ecf20Sopenharmony_ci break; 1428c2ecf20Sopenharmony_ci 1438c2ecf20Sopenharmony_ci case pci_fixup_suspend_late: 1448c2ecf20Sopenharmony_ci start = __start_pci_fixups_suspend_late; 1458c2ecf20Sopenharmony_ci end = __end_pci_fixups_suspend_late; 1468c2ecf20Sopenharmony_ci break; 1478c2ecf20Sopenharmony_ci 1488c2ecf20Sopenharmony_ci default: 1498c2ecf20Sopenharmony_ci /* stupid compiler warning, you would think with an enum... */ 1508c2ecf20Sopenharmony_ci return; 1518c2ecf20Sopenharmony_ci } 1528c2ecf20Sopenharmony_ci pci_do_fixups(dev, start, end); 1538c2ecf20Sopenharmony_ci} 1548c2ecf20Sopenharmony_ciEXPORT_SYMBOL(pci_fixup_device); 1558c2ecf20Sopenharmony_ci 1568c2ecf20Sopenharmony_cistatic int __init pci_apply_final_quirks(void) 1578c2ecf20Sopenharmony_ci{ 1588c2ecf20Sopenharmony_ci struct pci_dev *dev = NULL; 1598c2ecf20Sopenharmony_ci u8 cls = 0; 1608c2ecf20Sopenharmony_ci u8 tmp; 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_ci if (pci_cache_line_size) 1638c2ecf20Sopenharmony_ci pr_info("PCI: CLS %u bytes\n", pci_cache_line_size << 2); 1648c2ecf20Sopenharmony_ci 1658c2ecf20Sopenharmony_ci pci_apply_fixup_final_quirks = true; 1668c2ecf20Sopenharmony_ci for_each_pci_dev(dev) { 1678c2ecf20Sopenharmony_ci pci_fixup_device(pci_fixup_final, dev); 1688c2ecf20Sopenharmony_ci /* 1698c2ecf20Sopenharmony_ci * If arch hasn't set it explicitly yet, use the CLS 1708c2ecf20Sopenharmony_ci * value shared by all PCI devices. If there's a 1718c2ecf20Sopenharmony_ci * mismatch, fall back to the default value. 1728c2ecf20Sopenharmony_ci */ 1738c2ecf20Sopenharmony_ci if (!pci_cache_line_size) { 1748c2ecf20Sopenharmony_ci pci_read_config_byte(dev, PCI_CACHE_LINE_SIZE, &tmp); 1758c2ecf20Sopenharmony_ci if (!cls) 1768c2ecf20Sopenharmony_ci cls = tmp; 1778c2ecf20Sopenharmony_ci if (!tmp || cls == tmp) 1788c2ecf20Sopenharmony_ci continue; 1798c2ecf20Sopenharmony_ci 1808c2ecf20Sopenharmony_ci pci_info(dev, "CLS mismatch (%u != %u), using %u bytes\n", 1818c2ecf20Sopenharmony_ci cls << 2, tmp << 2, 1828c2ecf20Sopenharmony_ci pci_dfl_cache_line_size << 2); 1838c2ecf20Sopenharmony_ci pci_cache_line_size = pci_dfl_cache_line_size; 1848c2ecf20Sopenharmony_ci } 1858c2ecf20Sopenharmony_ci } 1868c2ecf20Sopenharmony_ci 1878c2ecf20Sopenharmony_ci if (!pci_cache_line_size) { 1888c2ecf20Sopenharmony_ci pr_info("PCI: CLS %u bytes, default %u\n", cls << 2, 1898c2ecf20Sopenharmony_ci pci_dfl_cache_line_size << 2); 1908c2ecf20Sopenharmony_ci pci_cache_line_size = cls ? cls : pci_dfl_cache_line_size; 1918c2ecf20Sopenharmony_ci } 1928c2ecf20Sopenharmony_ci 1938c2ecf20Sopenharmony_ci return 0; 1948c2ecf20Sopenharmony_ci} 1958c2ecf20Sopenharmony_cifs_initcall_sync(pci_apply_final_quirks); 1968c2ecf20Sopenharmony_ci 1978c2ecf20Sopenharmony_ci/* 1988c2ecf20Sopenharmony_ci * Decoding should be disabled for a PCI device during BAR sizing to avoid 1998c2ecf20Sopenharmony_ci * conflict. But doing so may cause problems on host bridge and perhaps other 2008c2ecf20Sopenharmony_ci * key system devices. For devices that need to have mmio decoding always-on, 2018c2ecf20Sopenharmony_ci * we need to set the dev->mmio_always_on bit. 2028c2ecf20Sopenharmony_ci */ 2038c2ecf20Sopenharmony_cistatic void quirk_mmio_always_on(struct pci_dev *dev) 2048c2ecf20Sopenharmony_ci{ 2058c2ecf20Sopenharmony_ci dev->mmio_always_on = 1; 2068c2ecf20Sopenharmony_ci} 2078c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_ANY_ID, PCI_ANY_ID, 2088c2ecf20Sopenharmony_ci PCI_CLASS_BRIDGE_HOST, 8, quirk_mmio_always_on); 2098c2ecf20Sopenharmony_ci 2108c2ecf20Sopenharmony_cistatic void aspeed_fixup_vgaarb(struct pci_dev *pdev) 2118c2ecf20Sopenharmony_ci{ 2128c2ecf20Sopenharmony_ci struct pci_dev *bridge; 2138c2ecf20Sopenharmony_ci struct pci_bus *bus; 2148c2ecf20Sopenharmony_ci struct pci_dev *vdevp = NULL; 2158c2ecf20Sopenharmony_ci u16 config; 2168c2ecf20Sopenharmony_ci 2178c2ecf20Sopenharmony_ci bus = pdev->bus; 2188c2ecf20Sopenharmony_ci bridge = bus->self; 2198c2ecf20Sopenharmony_ci 2208c2ecf20Sopenharmony_ci /* Is VGA routed to us? */ 2218c2ecf20Sopenharmony_ci if (bridge && (pci_is_bridge(bridge))) { 2228c2ecf20Sopenharmony_ci pci_read_config_word(bridge, PCI_BRIDGE_CONTROL, &config); 2238c2ecf20Sopenharmony_ci 2248c2ecf20Sopenharmony_ci /* Yes, this bridge is PCI bridge-to-bridge spec compliant, 2258c2ecf20Sopenharmony_ci * just return! 2268c2ecf20Sopenharmony_ci */ 2278c2ecf20Sopenharmony_ci if (config & PCI_BRIDGE_CTL_VGA) 2288c2ecf20Sopenharmony_ci return; 2298c2ecf20Sopenharmony_ci 2308c2ecf20Sopenharmony_ci dev_warn(&pdev->dev, "VGA bridge control is not enabled\n"); 2318c2ecf20Sopenharmony_ci } 2328c2ecf20Sopenharmony_ci 2338c2ecf20Sopenharmony_ci /* Just return if the system already have a default device */ 2348c2ecf20Sopenharmony_ci if (vga_default_device()) 2358c2ecf20Sopenharmony_ci return; 2368c2ecf20Sopenharmony_ci 2378c2ecf20Sopenharmony_ci /* No default vga device */ 2388c2ecf20Sopenharmony_ci while ((vdevp = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, vdevp))) { 2398c2ecf20Sopenharmony_ci if (vdevp->vendor != 0x1a03) { 2408c2ecf20Sopenharmony_ci /* Have other vga devcie in the system, do nothing */ 2418c2ecf20Sopenharmony_ci dev_info(&pdev->dev, "Another boot vga device: 0x%x:0x%x\n", 2428c2ecf20Sopenharmony_ci vdevp->vendor, vdevp->device); 2438c2ecf20Sopenharmony_ci return; 2448c2ecf20Sopenharmony_ci } 2458c2ecf20Sopenharmony_ci } 2468c2ecf20Sopenharmony_ci 2478c2ecf20Sopenharmony_ci vga_set_default_device(pdev); 2488c2ecf20Sopenharmony_ci 2498c2ecf20Sopenharmony_ci dev_info(&pdev->dev, "Boot vga device set as 0x%x:0x%x\n", 2508c2ecf20Sopenharmony_ci pdev->vendor, pdev->device); 2518c2ecf20Sopenharmony_ci} 2528c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_FINAL(0x1a03, 0x2000, PCI_CLASS_DISPLAY_VGA, 8, aspeed_fixup_vgaarb); 2538c2ecf20Sopenharmony_ci 2548c2ecf20Sopenharmony_ci/* 2558c2ecf20Sopenharmony_ci * The Mellanox Tavor device gives false positive parity errors. Mark this 2568c2ecf20Sopenharmony_ci * device with a broken_parity_status to allow PCI scanning code to "skip" 2578c2ecf20Sopenharmony_ci * this now blacklisted device. 2588c2ecf20Sopenharmony_ci */ 2598c2ecf20Sopenharmony_cistatic void quirk_mellanox_tavor(struct pci_dev *dev) 2608c2ecf20Sopenharmony_ci{ 2618c2ecf20Sopenharmony_ci dev->broken_parity_status = 1; /* This device gives false positives */ 2628c2ecf20Sopenharmony_ci} 2638c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_MELLANOX, PCI_DEVICE_ID_MELLANOX_TAVOR, quirk_mellanox_tavor); 2648c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_MELLANOX, PCI_DEVICE_ID_MELLANOX_TAVOR_BRIDGE, quirk_mellanox_tavor); 2658c2ecf20Sopenharmony_ci 2668c2ecf20Sopenharmony_ci/* 2678c2ecf20Sopenharmony_ci * Deal with broken BIOSes that neglect to enable passive release, 2688c2ecf20Sopenharmony_ci * which can cause problems in combination with the 82441FX/PPro MTRRs 2698c2ecf20Sopenharmony_ci */ 2708c2ecf20Sopenharmony_cistatic void quirk_passive_release(struct pci_dev *dev) 2718c2ecf20Sopenharmony_ci{ 2728c2ecf20Sopenharmony_ci struct pci_dev *d = NULL; 2738c2ecf20Sopenharmony_ci unsigned char dlc; 2748c2ecf20Sopenharmony_ci 2758c2ecf20Sopenharmony_ci /* 2768c2ecf20Sopenharmony_ci * We have to make sure a particular bit is set in the PIIX3 2778c2ecf20Sopenharmony_ci * ISA bridge, so we have to go out and find it. 2788c2ecf20Sopenharmony_ci */ 2798c2ecf20Sopenharmony_ci while ((d = pci_get_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371SB_0, d))) { 2808c2ecf20Sopenharmony_ci pci_read_config_byte(d, 0x82, &dlc); 2818c2ecf20Sopenharmony_ci if (!(dlc & 1<<1)) { 2828c2ecf20Sopenharmony_ci pci_info(d, "PIIX3: Enabling Passive Release\n"); 2838c2ecf20Sopenharmony_ci dlc |= 1<<1; 2848c2ecf20Sopenharmony_ci pci_write_config_byte(d, 0x82, dlc); 2858c2ecf20Sopenharmony_ci } 2868c2ecf20Sopenharmony_ci } 2878c2ecf20Sopenharmony_ci} 2888c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82441, quirk_passive_release); 2898c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82441, quirk_passive_release); 2908c2ecf20Sopenharmony_ci 2918c2ecf20Sopenharmony_ci/* 2928c2ecf20Sopenharmony_ci * The VIA VP2/VP3/MVP3 seem to have some 'features'. There may be a 2938c2ecf20Sopenharmony_ci * workaround but VIA don't answer queries. If you happen to have good 2948c2ecf20Sopenharmony_ci * contacts at VIA ask them for me please -- Alan 2958c2ecf20Sopenharmony_ci * 2968c2ecf20Sopenharmony_ci * This appears to be BIOS not version dependent. So presumably there is a 2978c2ecf20Sopenharmony_ci * chipset level fix. 2988c2ecf20Sopenharmony_ci */ 2998c2ecf20Sopenharmony_cistatic void quirk_isa_dma_hangs(struct pci_dev *dev) 3008c2ecf20Sopenharmony_ci{ 3018c2ecf20Sopenharmony_ci if (!isa_dma_bridge_buggy) { 3028c2ecf20Sopenharmony_ci isa_dma_bridge_buggy = 1; 3038c2ecf20Sopenharmony_ci pci_info(dev, "Activating ISA DMA hang workarounds\n"); 3048c2ecf20Sopenharmony_ci } 3058c2ecf20Sopenharmony_ci} 3068c2ecf20Sopenharmony_ci/* 3078c2ecf20Sopenharmony_ci * It's not totally clear which chipsets are the problematic ones. We know 3088c2ecf20Sopenharmony_ci * 82C586 and 82C596 variants are affected. 3098c2ecf20Sopenharmony_ci */ 3108c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_0, quirk_isa_dma_hangs); 3118c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C596, quirk_isa_dma_hangs); 3128c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371SB_0, quirk_isa_dma_hangs); 3138c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, quirk_isa_dma_hangs); 3148c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NEC, PCI_DEVICE_ID_NEC_CBUS_1, quirk_isa_dma_hangs); 3158c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NEC, PCI_DEVICE_ID_NEC_CBUS_2, quirk_isa_dma_hangs); 3168c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NEC, PCI_DEVICE_ID_NEC_CBUS_3, quirk_isa_dma_hangs); 3178c2ecf20Sopenharmony_ci 3188c2ecf20Sopenharmony_ci/* 3198c2ecf20Sopenharmony_ci * Intel NM10 "TigerPoint" LPC PM1a_STS.BM_STS must be clear 3208c2ecf20Sopenharmony_ci * for some HT machines to use C4 w/o hanging. 3218c2ecf20Sopenharmony_ci */ 3228c2ecf20Sopenharmony_cistatic void quirk_tigerpoint_bm_sts(struct pci_dev *dev) 3238c2ecf20Sopenharmony_ci{ 3248c2ecf20Sopenharmony_ci u32 pmbase; 3258c2ecf20Sopenharmony_ci u16 pm1a; 3268c2ecf20Sopenharmony_ci 3278c2ecf20Sopenharmony_ci pci_read_config_dword(dev, 0x40, &pmbase); 3288c2ecf20Sopenharmony_ci pmbase = pmbase & 0xff80; 3298c2ecf20Sopenharmony_ci pm1a = inw(pmbase); 3308c2ecf20Sopenharmony_ci 3318c2ecf20Sopenharmony_ci if (pm1a & 0x10) { 3328c2ecf20Sopenharmony_ci pci_info(dev, FW_BUG "TigerPoint LPC.BM_STS cleared\n"); 3338c2ecf20Sopenharmony_ci outw(0x10, pmbase); 3348c2ecf20Sopenharmony_ci } 3358c2ecf20Sopenharmony_ci} 3368c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_TGP_LPC, quirk_tigerpoint_bm_sts); 3378c2ecf20Sopenharmony_ci 3388c2ecf20Sopenharmony_ci/* Chipsets where PCI->PCI transfers vanish or hang */ 3398c2ecf20Sopenharmony_cistatic void quirk_nopcipci(struct pci_dev *dev) 3408c2ecf20Sopenharmony_ci{ 3418c2ecf20Sopenharmony_ci if ((pci_pci_problems & PCIPCI_FAIL) == 0) { 3428c2ecf20Sopenharmony_ci pci_info(dev, "Disabling direct PCI/PCI transfers\n"); 3438c2ecf20Sopenharmony_ci pci_pci_problems |= PCIPCI_FAIL; 3448c2ecf20Sopenharmony_ci } 3458c2ecf20Sopenharmony_ci} 3468c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_5597, quirk_nopcipci); 3478c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_496, quirk_nopcipci); 3488c2ecf20Sopenharmony_ci 3498c2ecf20Sopenharmony_cistatic void quirk_nopciamd(struct pci_dev *dev) 3508c2ecf20Sopenharmony_ci{ 3518c2ecf20Sopenharmony_ci u8 rev; 3528c2ecf20Sopenharmony_ci pci_read_config_byte(dev, 0x08, &rev); 3538c2ecf20Sopenharmony_ci if (rev == 0x13) { 3548c2ecf20Sopenharmony_ci /* Erratum 24 */ 3558c2ecf20Sopenharmony_ci pci_info(dev, "Chipset erratum: Disabling direct PCI/AGP transfers\n"); 3568c2ecf20Sopenharmony_ci pci_pci_problems |= PCIAGP_FAIL; 3578c2ecf20Sopenharmony_ci } 3588c2ecf20Sopenharmony_ci} 3598c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8151_0, quirk_nopciamd); 3608c2ecf20Sopenharmony_ci 3618c2ecf20Sopenharmony_ci/* Triton requires workarounds to be used by the drivers */ 3628c2ecf20Sopenharmony_cistatic void quirk_triton(struct pci_dev *dev) 3638c2ecf20Sopenharmony_ci{ 3648c2ecf20Sopenharmony_ci if ((pci_pci_problems&PCIPCI_TRITON) == 0) { 3658c2ecf20Sopenharmony_ci pci_info(dev, "Limiting direct PCI/PCI transfers\n"); 3668c2ecf20Sopenharmony_ci pci_pci_problems |= PCIPCI_TRITON; 3678c2ecf20Sopenharmony_ci } 3688c2ecf20Sopenharmony_ci} 3698c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82437, quirk_triton); 3708c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82437VX, quirk_triton); 3718c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82439, quirk_triton); 3728c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82439TX, quirk_triton); 3738c2ecf20Sopenharmony_ci 3748c2ecf20Sopenharmony_ci/* 3758c2ecf20Sopenharmony_ci * VIA Apollo KT133 needs PCI latency patch 3768c2ecf20Sopenharmony_ci * Made according to a Windows driver-based patch by George E. Breese; 3778c2ecf20Sopenharmony_ci * see PCI Latency Adjust on http://www.viahardware.com/download/viatweak.shtm 3788c2ecf20Sopenharmony_ci * Also see http://www.au-ja.org/review-kt133a-1-en.phtml for the info on 3798c2ecf20Sopenharmony_ci * which Mr Breese based his work. 3808c2ecf20Sopenharmony_ci * 3818c2ecf20Sopenharmony_ci * Updated based on further information from the site and also on 3828c2ecf20Sopenharmony_ci * information provided by VIA 3838c2ecf20Sopenharmony_ci */ 3848c2ecf20Sopenharmony_cistatic void quirk_vialatency(struct pci_dev *dev) 3858c2ecf20Sopenharmony_ci{ 3868c2ecf20Sopenharmony_ci struct pci_dev *p; 3878c2ecf20Sopenharmony_ci u8 busarb; 3888c2ecf20Sopenharmony_ci 3898c2ecf20Sopenharmony_ci /* 3908c2ecf20Sopenharmony_ci * Ok, we have a potential problem chipset here. Now see if we have 3918c2ecf20Sopenharmony_ci * a buggy southbridge. 3928c2ecf20Sopenharmony_ci */ 3938c2ecf20Sopenharmony_ci p = pci_get_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686, NULL); 3948c2ecf20Sopenharmony_ci if (p != NULL) { 3958c2ecf20Sopenharmony_ci 3968c2ecf20Sopenharmony_ci /* 3978c2ecf20Sopenharmony_ci * 0x40 - 0x4f == 686B, 0x10 - 0x2f == 686A; 3988c2ecf20Sopenharmony_ci * thanks Dan Hollis. 3998c2ecf20Sopenharmony_ci * Check for buggy part revisions 4008c2ecf20Sopenharmony_ci */ 4018c2ecf20Sopenharmony_ci if (p->revision < 0x40 || p->revision > 0x42) 4028c2ecf20Sopenharmony_ci goto exit; 4038c2ecf20Sopenharmony_ci } else { 4048c2ecf20Sopenharmony_ci p = pci_get_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8231, NULL); 4058c2ecf20Sopenharmony_ci if (p == NULL) /* No problem parts */ 4068c2ecf20Sopenharmony_ci goto exit; 4078c2ecf20Sopenharmony_ci 4088c2ecf20Sopenharmony_ci /* Check for buggy part revisions */ 4098c2ecf20Sopenharmony_ci if (p->revision < 0x10 || p->revision > 0x12) 4108c2ecf20Sopenharmony_ci goto exit; 4118c2ecf20Sopenharmony_ci } 4128c2ecf20Sopenharmony_ci 4138c2ecf20Sopenharmony_ci /* 4148c2ecf20Sopenharmony_ci * Ok we have the problem. Now set the PCI master grant to occur 4158c2ecf20Sopenharmony_ci * every master grant. The apparent bug is that under high PCI load 4168c2ecf20Sopenharmony_ci * (quite common in Linux of course) you can get data loss when the 4178c2ecf20Sopenharmony_ci * CPU is held off the bus for 3 bus master requests. This happens 4188c2ecf20Sopenharmony_ci * to include the IDE controllers.... 4198c2ecf20Sopenharmony_ci * 4208c2ecf20Sopenharmony_ci * VIA only apply this fix when an SB Live! is present but under 4218c2ecf20Sopenharmony_ci * both Linux and Windows this isn't enough, and we have seen 4228c2ecf20Sopenharmony_ci * corruption without SB Live! but with things like 3 UDMA IDE 4238c2ecf20Sopenharmony_ci * controllers. So we ignore that bit of the VIA recommendation.. 4248c2ecf20Sopenharmony_ci */ 4258c2ecf20Sopenharmony_ci pci_read_config_byte(dev, 0x76, &busarb); 4268c2ecf20Sopenharmony_ci 4278c2ecf20Sopenharmony_ci /* 4288c2ecf20Sopenharmony_ci * Set bit 4 and bit 5 of byte 76 to 0x01 4298c2ecf20Sopenharmony_ci * "Master priority rotation on every PCI master grant" 4308c2ecf20Sopenharmony_ci */ 4318c2ecf20Sopenharmony_ci busarb &= ~(1<<5); 4328c2ecf20Sopenharmony_ci busarb |= (1<<4); 4338c2ecf20Sopenharmony_ci pci_write_config_byte(dev, 0x76, busarb); 4348c2ecf20Sopenharmony_ci pci_info(dev, "Applying VIA southbridge workaround\n"); 4358c2ecf20Sopenharmony_ciexit: 4368c2ecf20Sopenharmony_ci pci_dev_put(p); 4378c2ecf20Sopenharmony_ci} 4388c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8363_0, quirk_vialatency); 4398c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8371_1, quirk_vialatency); 4408c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8361, quirk_vialatency); 4418c2ecf20Sopenharmony_ci/* Must restore this on a resume from RAM */ 4428c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8363_0, quirk_vialatency); 4438c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8371_1, quirk_vialatency); 4448c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8361, quirk_vialatency); 4458c2ecf20Sopenharmony_ci 4468c2ecf20Sopenharmony_ci/* VIA Apollo VP3 needs ETBF on BT848/878 */ 4478c2ecf20Sopenharmony_cistatic void quirk_viaetbf(struct pci_dev *dev) 4488c2ecf20Sopenharmony_ci{ 4498c2ecf20Sopenharmony_ci if ((pci_pci_problems&PCIPCI_VIAETBF) == 0) { 4508c2ecf20Sopenharmony_ci pci_info(dev, "Limiting direct PCI/PCI transfers\n"); 4518c2ecf20Sopenharmony_ci pci_pci_problems |= PCIPCI_VIAETBF; 4528c2ecf20Sopenharmony_ci } 4538c2ecf20Sopenharmony_ci} 4548c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C597_0, quirk_viaetbf); 4558c2ecf20Sopenharmony_ci 4568c2ecf20Sopenharmony_cistatic void quirk_vsfx(struct pci_dev *dev) 4578c2ecf20Sopenharmony_ci{ 4588c2ecf20Sopenharmony_ci if ((pci_pci_problems&PCIPCI_VSFX) == 0) { 4598c2ecf20Sopenharmony_ci pci_info(dev, "Limiting direct PCI/PCI transfers\n"); 4608c2ecf20Sopenharmony_ci pci_pci_problems |= PCIPCI_VSFX; 4618c2ecf20Sopenharmony_ci } 4628c2ecf20Sopenharmony_ci} 4638c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C576, quirk_vsfx); 4648c2ecf20Sopenharmony_ci 4658c2ecf20Sopenharmony_ci/* 4668c2ecf20Sopenharmony_ci * ALi Magik requires workarounds to be used by the drivers that DMA to AGP 4678c2ecf20Sopenharmony_ci * space. Latency must be set to 0xA and Triton workaround applied too. 4688c2ecf20Sopenharmony_ci * [Info kindly provided by ALi] 4698c2ecf20Sopenharmony_ci */ 4708c2ecf20Sopenharmony_cistatic void quirk_alimagik(struct pci_dev *dev) 4718c2ecf20Sopenharmony_ci{ 4728c2ecf20Sopenharmony_ci if ((pci_pci_problems&PCIPCI_ALIMAGIK) == 0) { 4738c2ecf20Sopenharmony_ci pci_info(dev, "Limiting direct PCI/PCI transfers\n"); 4748c2ecf20Sopenharmony_ci pci_pci_problems |= PCIPCI_ALIMAGIK|PCIPCI_TRITON; 4758c2ecf20Sopenharmony_ci } 4768c2ecf20Sopenharmony_ci} 4778c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1647, quirk_alimagik); 4788c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1651, quirk_alimagik); 4798c2ecf20Sopenharmony_ci 4808c2ecf20Sopenharmony_ci/* Natoma has some interesting boundary conditions with Zoran stuff at least */ 4818c2ecf20Sopenharmony_cistatic void quirk_natoma(struct pci_dev *dev) 4828c2ecf20Sopenharmony_ci{ 4838c2ecf20Sopenharmony_ci if ((pci_pci_problems&PCIPCI_NATOMA) == 0) { 4848c2ecf20Sopenharmony_ci pci_info(dev, "Limiting direct PCI/PCI transfers\n"); 4858c2ecf20Sopenharmony_ci pci_pci_problems |= PCIPCI_NATOMA; 4868c2ecf20Sopenharmony_ci } 4878c2ecf20Sopenharmony_ci} 4888c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82441, quirk_natoma); 4898c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82443LX_0, quirk_natoma); 4908c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82443LX_1, quirk_natoma); 4918c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82443BX_0, quirk_natoma); 4928c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82443BX_1, quirk_natoma); 4938c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82443BX_2, quirk_natoma); 4948c2ecf20Sopenharmony_ci 4958c2ecf20Sopenharmony_ci/* 4968c2ecf20Sopenharmony_ci * This chip can cause PCI parity errors if config register 0xA0 is read 4978c2ecf20Sopenharmony_ci * while DMAs are occurring. 4988c2ecf20Sopenharmony_ci */ 4998c2ecf20Sopenharmony_cistatic void quirk_citrine(struct pci_dev *dev) 5008c2ecf20Sopenharmony_ci{ 5018c2ecf20Sopenharmony_ci dev->cfg_size = 0xA0; 5028c2ecf20Sopenharmony_ci} 5038c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CITRINE, quirk_citrine); 5048c2ecf20Sopenharmony_ci 5058c2ecf20Sopenharmony_ci/* 5068c2ecf20Sopenharmony_ci * This chip can cause bus lockups if config addresses above 0x600 5078c2ecf20Sopenharmony_ci * are read or written. 5088c2ecf20Sopenharmony_ci */ 5098c2ecf20Sopenharmony_cistatic void quirk_nfp6000(struct pci_dev *dev) 5108c2ecf20Sopenharmony_ci{ 5118c2ecf20Sopenharmony_ci dev->cfg_size = 0x600; 5128c2ecf20Sopenharmony_ci} 5138c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NETRONOME, PCI_DEVICE_ID_NETRONOME_NFP4000, quirk_nfp6000); 5148c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NETRONOME, PCI_DEVICE_ID_NETRONOME_NFP6000, quirk_nfp6000); 5158c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NETRONOME, PCI_DEVICE_ID_NETRONOME_NFP5000, quirk_nfp6000); 5168c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NETRONOME, PCI_DEVICE_ID_NETRONOME_NFP6000_VF, quirk_nfp6000); 5178c2ecf20Sopenharmony_ci 5188c2ecf20Sopenharmony_ci/* On IBM Crocodile ipr SAS adapters, expand BAR to system page size */ 5198c2ecf20Sopenharmony_cistatic void quirk_extend_bar_to_page(struct pci_dev *dev) 5208c2ecf20Sopenharmony_ci{ 5218c2ecf20Sopenharmony_ci int i; 5228c2ecf20Sopenharmony_ci 5238c2ecf20Sopenharmony_ci for (i = 0; i < PCI_STD_NUM_BARS; i++) { 5248c2ecf20Sopenharmony_ci struct resource *r = &dev->resource[i]; 5258c2ecf20Sopenharmony_ci 5268c2ecf20Sopenharmony_ci if (r->flags & IORESOURCE_MEM && resource_size(r) < PAGE_SIZE) { 5278c2ecf20Sopenharmony_ci r->end = PAGE_SIZE - 1; 5288c2ecf20Sopenharmony_ci r->start = 0; 5298c2ecf20Sopenharmony_ci r->flags |= IORESOURCE_UNSET; 5308c2ecf20Sopenharmony_ci pci_info(dev, "expanded BAR %d to page size: %pR\n", 5318c2ecf20Sopenharmony_ci i, r); 5328c2ecf20Sopenharmony_ci } 5338c2ecf20Sopenharmony_ci } 5348c2ecf20Sopenharmony_ci} 5358c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_IBM, 0x034a, quirk_extend_bar_to_page); 5368c2ecf20Sopenharmony_ci 5378c2ecf20Sopenharmony_ci/* 5388c2ecf20Sopenharmony_ci * S3 868 and 968 chips report region size equal to 32M, but they decode 64M. 5398c2ecf20Sopenharmony_ci * If it's needed, re-allocate the region. 5408c2ecf20Sopenharmony_ci */ 5418c2ecf20Sopenharmony_cistatic void quirk_s3_64M(struct pci_dev *dev) 5428c2ecf20Sopenharmony_ci{ 5438c2ecf20Sopenharmony_ci struct resource *r = &dev->resource[0]; 5448c2ecf20Sopenharmony_ci 5458c2ecf20Sopenharmony_ci if ((r->start & 0x3ffffff) || r->end != r->start + 0x3ffffff) { 5468c2ecf20Sopenharmony_ci r->flags |= IORESOURCE_UNSET; 5478c2ecf20Sopenharmony_ci r->start = 0; 5488c2ecf20Sopenharmony_ci r->end = 0x3ffffff; 5498c2ecf20Sopenharmony_ci } 5508c2ecf20Sopenharmony_ci} 5518c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_S3, PCI_DEVICE_ID_S3_868, quirk_s3_64M); 5528c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_S3, PCI_DEVICE_ID_S3_968, quirk_s3_64M); 5538c2ecf20Sopenharmony_ci 5548c2ecf20Sopenharmony_cistatic void quirk_io(struct pci_dev *dev, int pos, unsigned size, 5558c2ecf20Sopenharmony_ci const char *name) 5568c2ecf20Sopenharmony_ci{ 5578c2ecf20Sopenharmony_ci u32 region; 5588c2ecf20Sopenharmony_ci struct pci_bus_region bus_region; 5598c2ecf20Sopenharmony_ci struct resource *res = dev->resource + pos; 5608c2ecf20Sopenharmony_ci 5618c2ecf20Sopenharmony_ci pci_read_config_dword(dev, PCI_BASE_ADDRESS_0 + (pos << 2), ®ion); 5628c2ecf20Sopenharmony_ci 5638c2ecf20Sopenharmony_ci if (!region) 5648c2ecf20Sopenharmony_ci return; 5658c2ecf20Sopenharmony_ci 5668c2ecf20Sopenharmony_ci res->name = pci_name(dev); 5678c2ecf20Sopenharmony_ci res->flags = region & ~PCI_BASE_ADDRESS_IO_MASK; 5688c2ecf20Sopenharmony_ci res->flags |= 5698c2ecf20Sopenharmony_ci (IORESOURCE_IO | IORESOURCE_PCI_FIXED | IORESOURCE_SIZEALIGN); 5708c2ecf20Sopenharmony_ci region &= ~(size - 1); 5718c2ecf20Sopenharmony_ci 5728c2ecf20Sopenharmony_ci /* Convert from PCI bus to resource space */ 5738c2ecf20Sopenharmony_ci bus_region.start = region; 5748c2ecf20Sopenharmony_ci bus_region.end = region + size - 1; 5758c2ecf20Sopenharmony_ci pcibios_bus_to_resource(dev->bus, res, &bus_region); 5768c2ecf20Sopenharmony_ci 5778c2ecf20Sopenharmony_ci pci_info(dev, FW_BUG "%s quirk: reg 0x%x: %pR\n", 5788c2ecf20Sopenharmony_ci name, PCI_BASE_ADDRESS_0 + (pos << 2), res); 5798c2ecf20Sopenharmony_ci} 5808c2ecf20Sopenharmony_ci 5818c2ecf20Sopenharmony_ci/* 5828c2ecf20Sopenharmony_ci * Some CS5536 BIOSes (for example, the Soekris NET5501 board w/ comBIOS 5838c2ecf20Sopenharmony_ci * ver. 1.33 20070103) don't set the correct ISA PCI region header info. 5848c2ecf20Sopenharmony_ci * BAR0 should be 8 bytes; instead, it may be set to something like 8k 5858c2ecf20Sopenharmony_ci * (which conflicts w/ BAR1's memory range). 5868c2ecf20Sopenharmony_ci * 5878c2ecf20Sopenharmony_ci * CS553x's ISA PCI BARs may also be read-only (ref: 5888c2ecf20Sopenharmony_ci * https://bugzilla.kernel.org/show_bug.cgi?id=85991 - Comment #4 forward). 5898c2ecf20Sopenharmony_ci */ 5908c2ecf20Sopenharmony_cistatic void quirk_cs5536_vsa(struct pci_dev *dev) 5918c2ecf20Sopenharmony_ci{ 5928c2ecf20Sopenharmony_ci static char *name = "CS5536 ISA bridge"; 5938c2ecf20Sopenharmony_ci 5948c2ecf20Sopenharmony_ci if (pci_resource_len(dev, 0) != 8) { 5958c2ecf20Sopenharmony_ci quirk_io(dev, 0, 8, name); /* SMB */ 5968c2ecf20Sopenharmony_ci quirk_io(dev, 1, 256, name); /* GPIO */ 5978c2ecf20Sopenharmony_ci quirk_io(dev, 2, 64, name); /* MFGPT */ 5988c2ecf20Sopenharmony_ci pci_info(dev, "%s bug detected (incorrect header); workaround applied\n", 5998c2ecf20Sopenharmony_ci name); 6008c2ecf20Sopenharmony_ci } 6018c2ecf20Sopenharmony_ci} 6028c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_ISA, quirk_cs5536_vsa); 6038c2ecf20Sopenharmony_ci 6048c2ecf20Sopenharmony_cistatic void quirk_io_region(struct pci_dev *dev, int port, 6058c2ecf20Sopenharmony_ci unsigned size, int nr, const char *name) 6068c2ecf20Sopenharmony_ci{ 6078c2ecf20Sopenharmony_ci u16 region; 6088c2ecf20Sopenharmony_ci struct pci_bus_region bus_region; 6098c2ecf20Sopenharmony_ci struct resource *res = dev->resource + nr; 6108c2ecf20Sopenharmony_ci 6118c2ecf20Sopenharmony_ci pci_read_config_word(dev, port, ®ion); 6128c2ecf20Sopenharmony_ci region &= ~(size - 1); 6138c2ecf20Sopenharmony_ci 6148c2ecf20Sopenharmony_ci if (!region) 6158c2ecf20Sopenharmony_ci return; 6168c2ecf20Sopenharmony_ci 6178c2ecf20Sopenharmony_ci res->name = pci_name(dev); 6188c2ecf20Sopenharmony_ci res->flags = IORESOURCE_IO; 6198c2ecf20Sopenharmony_ci 6208c2ecf20Sopenharmony_ci /* Convert from PCI bus to resource space */ 6218c2ecf20Sopenharmony_ci bus_region.start = region; 6228c2ecf20Sopenharmony_ci bus_region.end = region + size - 1; 6238c2ecf20Sopenharmony_ci pcibios_bus_to_resource(dev->bus, res, &bus_region); 6248c2ecf20Sopenharmony_ci 6258c2ecf20Sopenharmony_ci if (!pci_claim_resource(dev, nr)) 6268c2ecf20Sopenharmony_ci pci_info(dev, "quirk: %pR claimed by %s\n", res, name); 6278c2ecf20Sopenharmony_ci} 6288c2ecf20Sopenharmony_ci 6298c2ecf20Sopenharmony_ci/* 6308c2ecf20Sopenharmony_ci * ATI Northbridge setups MCE the processor if you even read somewhere 6318c2ecf20Sopenharmony_ci * between 0x3b0->0x3bb or read 0x3d3 6328c2ecf20Sopenharmony_ci */ 6338c2ecf20Sopenharmony_cistatic void quirk_ati_exploding_mce(struct pci_dev *dev) 6348c2ecf20Sopenharmony_ci{ 6358c2ecf20Sopenharmony_ci pci_info(dev, "ATI Northbridge, reserving I/O ports 0x3b0 to 0x3bb\n"); 6368c2ecf20Sopenharmony_ci /* Mae rhaid i ni beidio ag edrych ar y lleoliadiau I/O hyn */ 6378c2ecf20Sopenharmony_ci request_region(0x3b0, 0x0C, "RadeonIGP"); 6388c2ecf20Sopenharmony_ci request_region(0x3d3, 0x01, "RadeonIGP"); 6398c2ecf20Sopenharmony_ci} 6408c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RS100, quirk_ati_exploding_mce); 6418c2ecf20Sopenharmony_ci 6428c2ecf20Sopenharmony_ci/* 6438c2ecf20Sopenharmony_ci * In the AMD NL platform, this device ([1022:7912]) has a class code of 6448c2ecf20Sopenharmony_ci * PCI_CLASS_SERIAL_USB_XHCI (0x0c0330), which means the xhci driver will 6458c2ecf20Sopenharmony_ci * claim it. The same applies on the VanGogh platform device ([1022:163a]). 6468c2ecf20Sopenharmony_ci * 6478c2ecf20Sopenharmony_ci * But the dwc3 driver is a more specific driver for this device, and we'd 6488c2ecf20Sopenharmony_ci * prefer to use it instead of xhci. To prevent xhci from claiming the 6498c2ecf20Sopenharmony_ci * device, change the class code to 0x0c03fe, which the PCI r3.0 spec 6508c2ecf20Sopenharmony_ci * defines as "USB device (not host controller)". The dwc3 driver can then 6518c2ecf20Sopenharmony_ci * claim it based on its Vendor and Device ID. 6528c2ecf20Sopenharmony_ci */ 6538c2ecf20Sopenharmony_cistatic void quirk_amd_dwc_class(struct pci_dev *pdev) 6548c2ecf20Sopenharmony_ci{ 6558c2ecf20Sopenharmony_ci u32 class = pdev->class; 6568c2ecf20Sopenharmony_ci 6578c2ecf20Sopenharmony_ci if (class != PCI_CLASS_SERIAL_USB_DEVICE) { 6588c2ecf20Sopenharmony_ci /* Use "USB Device (not host controller)" class */ 6598c2ecf20Sopenharmony_ci pdev->class = PCI_CLASS_SERIAL_USB_DEVICE; 6608c2ecf20Sopenharmony_ci pci_info(pdev, 6618c2ecf20Sopenharmony_ci "PCI class overridden (%#08x -> %#08x) so dwc3 driver can claim this instead of xhci\n", 6628c2ecf20Sopenharmony_ci class, pdev->class); 6638c2ecf20Sopenharmony_ci } 6648c2ecf20Sopenharmony_ci} 6658c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_NL_USB, 6668c2ecf20Sopenharmony_ci quirk_amd_dwc_class); 6678c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_VANGOGH_USB, 6688c2ecf20Sopenharmony_ci quirk_amd_dwc_class); 6698c2ecf20Sopenharmony_ci 6708c2ecf20Sopenharmony_ci/* 6718c2ecf20Sopenharmony_ci * Synopsys USB 3.x host HAPS platform has a class code of 6728c2ecf20Sopenharmony_ci * PCI_CLASS_SERIAL_USB_XHCI, and xhci driver can claim it. However, these 6738c2ecf20Sopenharmony_ci * devices should use dwc3-haps driver. Change these devices' class code to 6748c2ecf20Sopenharmony_ci * PCI_CLASS_SERIAL_USB_DEVICE to prevent the xhci-pci driver from claiming 6758c2ecf20Sopenharmony_ci * them. 6768c2ecf20Sopenharmony_ci */ 6778c2ecf20Sopenharmony_cistatic void quirk_synopsys_haps(struct pci_dev *pdev) 6788c2ecf20Sopenharmony_ci{ 6798c2ecf20Sopenharmony_ci u32 class = pdev->class; 6808c2ecf20Sopenharmony_ci 6818c2ecf20Sopenharmony_ci switch (pdev->device) { 6828c2ecf20Sopenharmony_ci case PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3: 6838c2ecf20Sopenharmony_ci case PCI_DEVICE_ID_SYNOPSYS_HAPSUSB3_AXI: 6848c2ecf20Sopenharmony_ci case PCI_DEVICE_ID_SYNOPSYS_HAPSUSB31: 6858c2ecf20Sopenharmony_ci pdev->class = PCI_CLASS_SERIAL_USB_DEVICE; 6868c2ecf20Sopenharmony_ci pci_info(pdev, "PCI class overridden (%#08x -> %#08x) so dwc3 driver can claim this instead of xhci\n", 6878c2ecf20Sopenharmony_ci class, pdev->class); 6888c2ecf20Sopenharmony_ci break; 6898c2ecf20Sopenharmony_ci } 6908c2ecf20Sopenharmony_ci} 6918c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_HEADER(PCI_VENDOR_ID_SYNOPSYS, PCI_ANY_ID, 6928c2ecf20Sopenharmony_ci PCI_CLASS_SERIAL_USB_XHCI, 0, 6938c2ecf20Sopenharmony_ci quirk_synopsys_haps); 6948c2ecf20Sopenharmony_ci 6958c2ecf20Sopenharmony_ci/* 6968c2ecf20Sopenharmony_ci * Let's make the southbridge information explicit instead of having to 6978c2ecf20Sopenharmony_ci * worry about people probing the ACPI areas, for example.. (Yes, it 6988c2ecf20Sopenharmony_ci * happens, and if you read the wrong ACPI register it will put the machine 6998c2ecf20Sopenharmony_ci * to sleep with no way of waking it up again. Bummer). 7008c2ecf20Sopenharmony_ci * 7018c2ecf20Sopenharmony_ci * ALI M7101: Two IO regions pointed to by words at 7028c2ecf20Sopenharmony_ci * 0xE0 (64 bytes of ACPI registers) 7038c2ecf20Sopenharmony_ci * 0xE2 (32 bytes of SMB registers) 7048c2ecf20Sopenharmony_ci */ 7058c2ecf20Sopenharmony_cistatic void quirk_ali7101_acpi(struct pci_dev *dev) 7068c2ecf20Sopenharmony_ci{ 7078c2ecf20Sopenharmony_ci quirk_io_region(dev, 0xE0, 64, PCI_BRIDGE_RESOURCES, "ali7101 ACPI"); 7088c2ecf20Sopenharmony_ci quirk_io_region(dev, 0xE2, 32, PCI_BRIDGE_RESOURCES+1, "ali7101 SMB"); 7098c2ecf20Sopenharmony_ci} 7108c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101, quirk_ali7101_acpi); 7118c2ecf20Sopenharmony_ci 7128c2ecf20Sopenharmony_cistatic void piix4_io_quirk(struct pci_dev *dev, const char *name, unsigned int port, unsigned int enable) 7138c2ecf20Sopenharmony_ci{ 7148c2ecf20Sopenharmony_ci u32 devres; 7158c2ecf20Sopenharmony_ci u32 mask, size, base; 7168c2ecf20Sopenharmony_ci 7178c2ecf20Sopenharmony_ci pci_read_config_dword(dev, port, &devres); 7188c2ecf20Sopenharmony_ci if ((devres & enable) != enable) 7198c2ecf20Sopenharmony_ci return; 7208c2ecf20Sopenharmony_ci mask = (devres >> 16) & 15; 7218c2ecf20Sopenharmony_ci base = devres & 0xffff; 7228c2ecf20Sopenharmony_ci size = 16; 7238c2ecf20Sopenharmony_ci for (;;) { 7248c2ecf20Sopenharmony_ci unsigned bit = size >> 1; 7258c2ecf20Sopenharmony_ci if ((bit & mask) == bit) 7268c2ecf20Sopenharmony_ci break; 7278c2ecf20Sopenharmony_ci size = bit; 7288c2ecf20Sopenharmony_ci } 7298c2ecf20Sopenharmony_ci /* 7308c2ecf20Sopenharmony_ci * For now we only print it out. Eventually we'll want to 7318c2ecf20Sopenharmony_ci * reserve it (at least if it's in the 0x1000+ range), but 7328c2ecf20Sopenharmony_ci * let's get enough confirmation reports first. 7338c2ecf20Sopenharmony_ci */ 7348c2ecf20Sopenharmony_ci base &= -size; 7358c2ecf20Sopenharmony_ci pci_info(dev, "%s PIO at %04x-%04x\n", name, base, base + size - 1); 7368c2ecf20Sopenharmony_ci} 7378c2ecf20Sopenharmony_ci 7388c2ecf20Sopenharmony_cistatic void piix4_mem_quirk(struct pci_dev *dev, const char *name, unsigned int port, unsigned int enable) 7398c2ecf20Sopenharmony_ci{ 7408c2ecf20Sopenharmony_ci u32 devres; 7418c2ecf20Sopenharmony_ci u32 mask, size, base; 7428c2ecf20Sopenharmony_ci 7438c2ecf20Sopenharmony_ci pci_read_config_dword(dev, port, &devres); 7448c2ecf20Sopenharmony_ci if ((devres & enable) != enable) 7458c2ecf20Sopenharmony_ci return; 7468c2ecf20Sopenharmony_ci base = devres & 0xffff0000; 7478c2ecf20Sopenharmony_ci mask = (devres & 0x3f) << 16; 7488c2ecf20Sopenharmony_ci size = 128 << 16; 7498c2ecf20Sopenharmony_ci for (;;) { 7508c2ecf20Sopenharmony_ci unsigned bit = size >> 1; 7518c2ecf20Sopenharmony_ci if ((bit & mask) == bit) 7528c2ecf20Sopenharmony_ci break; 7538c2ecf20Sopenharmony_ci size = bit; 7548c2ecf20Sopenharmony_ci } 7558c2ecf20Sopenharmony_ci 7568c2ecf20Sopenharmony_ci /* 7578c2ecf20Sopenharmony_ci * For now we only print it out. Eventually we'll want to 7588c2ecf20Sopenharmony_ci * reserve it, but let's get enough confirmation reports first. 7598c2ecf20Sopenharmony_ci */ 7608c2ecf20Sopenharmony_ci base &= -size; 7618c2ecf20Sopenharmony_ci pci_info(dev, "%s MMIO at %04x-%04x\n", name, base, base + size - 1); 7628c2ecf20Sopenharmony_ci} 7638c2ecf20Sopenharmony_ci 7648c2ecf20Sopenharmony_ci/* 7658c2ecf20Sopenharmony_ci * PIIX4 ACPI: Two IO regions pointed to by longwords at 7668c2ecf20Sopenharmony_ci * 0x40 (64 bytes of ACPI registers) 7678c2ecf20Sopenharmony_ci * 0x90 (16 bytes of SMB registers) 7688c2ecf20Sopenharmony_ci * and a few strange programmable PIIX4 device resources. 7698c2ecf20Sopenharmony_ci */ 7708c2ecf20Sopenharmony_cistatic void quirk_piix4_acpi(struct pci_dev *dev) 7718c2ecf20Sopenharmony_ci{ 7728c2ecf20Sopenharmony_ci u32 res_a; 7738c2ecf20Sopenharmony_ci 7748c2ecf20Sopenharmony_ci quirk_io_region(dev, 0x40, 64, PCI_BRIDGE_RESOURCES, "PIIX4 ACPI"); 7758c2ecf20Sopenharmony_ci quirk_io_region(dev, 0x90, 16, PCI_BRIDGE_RESOURCES+1, "PIIX4 SMB"); 7768c2ecf20Sopenharmony_ci 7778c2ecf20Sopenharmony_ci /* Device resource A has enables for some of the other ones */ 7788c2ecf20Sopenharmony_ci pci_read_config_dword(dev, 0x5c, &res_a); 7798c2ecf20Sopenharmony_ci 7808c2ecf20Sopenharmony_ci piix4_io_quirk(dev, "PIIX4 devres B", 0x60, 3 << 21); 7818c2ecf20Sopenharmony_ci piix4_io_quirk(dev, "PIIX4 devres C", 0x64, 3 << 21); 7828c2ecf20Sopenharmony_ci 7838c2ecf20Sopenharmony_ci /* Device resource D is just bitfields for static resources */ 7848c2ecf20Sopenharmony_ci 7858c2ecf20Sopenharmony_ci /* Device 12 enabled? */ 7868c2ecf20Sopenharmony_ci if (res_a & (1 << 29)) { 7878c2ecf20Sopenharmony_ci piix4_io_quirk(dev, "PIIX4 devres E", 0x68, 1 << 20); 7888c2ecf20Sopenharmony_ci piix4_mem_quirk(dev, "PIIX4 devres F", 0x6c, 1 << 7); 7898c2ecf20Sopenharmony_ci } 7908c2ecf20Sopenharmony_ci /* Device 13 enabled? */ 7918c2ecf20Sopenharmony_ci if (res_a & (1 << 30)) { 7928c2ecf20Sopenharmony_ci piix4_io_quirk(dev, "PIIX4 devres G", 0x70, 1 << 20); 7938c2ecf20Sopenharmony_ci piix4_mem_quirk(dev, "PIIX4 devres H", 0x74, 1 << 7); 7948c2ecf20Sopenharmony_ci } 7958c2ecf20Sopenharmony_ci piix4_io_quirk(dev, "PIIX4 devres I", 0x78, 1 << 20); 7968c2ecf20Sopenharmony_ci piix4_io_quirk(dev, "PIIX4 devres J", 0x7c, 1 << 20); 7978c2ecf20Sopenharmony_ci} 7988c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_3, quirk_piix4_acpi); 7998c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82443MX_3, quirk_piix4_acpi); 8008c2ecf20Sopenharmony_ci 8018c2ecf20Sopenharmony_ci#define ICH_PMBASE 0x40 8028c2ecf20Sopenharmony_ci#define ICH_ACPI_CNTL 0x44 8038c2ecf20Sopenharmony_ci#define ICH4_ACPI_EN 0x10 8048c2ecf20Sopenharmony_ci#define ICH6_ACPI_EN 0x80 8058c2ecf20Sopenharmony_ci#define ICH4_GPIOBASE 0x58 8068c2ecf20Sopenharmony_ci#define ICH4_GPIO_CNTL 0x5c 8078c2ecf20Sopenharmony_ci#define ICH4_GPIO_EN 0x10 8088c2ecf20Sopenharmony_ci#define ICH6_GPIOBASE 0x48 8098c2ecf20Sopenharmony_ci#define ICH6_GPIO_CNTL 0x4c 8108c2ecf20Sopenharmony_ci#define ICH6_GPIO_EN 0x10 8118c2ecf20Sopenharmony_ci 8128c2ecf20Sopenharmony_ci/* 8138c2ecf20Sopenharmony_ci * ICH4, ICH4-M, ICH5, ICH5-M ACPI: Three IO regions pointed to by longwords at 8148c2ecf20Sopenharmony_ci * 0x40 (128 bytes of ACPI, GPIO & TCO registers) 8158c2ecf20Sopenharmony_ci * 0x58 (64 bytes of GPIO I/O space) 8168c2ecf20Sopenharmony_ci */ 8178c2ecf20Sopenharmony_cistatic void quirk_ich4_lpc_acpi(struct pci_dev *dev) 8188c2ecf20Sopenharmony_ci{ 8198c2ecf20Sopenharmony_ci u8 enable; 8208c2ecf20Sopenharmony_ci 8218c2ecf20Sopenharmony_ci /* 8228c2ecf20Sopenharmony_ci * The check for PCIBIOS_MIN_IO is to ensure we won't create a conflict 8238c2ecf20Sopenharmony_ci * with low legacy (and fixed) ports. We don't know the decoding 8248c2ecf20Sopenharmony_ci * priority and can't tell whether the legacy device or the one created 8258c2ecf20Sopenharmony_ci * here is really at that address. This happens on boards with broken 8268c2ecf20Sopenharmony_ci * BIOSes. 8278c2ecf20Sopenharmony_ci */ 8288c2ecf20Sopenharmony_ci pci_read_config_byte(dev, ICH_ACPI_CNTL, &enable); 8298c2ecf20Sopenharmony_ci if (enable & ICH4_ACPI_EN) 8308c2ecf20Sopenharmony_ci quirk_io_region(dev, ICH_PMBASE, 128, PCI_BRIDGE_RESOURCES, 8318c2ecf20Sopenharmony_ci "ICH4 ACPI/GPIO/TCO"); 8328c2ecf20Sopenharmony_ci 8338c2ecf20Sopenharmony_ci pci_read_config_byte(dev, ICH4_GPIO_CNTL, &enable); 8348c2ecf20Sopenharmony_ci if (enable & ICH4_GPIO_EN) 8358c2ecf20Sopenharmony_ci quirk_io_region(dev, ICH4_GPIOBASE, 64, PCI_BRIDGE_RESOURCES+1, 8368c2ecf20Sopenharmony_ci "ICH4 GPIO"); 8378c2ecf20Sopenharmony_ci} 8388c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801AA_0, quirk_ich4_lpc_acpi); 8398c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801AB_0, quirk_ich4_lpc_acpi); 8408c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801BA_0, quirk_ich4_lpc_acpi); 8418c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801BA_10, quirk_ich4_lpc_acpi); 8428c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_0, quirk_ich4_lpc_acpi); 8438c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_12, quirk_ich4_lpc_acpi); 8448c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_0, quirk_ich4_lpc_acpi); 8458c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_12, quirk_ich4_lpc_acpi); 8468c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_0, quirk_ich4_lpc_acpi); 8478c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_1, quirk_ich4_lpc_acpi); 8488c2ecf20Sopenharmony_ci 8498c2ecf20Sopenharmony_cistatic void ich6_lpc_acpi_gpio(struct pci_dev *dev) 8508c2ecf20Sopenharmony_ci{ 8518c2ecf20Sopenharmony_ci u8 enable; 8528c2ecf20Sopenharmony_ci 8538c2ecf20Sopenharmony_ci pci_read_config_byte(dev, ICH_ACPI_CNTL, &enable); 8548c2ecf20Sopenharmony_ci if (enable & ICH6_ACPI_EN) 8558c2ecf20Sopenharmony_ci quirk_io_region(dev, ICH_PMBASE, 128, PCI_BRIDGE_RESOURCES, 8568c2ecf20Sopenharmony_ci "ICH6 ACPI/GPIO/TCO"); 8578c2ecf20Sopenharmony_ci 8588c2ecf20Sopenharmony_ci pci_read_config_byte(dev, ICH6_GPIO_CNTL, &enable); 8598c2ecf20Sopenharmony_ci if (enable & ICH6_GPIO_EN) 8608c2ecf20Sopenharmony_ci quirk_io_region(dev, ICH6_GPIOBASE, 64, PCI_BRIDGE_RESOURCES+1, 8618c2ecf20Sopenharmony_ci "ICH6 GPIO"); 8628c2ecf20Sopenharmony_ci} 8638c2ecf20Sopenharmony_ci 8648c2ecf20Sopenharmony_cistatic void ich6_lpc_generic_decode(struct pci_dev *dev, unsigned reg, 8658c2ecf20Sopenharmony_ci const char *name, int dynsize) 8668c2ecf20Sopenharmony_ci{ 8678c2ecf20Sopenharmony_ci u32 val; 8688c2ecf20Sopenharmony_ci u32 size, base; 8698c2ecf20Sopenharmony_ci 8708c2ecf20Sopenharmony_ci pci_read_config_dword(dev, reg, &val); 8718c2ecf20Sopenharmony_ci 8728c2ecf20Sopenharmony_ci /* Enabled? */ 8738c2ecf20Sopenharmony_ci if (!(val & 1)) 8748c2ecf20Sopenharmony_ci return; 8758c2ecf20Sopenharmony_ci base = val & 0xfffc; 8768c2ecf20Sopenharmony_ci if (dynsize) { 8778c2ecf20Sopenharmony_ci /* 8788c2ecf20Sopenharmony_ci * This is not correct. It is 16, 32 or 64 bytes depending on 8798c2ecf20Sopenharmony_ci * register D31:F0:ADh bits 5:4. 8808c2ecf20Sopenharmony_ci * 8818c2ecf20Sopenharmony_ci * But this gets us at least _part_ of it. 8828c2ecf20Sopenharmony_ci */ 8838c2ecf20Sopenharmony_ci size = 16; 8848c2ecf20Sopenharmony_ci } else { 8858c2ecf20Sopenharmony_ci size = 128; 8868c2ecf20Sopenharmony_ci } 8878c2ecf20Sopenharmony_ci base &= ~(size-1); 8888c2ecf20Sopenharmony_ci 8898c2ecf20Sopenharmony_ci /* 8908c2ecf20Sopenharmony_ci * Just print it out for now. We should reserve it after more 8918c2ecf20Sopenharmony_ci * debugging. 8928c2ecf20Sopenharmony_ci */ 8938c2ecf20Sopenharmony_ci pci_info(dev, "%s PIO at %04x-%04x\n", name, base, base+size-1); 8948c2ecf20Sopenharmony_ci} 8958c2ecf20Sopenharmony_ci 8968c2ecf20Sopenharmony_cistatic void quirk_ich6_lpc(struct pci_dev *dev) 8978c2ecf20Sopenharmony_ci{ 8988c2ecf20Sopenharmony_ci /* Shared ACPI/GPIO decode with all ICH6+ */ 8998c2ecf20Sopenharmony_ci ich6_lpc_acpi_gpio(dev); 9008c2ecf20Sopenharmony_ci 9018c2ecf20Sopenharmony_ci /* ICH6-specific generic IO decode */ 9028c2ecf20Sopenharmony_ci ich6_lpc_generic_decode(dev, 0x84, "LPC Generic IO decode 1", 0); 9038c2ecf20Sopenharmony_ci ich6_lpc_generic_decode(dev, 0x88, "LPC Generic IO decode 2", 1); 9048c2ecf20Sopenharmony_ci} 9058c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_0, quirk_ich6_lpc); 9068c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_1, quirk_ich6_lpc); 9078c2ecf20Sopenharmony_ci 9088c2ecf20Sopenharmony_cistatic void ich7_lpc_generic_decode(struct pci_dev *dev, unsigned reg, 9098c2ecf20Sopenharmony_ci const char *name) 9108c2ecf20Sopenharmony_ci{ 9118c2ecf20Sopenharmony_ci u32 val; 9128c2ecf20Sopenharmony_ci u32 mask, base; 9138c2ecf20Sopenharmony_ci 9148c2ecf20Sopenharmony_ci pci_read_config_dword(dev, reg, &val); 9158c2ecf20Sopenharmony_ci 9168c2ecf20Sopenharmony_ci /* Enabled? */ 9178c2ecf20Sopenharmony_ci if (!(val & 1)) 9188c2ecf20Sopenharmony_ci return; 9198c2ecf20Sopenharmony_ci 9208c2ecf20Sopenharmony_ci /* IO base in bits 15:2, mask in bits 23:18, both are dword-based */ 9218c2ecf20Sopenharmony_ci base = val & 0xfffc; 9228c2ecf20Sopenharmony_ci mask = (val >> 16) & 0xfc; 9238c2ecf20Sopenharmony_ci mask |= 3; 9248c2ecf20Sopenharmony_ci 9258c2ecf20Sopenharmony_ci /* 9268c2ecf20Sopenharmony_ci * Just print it out for now. We should reserve it after more 9278c2ecf20Sopenharmony_ci * debugging. 9288c2ecf20Sopenharmony_ci */ 9298c2ecf20Sopenharmony_ci pci_info(dev, "%s PIO at %04x (mask %04x)\n", name, base, mask); 9308c2ecf20Sopenharmony_ci} 9318c2ecf20Sopenharmony_ci 9328c2ecf20Sopenharmony_ci/* ICH7-10 has the same common LPC generic IO decode registers */ 9338c2ecf20Sopenharmony_cistatic void quirk_ich7_lpc(struct pci_dev *dev) 9348c2ecf20Sopenharmony_ci{ 9358c2ecf20Sopenharmony_ci /* We share the common ACPI/GPIO decode with ICH6 */ 9368c2ecf20Sopenharmony_ci ich6_lpc_acpi_gpio(dev); 9378c2ecf20Sopenharmony_ci 9388c2ecf20Sopenharmony_ci /* And have 4 ICH7+ generic decodes */ 9398c2ecf20Sopenharmony_ci ich7_lpc_generic_decode(dev, 0x84, "ICH7 LPC Generic IO decode 1"); 9408c2ecf20Sopenharmony_ci ich7_lpc_generic_decode(dev, 0x88, "ICH7 LPC Generic IO decode 2"); 9418c2ecf20Sopenharmony_ci ich7_lpc_generic_decode(dev, 0x8c, "ICH7 LPC Generic IO decode 3"); 9428c2ecf20Sopenharmony_ci ich7_lpc_generic_decode(dev, 0x90, "ICH7 LPC Generic IO decode 4"); 9438c2ecf20Sopenharmony_ci} 9448c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_0, quirk_ich7_lpc); 9458c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_1, quirk_ich7_lpc); 9468c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_31, quirk_ich7_lpc); 9478c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_0, quirk_ich7_lpc); 9488c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_2, quirk_ich7_lpc); 9498c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_3, quirk_ich7_lpc); 9508c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_1, quirk_ich7_lpc); 9518c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_4, quirk_ich7_lpc); 9528c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH9_2, quirk_ich7_lpc); 9538c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH9_4, quirk_ich7_lpc); 9548c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH9_7, quirk_ich7_lpc); 9558c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH9_8, quirk_ich7_lpc); 9568c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH10_1, quirk_ich7_lpc); 9578c2ecf20Sopenharmony_ci 9588c2ecf20Sopenharmony_ci/* 9598c2ecf20Sopenharmony_ci * VIA ACPI: One IO region pointed to by longword at 9608c2ecf20Sopenharmony_ci * 0x48 or 0x20 (256 bytes of ACPI registers) 9618c2ecf20Sopenharmony_ci */ 9628c2ecf20Sopenharmony_cistatic void quirk_vt82c586_acpi(struct pci_dev *dev) 9638c2ecf20Sopenharmony_ci{ 9648c2ecf20Sopenharmony_ci if (dev->revision & 0x10) 9658c2ecf20Sopenharmony_ci quirk_io_region(dev, 0x48, 256, PCI_BRIDGE_RESOURCES, 9668c2ecf20Sopenharmony_ci "vt82c586 ACPI"); 9678c2ecf20Sopenharmony_ci} 9688c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_3, quirk_vt82c586_acpi); 9698c2ecf20Sopenharmony_ci 9708c2ecf20Sopenharmony_ci/* 9718c2ecf20Sopenharmony_ci * VIA VT82C686 ACPI: Three IO region pointed to by (long)words at 9728c2ecf20Sopenharmony_ci * 0x48 (256 bytes of ACPI registers) 9738c2ecf20Sopenharmony_ci * 0x70 (128 bytes of hardware monitoring register) 9748c2ecf20Sopenharmony_ci * 0x90 (16 bytes of SMB registers) 9758c2ecf20Sopenharmony_ci */ 9768c2ecf20Sopenharmony_cistatic void quirk_vt82c686_acpi(struct pci_dev *dev) 9778c2ecf20Sopenharmony_ci{ 9788c2ecf20Sopenharmony_ci quirk_vt82c586_acpi(dev); 9798c2ecf20Sopenharmony_ci 9808c2ecf20Sopenharmony_ci quirk_io_region(dev, 0x70, 128, PCI_BRIDGE_RESOURCES+1, 9818c2ecf20Sopenharmony_ci "vt82c686 HW-mon"); 9828c2ecf20Sopenharmony_ci 9838c2ecf20Sopenharmony_ci quirk_io_region(dev, 0x90, 16, PCI_BRIDGE_RESOURCES+2, "vt82c686 SMB"); 9848c2ecf20Sopenharmony_ci} 9858c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_4, quirk_vt82c686_acpi); 9868c2ecf20Sopenharmony_ci 9878c2ecf20Sopenharmony_ci/* 9888c2ecf20Sopenharmony_ci * VIA VT8235 ISA Bridge: Two IO regions pointed to by words at 9898c2ecf20Sopenharmony_ci * 0x88 (128 bytes of power management registers) 9908c2ecf20Sopenharmony_ci * 0xd0 (16 bytes of SMB registers) 9918c2ecf20Sopenharmony_ci */ 9928c2ecf20Sopenharmony_cistatic void quirk_vt8235_acpi(struct pci_dev *dev) 9938c2ecf20Sopenharmony_ci{ 9948c2ecf20Sopenharmony_ci quirk_io_region(dev, 0x88, 128, PCI_BRIDGE_RESOURCES, "vt8235 PM"); 9958c2ecf20Sopenharmony_ci quirk_io_region(dev, 0xd0, 16, PCI_BRIDGE_RESOURCES+1, "vt8235 SMB"); 9968c2ecf20Sopenharmony_ci} 9978c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8235, quirk_vt8235_acpi); 9988c2ecf20Sopenharmony_ci 9998c2ecf20Sopenharmony_ci/* 10008c2ecf20Sopenharmony_ci * TI XIO2000a PCIe-PCI Bridge erroneously reports it supports fast 10018c2ecf20Sopenharmony_ci * back-to-back: Disable fast back-to-back on the secondary bus segment 10028c2ecf20Sopenharmony_ci */ 10038c2ecf20Sopenharmony_cistatic void quirk_xio2000a(struct pci_dev *dev) 10048c2ecf20Sopenharmony_ci{ 10058c2ecf20Sopenharmony_ci struct pci_dev *pdev; 10068c2ecf20Sopenharmony_ci u16 command; 10078c2ecf20Sopenharmony_ci 10088c2ecf20Sopenharmony_ci pci_warn(dev, "TI XIO2000a quirk detected; secondary bus fast back-to-back transfers disabled\n"); 10098c2ecf20Sopenharmony_ci list_for_each_entry(pdev, &dev->subordinate->devices, bus_list) { 10108c2ecf20Sopenharmony_ci pci_read_config_word(pdev, PCI_COMMAND, &command); 10118c2ecf20Sopenharmony_ci if (command & PCI_COMMAND_FAST_BACK) 10128c2ecf20Sopenharmony_ci pci_write_config_word(pdev, PCI_COMMAND, command & ~PCI_COMMAND_FAST_BACK); 10138c2ecf20Sopenharmony_ci } 10148c2ecf20Sopenharmony_ci} 10158c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_XIO2000A, 10168c2ecf20Sopenharmony_ci quirk_xio2000a); 10178c2ecf20Sopenharmony_ci 10188c2ecf20Sopenharmony_ci#ifdef CONFIG_X86_IO_APIC 10198c2ecf20Sopenharmony_ci 10208c2ecf20Sopenharmony_ci#include <asm/io_apic.h> 10218c2ecf20Sopenharmony_ci 10228c2ecf20Sopenharmony_ci/* 10238c2ecf20Sopenharmony_ci * VIA 686A/B: If an IO-APIC is active, we need to route all on-chip 10248c2ecf20Sopenharmony_ci * devices to the external APIC. 10258c2ecf20Sopenharmony_ci * 10268c2ecf20Sopenharmony_ci * TODO: When we have device-specific interrupt routers, this code will go 10278c2ecf20Sopenharmony_ci * away from quirks. 10288c2ecf20Sopenharmony_ci */ 10298c2ecf20Sopenharmony_cistatic void quirk_via_ioapic(struct pci_dev *dev) 10308c2ecf20Sopenharmony_ci{ 10318c2ecf20Sopenharmony_ci u8 tmp; 10328c2ecf20Sopenharmony_ci 10338c2ecf20Sopenharmony_ci if (nr_ioapics < 1) 10348c2ecf20Sopenharmony_ci tmp = 0; /* nothing routed to external APIC */ 10358c2ecf20Sopenharmony_ci else 10368c2ecf20Sopenharmony_ci tmp = 0x1f; /* all known bits (4-0) routed to external APIC */ 10378c2ecf20Sopenharmony_ci 10388c2ecf20Sopenharmony_ci pci_info(dev, "%sbling VIA external APIC routing\n", 10398c2ecf20Sopenharmony_ci tmp == 0 ? "Disa" : "Ena"); 10408c2ecf20Sopenharmony_ci 10418c2ecf20Sopenharmony_ci /* Offset 0x58: External APIC IRQ output control */ 10428c2ecf20Sopenharmony_ci pci_write_config_byte(dev, 0x58, tmp); 10438c2ecf20Sopenharmony_ci} 10448c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686, quirk_via_ioapic); 10458c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686, quirk_via_ioapic); 10468c2ecf20Sopenharmony_ci 10478c2ecf20Sopenharmony_ci/* 10488c2ecf20Sopenharmony_ci * VIA 8237: Some BIOSes don't set the 'Bypass APIC De-Assert Message' Bit. 10498c2ecf20Sopenharmony_ci * This leads to doubled level interrupt rates. 10508c2ecf20Sopenharmony_ci * Set this bit to get rid of cycle wastage. 10518c2ecf20Sopenharmony_ci * Otherwise uncritical. 10528c2ecf20Sopenharmony_ci */ 10538c2ecf20Sopenharmony_cistatic void quirk_via_vt8237_bypass_apic_deassert(struct pci_dev *dev) 10548c2ecf20Sopenharmony_ci{ 10558c2ecf20Sopenharmony_ci u8 misc_control2; 10568c2ecf20Sopenharmony_ci#define BYPASS_APIC_DEASSERT 8 10578c2ecf20Sopenharmony_ci 10588c2ecf20Sopenharmony_ci pci_read_config_byte(dev, 0x5B, &misc_control2); 10598c2ecf20Sopenharmony_ci if (!(misc_control2 & BYPASS_APIC_DEASSERT)) { 10608c2ecf20Sopenharmony_ci pci_info(dev, "Bypassing VIA 8237 APIC De-Assert Message\n"); 10618c2ecf20Sopenharmony_ci pci_write_config_byte(dev, 0x5B, misc_control2|BYPASS_APIC_DEASSERT); 10628c2ecf20Sopenharmony_ci } 10638c2ecf20Sopenharmony_ci} 10648c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237, quirk_via_vt8237_bypass_apic_deassert); 10658c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237, quirk_via_vt8237_bypass_apic_deassert); 10668c2ecf20Sopenharmony_ci 10678c2ecf20Sopenharmony_ci/* 10688c2ecf20Sopenharmony_ci * The AMD IO-APIC can hang the box when an APIC IRQ is masked. 10698c2ecf20Sopenharmony_ci * We check all revs >= B0 (yet not in the pre production!) as the bug 10708c2ecf20Sopenharmony_ci * is currently marked NoFix 10718c2ecf20Sopenharmony_ci * 10728c2ecf20Sopenharmony_ci * We have multiple reports of hangs with this chipset that went away with 10738c2ecf20Sopenharmony_ci * noapic specified. For the moment we assume it's the erratum. We may be wrong 10748c2ecf20Sopenharmony_ci * of course. However the advice is demonstrably good even if so. 10758c2ecf20Sopenharmony_ci */ 10768c2ecf20Sopenharmony_cistatic void quirk_amd_ioapic(struct pci_dev *dev) 10778c2ecf20Sopenharmony_ci{ 10788c2ecf20Sopenharmony_ci if (dev->revision >= 0x02) { 10798c2ecf20Sopenharmony_ci pci_warn(dev, "I/O APIC: AMD Erratum #22 may be present. In the event of instability try\n"); 10808c2ecf20Sopenharmony_ci pci_warn(dev, " : booting with the \"noapic\" option\n"); 10818c2ecf20Sopenharmony_ci } 10828c2ecf20Sopenharmony_ci} 10838c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_VIPER_7410, quirk_amd_ioapic); 10848c2ecf20Sopenharmony_ci#endif /* CONFIG_X86_IO_APIC */ 10858c2ecf20Sopenharmony_ci 10868c2ecf20Sopenharmony_ci#if defined(CONFIG_ARM64) && defined(CONFIG_PCI_ATS) 10878c2ecf20Sopenharmony_ci 10888c2ecf20Sopenharmony_cistatic void quirk_cavium_sriov_rnm_link(struct pci_dev *dev) 10898c2ecf20Sopenharmony_ci{ 10908c2ecf20Sopenharmony_ci /* Fix for improper SR-IOV configuration on Cavium cn88xx RNM device */ 10918c2ecf20Sopenharmony_ci if (dev->subsystem_device == 0xa118) 10928c2ecf20Sopenharmony_ci dev->sriov->link = dev->devfn; 10938c2ecf20Sopenharmony_ci} 10948c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CAVIUM, 0xa018, quirk_cavium_sriov_rnm_link); 10958c2ecf20Sopenharmony_ci#endif 10968c2ecf20Sopenharmony_ci 10978c2ecf20Sopenharmony_ci/* 10988c2ecf20Sopenharmony_ci * Some settings of MMRBC can lead to data corruption so block changes. 10998c2ecf20Sopenharmony_ci * See AMD 8131 HyperTransport PCI-X Tunnel Revision Guide 11008c2ecf20Sopenharmony_ci */ 11018c2ecf20Sopenharmony_cistatic void quirk_amd_8131_mmrbc(struct pci_dev *dev) 11028c2ecf20Sopenharmony_ci{ 11038c2ecf20Sopenharmony_ci if (dev->subordinate && dev->revision <= 0x12) { 11048c2ecf20Sopenharmony_ci pci_info(dev, "AMD8131 rev %x detected; disabling PCI-X MMRBC\n", 11058c2ecf20Sopenharmony_ci dev->revision); 11068c2ecf20Sopenharmony_ci dev->subordinate->bus_flags |= PCI_BUS_FLAGS_NO_MMRBC; 11078c2ecf20Sopenharmony_ci } 11088c2ecf20Sopenharmony_ci} 11098c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8131_BRIDGE, quirk_amd_8131_mmrbc); 11108c2ecf20Sopenharmony_ci 11118c2ecf20Sopenharmony_ci/* 11128c2ecf20Sopenharmony_ci * FIXME: it is questionable that quirk_via_acpi() is needed. It shows up 11138c2ecf20Sopenharmony_ci * as an ISA bridge, and does not support the PCI_INTERRUPT_LINE register 11148c2ecf20Sopenharmony_ci * at all. Therefore it seems like setting the pci_dev's IRQ to the value 11158c2ecf20Sopenharmony_ci * of the ACPI SCI interrupt is only done for convenience. 11168c2ecf20Sopenharmony_ci * -jgarzik 11178c2ecf20Sopenharmony_ci */ 11188c2ecf20Sopenharmony_cistatic void quirk_via_acpi(struct pci_dev *d) 11198c2ecf20Sopenharmony_ci{ 11208c2ecf20Sopenharmony_ci u8 irq; 11218c2ecf20Sopenharmony_ci 11228c2ecf20Sopenharmony_ci /* VIA ACPI device: SCI IRQ line in PCI config byte 0x42 */ 11238c2ecf20Sopenharmony_ci pci_read_config_byte(d, 0x42, &irq); 11248c2ecf20Sopenharmony_ci irq &= 0xf; 11258c2ecf20Sopenharmony_ci if (irq && (irq != 2)) 11268c2ecf20Sopenharmony_ci d->irq = irq; 11278c2ecf20Sopenharmony_ci} 11288c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_3, quirk_via_acpi); 11298c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_4, quirk_via_acpi); 11308c2ecf20Sopenharmony_ci 11318c2ecf20Sopenharmony_ci/* VIA bridges which have VLink */ 11328c2ecf20Sopenharmony_cistatic int via_vlink_dev_lo = -1, via_vlink_dev_hi = 18; 11338c2ecf20Sopenharmony_ci 11348c2ecf20Sopenharmony_cistatic void quirk_via_bridge(struct pci_dev *dev) 11358c2ecf20Sopenharmony_ci{ 11368c2ecf20Sopenharmony_ci /* See what bridge we have and find the device ranges */ 11378c2ecf20Sopenharmony_ci switch (dev->device) { 11388c2ecf20Sopenharmony_ci case PCI_DEVICE_ID_VIA_82C686: 11398c2ecf20Sopenharmony_ci /* 11408c2ecf20Sopenharmony_ci * The VT82C686 is special; it attaches to PCI and can have 11418c2ecf20Sopenharmony_ci * any device number. All its subdevices are functions of 11428c2ecf20Sopenharmony_ci * that single device. 11438c2ecf20Sopenharmony_ci */ 11448c2ecf20Sopenharmony_ci via_vlink_dev_lo = PCI_SLOT(dev->devfn); 11458c2ecf20Sopenharmony_ci via_vlink_dev_hi = PCI_SLOT(dev->devfn); 11468c2ecf20Sopenharmony_ci break; 11478c2ecf20Sopenharmony_ci case PCI_DEVICE_ID_VIA_8237: 11488c2ecf20Sopenharmony_ci case PCI_DEVICE_ID_VIA_8237A: 11498c2ecf20Sopenharmony_ci via_vlink_dev_lo = 15; 11508c2ecf20Sopenharmony_ci break; 11518c2ecf20Sopenharmony_ci case PCI_DEVICE_ID_VIA_8235: 11528c2ecf20Sopenharmony_ci via_vlink_dev_lo = 16; 11538c2ecf20Sopenharmony_ci break; 11548c2ecf20Sopenharmony_ci case PCI_DEVICE_ID_VIA_8231: 11558c2ecf20Sopenharmony_ci case PCI_DEVICE_ID_VIA_8233_0: 11568c2ecf20Sopenharmony_ci case PCI_DEVICE_ID_VIA_8233A: 11578c2ecf20Sopenharmony_ci case PCI_DEVICE_ID_VIA_8233C_0: 11588c2ecf20Sopenharmony_ci via_vlink_dev_lo = 17; 11598c2ecf20Sopenharmony_ci break; 11608c2ecf20Sopenharmony_ci } 11618c2ecf20Sopenharmony_ci} 11628c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686, quirk_via_bridge); 11638c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8231, quirk_via_bridge); 11648c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8233_0, quirk_via_bridge); 11658c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8233A, quirk_via_bridge); 11668c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8233C_0, quirk_via_bridge); 11678c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8235, quirk_via_bridge); 11688c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237, quirk_via_bridge); 11698c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237A, quirk_via_bridge); 11708c2ecf20Sopenharmony_ci 11718c2ecf20Sopenharmony_ci/* 11728c2ecf20Sopenharmony_ci * quirk_via_vlink - VIA VLink IRQ number update 11738c2ecf20Sopenharmony_ci * @dev: PCI device 11748c2ecf20Sopenharmony_ci * 11758c2ecf20Sopenharmony_ci * If the device we are dealing with is on a PIC IRQ we need to ensure that 11768c2ecf20Sopenharmony_ci * the IRQ line register which usually is not relevant for PCI cards, is 11778c2ecf20Sopenharmony_ci * actually written so that interrupts get sent to the right place. 11788c2ecf20Sopenharmony_ci * 11798c2ecf20Sopenharmony_ci * We only do this on systems where a VIA south bridge was detected, and 11808c2ecf20Sopenharmony_ci * only for VIA devices on the motherboard (see quirk_via_bridge above). 11818c2ecf20Sopenharmony_ci */ 11828c2ecf20Sopenharmony_cistatic void quirk_via_vlink(struct pci_dev *dev) 11838c2ecf20Sopenharmony_ci{ 11848c2ecf20Sopenharmony_ci u8 irq, new_irq; 11858c2ecf20Sopenharmony_ci 11868c2ecf20Sopenharmony_ci /* Check if we have VLink at all */ 11878c2ecf20Sopenharmony_ci if (via_vlink_dev_lo == -1) 11888c2ecf20Sopenharmony_ci return; 11898c2ecf20Sopenharmony_ci 11908c2ecf20Sopenharmony_ci new_irq = dev->irq; 11918c2ecf20Sopenharmony_ci 11928c2ecf20Sopenharmony_ci /* Don't quirk interrupts outside the legacy IRQ range */ 11938c2ecf20Sopenharmony_ci if (!new_irq || new_irq > 15) 11948c2ecf20Sopenharmony_ci return; 11958c2ecf20Sopenharmony_ci 11968c2ecf20Sopenharmony_ci /* Internal device ? */ 11978c2ecf20Sopenharmony_ci if (dev->bus->number != 0 || PCI_SLOT(dev->devfn) > via_vlink_dev_hi || 11988c2ecf20Sopenharmony_ci PCI_SLOT(dev->devfn) < via_vlink_dev_lo) 11998c2ecf20Sopenharmony_ci return; 12008c2ecf20Sopenharmony_ci 12018c2ecf20Sopenharmony_ci /* 12028c2ecf20Sopenharmony_ci * This is an internal VLink device on a PIC interrupt. The BIOS 12038c2ecf20Sopenharmony_ci * ought to have set this but may not have, so we redo it. 12048c2ecf20Sopenharmony_ci */ 12058c2ecf20Sopenharmony_ci pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &irq); 12068c2ecf20Sopenharmony_ci if (new_irq != irq) { 12078c2ecf20Sopenharmony_ci pci_info(dev, "VIA VLink IRQ fixup, from %d to %d\n", 12088c2ecf20Sopenharmony_ci irq, new_irq); 12098c2ecf20Sopenharmony_ci udelay(15); /* unknown if delay really needed */ 12108c2ecf20Sopenharmony_ci pci_write_config_byte(dev, PCI_INTERRUPT_LINE, new_irq); 12118c2ecf20Sopenharmony_ci } 12128c2ecf20Sopenharmony_ci} 12138c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA, PCI_ANY_ID, quirk_via_vlink); 12148c2ecf20Sopenharmony_ci 12158c2ecf20Sopenharmony_ci/* 12168c2ecf20Sopenharmony_ci * VIA VT82C598 has its device ID settable and many BIOSes set it to the ID 12178c2ecf20Sopenharmony_ci * of VT82C597 for backward compatibility. We need to switch it off to be 12188c2ecf20Sopenharmony_ci * able to recognize the real type of the chip. 12198c2ecf20Sopenharmony_ci */ 12208c2ecf20Sopenharmony_cistatic void quirk_vt82c598_id(struct pci_dev *dev) 12218c2ecf20Sopenharmony_ci{ 12228c2ecf20Sopenharmony_ci pci_write_config_byte(dev, 0xfc, 0); 12238c2ecf20Sopenharmony_ci pci_read_config_word(dev, PCI_DEVICE_ID, &dev->device); 12248c2ecf20Sopenharmony_ci} 12258c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C597_0, quirk_vt82c598_id); 12268c2ecf20Sopenharmony_ci 12278c2ecf20Sopenharmony_ci/* 12288c2ecf20Sopenharmony_ci * CardBus controllers have a legacy base address that enables them to 12298c2ecf20Sopenharmony_ci * respond as i82365 pcmcia controllers. We don't want them to do this 12308c2ecf20Sopenharmony_ci * even if the Linux CardBus driver is not loaded, because the Linux i82365 12318c2ecf20Sopenharmony_ci * driver does not (and should not) handle CardBus. 12328c2ecf20Sopenharmony_ci */ 12338c2ecf20Sopenharmony_cistatic void quirk_cardbus_legacy(struct pci_dev *dev) 12348c2ecf20Sopenharmony_ci{ 12358c2ecf20Sopenharmony_ci pci_write_config_dword(dev, PCI_CB_LEGACY_MODE_BASE, 0); 12368c2ecf20Sopenharmony_ci} 12378c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_FINAL(PCI_ANY_ID, PCI_ANY_ID, 12388c2ecf20Sopenharmony_ci PCI_CLASS_BRIDGE_CARDBUS, 8, quirk_cardbus_legacy); 12398c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_RESUME_EARLY(PCI_ANY_ID, PCI_ANY_ID, 12408c2ecf20Sopenharmony_ci PCI_CLASS_BRIDGE_CARDBUS, 8, quirk_cardbus_legacy); 12418c2ecf20Sopenharmony_ci 12428c2ecf20Sopenharmony_ci/* 12438c2ecf20Sopenharmony_ci * Following the PCI ordering rules is optional on the AMD762. I'm not sure 12448c2ecf20Sopenharmony_ci * what the designers were smoking but let's not inhale... 12458c2ecf20Sopenharmony_ci * 12468c2ecf20Sopenharmony_ci * To be fair to AMD, it follows the spec by default, it's BIOS people who 12478c2ecf20Sopenharmony_ci * turn it off! 12488c2ecf20Sopenharmony_ci */ 12498c2ecf20Sopenharmony_cistatic void quirk_amd_ordering(struct pci_dev *dev) 12508c2ecf20Sopenharmony_ci{ 12518c2ecf20Sopenharmony_ci u32 pcic; 12528c2ecf20Sopenharmony_ci pci_read_config_dword(dev, 0x4C, &pcic); 12538c2ecf20Sopenharmony_ci if ((pcic & 6) != 6) { 12548c2ecf20Sopenharmony_ci pcic |= 6; 12558c2ecf20Sopenharmony_ci pci_warn(dev, "BIOS failed to enable PCI standards compliance; fixing this error\n"); 12568c2ecf20Sopenharmony_ci pci_write_config_dword(dev, 0x4C, pcic); 12578c2ecf20Sopenharmony_ci pci_read_config_dword(dev, 0x84, &pcic); 12588c2ecf20Sopenharmony_ci pcic |= (1 << 23); /* Required in this mode */ 12598c2ecf20Sopenharmony_ci pci_write_config_dword(dev, 0x84, pcic); 12608c2ecf20Sopenharmony_ci } 12618c2ecf20Sopenharmony_ci} 12628c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_FE_GATE_700C, quirk_amd_ordering); 12638c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_FE_GATE_700C, quirk_amd_ordering); 12648c2ecf20Sopenharmony_ci 12658c2ecf20Sopenharmony_ci/* 12668c2ecf20Sopenharmony_ci * DreamWorks-provided workaround for Dunord I-3000 problem 12678c2ecf20Sopenharmony_ci * 12688c2ecf20Sopenharmony_ci * This card decodes and responds to addresses not apparently assigned to 12698c2ecf20Sopenharmony_ci * it. We force a larger allocation to ensure that nothing gets put too 12708c2ecf20Sopenharmony_ci * close to it. 12718c2ecf20Sopenharmony_ci */ 12728c2ecf20Sopenharmony_cistatic void quirk_dunord(struct pci_dev *dev) 12738c2ecf20Sopenharmony_ci{ 12748c2ecf20Sopenharmony_ci struct resource *r = &dev->resource[1]; 12758c2ecf20Sopenharmony_ci 12768c2ecf20Sopenharmony_ci r->flags |= IORESOURCE_UNSET; 12778c2ecf20Sopenharmony_ci r->start = 0; 12788c2ecf20Sopenharmony_ci r->end = 0xffffff; 12798c2ecf20Sopenharmony_ci} 12808c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_DUNORD, PCI_DEVICE_ID_DUNORD_I3000, quirk_dunord); 12818c2ecf20Sopenharmony_ci 12828c2ecf20Sopenharmony_ci/* 12838c2ecf20Sopenharmony_ci * i82380FB mobile docking controller: its PCI-to-PCI bridge is subtractive 12848c2ecf20Sopenharmony_ci * decoding (transparent), and does indicate this in the ProgIf. 12858c2ecf20Sopenharmony_ci * Unfortunately, the ProgIf value is wrong - 0x80 instead of 0x01. 12868c2ecf20Sopenharmony_ci */ 12878c2ecf20Sopenharmony_cistatic void quirk_transparent_bridge(struct pci_dev *dev) 12888c2ecf20Sopenharmony_ci{ 12898c2ecf20Sopenharmony_ci dev->transparent = 1; 12908c2ecf20Sopenharmony_ci} 12918c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82380FB, quirk_transparent_bridge); 12928c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_TOSHIBA, 0x605, quirk_transparent_bridge); 12938c2ecf20Sopenharmony_ci 12948c2ecf20Sopenharmony_ci/* 12958c2ecf20Sopenharmony_ci * Common misconfiguration of the MediaGX/Geode PCI master that will reduce 12968c2ecf20Sopenharmony_ci * PCI bandwidth from 70MB/s to 25MB/s. See the GXM/GXLV/GX1 datasheets 12978c2ecf20Sopenharmony_ci * found at http://www.national.com/analog for info on what these bits do. 12988c2ecf20Sopenharmony_ci * <christer@weinigel.se> 12998c2ecf20Sopenharmony_ci */ 13008c2ecf20Sopenharmony_cistatic void quirk_mediagx_master(struct pci_dev *dev) 13018c2ecf20Sopenharmony_ci{ 13028c2ecf20Sopenharmony_ci u8 reg; 13038c2ecf20Sopenharmony_ci 13048c2ecf20Sopenharmony_ci pci_read_config_byte(dev, 0x41, ®); 13058c2ecf20Sopenharmony_ci if (reg & 2) { 13068c2ecf20Sopenharmony_ci reg &= ~2; 13078c2ecf20Sopenharmony_ci pci_info(dev, "Fixup for MediaGX/Geode Slave Disconnect Boundary (0x41=0x%02x)\n", 13088c2ecf20Sopenharmony_ci reg); 13098c2ecf20Sopenharmony_ci pci_write_config_byte(dev, 0x41, reg); 13108c2ecf20Sopenharmony_ci } 13118c2ecf20Sopenharmony_ci} 13128c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CYRIX, PCI_DEVICE_ID_CYRIX_PCI_MASTER, quirk_mediagx_master); 13138c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_CYRIX, PCI_DEVICE_ID_CYRIX_PCI_MASTER, quirk_mediagx_master); 13148c2ecf20Sopenharmony_ci 13158c2ecf20Sopenharmony_ci/* 13168c2ecf20Sopenharmony_ci * Ensure C0 rev restreaming is off. This is normally done by the BIOS but 13178c2ecf20Sopenharmony_ci * in the odd case it is not the results are corruption hence the presence 13188c2ecf20Sopenharmony_ci * of a Linux check. 13198c2ecf20Sopenharmony_ci */ 13208c2ecf20Sopenharmony_cistatic void quirk_disable_pxb(struct pci_dev *pdev) 13218c2ecf20Sopenharmony_ci{ 13228c2ecf20Sopenharmony_ci u16 config; 13238c2ecf20Sopenharmony_ci 13248c2ecf20Sopenharmony_ci if (pdev->revision != 0x04) /* Only C0 requires this */ 13258c2ecf20Sopenharmony_ci return; 13268c2ecf20Sopenharmony_ci pci_read_config_word(pdev, 0x40, &config); 13278c2ecf20Sopenharmony_ci if (config & (1<<6)) { 13288c2ecf20Sopenharmony_ci config &= ~(1<<6); 13298c2ecf20Sopenharmony_ci pci_write_config_word(pdev, 0x40, config); 13308c2ecf20Sopenharmony_ci pci_info(pdev, "C0 revision 450NX. Disabling PCI restreaming\n"); 13318c2ecf20Sopenharmony_ci } 13328c2ecf20Sopenharmony_ci} 13338c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82454NX, quirk_disable_pxb); 13348c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82454NX, quirk_disable_pxb); 13358c2ecf20Sopenharmony_ci 13368c2ecf20Sopenharmony_cistatic void quirk_amd_ide_mode(struct pci_dev *pdev) 13378c2ecf20Sopenharmony_ci{ 13388c2ecf20Sopenharmony_ci /* set SBX00/Hudson-2 SATA in IDE mode to AHCI mode */ 13398c2ecf20Sopenharmony_ci u8 tmp; 13408c2ecf20Sopenharmony_ci 13418c2ecf20Sopenharmony_ci pci_read_config_byte(pdev, PCI_CLASS_DEVICE, &tmp); 13428c2ecf20Sopenharmony_ci if (tmp == 0x01) { 13438c2ecf20Sopenharmony_ci pci_read_config_byte(pdev, 0x40, &tmp); 13448c2ecf20Sopenharmony_ci pci_write_config_byte(pdev, 0x40, tmp|1); 13458c2ecf20Sopenharmony_ci pci_write_config_byte(pdev, 0x9, 1); 13468c2ecf20Sopenharmony_ci pci_write_config_byte(pdev, 0xa, 6); 13478c2ecf20Sopenharmony_ci pci_write_config_byte(pdev, 0x40, tmp); 13488c2ecf20Sopenharmony_ci 13498c2ecf20Sopenharmony_ci pdev->class = PCI_CLASS_STORAGE_SATA_AHCI; 13508c2ecf20Sopenharmony_ci pci_info(pdev, "set SATA to AHCI mode\n"); 13518c2ecf20Sopenharmony_ci } 13528c2ecf20Sopenharmony_ci} 13538c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP600_SATA, quirk_amd_ide_mode); 13548c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP600_SATA, quirk_amd_ide_mode); 13558c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP700_SATA, quirk_amd_ide_mode); 13568c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP700_SATA, quirk_amd_ide_mode); 13578c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_HUDSON2_SATA_IDE, quirk_amd_ide_mode); 13588c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_HUDSON2_SATA_IDE, quirk_amd_ide_mode); 13598c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AMD, 0x7900, quirk_amd_ide_mode); 13608c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_AMD, 0x7900, quirk_amd_ide_mode); 13618c2ecf20Sopenharmony_ci 13628c2ecf20Sopenharmony_ci/* Serverworks CSB5 IDE does not fully support native mode */ 13638c2ecf20Sopenharmony_cistatic void quirk_svwks_csb5ide(struct pci_dev *pdev) 13648c2ecf20Sopenharmony_ci{ 13658c2ecf20Sopenharmony_ci u8 prog; 13668c2ecf20Sopenharmony_ci pci_read_config_byte(pdev, PCI_CLASS_PROG, &prog); 13678c2ecf20Sopenharmony_ci if (prog & 5) { 13688c2ecf20Sopenharmony_ci prog &= ~5; 13698c2ecf20Sopenharmony_ci pdev->class &= ~5; 13708c2ecf20Sopenharmony_ci pci_write_config_byte(pdev, PCI_CLASS_PROG, prog); 13718c2ecf20Sopenharmony_ci /* PCI layer will sort out resources */ 13728c2ecf20Sopenharmony_ci } 13738c2ecf20Sopenharmony_ci} 13748c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB5IDE, quirk_svwks_csb5ide); 13758c2ecf20Sopenharmony_ci 13768c2ecf20Sopenharmony_ci/* Intel 82801CAM ICH3-M datasheet says IDE modes must be the same */ 13778c2ecf20Sopenharmony_cistatic void quirk_ide_samemode(struct pci_dev *pdev) 13788c2ecf20Sopenharmony_ci{ 13798c2ecf20Sopenharmony_ci u8 prog; 13808c2ecf20Sopenharmony_ci 13818c2ecf20Sopenharmony_ci pci_read_config_byte(pdev, PCI_CLASS_PROG, &prog); 13828c2ecf20Sopenharmony_ci 13838c2ecf20Sopenharmony_ci if (((prog & 1) && !(prog & 4)) || ((prog & 4) && !(prog & 1))) { 13848c2ecf20Sopenharmony_ci pci_info(pdev, "IDE mode mismatch; forcing legacy mode\n"); 13858c2ecf20Sopenharmony_ci prog &= ~5; 13868c2ecf20Sopenharmony_ci pdev->class &= ~5; 13878c2ecf20Sopenharmony_ci pci_write_config_byte(pdev, PCI_CLASS_PROG, prog); 13888c2ecf20Sopenharmony_ci } 13898c2ecf20Sopenharmony_ci} 13908c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_10, quirk_ide_samemode); 13918c2ecf20Sopenharmony_ci 13928c2ecf20Sopenharmony_ci/* Some ATA devices break if put into D3 */ 13938c2ecf20Sopenharmony_cistatic void quirk_no_ata_d3(struct pci_dev *pdev) 13948c2ecf20Sopenharmony_ci{ 13958c2ecf20Sopenharmony_ci pdev->dev_flags |= PCI_DEV_FLAGS_NO_D3; 13968c2ecf20Sopenharmony_ci} 13978c2ecf20Sopenharmony_ci/* Quirk the legacy ATA devices only. The AHCI ones are ok */ 13988c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_SERVERWORKS, PCI_ANY_ID, 13998c2ecf20Sopenharmony_ci PCI_CLASS_STORAGE_IDE, 8, quirk_no_ata_d3); 14008c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_ATI, PCI_ANY_ID, 14018c2ecf20Sopenharmony_ci PCI_CLASS_STORAGE_IDE, 8, quirk_no_ata_d3); 14028c2ecf20Sopenharmony_ci/* ALi loses some register settings that we cannot then restore */ 14038c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_AL, PCI_ANY_ID, 14048c2ecf20Sopenharmony_ci PCI_CLASS_STORAGE_IDE, 8, quirk_no_ata_d3); 14058c2ecf20Sopenharmony_ci/* VIA comes back fine but we need to keep it alive or ACPI GTM failures 14068c2ecf20Sopenharmony_ci occur when mode detecting */ 14078c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_VIA, PCI_ANY_ID, 14088c2ecf20Sopenharmony_ci PCI_CLASS_STORAGE_IDE, 8, quirk_no_ata_d3); 14098c2ecf20Sopenharmony_ci 14108c2ecf20Sopenharmony_ci/* 14118c2ecf20Sopenharmony_ci * This was originally an Alpha-specific thing, but it really fits here. 14128c2ecf20Sopenharmony_ci * The i82375 PCI/EISA bridge appears as non-classified. Fix that. 14138c2ecf20Sopenharmony_ci */ 14148c2ecf20Sopenharmony_cistatic void quirk_eisa_bridge(struct pci_dev *dev) 14158c2ecf20Sopenharmony_ci{ 14168c2ecf20Sopenharmony_ci dev->class = PCI_CLASS_BRIDGE_EISA << 8; 14178c2ecf20Sopenharmony_ci} 14188c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82375, quirk_eisa_bridge); 14198c2ecf20Sopenharmony_ci 14208c2ecf20Sopenharmony_ci/* 14218c2ecf20Sopenharmony_ci * On ASUS P4B boards, the SMBus PCI Device within the ICH2/4 southbridge 14228c2ecf20Sopenharmony_ci * is not activated. The myth is that Asus said that they do not want the 14238c2ecf20Sopenharmony_ci * users to be irritated by just another PCI Device in the Win98 device 14248c2ecf20Sopenharmony_ci * manager. (see the file prog/hotplug/README.p4b in the lm_sensors 14258c2ecf20Sopenharmony_ci * package 2.7.0 for details) 14268c2ecf20Sopenharmony_ci * 14278c2ecf20Sopenharmony_ci * The SMBus PCI Device can be activated by setting a bit in the ICH LPC 14288c2ecf20Sopenharmony_ci * bridge. Unfortunately, this device has no subvendor/subdevice ID. So it 14298c2ecf20Sopenharmony_ci * becomes necessary to do this tweak in two steps -- the chosen trigger 14308c2ecf20Sopenharmony_ci * is either the Host bridge (preferred) or on-board VGA controller. 14318c2ecf20Sopenharmony_ci * 14328c2ecf20Sopenharmony_ci * Note that we used to unhide the SMBus that way on Toshiba laptops 14338c2ecf20Sopenharmony_ci * (Satellite A40 and Tecra M2) but then found that the thermal management 14348c2ecf20Sopenharmony_ci * was done by SMM code, which could cause unsynchronized concurrent 14358c2ecf20Sopenharmony_ci * accesses to the SMBus registers, with potentially bad effects. Thus you 14368c2ecf20Sopenharmony_ci * should be very careful when adding new entries: if SMM is accessing the 14378c2ecf20Sopenharmony_ci * Intel SMBus, this is a very good reason to leave it hidden. 14388c2ecf20Sopenharmony_ci * 14398c2ecf20Sopenharmony_ci * Likewise, many recent laptops use ACPI for thermal management. If the 14408c2ecf20Sopenharmony_ci * ACPI DSDT code accesses the SMBus, then Linux should not access it 14418c2ecf20Sopenharmony_ci * natively, and keeping the SMBus hidden is the right thing to do. If you 14428c2ecf20Sopenharmony_ci * are about to add an entry in the table below, please first disassemble 14438c2ecf20Sopenharmony_ci * the DSDT and double-check that there is no code accessing the SMBus. 14448c2ecf20Sopenharmony_ci */ 14458c2ecf20Sopenharmony_cistatic int asus_hides_smbus; 14468c2ecf20Sopenharmony_ci 14478c2ecf20Sopenharmony_cistatic void asus_hides_smbus_hostbridge(struct pci_dev *dev) 14488c2ecf20Sopenharmony_ci{ 14498c2ecf20Sopenharmony_ci if (unlikely(dev->subsystem_vendor == PCI_VENDOR_ID_ASUSTEK)) { 14508c2ecf20Sopenharmony_ci if (dev->device == PCI_DEVICE_ID_INTEL_82845_HB) 14518c2ecf20Sopenharmony_ci switch (dev->subsystem_device) { 14528c2ecf20Sopenharmony_ci case 0x8025: /* P4B-LX */ 14538c2ecf20Sopenharmony_ci case 0x8070: /* P4B */ 14548c2ecf20Sopenharmony_ci case 0x8088: /* P4B533 */ 14558c2ecf20Sopenharmony_ci case 0x1626: /* L3C notebook */ 14568c2ecf20Sopenharmony_ci asus_hides_smbus = 1; 14578c2ecf20Sopenharmony_ci } 14588c2ecf20Sopenharmony_ci else if (dev->device == PCI_DEVICE_ID_INTEL_82845G_HB) 14598c2ecf20Sopenharmony_ci switch (dev->subsystem_device) { 14608c2ecf20Sopenharmony_ci case 0x80b1: /* P4GE-V */ 14618c2ecf20Sopenharmony_ci case 0x80b2: /* P4PE */ 14628c2ecf20Sopenharmony_ci case 0x8093: /* P4B533-V */ 14638c2ecf20Sopenharmony_ci asus_hides_smbus = 1; 14648c2ecf20Sopenharmony_ci } 14658c2ecf20Sopenharmony_ci else if (dev->device == PCI_DEVICE_ID_INTEL_82850_HB) 14668c2ecf20Sopenharmony_ci switch (dev->subsystem_device) { 14678c2ecf20Sopenharmony_ci case 0x8030: /* P4T533 */ 14688c2ecf20Sopenharmony_ci asus_hides_smbus = 1; 14698c2ecf20Sopenharmony_ci } 14708c2ecf20Sopenharmony_ci else if (dev->device == PCI_DEVICE_ID_INTEL_7205_0) 14718c2ecf20Sopenharmony_ci switch (dev->subsystem_device) { 14728c2ecf20Sopenharmony_ci case 0x8070: /* P4G8X Deluxe */ 14738c2ecf20Sopenharmony_ci asus_hides_smbus = 1; 14748c2ecf20Sopenharmony_ci } 14758c2ecf20Sopenharmony_ci else if (dev->device == PCI_DEVICE_ID_INTEL_E7501_MCH) 14768c2ecf20Sopenharmony_ci switch (dev->subsystem_device) { 14778c2ecf20Sopenharmony_ci case 0x80c9: /* PU-DLS */ 14788c2ecf20Sopenharmony_ci asus_hides_smbus = 1; 14798c2ecf20Sopenharmony_ci } 14808c2ecf20Sopenharmony_ci else if (dev->device == PCI_DEVICE_ID_INTEL_82855GM_HB) 14818c2ecf20Sopenharmony_ci switch (dev->subsystem_device) { 14828c2ecf20Sopenharmony_ci case 0x1751: /* M2N notebook */ 14838c2ecf20Sopenharmony_ci case 0x1821: /* M5N notebook */ 14848c2ecf20Sopenharmony_ci case 0x1897: /* A6L notebook */ 14858c2ecf20Sopenharmony_ci asus_hides_smbus = 1; 14868c2ecf20Sopenharmony_ci } 14878c2ecf20Sopenharmony_ci else if (dev->device == PCI_DEVICE_ID_INTEL_82855PM_HB) 14888c2ecf20Sopenharmony_ci switch (dev->subsystem_device) { 14898c2ecf20Sopenharmony_ci case 0x184b: /* W1N notebook */ 14908c2ecf20Sopenharmony_ci case 0x186a: /* M6Ne notebook */ 14918c2ecf20Sopenharmony_ci asus_hides_smbus = 1; 14928c2ecf20Sopenharmony_ci } 14938c2ecf20Sopenharmony_ci else if (dev->device == PCI_DEVICE_ID_INTEL_82865_HB) 14948c2ecf20Sopenharmony_ci switch (dev->subsystem_device) { 14958c2ecf20Sopenharmony_ci case 0x80f2: /* P4P800-X */ 14968c2ecf20Sopenharmony_ci asus_hides_smbus = 1; 14978c2ecf20Sopenharmony_ci } 14988c2ecf20Sopenharmony_ci else if (dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB) 14998c2ecf20Sopenharmony_ci switch (dev->subsystem_device) { 15008c2ecf20Sopenharmony_ci case 0x1882: /* M6V notebook */ 15018c2ecf20Sopenharmony_ci case 0x1977: /* A6VA notebook */ 15028c2ecf20Sopenharmony_ci asus_hides_smbus = 1; 15038c2ecf20Sopenharmony_ci } 15048c2ecf20Sopenharmony_ci } else if (unlikely(dev->subsystem_vendor == PCI_VENDOR_ID_HP)) { 15058c2ecf20Sopenharmony_ci if (dev->device == PCI_DEVICE_ID_INTEL_82855PM_HB) 15068c2ecf20Sopenharmony_ci switch (dev->subsystem_device) { 15078c2ecf20Sopenharmony_ci case 0x088C: /* HP Compaq nc8000 */ 15088c2ecf20Sopenharmony_ci case 0x0890: /* HP Compaq nc6000 */ 15098c2ecf20Sopenharmony_ci asus_hides_smbus = 1; 15108c2ecf20Sopenharmony_ci } 15118c2ecf20Sopenharmony_ci else if (dev->device == PCI_DEVICE_ID_INTEL_82865_HB) 15128c2ecf20Sopenharmony_ci switch (dev->subsystem_device) { 15138c2ecf20Sopenharmony_ci case 0x12bc: /* HP D330L */ 15148c2ecf20Sopenharmony_ci case 0x12bd: /* HP D530 */ 15158c2ecf20Sopenharmony_ci case 0x006a: /* HP Compaq nx9500 */ 15168c2ecf20Sopenharmony_ci asus_hides_smbus = 1; 15178c2ecf20Sopenharmony_ci } 15188c2ecf20Sopenharmony_ci else if (dev->device == PCI_DEVICE_ID_INTEL_82875_HB) 15198c2ecf20Sopenharmony_ci switch (dev->subsystem_device) { 15208c2ecf20Sopenharmony_ci case 0x12bf: /* HP xw4100 */ 15218c2ecf20Sopenharmony_ci asus_hides_smbus = 1; 15228c2ecf20Sopenharmony_ci } 15238c2ecf20Sopenharmony_ci } else if (unlikely(dev->subsystem_vendor == PCI_VENDOR_ID_SAMSUNG)) { 15248c2ecf20Sopenharmony_ci if (dev->device == PCI_DEVICE_ID_INTEL_82855PM_HB) 15258c2ecf20Sopenharmony_ci switch (dev->subsystem_device) { 15268c2ecf20Sopenharmony_ci case 0xC00C: /* Samsung P35 notebook */ 15278c2ecf20Sopenharmony_ci asus_hides_smbus = 1; 15288c2ecf20Sopenharmony_ci } 15298c2ecf20Sopenharmony_ci } else if (unlikely(dev->subsystem_vendor == PCI_VENDOR_ID_COMPAQ)) { 15308c2ecf20Sopenharmony_ci if (dev->device == PCI_DEVICE_ID_INTEL_82855PM_HB) 15318c2ecf20Sopenharmony_ci switch (dev->subsystem_device) { 15328c2ecf20Sopenharmony_ci case 0x0058: /* Compaq Evo N620c */ 15338c2ecf20Sopenharmony_ci asus_hides_smbus = 1; 15348c2ecf20Sopenharmony_ci } 15358c2ecf20Sopenharmony_ci else if (dev->device == PCI_DEVICE_ID_INTEL_82810_IG3) 15368c2ecf20Sopenharmony_ci switch (dev->subsystem_device) { 15378c2ecf20Sopenharmony_ci case 0xB16C: /* Compaq Deskpro EP 401963-001 (PCA# 010174) */ 15388c2ecf20Sopenharmony_ci /* Motherboard doesn't have Host bridge 15398c2ecf20Sopenharmony_ci * subvendor/subdevice IDs, therefore checking 15408c2ecf20Sopenharmony_ci * its on-board VGA controller */ 15418c2ecf20Sopenharmony_ci asus_hides_smbus = 1; 15428c2ecf20Sopenharmony_ci } 15438c2ecf20Sopenharmony_ci else if (dev->device == PCI_DEVICE_ID_INTEL_82801DB_2) 15448c2ecf20Sopenharmony_ci switch (dev->subsystem_device) { 15458c2ecf20Sopenharmony_ci case 0x00b8: /* Compaq Evo D510 CMT */ 15468c2ecf20Sopenharmony_ci case 0x00b9: /* Compaq Evo D510 SFF */ 15478c2ecf20Sopenharmony_ci case 0x00ba: /* Compaq Evo D510 USDT */ 15488c2ecf20Sopenharmony_ci /* Motherboard doesn't have Host bridge 15498c2ecf20Sopenharmony_ci * subvendor/subdevice IDs and on-board VGA 15508c2ecf20Sopenharmony_ci * controller is disabled if an AGP card is 15518c2ecf20Sopenharmony_ci * inserted, therefore checking USB UHCI 15528c2ecf20Sopenharmony_ci * Controller #1 */ 15538c2ecf20Sopenharmony_ci asus_hides_smbus = 1; 15548c2ecf20Sopenharmony_ci } 15558c2ecf20Sopenharmony_ci else if (dev->device == PCI_DEVICE_ID_INTEL_82815_CGC) 15568c2ecf20Sopenharmony_ci switch (dev->subsystem_device) { 15578c2ecf20Sopenharmony_ci case 0x001A: /* Compaq Deskpro EN SSF P667 815E */ 15588c2ecf20Sopenharmony_ci /* Motherboard doesn't have host bridge 15598c2ecf20Sopenharmony_ci * subvendor/subdevice IDs, therefore checking 15608c2ecf20Sopenharmony_ci * its on-board VGA controller */ 15618c2ecf20Sopenharmony_ci asus_hides_smbus = 1; 15628c2ecf20Sopenharmony_ci } 15638c2ecf20Sopenharmony_ci } 15648c2ecf20Sopenharmony_ci} 15658c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82845_HB, asus_hides_smbus_hostbridge); 15668c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82845G_HB, asus_hides_smbus_hostbridge); 15678c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82850_HB, asus_hides_smbus_hostbridge); 15688c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82865_HB, asus_hides_smbus_hostbridge); 15698c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82875_HB, asus_hides_smbus_hostbridge); 15708c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_7205_0, asus_hides_smbus_hostbridge); 15718c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7501_MCH, asus_hides_smbus_hostbridge); 15728c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82855PM_HB, asus_hides_smbus_hostbridge); 15738c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82855GM_HB, asus_hides_smbus_hostbridge); 15748c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82915GM_HB, asus_hides_smbus_hostbridge); 15758c2ecf20Sopenharmony_ci 15768c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82810_IG3, asus_hides_smbus_hostbridge); 15778c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_2, asus_hides_smbus_hostbridge); 15788c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82815_CGC, asus_hides_smbus_hostbridge); 15798c2ecf20Sopenharmony_ci 15808c2ecf20Sopenharmony_cistatic void asus_hides_smbus_lpc(struct pci_dev *dev) 15818c2ecf20Sopenharmony_ci{ 15828c2ecf20Sopenharmony_ci u16 val; 15838c2ecf20Sopenharmony_ci 15848c2ecf20Sopenharmony_ci if (likely(!asus_hides_smbus)) 15858c2ecf20Sopenharmony_ci return; 15868c2ecf20Sopenharmony_ci 15878c2ecf20Sopenharmony_ci pci_read_config_word(dev, 0xF2, &val); 15888c2ecf20Sopenharmony_ci if (val & 0x8) { 15898c2ecf20Sopenharmony_ci pci_write_config_word(dev, 0xF2, val & (~0x8)); 15908c2ecf20Sopenharmony_ci pci_read_config_word(dev, 0xF2, &val); 15918c2ecf20Sopenharmony_ci if (val & 0x8) 15928c2ecf20Sopenharmony_ci pci_info(dev, "i801 SMBus device continues to play 'hide and seek'! 0x%x\n", 15938c2ecf20Sopenharmony_ci val); 15948c2ecf20Sopenharmony_ci else 15958c2ecf20Sopenharmony_ci pci_info(dev, "Enabled i801 SMBus device\n"); 15968c2ecf20Sopenharmony_ci } 15978c2ecf20Sopenharmony_ci} 15988c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801AA_0, asus_hides_smbus_lpc); 15998c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_0, asus_hides_smbus_lpc); 16008c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801BA_0, asus_hides_smbus_lpc); 16018c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_0, asus_hides_smbus_lpc); 16028c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_12, asus_hides_smbus_lpc); 16038c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_12, asus_hides_smbus_lpc); 16048c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_0, asus_hides_smbus_lpc); 16058c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801AA_0, asus_hides_smbus_lpc); 16068c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_0, asus_hides_smbus_lpc); 16078c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801BA_0, asus_hides_smbus_lpc); 16088c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_0, asus_hides_smbus_lpc); 16098c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_12, asus_hides_smbus_lpc); 16108c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_12, asus_hides_smbus_lpc); 16118c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_0, asus_hides_smbus_lpc); 16128c2ecf20Sopenharmony_ci 16138c2ecf20Sopenharmony_ci/* It appears we just have one such device. If not, we have a warning */ 16148c2ecf20Sopenharmony_cistatic void __iomem *asus_rcba_base; 16158c2ecf20Sopenharmony_cistatic void asus_hides_smbus_lpc_ich6_suspend(struct pci_dev *dev) 16168c2ecf20Sopenharmony_ci{ 16178c2ecf20Sopenharmony_ci u32 rcba; 16188c2ecf20Sopenharmony_ci 16198c2ecf20Sopenharmony_ci if (likely(!asus_hides_smbus)) 16208c2ecf20Sopenharmony_ci return; 16218c2ecf20Sopenharmony_ci WARN_ON(asus_rcba_base); 16228c2ecf20Sopenharmony_ci 16238c2ecf20Sopenharmony_ci pci_read_config_dword(dev, 0xF0, &rcba); 16248c2ecf20Sopenharmony_ci /* use bits 31:14, 16 kB aligned */ 16258c2ecf20Sopenharmony_ci asus_rcba_base = ioremap(rcba & 0xFFFFC000, 0x4000); 16268c2ecf20Sopenharmony_ci if (asus_rcba_base == NULL) 16278c2ecf20Sopenharmony_ci return; 16288c2ecf20Sopenharmony_ci} 16298c2ecf20Sopenharmony_ci 16308c2ecf20Sopenharmony_cistatic void asus_hides_smbus_lpc_ich6_resume_early(struct pci_dev *dev) 16318c2ecf20Sopenharmony_ci{ 16328c2ecf20Sopenharmony_ci u32 val; 16338c2ecf20Sopenharmony_ci 16348c2ecf20Sopenharmony_ci if (likely(!asus_hides_smbus || !asus_rcba_base)) 16358c2ecf20Sopenharmony_ci return; 16368c2ecf20Sopenharmony_ci 16378c2ecf20Sopenharmony_ci /* read the Function Disable register, dword mode only */ 16388c2ecf20Sopenharmony_ci val = readl(asus_rcba_base + 0x3418); 16398c2ecf20Sopenharmony_ci 16408c2ecf20Sopenharmony_ci /* enable the SMBus device */ 16418c2ecf20Sopenharmony_ci writel(val & 0xFFFFFFF7, asus_rcba_base + 0x3418); 16428c2ecf20Sopenharmony_ci} 16438c2ecf20Sopenharmony_ci 16448c2ecf20Sopenharmony_cistatic void asus_hides_smbus_lpc_ich6_resume(struct pci_dev *dev) 16458c2ecf20Sopenharmony_ci{ 16468c2ecf20Sopenharmony_ci if (likely(!asus_hides_smbus || !asus_rcba_base)) 16478c2ecf20Sopenharmony_ci return; 16488c2ecf20Sopenharmony_ci 16498c2ecf20Sopenharmony_ci iounmap(asus_rcba_base); 16508c2ecf20Sopenharmony_ci asus_rcba_base = NULL; 16518c2ecf20Sopenharmony_ci pci_info(dev, "Enabled ICH6/i801 SMBus device\n"); 16528c2ecf20Sopenharmony_ci} 16538c2ecf20Sopenharmony_ci 16548c2ecf20Sopenharmony_cistatic void asus_hides_smbus_lpc_ich6(struct pci_dev *dev) 16558c2ecf20Sopenharmony_ci{ 16568c2ecf20Sopenharmony_ci asus_hides_smbus_lpc_ich6_suspend(dev); 16578c2ecf20Sopenharmony_ci asus_hides_smbus_lpc_ich6_resume_early(dev); 16588c2ecf20Sopenharmony_ci asus_hides_smbus_lpc_ich6_resume(dev); 16598c2ecf20Sopenharmony_ci} 16608c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_1, asus_hides_smbus_lpc_ich6); 16618c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_SUSPEND(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_1, asus_hides_smbus_lpc_ich6_suspend); 16628c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_1, asus_hides_smbus_lpc_ich6_resume); 16638c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_1, asus_hides_smbus_lpc_ich6_resume_early); 16648c2ecf20Sopenharmony_ci 16658c2ecf20Sopenharmony_ci/* SiS 96x south bridge: BIOS typically hides SMBus device... */ 16668c2ecf20Sopenharmony_cistatic void quirk_sis_96x_smbus(struct pci_dev *dev) 16678c2ecf20Sopenharmony_ci{ 16688c2ecf20Sopenharmony_ci u8 val = 0; 16698c2ecf20Sopenharmony_ci pci_read_config_byte(dev, 0x77, &val); 16708c2ecf20Sopenharmony_ci if (val & 0x10) { 16718c2ecf20Sopenharmony_ci pci_info(dev, "Enabling SiS 96x SMBus\n"); 16728c2ecf20Sopenharmony_ci pci_write_config_byte(dev, 0x77, val & ~0x10); 16738c2ecf20Sopenharmony_ci } 16748c2ecf20Sopenharmony_ci} 16758c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_961, quirk_sis_96x_smbus); 16768c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_962, quirk_sis_96x_smbus); 16778c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_963, quirk_sis_96x_smbus); 16788c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_LPC, quirk_sis_96x_smbus); 16798c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_961, quirk_sis_96x_smbus); 16808c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_962, quirk_sis_96x_smbus); 16818c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_963, quirk_sis_96x_smbus); 16828c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_LPC, quirk_sis_96x_smbus); 16838c2ecf20Sopenharmony_ci 16848c2ecf20Sopenharmony_ci/* 16858c2ecf20Sopenharmony_ci * ... This is further complicated by the fact that some SiS96x south 16868c2ecf20Sopenharmony_ci * bridges pretend to be 85C503/5513 instead. In that case see if we 16878c2ecf20Sopenharmony_ci * spotted a compatible north bridge to make sure. 16888c2ecf20Sopenharmony_ci * (pci_find_device() doesn't work yet) 16898c2ecf20Sopenharmony_ci * 16908c2ecf20Sopenharmony_ci * We can also enable the sis96x bit in the discovery register.. 16918c2ecf20Sopenharmony_ci */ 16928c2ecf20Sopenharmony_ci#define SIS_DETECT_REGISTER 0x40 16938c2ecf20Sopenharmony_ci 16948c2ecf20Sopenharmony_cistatic void quirk_sis_503(struct pci_dev *dev) 16958c2ecf20Sopenharmony_ci{ 16968c2ecf20Sopenharmony_ci u8 reg; 16978c2ecf20Sopenharmony_ci u16 devid; 16988c2ecf20Sopenharmony_ci 16998c2ecf20Sopenharmony_ci pci_read_config_byte(dev, SIS_DETECT_REGISTER, ®); 17008c2ecf20Sopenharmony_ci pci_write_config_byte(dev, SIS_DETECT_REGISTER, reg | (1 << 6)); 17018c2ecf20Sopenharmony_ci pci_read_config_word(dev, PCI_DEVICE_ID, &devid); 17028c2ecf20Sopenharmony_ci if (((devid & 0xfff0) != 0x0960) && (devid != 0x0018)) { 17038c2ecf20Sopenharmony_ci pci_write_config_byte(dev, SIS_DETECT_REGISTER, reg); 17048c2ecf20Sopenharmony_ci return; 17058c2ecf20Sopenharmony_ci } 17068c2ecf20Sopenharmony_ci 17078c2ecf20Sopenharmony_ci /* 17088c2ecf20Sopenharmony_ci * Ok, it now shows up as a 96x. Run the 96x quirk by hand in case 17098c2ecf20Sopenharmony_ci * it has already been processed. (Depends on link order, which is 17108c2ecf20Sopenharmony_ci * apparently not guaranteed) 17118c2ecf20Sopenharmony_ci */ 17128c2ecf20Sopenharmony_ci dev->device = devid; 17138c2ecf20Sopenharmony_ci quirk_sis_96x_smbus(dev); 17148c2ecf20Sopenharmony_ci} 17158c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_503, quirk_sis_503); 17168c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_503, quirk_sis_503); 17178c2ecf20Sopenharmony_ci 17188c2ecf20Sopenharmony_ci/* 17198c2ecf20Sopenharmony_ci * On ASUS A8V and A8V Deluxe boards, the onboard AC97 audio controller 17208c2ecf20Sopenharmony_ci * and MC97 modem controller are disabled when a second PCI soundcard is 17218c2ecf20Sopenharmony_ci * present. This patch, tweaking the VT8237 ISA bridge, enables them. 17228c2ecf20Sopenharmony_ci * -- bjd 17238c2ecf20Sopenharmony_ci */ 17248c2ecf20Sopenharmony_cistatic void asus_hides_ac97_lpc(struct pci_dev *dev) 17258c2ecf20Sopenharmony_ci{ 17268c2ecf20Sopenharmony_ci u8 val; 17278c2ecf20Sopenharmony_ci int asus_hides_ac97 = 0; 17288c2ecf20Sopenharmony_ci 17298c2ecf20Sopenharmony_ci if (likely(dev->subsystem_vendor == PCI_VENDOR_ID_ASUSTEK)) { 17308c2ecf20Sopenharmony_ci if (dev->device == PCI_DEVICE_ID_VIA_8237) 17318c2ecf20Sopenharmony_ci asus_hides_ac97 = 1; 17328c2ecf20Sopenharmony_ci } 17338c2ecf20Sopenharmony_ci 17348c2ecf20Sopenharmony_ci if (!asus_hides_ac97) 17358c2ecf20Sopenharmony_ci return; 17368c2ecf20Sopenharmony_ci 17378c2ecf20Sopenharmony_ci pci_read_config_byte(dev, 0x50, &val); 17388c2ecf20Sopenharmony_ci if (val & 0xc0) { 17398c2ecf20Sopenharmony_ci pci_write_config_byte(dev, 0x50, val & (~0xc0)); 17408c2ecf20Sopenharmony_ci pci_read_config_byte(dev, 0x50, &val); 17418c2ecf20Sopenharmony_ci if (val & 0xc0) 17428c2ecf20Sopenharmony_ci pci_info(dev, "Onboard AC97/MC97 devices continue to play 'hide and seek'! 0x%x\n", 17438c2ecf20Sopenharmony_ci val); 17448c2ecf20Sopenharmony_ci else 17458c2ecf20Sopenharmony_ci pci_info(dev, "Enabled onboard AC97/MC97 devices\n"); 17468c2ecf20Sopenharmony_ci } 17478c2ecf20Sopenharmony_ci} 17488c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237, asus_hides_ac97_lpc); 17498c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237, asus_hides_ac97_lpc); 17508c2ecf20Sopenharmony_ci 17518c2ecf20Sopenharmony_ci#if defined(CONFIG_ATA) || defined(CONFIG_ATA_MODULE) 17528c2ecf20Sopenharmony_ci 17538c2ecf20Sopenharmony_ci/* 17548c2ecf20Sopenharmony_ci * If we are using libata we can drive this chip properly but must do this 17558c2ecf20Sopenharmony_ci * early on to make the additional device appear during the PCI scanning. 17568c2ecf20Sopenharmony_ci */ 17578c2ecf20Sopenharmony_cistatic void quirk_jmicron_ata(struct pci_dev *pdev) 17588c2ecf20Sopenharmony_ci{ 17598c2ecf20Sopenharmony_ci u32 conf1, conf5, class; 17608c2ecf20Sopenharmony_ci u8 hdr; 17618c2ecf20Sopenharmony_ci 17628c2ecf20Sopenharmony_ci /* Only poke fn 0 */ 17638c2ecf20Sopenharmony_ci if (PCI_FUNC(pdev->devfn)) 17648c2ecf20Sopenharmony_ci return; 17658c2ecf20Sopenharmony_ci 17668c2ecf20Sopenharmony_ci pci_read_config_dword(pdev, 0x40, &conf1); 17678c2ecf20Sopenharmony_ci pci_read_config_dword(pdev, 0x80, &conf5); 17688c2ecf20Sopenharmony_ci 17698c2ecf20Sopenharmony_ci conf1 &= ~0x00CFF302; /* Clear bit 1, 8, 9, 12-19, 22, 23 */ 17708c2ecf20Sopenharmony_ci conf5 &= ~(1 << 24); /* Clear bit 24 */ 17718c2ecf20Sopenharmony_ci 17728c2ecf20Sopenharmony_ci switch (pdev->device) { 17738c2ecf20Sopenharmony_ci case PCI_DEVICE_ID_JMICRON_JMB360: /* SATA single port */ 17748c2ecf20Sopenharmony_ci case PCI_DEVICE_ID_JMICRON_JMB362: /* SATA dual ports */ 17758c2ecf20Sopenharmony_ci case PCI_DEVICE_ID_JMICRON_JMB364: /* SATA dual ports */ 17768c2ecf20Sopenharmony_ci /* The controller should be in single function ahci mode */ 17778c2ecf20Sopenharmony_ci conf1 |= 0x0002A100; /* Set 8, 13, 15, 17 */ 17788c2ecf20Sopenharmony_ci break; 17798c2ecf20Sopenharmony_ci 17808c2ecf20Sopenharmony_ci case PCI_DEVICE_ID_JMICRON_JMB365: 17818c2ecf20Sopenharmony_ci case PCI_DEVICE_ID_JMICRON_JMB366: 17828c2ecf20Sopenharmony_ci /* Redirect IDE second PATA port to the right spot */ 17838c2ecf20Sopenharmony_ci conf5 |= (1 << 24); 17848c2ecf20Sopenharmony_ci fallthrough; 17858c2ecf20Sopenharmony_ci case PCI_DEVICE_ID_JMICRON_JMB361: 17868c2ecf20Sopenharmony_ci case PCI_DEVICE_ID_JMICRON_JMB363: 17878c2ecf20Sopenharmony_ci case PCI_DEVICE_ID_JMICRON_JMB369: 17888c2ecf20Sopenharmony_ci /* Enable dual function mode, AHCI on fn 0, IDE fn1 */ 17898c2ecf20Sopenharmony_ci /* Set the class codes correctly and then direct IDE 0 */ 17908c2ecf20Sopenharmony_ci conf1 |= 0x00C2A1B3; /* Set 0, 1, 4, 5, 7, 8, 13, 15, 17, 22, 23 */ 17918c2ecf20Sopenharmony_ci break; 17928c2ecf20Sopenharmony_ci 17938c2ecf20Sopenharmony_ci case PCI_DEVICE_ID_JMICRON_JMB368: 17948c2ecf20Sopenharmony_ci /* The controller should be in single function IDE mode */ 17958c2ecf20Sopenharmony_ci conf1 |= 0x00C00000; /* Set 22, 23 */ 17968c2ecf20Sopenharmony_ci break; 17978c2ecf20Sopenharmony_ci } 17988c2ecf20Sopenharmony_ci 17998c2ecf20Sopenharmony_ci pci_write_config_dword(pdev, 0x40, conf1); 18008c2ecf20Sopenharmony_ci pci_write_config_dword(pdev, 0x80, conf5); 18018c2ecf20Sopenharmony_ci 18028c2ecf20Sopenharmony_ci /* Update pdev accordingly */ 18038c2ecf20Sopenharmony_ci pci_read_config_byte(pdev, PCI_HEADER_TYPE, &hdr); 18048c2ecf20Sopenharmony_ci pdev->hdr_type = hdr & 0x7f; 18058c2ecf20Sopenharmony_ci pdev->multifunction = !!(hdr & 0x80); 18068c2ecf20Sopenharmony_ci 18078c2ecf20Sopenharmony_ci pci_read_config_dword(pdev, PCI_CLASS_REVISION, &class); 18088c2ecf20Sopenharmony_ci pdev->class = class >> 8; 18098c2ecf20Sopenharmony_ci} 18108c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB360, quirk_jmicron_ata); 18118c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB361, quirk_jmicron_ata); 18128c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB362, quirk_jmicron_ata); 18138c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB363, quirk_jmicron_ata); 18148c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB364, quirk_jmicron_ata); 18158c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB365, quirk_jmicron_ata); 18168c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB366, quirk_jmicron_ata); 18178c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB368, quirk_jmicron_ata); 18188c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB369, quirk_jmicron_ata); 18198c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB360, quirk_jmicron_ata); 18208c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB361, quirk_jmicron_ata); 18218c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB362, quirk_jmicron_ata); 18228c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB363, quirk_jmicron_ata); 18238c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB364, quirk_jmicron_ata); 18248c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB365, quirk_jmicron_ata); 18258c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB366, quirk_jmicron_ata); 18268c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB368, quirk_jmicron_ata); 18278c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB369, quirk_jmicron_ata); 18288c2ecf20Sopenharmony_ci 18298c2ecf20Sopenharmony_ci#endif 18308c2ecf20Sopenharmony_ci 18318c2ecf20Sopenharmony_cistatic void quirk_jmicron_async_suspend(struct pci_dev *dev) 18328c2ecf20Sopenharmony_ci{ 18338c2ecf20Sopenharmony_ci if (dev->multifunction) { 18348c2ecf20Sopenharmony_ci device_disable_async_suspend(&dev->dev); 18358c2ecf20Sopenharmony_ci pci_info(dev, "async suspend disabled to avoid multi-function power-on ordering issue\n"); 18368c2ecf20Sopenharmony_ci } 18378c2ecf20Sopenharmony_ci} 18388c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_JMICRON, PCI_ANY_ID, PCI_CLASS_STORAGE_IDE, 8, quirk_jmicron_async_suspend); 18398c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_JMICRON, PCI_ANY_ID, PCI_CLASS_STORAGE_SATA_AHCI, 0, quirk_jmicron_async_suspend); 18408c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_JMICRON, 0x2362, quirk_jmicron_async_suspend); 18418c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_JMICRON, 0x236f, quirk_jmicron_async_suspend); 18428c2ecf20Sopenharmony_ci 18438c2ecf20Sopenharmony_ci#ifdef CONFIG_X86_IO_APIC 18448c2ecf20Sopenharmony_cistatic void quirk_alder_ioapic(struct pci_dev *pdev) 18458c2ecf20Sopenharmony_ci{ 18468c2ecf20Sopenharmony_ci int i; 18478c2ecf20Sopenharmony_ci 18488c2ecf20Sopenharmony_ci if ((pdev->class >> 8) != 0xff00) 18498c2ecf20Sopenharmony_ci return; 18508c2ecf20Sopenharmony_ci 18518c2ecf20Sopenharmony_ci /* 18528c2ecf20Sopenharmony_ci * The first BAR is the location of the IO-APIC... we must 18538c2ecf20Sopenharmony_ci * not touch this (and it's already covered by the fixmap), so 18548c2ecf20Sopenharmony_ci * forcibly insert it into the resource tree. 18558c2ecf20Sopenharmony_ci */ 18568c2ecf20Sopenharmony_ci if (pci_resource_start(pdev, 0) && pci_resource_len(pdev, 0)) 18578c2ecf20Sopenharmony_ci insert_resource(&iomem_resource, &pdev->resource[0]); 18588c2ecf20Sopenharmony_ci 18598c2ecf20Sopenharmony_ci /* 18608c2ecf20Sopenharmony_ci * The next five BARs all seem to be rubbish, so just clean 18618c2ecf20Sopenharmony_ci * them out. 18628c2ecf20Sopenharmony_ci */ 18638c2ecf20Sopenharmony_ci for (i = 1; i < PCI_STD_NUM_BARS; i++) 18648c2ecf20Sopenharmony_ci memset(&pdev->resource[i], 0, sizeof(pdev->resource[i])); 18658c2ecf20Sopenharmony_ci} 18668c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_EESSC, quirk_alder_ioapic); 18678c2ecf20Sopenharmony_ci#endif 18688c2ecf20Sopenharmony_ci 18698c2ecf20Sopenharmony_cistatic void quirk_no_msi(struct pci_dev *dev) 18708c2ecf20Sopenharmony_ci{ 18718c2ecf20Sopenharmony_ci pci_info(dev, "avoiding MSI to work around a hardware defect\n"); 18728c2ecf20Sopenharmony_ci dev->no_msi = 1; 18738c2ecf20Sopenharmony_ci} 18748c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x4386, quirk_no_msi); 18758c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x4387, quirk_no_msi); 18768c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x4388, quirk_no_msi); 18778c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x4389, quirk_no_msi); 18788c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x438a, quirk_no_msi); 18798c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x438b, quirk_no_msi); 18808c2ecf20Sopenharmony_ci 18818c2ecf20Sopenharmony_cistatic void quirk_pcie_mch(struct pci_dev *pdev) 18828c2ecf20Sopenharmony_ci{ 18838c2ecf20Sopenharmony_ci pdev->no_msi = 1; 18848c2ecf20Sopenharmony_ci} 18858c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7520_MCH, quirk_pcie_mch); 18868c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7320_MCH, quirk_pcie_mch); 18878c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7525_MCH, quirk_pcie_mch); 18888c2ecf20Sopenharmony_ci 18898c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_HUAWEI, 0x1610, PCI_CLASS_BRIDGE_PCI, 8, quirk_pcie_mch); 18908c2ecf20Sopenharmony_ci 18918c2ecf20Sopenharmony_ci/* 18928c2ecf20Sopenharmony_ci * It's possible for the MSI to get corrupted if SHPC and ACPI are used 18938c2ecf20Sopenharmony_ci * together on certain PXH-based systems. 18948c2ecf20Sopenharmony_ci */ 18958c2ecf20Sopenharmony_cistatic void quirk_pcie_pxh(struct pci_dev *dev) 18968c2ecf20Sopenharmony_ci{ 18978c2ecf20Sopenharmony_ci dev->no_msi = 1; 18988c2ecf20Sopenharmony_ci pci_warn(dev, "PXH quirk detected; SHPC device MSI disabled\n"); 18998c2ecf20Sopenharmony_ci} 19008c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PXHD_0, quirk_pcie_pxh); 19018c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PXHD_1, quirk_pcie_pxh); 19028c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PXH_0, quirk_pcie_pxh); 19038c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PXH_1, quirk_pcie_pxh); 19048c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PXHV, quirk_pcie_pxh); 19058c2ecf20Sopenharmony_ci 19068c2ecf20Sopenharmony_ci/* 19078c2ecf20Sopenharmony_ci * Some Intel PCI Express chipsets have trouble with downstream device 19088c2ecf20Sopenharmony_ci * power management. 19098c2ecf20Sopenharmony_ci */ 19108c2ecf20Sopenharmony_cistatic void quirk_intel_pcie_pm(struct pci_dev *dev) 19118c2ecf20Sopenharmony_ci{ 19128c2ecf20Sopenharmony_ci pci_pm_d3hot_delay = 120; 19138c2ecf20Sopenharmony_ci dev->no_d1d2 = 1; 19148c2ecf20Sopenharmony_ci} 19158c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x25e2, quirk_intel_pcie_pm); 19168c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x25e3, quirk_intel_pcie_pm); 19178c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x25e4, quirk_intel_pcie_pm); 19188c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x25e5, quirk_intel_pcie_pm); 19198c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x25e6, quirk_intel_pcie_pm); 19208c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x25e7, quirk_intel_pcie_pm); 19218c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x25f7, quirk_intel_pcie_pm); 19228c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x25f8, quirk_intel_pcie_pm); 19238c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x25f9, quirk_intel_pcie_pm); 19248c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x25fa, quirk_intel_pcie_pm); 19258c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x2601, quirk_intel_pcie_pm); 19268c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x2602, quirk_intel_pcie_pm); 19278c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x2603, quirk_intel_pcie_pm); 19288c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x2604, quirk_intel_pcie_pm); 19298c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x2605, quirk_intel_pcie_pm); 19308c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x2606, quirk_intel_pcie_pm); 19318c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x2607, quirk_intel_pcie_pm); 19328c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x2608, quirk_intel_pcie_pm); 19338c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x2609, quirk_intel_pcie_pm); 19348c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x260a, quirk_intel_pcie_pm); 19358c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x260b, quirk_intel_pcie_pm); 19368c2ecf20Sopenharmony_ci 19378c2ecf20Sopenharmony_cistatic void quirk_d3hot_delay(struct pci_dev *dev, unsigned int delay) 19388c2ecf20Sopenharmony_ci{ 19398c2ecf20Sopenharmony_ci if (dev->d3hot_delay >= delay) 19408c2ecf20Sopenharmony_ci return; 19418c2ecf20Sopenharmony_ci 19428c2ecf20Sopenharmony_ci dev->d3hot_delay = delay; 19438c2ecf20Sopenharmony_ci pci_info(dev, "extending delay after power-on from D3hot to %d msec\n", 19448c2ecf20Sopenharmony_ci dev->d3hot_delay); 19458c2ecf20Sopenharmony_ci} 19468c2ecf20Sopenharmony_ci 19478c2ecf20Sopenharmony_cistatic void quirk_radeon_pm(struct pci_dev *dev) 19488c2ecf20Sopenharmony_ci{ 19498c2ecf20Sopenharmony_ci if (dev->subsystem_vendor == PCI_VENDOR_ID_APPLE && 19508c2ecf20Sopenharmony_ci dev->subsystem_device == 0x00e2) 19518c2ecf20Sopenharmony_ci quirk_d3hot_delay(dev, 20); 19528c2ecf20Sopenharmony_ci} 19538c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x6741, quirk_radeon_pm); 19548c2ecf20Sopenharmony_ci 19558c2ecf20Sopenharmony_ci/* 19568c2ecf20Sopenharmony_ci * Ryzen5/7 XHCI controllers fail upon resume from runtime suspend or s2idle. 19578c2ecf20Sopenharmony_ci * https://bugzilla.kernel.org/show_bug.cgi?id=205587 19588c2ecf20Sopenharmony_ci * 19598c2ecf20Sopenharmony_ci * The kernel attempts to transition these devices to D3cold, but that seems 19608c2ecf20Sopenharmony_ci * to be ineffective on the platforms in question; the PCI device appears to 19618c2ecf20Sopenharmony_ci * remain on in D3hot state. The D3hot-to-D0 transition then requires an 19628c2ecf20Sopenharmony_ci * extended delay in order to succeed. 19638c2ecf20Sopenharmony_ci */ 19648c2ecf20Sopenharmony_cistatic void quirk_ryzen_xhci_d3hot(struct pci_dev *dev) 19658c2ecf20Sopenharmony_ci{ 19668c2ecf20Sopenharmony_ci quirk_d3hot_delay(dev, 20); 19678c2ecf20Sopenharmony_ci} 19688c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, 0x15e0, quirk_ryzen_xhci_d3hot); 19698c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, 0x15e1, quirk_ryzen_xhci_d3hot); 19708c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, 0x1639, quirk_ryzen_xhci_d3hot); 19718c2ecf20Sopenharmony_ci 19728c2ecf20Sopenharmony_ci#ifdef CONFIG_X86_IO_APIC 19738c2ecf20Sopenharmony_cistatic int dmi_disable_ioapicreroute(const struct dmi_system_id *d) 19748c2ecf20Sopenharmony_ci{ 19758c2ecf20Sopenharmony_ci noioapicreroute = 1; 19768c2ecf20Sopenharmony_ci pr_info("%s detected: disable boot interrupt reroute\n", d->ident); 19778c2ecf20Sopenharmony_ci 19788c2ecf20Sopenharmony_ci return 0; 19798c2ecf20Sopenharmony_ci} 19808c2ecf20Sopenharmony_ci 19818c2ecf20Sopenharmony_cistatic const struct dmi_system_id boot_interrupt_dmi_table[] = { 19828c2ecf20Sopenharmony_ci /* 19838c2ecf20Sopenharmony_ci * Systems to exclude from boot interrupt reroute quirks 19848c2ecf20Sopenharmony_ci */ 19858c2ecf20Sopenharmony_ci { 19868c2ecf20Sopenharmony_ci .callback = dmi_disable_ioapicreroute, 19878c2ecf20Sopenharmony_ci .ident = "ASUSTek Computer INC. M2N-LR", 19888c2ecf20Sopenharmony_ci .matches = { 19898c2ecf20Sopenharmony_ci DMI_MATCH(DMI_SYS_VENDOR, "ASUSTek Computer INC."), 19908c2ecf20Sopenharmony_ci DMI_MATCH(DMI_PRODUCT_NAME, "M2N-LR"), 19918c2ecf20Sopenharmony_ci }, 19928c2ecf20Sopenharmony_ci }, 19938c2ecf20Sopenharmony_ci {} 19948c2ecf20Sopenharmony_ci}; 19958c2ecf20Sopenharmony_ci 19968c2ecf20Sopenharmony_ci/* 19978c2ecf20Sopenharmony_ci * Boot interrupts on some chipsets cannot be turned off. For these chipsets, 19988c2ecf20Sopenharmony_ci * remap the original interrupt in the Linux kernel to the boot interrupt, so 19998c2ecf20Sopenharmony_ci * that a PCI device's interrupt handler is installed on the boot interrupt 20008c2ecf20Sopenharmony_ci * line instead. 20018c2ecf20Sopenharmony_ci */ 20028c2ecf20Sopenharmony_cistatic void quirk_reroute_to_boot_interrupts_intel(struct pci_dev *dev) 20038c2ecf20Sopenharmony_ci{ 20048c2ecf20Sopenharmony_ci dmi_check_system(boot_interrupt_dmi_table); 20058c2ecf20Sopenharmony_ci if (noioapicquirk || noioapicreroute) 20068c2ecf20Sopenharmony_ci return; 20078c2ecf20Sopenharmony_ci 20088c2ecf20Sopenharmony_ci dev->irq_reroute_variant = INTEL_IRQ_REROUTE_VARIANT; 20098c2ecf20Sopenharmony_ci pci_info(dev, "rerouting interrupts for [%04x:%04x]\n", 20108c2ecf20Sopenharmony_ci dev->vendor, dev->device); 20118c2ecf20Sopenharmony_ci} 20128c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_80333_0, quirk_reroute_to_boot_interrupts_intel); 20138c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_80333_1, quirk_reroute_to_boot_interrupts_intel); 20148c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB2_0, quirk_reroute_to_boot_interrupts_intel); 20158c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PXH_0, quirk_reroute_to_boot_interrupts_intel); 20168c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PXH_1, quirk_reroute_to_boot_interrupts_intel); 20178c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PXHV, quirk_reroute_to_boot_interrupts_intel); 20188c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_80332_0, quirk_reroute_to_boot_interrupts_intel); 20198c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_80332_1, quirk_reroute_to_boot_interrupts_intel); 20208c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_80333_0, quirk_reroute_to_boot_interrupts_intel); 20218c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_80333_1, quirk_reroute_to_boot_interrupts_intel); 20228c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB2_0, quirk_reroute_to_boot_interrupts_intel); 20238c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PXH_0, quirk_reroute_to_boot_interrupts_intel); 20248c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PXH_1, quirk_reroute_to_boot_interrupts_intel); 20258c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PXHV, quirk_reroute_to_boot_interrupts_intel); 20268c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_80332_0, quirk_reroute_to_boot_interrupts_intel); 20278c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_80332_1, quirk_reroute_to_boot_interrupts_intel); 20288c2ecf20Sopenharmony_ci 20298c2ecf20Sopenharmony_ci/* 20308c2ecf20Sopenharmony_ci * On some chipsets we can disable the generation of legacy INTx boot 20318c2ecf20Sopenharmony_ci * interrupts. 20328c2ecf20Sopenharmony_ci */ 20338c2ecf20Sopenharmony_ci 20348c2ecf20Sopenharmony_ci/* 20358c2ecf20Sopenharmony_ci * IO-APIC1 on 6300ESB generates boot interrupts, see Intel order no 20368c2ecf20Sopenharmony_ci * 300641-004US, section 5.7.3. 20378c2ecf20Sopenharmony_ci * 20388c2ecf20Sopenharmony_ci * Core IO on Xeon E5 1600/2600/4600, see Intel order no 326509-003. 20398c2ecf20Sopenharmony_ci * Core IO on Xeon E5 v2, see Intel order no 329188-003. 20408c2ecf20Sopenharmony_ci * Core IO on Xeon E7 v2, see Intel order no 329595-002. 20418c2ecf20Sopenharmony_ci * Core IO on Xeon E5 v3, see Intel order no 330784-003. 20428c2ecf20Sopenharmony_ci * Core IO on Xeon E7 v3, see Intel order no 332315-001US. 20438c2ecf20Sopenharmony_ci * Core IO on Xeon E5 v4, see Intel order no 333810-002US. 20448c2ecf20Sopenharmony_ci * Core IO on Xeon E7 v4, see Intel order no 332315-001US. 20458c2ecf20Sopenharmony_ci * Core IO on Xeon D-1500, see Intel order no 332051-001. 20468c2ecf20Sopenharmony_ci * Core IO on Xeon Scalable, see Intel order no 610950. 20478c2ecf20Sopenharmony_ci */ 20488c2ecf20Sopenharmony_ci#define INTEL_6300_IOAPIC_ABAR 0x40 /* Bus 0, Dev 29, Func 5 */ 20498c2ecf20Sopenharmony_ci#define INTEL_6300_DISABLE_BOOT_IRQ (1<<14) 20508c2ecf20Sopenharmony_ci 20518c2ecf20Sopenharmony_ci#define INTEL_CIPINTRC_CFG_OFFSET 0x14C /* Bus 0, Dev 5, Func 0 */ 20528c2ecf20Sopenharmony_ci#define INTEL_CIPINTRC_DIS_INTX_ICH (1<<25) 20538c2ecf20Sopenharmony_ci 20548c2ecf20Sopenharmony_cistatic void quirk_disable_intel_boot_interrupt(struct pci_dev *dev) 20558c2ecf20Sopenharmony_ci{ 20568c2ecf20Sopenharmony_ci u16 pci_config_word; 20578c2ecf20Sopenharmony_ci u32 pci_config_dword; 20588c2ecf20Sopenharmony_ci 20598c2ecf20Sopenharmony_ci if (noioapicquirk) 20608c2ecf20Sopenharmony_ci return; 20618c2ecf20Sopenharmony_ci 20628c2ecf20Sopenharmony_ci switch (dev->device) { 20638c2ecf20Sopenharmony_ci case PCI_DEVICE_ID_INTEL_ESB_10: 20648c2ecf20Sopenharmony_ci pci_read_config_word(dev, INTEL_6300_IOAPIC_ABAR, 20658c2ecf20Sopenharmony_ci &pci_config_word); 20668c2ecf20Sopenharmony_ci pci_config_word |= INTEL_6300_DISABLE_BOOT_IRQ; 20678c2ecf20Sopenharmony_ci pci_write_config_word(dev, INTEL_6300_IOAPIC_ABAR, 20688c2ecf20Sopenharmony_ci pci_config_word); 20698c2ecf20Sopenharmony_ci break; 20708c2ecf20Sopenharmony_ci case 0x3c28: /* Xeon E5 1600/2600/4600 */ 20718c2ecf20Sopenharmony_ci case 0x0e28: /* Xeon E5/E7 V2 */ 20728c2ecf20Sopenharmony_ci case 0x2f28: /* Xeon E5/E7 V3,V4 */ 20738c2ecf20Sopenharmony_ci case 0x6f28: /* Xeon D-1500 */ 20748c2ecf20Sopenharmony_ci case 0x2034: /* Xeon Scalable Family */ 20758c2ecf20Sopenharmony_ci pci_read_config_dword(dev, INTEL_CIPINTRC_CFG_OFFSET, 20768c2ecf20Sopenharmony_ci &pci_config_dword); 20778c2ecf20Sopenharmony_ci pci_config_dword |= INTEL_CIPINTRC_DIS_INTX_ICH; 20788c2ecf20Sopenharmony_ci pci_write_config_dword(dev, INTEL_CIPINTRC_CFG_OFFSET, 20798c2ecf20Sopenharmony_ci pci_config_dword); 20808c2ecf20Sopenharmony_ci break; 20818c2ecf20Sopenharmony_ci default: 20828c2ecf20Sopenharmony_ci return; 20838c2ecf20Sopenharmony_ci } 20848c2ecf20Sopenharmony_ci pci_info(dev, "disabled boot interrupts on device [%04x:%04x]\n", 20858c2ecf20Sopenharmony_ci dev->vendor, dev->device); 20868c2ecf20Sopenharmony_ci} 20878c2ecf20Sopenharmony_ci/* 20888c2ecf20Sopenharmony_ci * Device 29 Func 5 Device IDs of IO-APIC 20898c2ecf20Sopenharmony_ci * containing ABAR—APIC1 Alternate Base Address Register 20908c2ecf20Sopenharmony_ci */ 20918c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_10, 20928c2ecf20Sopenharmony_ci quirk_disable_intel_boot_interrupt); 20938c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_10, 20948c2ecf20Sopenharmony_ci quirk_disable_intel_boot_interrupt); 20958c2ecf20Sopenharmony_ci 20968c2ecf20Sopenharmony_ci/* 20978c2ecf20Sopenharmony_ci * Device 5 Func 0 Device IDs of Core IO modules/hubs 20988c2ecf20Sopenharmony_ci * containing Coherent Interface Protocol Interrupt Control 20998c2ecf20Sopenharmony_ci * 21008c2ecf20Sopenharmony_ci * Device IDs obtained from volume 2 datasheets of commented 21018c2ecf20Sopenharmony_ci * families above. 21028c2ecf20Sopenharmony_ci */ 21038c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x3c28, 21048c2ecf20Sopenharmony_ci quirk_disable_intel_boot_interrupt); 21058c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x0e28, 21068c2ecf20Sopenharmony_ci quirk_disable_intel_boot_interrupt); 21078c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x2f28, 21088c2ecf20Sopenharmony_ci quirk_disable_intel_boot_interrupt); 21098c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x6f28, 21108c2ecf20Sopenharmony_ci quirk_disable_intel_boot_interrupt); 21118c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x2034, 21128c2ecf20Sopenharmony_ci quirk_disable_intel_boot_interrupt); 21138c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_INTEL, 0x3c28, 21148c2ecf20Sopenharmony_ci quirk_disable_intel_boot_interrupt); 21158c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_INTEL, 0x0e28, 21168c2ecf20Sopenharmony_ci quirk_disable_intel_boot_interrupt); 21178c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_INTEL, 0x2f28, 21188c2ecf20Sopenharmony_ci quirk_disable_intel_boot_interrupt); 21198c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_INTEL, 0x6f28, 21208c2ecf20Sopenharmony_ci quirk_disable_intel_boot_interrupt); 21218c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_INTEL, 0x2034, 21228c2ecf20Sopenharmony_ci quirk_disable_intel_boot_interrupt); 21238c2ecf20Sopenharmony_ci 21248c2ecf20Sopenharmony_ci/* Disable boot interrupts on HT-1000 */ 21258c2ecf20Sopenharmony_ci#define BC_HT1000_FEATURE_REG 0x64 21268c2ecf20Sopenharmony_ci#define BC_HT1000_PIC_REGS_ENABLE (1<<0) 21278c2ecf20Sopenharmony_ci#define BC_HT1000_MAP_IDX 0xC00 21288c2ecf20Sopenharmony_ci#define BC_HT1000_MAP_DATA 0xC01 21298c2ecf20Sopenharmony_ci 21308c2ecf20Sopenharmony_cistatic void quirk_disable_broadcom_boot_interrupt(struct pci_dev *dev) 21318c2ecf20Sopenharmony_ci{ 21328c2ecf20Sopenharmony_ci u32 pci_config_dword; 21338c2ecf20Sopenharmony_ci u8 irq; 21348c2ecf20Sopenharmony_ci 21358c2ecf20Sopenharmony_ci if (noioapicquirk) 21368c2ecf20Sopenharmony_ci return; 21378c2ecf20Sopenharmony_ci 21388c2ecf20Sopenharmony_ci pci_read_config_dword(dev, BC_HT1000_FEATURE_REG, &pci_config_dword); 21398c2ecf20Sopenharmony_ci pci_write_config_dword(dev, BC_HT1000_FEATURE_REG, pci_config_dword | 21408c2ecf20Sopenharmony_ci BC_HT1000_PIC_REGS_ENABLE); 21418c2ecf20Sopenharmony_ci 21428c2ecf20Sopenharmony_ci for (irq = 0x10; irq < 0x10 + 32; irq++) { 21438c2ecf20Sopenharmony_ci outb(irq, BC_HT1000_MAP_IDX); 21448c2ecf20Sopenharmony_ci outb(0x00, BC_HT1000_MAP_DATA); 21458c2ecf20Sopenharmony_ci } 21468c2ecf20Sopenharmony_ci 21478c2ecf20Sopenharmony_ci pci_write_config_dword(dev, BC_HT1000_FEATURE_REG, pci_config_dword); 21488c2ecf20Sopenharmony_ci 21498c2ecf20Sopenharmony_ci pci_info(dev, "disabled boot interrupts on device [%04x:%04x]\n", 21508c2ecf20Sopenharmony_ci dev->vendor, dev->device); 21518c2ecf20Sopenharmony_ci} 21528c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_HT1000SB, quirk_disable_broadcom_boot_interrupt); 21538c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_HT1000SB, quirk_disable_broadcom_boot_interrupt); 21548c2ecf20Sopenharmony_ci 21558c2ecf20Sopenharmony_ci/* Disable boot interrupts on AMD and ATI chipsets */ 21568c2ecf20Sopenharmony_ci 21578c2ecf20Sopenharmony_ci/* 21588c2ecf20Sopenharmony_ci * NOIOAMODE needs to be disabled to disable "boot interrupts". For AMD 8131 21598c2ecf20Sopenharmony_ci * rev. A0 and B0, NOIOAMODE needs to be disabled anyway to fix IO-APIC mode 21608c2ecf20Sopenharmony_ci * (due to an erratum). 21618c2ecf20Sopenharmony_ci */ 21628c2ecf20Sopenharmony_ci#define AMD_813X_MISC 0x40 21638c2ecf20Sopenharmony_ci#define AMD_813X_NOIOAMODE (1<<0) 21648c2ecf20Sopenharmony_ci#define AMD_813X_REV_B1 0x12 21658c2ecf20Sopenharmony_ci#define AMD_813X_REV_B2 0x13 21668c2ecf20Sopenharmony_ci 21678c2ecf20Sopenharmony_cistatic void quirk_disable_amd_813x_boot_interrupt(struct pci_dev *dev) 21688c2ecf20Sopenharmony_ci{ 21698c2ecf20Sopenharmony_ci u32 pci_config_dword; 21708c2ecf20Sopenharmony_ci 21718c2ecf20Sopenharmony_ci if (noioapicquirk) 21728c2ecf20Sopenharmony_ci return; 21738c2ecf20Sopenharmony_ci if ((dev->revision == AMD_813X_REV_B1) || 21748c2ecf20Sopenharmony_ci (dev->revision == AMD_813X_REV_B2)) 21758c2ecf20Sopenharmony_ci return; 21768c2ecf20Sopenharmony_ci 21778c2ecf20Sopenharmony_ci pci_read_config_dword(dev, AMD_813X_MISC, &pci_config_dword); 21788c2ecf20Sopenharmony_ci pci_config_dword &= ~AMD_813X_NOIOAMODE; 21798c2ecf20Sopenharmony_ci pci_write_config_dword(dev, AMD_813X_MISC, pci_config_dword); 21808c2ecf20Sopenharmony_ci 21818c2ecf20Sopenharmony_ci pci_info(dev, "disabled boot interrupts on device [%04x:%04x]\n", 21828c2ecf20Sopenharmony_ci dev->vendor, dev->device); 21838c2ecf20Sopenharmony_ci} 21848c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8131_BRIDGE, quirk_disable_amd_813x_boot_interrupt); 21858c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8131_BRIDGE, quirk_disable_amd_813x_boot_interrupt); 21868c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8132_BRIDGE, quirk_disable_amd_813x_boot_interrupt); 21878c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8132_BRIDGE, quirk_disable_amd_813x_boot_interrupt); 21888c2ecf20Sopenharmony_ci 21898c2ecf20Sopenharmony_ci#define AMD_8111_PCI_IRQ_ROUTING 0x56 21908c2ecf20Sopenharmony_ci 21918c2ecf20Sopenharmony_cistatic void quirk_disable_amd_8111_boot_interrupt(struct pci_dev *dev) 21928c2ecf20Sopenharmony_ci{ 21938c2ecf20Sopenharmony_ci u16 pci_config_word; 21948c2ecf20Sopenharmony_ci 21958c2ecf20Sopenharmony_ci if (noioapicquirk) 21968c2ecf20Sopenharmony_ci return; 21978c2ecf20Sopenharmony_ci 21988c2ecf20Sopenharmony_ci pci_read_config_word(dev, AMD_8111_PCI_IRQ_ROUTING, &pci_config_word); 21998c2ecf20Sopenharmony_ci if (!pci_config_word) { 22008c2ecf20Sopenharmony_ci pci_info(dev, "boot interrupts on device [%04x:%04x] already disabled\n", 22018c2ecf20Sopenharmony_ci dev->vendor, dev->device); 22028c2ecf20Sopenharmony_ci return; 22038c2ecf20Sopenharmony_ci } 22048c2ecf20Sopenharmony_ci pci_write_config_word(dev, AMD_8111_PCI_IRQ_ROUTING, 0); 22058c2ecf20Sopenharmony_ci pci_info(dev, "disabled boot interrupts on device [%04x:%04x]\n", 22068c2ecf20Sopenharmony_ci dev->vendor, dev->device); 22078c2ecf20Sopenharmony_ci} 22088c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8111_SMBUS, quirk_disable_amd_8111_boot_interrupt); 22098c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8111_SMBUS, quirk_disable_amd_8111_boot_interrupt); 22108c2ecf20Sopenharmony_ci#endif /* CONFIG_X86_IO_APIC */ 22118c2ecf20Sopenharmony_ci 22128c2ecf20Sopenharmony_ci/* 22138c2ecf20Sopenharmony_ci * Toshiba TC86C001 IDE controller reports the standard 8-byte BAR0 size 22148c2ecf20Sopenharmony_ci * but the PIO transfers won't work if BAR0 falls at the odd 8 bytes. 22158c2ecf20Sopenharmony_ci * Re-allocate the region if needed... 22168c2ecf20Sopenharmony_ci */ 22178c2ecf20Sopenharmony_cistatic void quirk_tc86c001_ide(struct pci_dev *dev) 22188c2ecf20Sopenharmony_ci{ 22198c2ecf20Sopenharmony_ci struct resource *r = &dev->resource[0]; 22208c2ecf20Sopenharmony_ci 22218c2ecf20Sopenharmony_ci if (r->start & 0x8) { 22228c2ecf20Sopenharmony_ci r->flags |= IORESOURCE_UNSET; 22238c2ecf20Sopenharmony_ci r->start = 0; 22248c2ecf20Sopenharmony_ci r->end = 0xf; 22258c2ecf20Sopenharmony_ci } 22268c2ecf20Sopenharmony_ci} 22278c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_TOSHIBA_2, 22288c2ecf20Sopenharmony_ci PCI_DEVICE_ID_TOSHIBA_TC86C001_IDE, 22298c2ecf20Sopenharmony_ci quirk_tc86c001_ide); 22308c2ecf20Sopenharmony_ci 22318c2ecf20Sopenharmony_ci/* 22328c2ecf20Sopenharmony_ci * PLX PCI 9050 PCI Target bridge controller has an erratum that prevents the 22338c2ecf20Sopenharmony_ci * local configuration registers accessible via BAR0 (memory) or BAR1 (i/o) 22348c2ecf20Sopenharmony_ci * being read correctly if bit 7 of the base address is set. 22358c2ecf20Sopenharmony_ci * The BAR0 or BAR1 region may be disabled (size 0) or enabled (size 128). 22368c2ecf20Sopenharmony_ci * Re-allocate the regions to a 256-byte boundary if necessary. 22378c2ecf20Sopenharmony_ci */ 22388c2ecf20Sopenharmony_cistatic void quirk_plx_pci9050(struct pci_dev *dev) 22398c2ecf20Sopenharmony_ci{ 22408c2ecf20Sopenharmony_ci unsigned int bar; 22418c2ecf20Sopenharmony_ci 22428c2ecf20Sopenharmony_ci /* Fixed in revision 2 (PCI 9052). */ 22438c2ecf20Sopenharmony_ci if (dev->revision >= 2) 22448c2ecf20Sopenharmony_ci return; 22458c2ecf20Sopenharmony_ci for (bar = 0; bar <= 1; bar++) 22468c2ecf20Sopenharmony_ci if (pci_resource_len(dev, bar) == 0x80 && 22478c2ecf20Sopenharmony_ci (pci_resource_start(dev, bar) & 0x80)) { 22488c2ecf20Sopenharmony_ci struct resource *r = &dev->resource[bar]; 22498c2ecf20Sopenharmony_ci pci_info(dev, "Re-allocating PLX PCI 9050 BAR %u to length 256 to avoid bit 7 bug\n", 22508c2ecf20Sopenharmony_ci bar); 22518c2ecf20Sopenharmony_ci r->flags |= IORESOURCE_UNSET; 22528c2ecf20Sopenharmony_ci r->start = 0; 22538c2ecf20Sopenharmony_ci r->end = 0xff; 22548c2ecf20Sopenharmony_ci } 22558c2ecf20Sopenharmony_ci} 22568c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9050, 22578c2ecf20Sopenharmony_ci quirk_plx_pci9050); 22588c2ecf20Sopenharmony_ci/* 22598c2ecf20Sopenharmony_ci * The following Meilhaus (vendor ID 0x1402) device IDs (amongst others) 22608c2ecf20Sopenharmony_ci * may be using the PLX PCI 9050: 0x0630, 0x0940, 0x0950, 0x0960, 0x100b, 22618c2ecf20Sopenharmony_ci * 0x1400, 0x140a, 0x140b, 0x14e0, 0x14ea, 0x14eb, 0x1604, 0x1608, 0x160c, 22628c2ecf20Sopenharmony_ci * 0x168f, 0x2000, 0x2600, 0x3000, 0x810a, 0x810b. 22638c2ecf20Sopenharmony_ci * 22648c2ecf20Sopenharmony_ci * Currently, device IDs 0x2000 and 0x2600 are used by the Comedi "me_daq" 22658c2ecf20Sopenharmony_ci * driver. 22668c2ecf20Sopenharmony_ci */ 22678c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(0x1402, 0x2000, quirk_plx_pci9050); 22688c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(0x1402, 0x2600, quirk_plx_pci9050); 22698c2ecf20Sopenharmony_ci 22708c2ecf20Sopenharmony_cistatic void quirk_netmos(struct pci_dev *dev) 22718c2ecf20Sopenharmony_ci{ 22728c2ecf20Sopenharmony_ci unsigned int num_parallel = (dev->subsystem_device & 0xf0) >> 4; 22738c2ecf20Sopenharmony_ci unsigned int num_serial = dev->subsystem_device & 0xf; 22748c2ecf20Sopenharmony_ci 22758c2ecf20Sopenharmony_ci /* 22768c2ecf20Sopenharmony_ci * These Netmos parts are multiport serial devices with optional 22778c2ecf20Sopenharmony_ci * parallel ports. Even when parallel ports are present, they 22788c2ecf20Sopenharmony_ci * are identified as class SERIAL, which means the serial driver 22798c2ecf20Sopenharmony_ci * will claim them. To prevent this, mark them as class OTHER. 22808c2ecf20Sopenharmony_ci * These combo devices should be claimed by parport_serial. 22818c2ecf20Sopenharmony_ci * 22828c2ecf20Sopenharmony_ci * The subdevice ID is of the form 0x00PS, where <P> is the number 22838c2ecf20Sopenharmony_ci * of parallel ports and <S> is the number of serial ports. 22848c2ecf20Sopenharmony_ci */ 22858c2ecf20Sopenharmony_ci switch (dev->device) { 22868c2ecf20Sopenharmony_ci case PCI_DEVICE_ID_NETMOS_9835: 22878c2ecf20Sopenharmony_ci /* Well, this rule doesn't hold for the following 9835 device */ 22888c2ecf20Sopenharmony_ci if (dev->subsystem_vendor == PCI_VENDOR_ID_IBM && 22898c2ecf20Sopenharmony_ci dev->subsystem_device == 0x0299) 22908c2ecf20Sopenharmony_ci return; 22918c2ecf20Sopenharmony_ci fallthrough; 22928c2ecf20Sopenharmony_ci case PCI_DEVICE_ID_NETMOS_9735: 22938c2ecf20Sopenharmony_ci case PCI_DEVICE_ID_NETMOS_9745: 22948c2ecf20Sopenharmony_ci case PCI_DEVICE_ID_NETMOS_9845: 22958c2ecf20Sopenharmony_ci case PCI_DEVICE_ID_NETMOS_9855: 22968c2ecf20Sopenharmony_ci if (num_parallel) { 22978c2ecf20Sopenharmony_ci pci_info(dev, "Netmos %04x (%u parallel, %u serial); changing class SERIAL to OTHER (use parport_serial)\n", 22988c2ecf20Sopenharmony_ci dev->device, num_parallel, num_serial); 22998c2ecf20Sopenharmony_ci dev->class = (PCI_CLASS_COMMUNICATION_OTHER << 8) | 23008c2ecf20Sopenharmony_ci (dev->class & 0xff); 23018c2ecf20Sopenharmony_ci } 23028c2ecf20Sopenharmony_ci } 23038c2ecf20Sopenharmony_ci} 23048c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_HEADER(PCI_VENDOR_ID_NETMOS, PCI_ANY_ID, 23058c2ecf20Sopenharmony_ci PCI_CLASS_COMMUNICATION_SERIAL, 8, quirk_netmos); 23068c2ecf20Sopenharmony_ci 23078c2ecf20Sopenharmony_cistatic void quirk_e100_interrupt(struct pci_dev *dev) 23088c2ecf20Sopenharmony_ci{ 23098c2ecf20Sopenharmony_ci u16 command, pmcsr; 23108c2ecf20Sopenharmony_ci u8 __iomem *csr; 23118c2ecf20Sopenharmony_ci u8 cmd_hi; 23128c2ecf20Sopenharmony_ci 23138c2ecf20Sopenharmony_ci switch (dev->device) { 23148c2ecf20Sopenharmony_ci /* PCI IDs taken from drivers/net/e100.c */ 23158c2ecf20Sopenharmony_ci case 0x1029: 23168c2ecf20Sopenharmony_ci case 0x1030 ... 0x1034: 23178c2ecf20Sopenharmony_ci case 0x1038 ... 0x103E: 23188c2ecf20Sopenharmony_ci case 0x1050 ... 0x1057: 23198c2ecf20Sopenharmony_ci case 0x1059: 23208c2ecf20Sopenharmony_ci case 0x1064 ... 0x106B: 23218c2ecf20Sopenharmony_ci case 0x1091 ... 0x1095: 23228c2ecf20Sopenharmony_ci case 0x1209: 23238c2ecf20Sopenharmony_ci case 0x1229: 23248c2ecf20Sopenharmony_ci case 0x2449: 23258c2ecf20Sopenharmony_ci case 0x2459: 23268c2ecf20Sopenharmony_ci case 0x245D: 23278c2ecf20Sopenharmony_ci case 0x27DC: 23288c2ecf20Sopenharmony_ci break; 23298c2ecf20Sopenharmony_ci default: 23308c2ecf20Sopenharmony_ci return; 23318c2ecf20Sopenharmony_ci } 23328c2ecf20Sopenharmony_ci 23338c2ecf20Sopenharmony_ci /* 23348c2ecf20Sopenharmony_ci * Some firmware hands off the e100 with interrupts enabled, 23358c2ecf20Sopenharmony_ci * which can cause a flood of interrupts if packets are 23368c2ecf20Sopenharmony_ci * received before the driver attaches to the device. So 23378c2ecf20Sopenharmony_ci * disable all e100 interrupts here. The driver will 23388c2ecf20Sopenharmony_ci * re-enable them when it's ready. 23398c2ecf20Sopenharmony_ci */ 23408c2ecf20Sopenharmony_ci pci_read_config_word(dev, PCI_COMMAND, &command); 23418c2ecf20Sopenharmony_ci 23428c2ecf20Sopenharmony_ci if (!(command & PCI_COMMAND_MEMORY) || !pci_resource_start(dev, 0)) 23438c2ecf20Sopenharmony_ci return; 23448c2ecf20Sopenharmony_ci 23458c2ecf20Sopenharmony_ci /* 23468c2ecf20Sopenharmony_ci * Check that the device is in the D0 power state. If it's not, 23478c2ecf20Sopenharmony_ci * there is no point to look any further. 23488c2ecf20Sopenharmony_ci */ 23498c2ecf20Sopenharmony_ci if (dev->pm_cap) { 23508c2ecf20Sopenharmony_ci pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr); 23518c2ecf20Sopenharmony_ci if ((pmcsr & PCI_PM_CTRL_STATE_MASK) != PCI_D0) 23528c2ecf20Sopenharmony_ci return; 23538c2ecf20Sopenharmony_ci } 23548c2ecf20Sopenharmony_ci 23558c2ecf20Sopenharmony_ci /* Convert from PCI bus to resource space. */ 23568c2ecf20Sopenharmony_ci csr = ioremap(pci_resource_start(dev, 0), 8); 23578c2ecf20Sopenharmony_ci if (!csr) { 23588c2ecf20Sopenharmony_ci pci_warn(dev, "Can't map e100 registers\n"); 23598c2ecf20Sopenharmony_ci return; 23608c2ecf20Sopenharmony_ci } 23618c2ecf20Sopenharmony_ci 23628c2ecf20Sopenharmony_ci cmd_hi = readb(csr + 3); 23638c2ecf20Sopenharmony_ci if (cmd_hi == 0) { 23648c2ecf20Sopenharmony_ci pci_warn(dev, "Firmware left e100 interrupts enabled; disabling\n"); 23658c2ecf20Sopenharmony_ci writeb(1, csr + 3); 23668c2ecf20Sopenharmony_ci } 23678c2ecf20Sopenharmony_ci 23688c2ecf20Sopenharmony_ci iounmap(csr); 23698c2ecf20Sopenharmony_ci} 23708c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_INTEL, PCI_ANY_ID, 23718c2ecf20Sopenharmony_ci PCI_CLASS_NETWORK_ETHERNET, 8, quirk_e100_interrupt); 23728c2ecf20Sopenharmony_ci 23738c2ecf20Sopenharmony_ci/* 23748c2ecf20Sopenharmony_ci * The 82575 and 82598 may experience data corruption issues when transitioning 23758c2ecf20Sopenharmony_ci * out of L0S. To prevent this we need to disable L0S on the PCIe link. 23768c2ecf20Sopenharmony_ci */ 23778c2ecf20Sopenharmony_cistatic void quirk_disable_aspm_l0s(struct pci_dev *dev) 23788c2ecf20Sopenharmony_ci{ 23798c2ecf20Sopenharmony_ci pci_info(dev, "Disabling L0s\n"); 23808c2ecf20Sopenharmony_ci pci_disable_link_state(dev, PCIE_LINK_STATE_L0S); 23818c2ecf20Sopenharmony_ci} 23828c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10a7, quirk_disable_aspm_l0s); 23838c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10a9, quirk_disable_aspm_l0s); 23848c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10b6, quirk_disable_aspm_l0s); 23858c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10c6, quirk_disable_aspm_l0s); 23868c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10c7, quirk_disable_aspm_l0s); 23878c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10c8, quirk_disable_aspm_l0s); 23888c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10d6, quirk_disable_aspm_l0s); 23898c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10db, quirk_disable_aspm_l0s); 23908c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10dd, quirk_disable_aspm_l0s); 23918c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10e1, quirk_disable_aspm_l0s); 23928c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10ec, quirk_disable_aspm_l0s); 23938c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10f1, quirk_disable_aspm_l0s); 23948c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x10f4, quirk_disable_aspm_l0s); 23958c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x1508, quirk_disable_aspm_l0s); 23968c2ecf20Sopenharmony_ci 23978c2ecf20Sopenharmony_cistatic void quirk_disable_aspm_l0s_l1(struct pci_dev *dev) 23988c2ecf20Sopenharmony_ci{ 23998c2ecf20Sopenharmony_ci pci_info(dev, "Disabling ASPM L0s/L1\n"); 24008c2ecf20Sopenharmony_ci pci_disable_link_state(dev, PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1); 24018c2ecf20Sopenharmony_ci} 24028c2ecf20Sopenharmony_ci 24038c2ecf20Sopenharmony_ci/* 24048c2ecf20Sopenharmony_ci * ASM1083/1085 PCIe-PCI bridge devices cause AER timeout errors on the 24058c2ecf20Sopenharmony_ci * upstream PCIe root port when ASPM is enabled. At least L0s mode is affected; 24068c2ecf20Sopenharmony_ci * disable both L0s and L1 for now to be safe. 24078c2ecf20Sopenharmony_ci */ 24088c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ASMEDIA, 0x1080, quirk_disable_aspm_l0s_l1); 24098c2ecf20Sopenharmony_ci 24108c2ecf20Sopenharmony_ci/* 24118c2ecf20Sopenharmony_ci * Some Pericom PCIe-to-PCI bridges in reverse mode need the PCIe Retrain 24128c2ecf20Sopenharmony_ci * Link bit cleared after starting the link retrain process to allow this 24138c2ecf20Sopenharmony_ci * process to finish. 24148c2ecf20Sopenharmony_ci * 24158c2ecf20Sopenharmony_ci * Affected devices: PI7C9X110, PI7C9X111SL, PI7C9X130. See also the 24168c2ecf20Sopenharmony_ci * Pericom Errata Sheet PI7C9X111SLB_errata_rev1.2_102711.pdf. 24178c2ecf20Sopenharmony_ci */ 24188c2ecf20Sopenharmony_cistatic void quirk_enable_clear_retrain_link(struct pci_dev *dev) 24198c2ecf20Sopenharmony_ci{ 24208c2ecf20Sopenharmony_ci dev->clear_retrain_link = 1; 24218c2ecf20Sopenharmony_ci pci_info(dev, "Enable PCIe Retrain Link quirk\n"); 24228c2ecf20Sopenharmony_ci} 24238c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(0x12d8, 0xe110, quirk_enable_clear_retrain_link); 24248c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(0x12d8, 0xe111, quirk_enable_clear_retrain_link); 24258c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(0x12d8, 0xe130, quirk_enable_clear_retrain_link); 24268c2ecf20Sopenharmony_ci 24278c2ecf20Sopenharmony_cistatic void fixup_rev1_53c810(struct pci_dev *dev) 24288c2ecf20Sopenharmony_ci{ 24298c2ecf20Sopenharmony_ci u32 class = dev->class; 24308c2ecf20Sopenharmony_ci 24318c2ecf20Sopenharmony_ci /* 24328c2ecf20Sopenharmony_ci * rev 1 ncr53c810 chips don't set the class at all which means 24338c2ecf20Sopenharmony_ci * they don't get their resources remapped. Fix that here. 24348c2ecf20Sopenharmony_ci */ 24358c2ecf20Sopenharmony_ci if (class) 24368c2ecf20Sopenharmony_ci return; 24378c2ecf20Sopenharmony_ci 24388c2ecf20Sopenharmony_ci dev->class = PCI_CLASS_STORAGE_SCSI << 8; 24398c2ecf20Sopenharmony_ci pci_info(dev, "NCR 53c810 rev 1 PCI class overridden (%#08x -> %#08x)\n", 24408c2ecf20Sopenharmony_ci class, dev->class); 24418c2ecf20Sopenharmony_ci} 24428c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NCR, PCI_DEVICE_ID_NCR_53C810, fixup_rev1_53c810); 24438c2ecf20Sopenharmony_ci 24448c2ecf20Sopenharmony_ci/* Enable 1k I/O space granularity on the Intel P64H2 */ 24458c2ecf20Sopenharmony_cistatic void quirk_p64h2_1k_io(struct pci_dev *dev) 24468c2ecf20Sopenharmony_ci{ 24478c2ecf20Sopenharmony_ci u16 en1k; 24488c2ecf20Sopenharmony_ci 24498c2ecf20Sopenharmony_ci pci_read_config_word(dev, 0x40, &en1k); 24508c2ecf20Sopenharmony_ci 24518c2ecf20Sopenharmony_ci if (en1k & 0x200) { 24528c2ecf20Sopenharmony_ci pci_info(dev, "Enable I/O Space to 1KB granularity\n"); 24538c2ecf20Sopenharmony_ci dev->io_window_1k = 1; 24548c2ecf20Sopenharmony_ci } 24558c2ecf20Sopenharmony_ci} 24568c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x1460, quirk_p64h2_1k_io); 24578c2ecf20Sopenharmony_ci 24588c2ecf20Sopenharmony_ci/* 24598c2ecf20Sopenharmony_ci * Under some circumstances, AER is not linked with extended capabilities. 24608c2ecf20Sopenharmony_ci * Force it to be linked by setting the corresponding control bit in the 24618c2ecf20Sopenharmony_ci * config space. 24628c2ecf20Sopenharmony_ci */ 24638c2ecf20Sopenharmony_cistatic void quirk_nvidia_ck804_pcie_aer_ext_cap(struct pci_dev *dev) 24648c2ecf20Sopenharmony_ci{ 24658c2ecf20Sopenharmony_ci uint8_t b; 24668c2ecf20Sopenharmony_ci 24678c2ecf20Sopenharmony_ci if (pci_read_config_byte(dev, 0xf41, &b) == 0) { 24688c2ecf20Sopenharmony_ci if (!(b & 0x20)) { 24698c2ecf20Sopenharmony_ci pci_write_config_byte(dev, 0xf41, b | 0x20); 24708c2ecf20Sopenharmony_ci pci_info(dev, "Linking AER extended capability\n"); 24718c2ecf20Sopenharmony_ci } 24728c2ecf20Sopenharmony_ci } 24738c2ecf20Sopenharmony_ci} 24748c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_CK804_PCIE, 24758c2ecf20Sopenharmony_ci quirk_nvidia_ck804_pcie_aer_ext_cap); 24768c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_CK804_PCIE, 24778c2ecf20Sopenharmony_ci quirk_nvidia_ck804_pcie_aer_ext_cap); 24788c2ecf20Sopenharmony_ci 24798c2ecf20Sopenharmony_cistatic void quirk_via_cx700_pci_parking_caching(struct pci_dev *dev) 24808c2ecf20Sopenharmony_ci{ 24818c2ecf20Sopenharmony_ci /* 24828c2ecf20Sopenharmony_ci * Disable PCI Bus Parking and PCI Master read caching on CX700 24838c2ecf20Sopenharmony_ci * which causes unspecified timing errors with a VT6212L on the PCI 24848c2ecf20Sopenharmony_ci * bus leading to USB2.0 packet loss. 24858c2ecf20Sopenharmony_ci * 24868c2ecf20Sopenharmony_ci * This quirk is only enabled if a second (on the external PCI bus) 24878c2ecf20Sopenharmony_ci * VT6212L is found -- the CX700 core itself also contains a USB 24888c2ecf20Sopenharmony_ci * host controller with the same PCI ID as the VT6212L. 24898c2ecf20Sopenharmony_ci */ 24908c2ecf20Sopenharmony_ci 24918c2ecf20Sopenharmony_ci /* Count VT6212L instances */ 24928c2ecf20Sopenharmony_ci struct pci_dev *p = pci_get_device(PCI_VENDOR_ID_VIA, 24938c2ecf20Sopenharmony_ci PCI_DEVICE_ID_VIA_8235_USB_2, NULL); 24948c2ecf20Sopenharmony_ci uint8_t b; 24958c2ecf20Sopenharmony_ci 24968c2ecf20Sopenharmony_ci /* 24978c2ecf20Sopenharmony_ci * p should contain the first (internal) VT6212L -- see if we have 24988c2ecf20Sopenharmony_ci * an external one by searching again. 24998c2ecf20Sopenharmony_ci */ 25008c2ecf20Sopenharmony_ci p = pci_get_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8235_USB_2, p); 25018c2ecf20Sopenharmony_ci if (!p) 25028c2ecf20Sopenharmony_ci return; 25038c2ecf20Sopenharmony_ci pci_dev_put(p); 25048c2ecf20Sopenharmony_ci 25058c2ecf20Sopenharmony_ci if (pci_read_config_byte(dev, 0x76, &b) == 0) { 25068c2ecf20Sopenharmony_ci if (b & 0x40) { 25078c2ecf20Sopenharmony_ci /* Turn off PCI Bus Parking */ 25088c2ecf20Sopenharmony_ci pci_write_config_byte(dev, 0x76, b ^ 0x40); 25098c2ecf20Sopenharmony_ci 25108c2ecf20Sopenharmony_ci pci_info(dev, "Disabling VIA CX700 PCI parking\n"); 25118c2ecf20Sopenharmony_ci } 25128c2ecf20Sopenharmony_ci } 25138c2ecf20Sopenharmony_ci 25148c2ecf20Sopenharmony_ci if (pci_read_config_byte(dev, 0x72, &b) == 0) { 25158c2ecf20Sopenharmony_ci if (b != 0) { 25168c2ecf20Sopenharmony_ci /* Turn off PCI Master read caching */ 25178c2ecf20Sopenharmony_ci pci_write_config_byte(dev, 0x72, 0x0); 25188c2ecf20Sopenharmony_ci 25198c2ecf20Sopenharmony_ci /* Set PCI Master Bus time-out to "1x16 PCLK" */ 25208c2ecf20Sopenharmony_ci pci_write_config_byte(dev, 0x75, 0x1); 25218c2ecf20Sopenharmony_ci 25228c2ecf20Sopenharmony_ci /* Disable "Read FIFO Timer" */ 25238c2ecf20Sopenharmony_ci pci_write_config_byte(dev, 0x77, 0x0); 25248c2ecf20Sopenharmony_ci 25258c2ecf20Sopenharmony_ci pci_info(dev, "Disabling VIA CX700 PCI caching\n"); 25268c2ecf20Sopenharmony_ci } 25278c2ecf20Sopenharmony_ci } 25288c2ecf20Sopenharmony_ci} 25298c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, 0x324e, quirk_via_cx700_pci_parking_caching); 25308c2ecf20Sopenharmony_ci 25318c2ecf20Sopenharmony_cistatic void quirk_brcm_5719_limit_mrrs(struct pci_dev *dev) 25328c2ecf20Sopenharmony_ci{ 25338c2ecf20Sopenharmony_ci u32 rev; 25348c2ecf20Sopenharmony_ci 25358c2ecf20Sopenharmony_ci pci_read_config_dword(dev, 0xf4, &rev); 25368c2ecf20Sopenharmony_ci 25378c2ecf20Sopenharmony_ci /* Only CAP the MRRS if the device is a 5719 A0 */ 25388c2ecf20Sopenharmony_ci if (rev == 0x05719000) { 25398c2ecf20Sopenharmony_ci int readrq = pcie_get_readrq(dev); 25408c2ecf20Sopenharmony_ci if (readrq > 2048) 25418c2ecf20Sopenharmony_ci pcie_set_readrq(dev, 2048); 25428c2ecf20Sopenharmony_ci } 25438c2ecf20Sopenharmony_ci} 25448c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_BROADCOM, 25458c2ecf20Sopenharmony_ci PCI_DEVICE_ID_TIGON3_5719, 25468c2ecf20Sopenharmony_ci quirk_brcm_5719_limit_mrrs); 25478c2ecf20Sopenharmony_ci 25488c2ecf20Sopenharmony_ci/* 25498c2ecf20Sopenharmony_ci * Originally in EDAC sources for i82875P: Intel tells BIOS developers to 25508c2ecf20Sopenharmony_ci * hide device 6 which configures the overflow device access containing the 25518c2ecf20Sopenharmony_ci * DRBs - this is where we expose device 6. 25528c2ecf20Sopenharmony_ci * http://www.x86-secret.com/articles/tweak/pat/patsecrets-2.htm 25538c2ecf20Sopenharmony_ci */ 25548c2ecf20Sopenharmony_cistatic void quirk_unhide_mch_dev6(struct pci_dev *dev) 25558c2ecf20Sopenharmony_ci{ 25568c2ecf20Sopenharmony_ci u8 reg; 25578c2ecf20Sopenharmony_ci 25588c2ecf20Sopenharmony_ci if (pci_read_config_byte(dev, 0xF4, ®) == 0 && !(reg & 0x02)) { 25598c2ecf20Sopenharmony_ci pci_info(dev, "Enabling MCH 'Overflow' Device\n"); 25608c2ecf20Sopenharmony_ci pci_write_config_byte(dev, 0xF4, reg | 0x02); 25618c2ecf20Sopenharmony_ci } 25628c2ecf20Sopenharmony_ci} 25638c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82865_HB, 25648c2ecf20Sopenharmony_ci quirk_unhide_mch_dev6); 25658c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82875_HB, 25668c2ecf20Sopenharmony_ci quirk_unhide_mch_dev6); 25678c2ecf20Sopenharmony_ci 25688c2ecf20Sopenharmony_ci#ifdef CONFIG_PCI_MSI 25698c2ecf20Sopenharmony_ci/* 25708c2ecf20Sopenharmony_ci * Some chipsets do not support MSI. We cannot easily rely on setting 25718c2ecf20Sopenharmony_ci * PCI_BUS_FLAGS_NO_MSI in its bus flags because there are actually some 25728c2ecf20Sopenharmony_ci * other buses controlled by the chipset even if Linux is not aware of it. 25738c2ecf20Sopenharmony_ci * Instead of setting the flag on all buses in the machine, simply disable 25748c2ecf20Sopenharmony_ci * MSI globally. 25758c2ecf20Sopenharmony_ci */ 25768c2ecf20Sopenharmony_cistatic void quirk_disable_all_msi(struct pci_dev *dev) 25778c2ecf20Sopenharmony_ci{ 25788c2ecf20Sopenharmony_ci pci_no_msi(); 25798c2ecf20Sopenharmony_ci pci_warn(dev, "MSI quirk detected; MSI disabled\n"); 25808c2ecf20Sopenharmony_ci} 25818c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_GCNB_LE, quirk_disable_all_msi); 25828c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RS400_200, quirk_disable_all_msi); 25838c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RS480, quirk_disable_all_msi); 25848c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VT3336, quirk_disable_all_msi); 25858c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VT3351, quirk_disable_all_msi); 25868c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VT3364, quirk_disable_all_msi); 25878c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8380_0, quirk_disable_all_msi); 25888c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_SI, 0x0761, quirk_disable_all_msi); 25898c2ecf20Sopenharmony_ci 25908c2ecf20Sopenharmony_ci/* Disable MSI on chipsets that are known to not support it */ 25918c2ecf20Sopenharmony_cistatic void quirk_disable_msi(struct pci_dev *dev) 25928c2ecf20Sopenharmony_ci{ 25938c2ecf20Sopenharmony_ci if (dev->subordinate) { 25948c2ecf20Sopenharmony_ci pci_warn(dev, "MSI quirk detected; subordinate MSI disabled\n"); 25958c2ecf20Sopenharmony_ci dev->subordinate->bus_flags |= PCI_BUS_FLAGS_NO_MSI; 25968c2ecf20Sopenharmony_ci } 25978c2ecf20Sopenharmony_ci} 25988c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8131_BRIDGE, quirk_disable_msi); 25998c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, 0xa238, quirk_disable_msi); 26008c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x5a3f, quirk_disable_msi); 26018c2ecf20Sopenharmony_ci 26028c2ecf20Sopenharmony_ci/* 26038c2ecf20Sopenharmony_ci * The APC bridge device in AMD 780 family northbridges has some random 26048c2ecf20Sopenharmony_ci * OEM subsystem ID in its vendor ID register (erratum 18), so instead 26058c2ecf20Sopenharmony_ci * we use the possible vendor/device IDs of the host bridge for the 26068c2ecf20Sopenharmony_ci * declared quirk, and search for the APC bridge by slot number. 26078c2ecf20Sopenharmony_ci */ 26088c2ecf20Sopenharmony_cistatic void quirk_amd_780_apc_msi(struct pci_dev *host_bridge) 26098c2ecf20Sopenharmony_ci{ 26108c2ecf20Sopenharmony_ci struct pci_dev *apc_bridge; 26118c2ecf20Sopenharmony_ci 26128c2ecf20Sopenharmony_ci apc_bridge = pci_get_slot(host_bridge->bus, PCI_DEVFN(1, 0)); 26138c2ecf20Sopenharmony_ci if (apc_bridge) { 26148c2ecf20Sopenharmony_ci if (apc_bridge->device == 0x9602) 26158c2ecf20Sopenharmony_ci quirk_disable_msi(apc_bridge); 26168c2ecf20Sopenharmony_ci pci_dev_put(apc_bridge); 26178c2ecf20Sopenharmony_ci } 26188c2ecf20Sopenharmony_ci} 26198c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, 0x9600, quirk_amd_780_apc_msi); 26208c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, 0x9601, quirk_amd_780_apc_msi); 26218c2ecf20Sopenharmony_ci 26228c2ecf20Sopenharmony_ci/* 26238c2ecf20Sopenharmony_ci * Go through the list of HyperTransport capabilities and return 1 if a HT 26248c2ecf20Sopenharmony_ci * MSI capability is found and enabled. 26258c2ecf20Sopenharmony_ci */ 26268c2ecf20Sopenharmony_cistatic int msi_ht_cap_enabled(struct pci_dev *dev) 26278c2ecf20Sopenharmony_ci{ 26288c2ecf20Sopenharmony_ci int pos, ttl = PCI_FIND_CAP_TTL; 26298c2ecf20Sopenharmony_ci 26308c2ecf20Sopenharmony_ci pos = pci_find_ht_capability(dev, HT_CAPTYPE_MSI_MAPPING); 26318c2ecf20Sopenharmony_ci while (pos && ttl--) { 26328c2ecf20Sopenharmony_ci u8 flags; 26338c2ecf20Sopenharmony_ci 26348c2ecf20Sopenharmony_ci if (pci_read_config_byte(dev, pos + HT_MSI_FLAGS, 26358c2ecf20Sopenharmony_ci &flags) == 0) { 26368c2ecf20Sopenharmony_ci pci_info(dev, "Found %s HT MSI Mapping\n", 26378c2ecf20Sopenharmony_ci flags & HT_MSI_FLAGS_ENABLE ? 26388c2ecf20Sopenharmony_ci "enabled" : "disabled"); 26398c2ecf20Sopenharmony_ci return (flags & HT_MSI_FLAGS_ENABLE) != 0; 26408c2ecf20Sopenharmony_ci } 26418c2ecf20Sopenharmony_ci 26428c2ecf20Sopenharmony_ci pos = pci_find_next_ht_capability(dev, pos, 26438c2ecf20Sopenharmony_ci HT_CAPTYPE_MSI_MAPPING); 26448c2ecf20Sopenharmony_ci } 26458c2ecf20Sopenharmony_ci return 0; 26468c2ecf20Sopenharmony_ci} 26478c2ecf20Sopenharmony_ci 26488c2ecf20Sopenharmony_ci/* Check the HyperTransport MSI mapping to know whether MSI is enabled or not */ 26498c2ecf20Sopenharmony_cistatic void quirk_msi_ht_cap(struct pci_dev *dev) 26508c2ecf20Sopenharmony_ci{ 26518c2ecf20Sopenharmony_ci if (dev->subordinate && !msi_ht_cap_enabled(dev)) { 26528c2ecf20Sopenharmony_ci pci_warn(dev, "MSI quirk detected; subordinate MSI disabled\n"); 26538c2ecf20Sopenharmony_ci dev->subordinate->bus_flags |= PCI_BUS_FLAGS_NO_MSI; 26548c2ecf20Sopenharmony_ci } 26558c2ecf20Sopenharmony_ci} 26568c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_HT2000_PCIE, 26578c2ecf20Sopenharmony_ci quirk_msi_ht_cap); 26588c2ecf20Sopenharmony_ci 26598c2ecf20Sopenharmony_ci/* 26608c2ecf20Sopenharmony_ci * The nVidia CK804 chipset may have 2 HT MSI mappings. MSI is supported 26618c2ecf20Sopenharmony_ci * if the MSI capability is set in any of these mappings. 26628c2ecf20Sopenharmony_ci */ 26638c2ecf20Sopenharmony_cistatic void quirk_nvidia_ck804_msi_ht_cap(struct pci_dev *dev) 26648c2ecf20Sopenharmony_ci{ 26658c2ecf20Sopenharmony_ci struct pci_dev *pdev; 26668c2ecf20Sopenharmony_ci 26678c2ecf20Sopenharmony_ci if (!dev->subordinate) 26688c2ecf20Sopenharmony_ci return; 26698c2ecf20Sopenharmony_ci 26708c2ecf20Sopenharmony_ci /* 26718c2ecf20Sopenharmony_ci * Check HT MSI cap on this chipset and the root one. A single one 26728c2ecf20Sopenharmony_ci * having MSI is enough to be sure that MSI is supported. 26738c2ecf20Sopenharmony_ci */ 26748c2ecf20Sopenharmony_ci pdev = pci_get_slot(dev->bus, 0); 26758c2ecf20Sopenharmony_ci if (!pdev) 26768c2ecf20Sopenharmony_ci return; 26778c2ecf20Sopenharmony_ci if (!msi_ht_cap_enabled(dev) && !msi_ht_cap_enabled(pdev)) { 26788c2ecf20Sopenharmony_ci pci_warn(dev, "MSI quirk detected; subordinate MSI disabled\n"); 26798c2ecf20Sopenharmony_ci dev->subordinate->bus_flags |= PCI_BUS_FLAGS_NO_MSI; 26808c2ecf20Sopenharmony_ci } 26818c2ecf20Sopenharmony_ci pci_dev_put(pdev); 26828c2ecf20Sopenharmony_ci} 26838c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_CK804_PCIE, 26848c2ecf20Sopenharmony_ci quirk_nvidia_ck804_msi_ht_cap); 26858c2ecf20Sopenharmony_ci 26868c2ecf20Sopenharmony_ci/* Force enable MSI mapping capability on HT bridges */ 26878c2ecf20Sopenharmony_cistatic void ht_enable_msi_mapping(struct pci_dev *dev) 26888c2ecf20Sopenharmony_ci{ 26898c2ecf20Sopenharmony_ci int pos, ttl = PCI_FIND_CAP_TTL; 26908c2ecf20Sopenharmony_ci 26918c2ecf20Sopenharmony_ci pos = pci_find_ht_capability(dev, HT_CAPTYPE_MSI_MAPPING); 26928c2ecf20Sopenharmony_ci while (pos && ttl--) { 26938c2ecf20Sopenharmony_ci u8 flags; 26948c2ecf20Sopenharmony_ci 26958c2ecf20Sopenharmony_ci if (pci_read_config_byte(dev, pos + HT_MSI_FLAGS, 26968c2ecf20Sopenharmony_ci &flags) == 0) { 26978c2ecf20Sopenharmony_ci pci_info(dev, "Enabling HT MSI Mapping\n"); 26988c2ecf20Sopenharmony_ci 26998c2ecf20Sopenharmony_ci pci_write_config_byte(dev, pos + HT_MSI_FLAGS, 27008c2ecf20Sopenharmony_ci flags | HT_MSI_FLAGS_ENABLE); 27018c2ecf20Sopenharmony_ci } 27028c2ecf20Sopenharmony_ci pos = pci_find_next_ht_capability(dev, pos, 27038c2ecf20Sopenharmony_ci HT_CAPTYPE_MSI_MAPPING); 27048c2ecf20Sopenharmony_ci } 27058c2ecf20Sopenharmony_ci} 27068c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SERVERWORKS, 27078c2ecf20Sopenharmony_ci PCI_DEVICE_ID_SERVERWORKS_HT1000_PXB, 27088c2ecf20Sopenharmony_ci ht_enable_msi_mapping); 27098c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8132_BRIDGE, 27108c2ecf20Sopenharmony_ci ht_enable_msi_mapping); 27118c2ecf20Sopenharmony_ci 27128c2ecf20Sopenharmony_ci/* 27138c2ecf20Sopenharmony_ci * The P5N32-SLI motherboards from Asus have a problem with MSI 27148c2ecf20Sopenharmony_ci * for the MCP55 NIC. It is not yet determined whether the MSI problem 27158c2ecf20Sopenharmony_ci * also affects other devices. As for now, turn off MSI for this device. 27168c2ecf20Sopenharmony_ci */ 27178c2ecf20Sopenharmony_cistatic void nvenet_msi_disable(struct pci_dev *dev) 27188c2ecf20Sopenharmony_ci{ 27198c2ecf20Sopenharmony_ci const char *board_name = dmi_get_system_info(DMI_BOARD_NAME); 27208c2ecf20Sopenharmony_ci 27218c2ecf20Sopenharmony_ci if (board_name && 27228c2ecf20Sopenharmony_ci (strstr(board_name, "P5N32-SLI PREMIUM") || 27238c2ecf20Sopenharmony_ci strstr(board_name, "P5N32-E SLI"))) { 27248c2ecf20Sopenharmony_ci pci_info(dev, "Disabling MSI for MCP55 NIC on P5N32-SLI\n"); 27258c2ecf20Sopenharmony_ci dev->no_msi = 1; 27268c2ecf20Sopenharmony_ci } 27278c2ecf20Sopenharmony_ci} 27288c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_NVIDIA, 27298c2ecf20Sopenharmony_ci PCI_DEVICE_ID_NVIDIA_NVENET_15, 27308c2ecf20Sopenharmony_ci nvenet_msi_disable); 27318c2ecf20Sopenharmony_ci 27328c2ecf20Sopenharmony_ci/* 27338c2ecf20Sopenharmony_ci * PCIe spec r4.0 sec 7.7.1.2 and sec 7.7.2.2 say that if MSI/MSI-X is enabled, 27348c2ecf20Sopenharmony_ci * then the device can't use INTx interrupts. Tegra's PCIe root ports don't 27358c2ecf20Sopenharmony_ci * generate MSI interrupts for PME and AER events instead only INTx interrupts 27368c2ecf20Sopenharmony_ci * are generated. Though Tegra's PCIe root ports can generate MSI interrupts 27378c2ecf20Sopenharmony_ci * for other events, since PCIe specificiation doesn't support using a mix of 27388c2ecf20Sopenharmony_ci * INTx and MSI/MSI-X, it is required to disable MSI interrupts to avoid port 27398c2ecf20Sopenharmony_ci * service drivers registering their respective ISRs for MSIs. 27408c2ecf20Sopenharmony_ci */ 27418c2ecf20Sopenharmony_cistatic void pci_quirk_nvidia_tegra_disable_rp_msi(struct pci_dev *dev) 27428c2ecf20Sopenharmony_ci{ 27438c2ecf20Sopenharmony_ci dev->no_msi = 1; 27448c2ecf20Sopenharmony_ci} 27458c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_NVIDIA, 0x1ad0, 27468c2ecf20Sopenharmony_ci PCI_CLASS_BRIDGE_PCI, 8, 27478c2ecf20Sopenharmony_ci pci_quirk_nvidia_tegra_disable_rp_msi); 27488c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_NVIDIA, 0x1ad1, 27498c2ecf20Sopenharmony_ci PCI_CLASS_BRIDGE_PCI, 8, 27508c2ecf20Sopenharmony_ci pci_quirk_nvidia_tegra_disable_rp_msi); 27518c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_NVIDIA, 0x1ad2, 27528c2ecf20Sopenharmony_ci PCI_CLASS_BRIDGE_PCI, 8, 27538c2ecf20Sopenharmony_ci pci_quirk_nvidia_tegra_disable_rp_msi); 27548c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_NVIDIA, 0x0bf0, 27558c2ecf20Sopenharmony_ci PCI_CLASS_BRIDGE_PCI, 8, 27568c2ecf20Sopenharmony_ci pci_quirk_nvidia_tegra_disable_rp_msi); 27578c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_NVIDIA, 0x0bf1, 27588c2ecf20Sopenharmony_ci PCI_CLASS_BRIDGE_PCI, 8, 27598c2ecf20Sopenharmony_ci pci_quirk_nvidia_tegra_disable_rp_msi); 27608c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_NVIDIA, 0x0e1c, 27618c2ecf20Sopenharmony_ci PCI_CLASS_BRIDGE_PCI, 8, 27628c2ecf20Sopenharmony_ci pci_quirk_nvidia_tegra_disable_rp_msi); 27638c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_NVIDIA, 0x0e1d, 27648c2ecf20Sopenharmony_ci PCI_CLASS_BRIDGE_PCI, 8, 27658c2ecf20Sopenharmony_ci pci_quirk_nvidia_tegra_disable_rp_msi); 27668c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_NVIDIA, 0x0e12, 27678c2ecf20Sopenharmony_ci PCI_CLASS_BRIDGE_PCI, 8, 27688c2ecf20Sopenharmony_ci pci_quirk_nvidia_tegra_disable_rp_msi); 27698c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_NVIDIA, 0x0e13, 27708c2ecf20Sopenharmony_ci PCI_CLASS_BRIDGE_PCI, 8, 27718c2ecf20Sopenharmony_ci pci_quirk_nvidia_tegra_disable_rp_msi); 27728c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_NVIDIA, 0x0fae, 27738c2ecf20Sopenharmony_ci PCI_CLASS_BRIDGE_PCI, 8, 27748c2ecf20Sopenharmony_ci pci_quirk_nvidia_tegra_disable_rp_msi); 27758c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_NVIDIA, 0x0faf, 27768c2ecf20Sopenharmony_ci PCI_CLASS_BRIDGE_PCI, 8, 27778c2ecf20Sopenharmony_ci pci_quirk_nvidia_tegra_disable_rp_msi); 27788c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_NVIDIA, 0x10e5, 27798c2ecf20Sopenharmony_ci PCI_CLASS_BRIDGE_PCI, 8, 27808c2ecf20Sopenharmony_ci pci_quirk_nvidia_tegra_disable_rp_msi); 27818c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_NVIDIA, 0x10e6, 27828c2ecf20Sopenharmony_ci PCI_CLASS_BRIDGE_PCI, 8, 27838c2ecf20Sopenharmony_ci pci_quirk_nvidia_tegra_disable_rp_msi); 27848c2ecf20Sopenharmony_ci 27858c2ecf20Sopenharmony_ci/* 27868c2ecf20Sopenharmony_ci * Some versions of the MCP55 bridge from Nvidia have a legacy IRQ routing 27878c2ecf20Sopenharmony_ci * config register. This register controls the routing of legacy 27888c2ecf20Sopenharmony_ci * interrupts from devices that route through the MCP55. If this register 27898c2ecf20Sopenharmony_ci * is misprogrammed, interrupts are only sent to the BSP, unlike 27908c2ecf20Sopenharmony_ci * conventional systems where the IRQ is broadcast to all online CPUs. Not 27918c2ecf20Sopenharmony_ci * having this register set properly prevents kdump from booting up 27928c2ecf20Sopenharmony_ci * properly, so let's make sure that we have it set correctly. 27938c2ecf20Sopenharmony_ci * Note that this is an undocumented register. 27948c2ecf20Sopenharmony_ci */ 27958c2ecf20Sopenharmony_cistatic void nvbridge_check_legacy_irq_routing(struct pci_dev *dev) 27968c2ecf20Sopenharmony_ci{ 27978c2ecf20Sopenharmony_ci u32 cfg; 27988c2ecf20Sopenharmony_ci 27998c2ecf20Sopenharmony_ci if (!pci_find_capability(dev, PCI_CAP_ID_HT)) 28008c2ecf20Sopenharmony_ci return; 28018c2ecf20Sopenharmony_ci 28028c2ecf20Sopenharmony_ci pci_read_config_dword(dev, 0x74, &cfg); 28038c2ecf20Sopenharmony_ci 28048c2ecf20Sopenharmony_ci if (cfg & ((1 << 2) | (1 << 15))) { 28058c2ecf20Sopenharmony_ci pr_info("Rewriting IRQ routing register on MCP55\n"); 28068c2ecf20Sopenharmony_ci cfg &= ~((1 << 2) | (1 << 15)); 28078c2ecf20Sopenharmony_ci pci_write_config_dword(dev, 0x74, cfg); 28088c2ecf20Sopenharmony_ci } 28098c2ecf20Sopenharmony_ci} 28108c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_NVIDIA, 28118c2ecf20Sopenharmony_ci PCI_DEVICE_ID_NVIDIA_MCP55_BRIDGE_V0, 28128c2ecf20Sopenharmony_ci nvbridge_check_legacy_irq_routing); 28138c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_NVIDIA, 28148c2ecf20Sopenharmony_ci PCI_DEVICE_ID_NVIDIA_MCP55_BRIDGE_V4, 28158c2ecf20Sopenharmony_ci nvbridge_check_legacy_irq_routing); 28168c2ecf20Sopenharmony_ci 28178c2ecf20Sopenharmony_cistatic int ht_check_msi_mapping(struct pci_dev *dev) 28188c2ecf20Sopenharmony_ci{ 28198c2ecf20Sopenharmony_ci int pos, ttl = PCI_FIND_CAP_TTL; 28208c2ecf20Sopenharmony_ci int found = 0; 28218c2ecf20Sopenharmony_ci 28228c2ecf20Sopenharmony_ci /* Check if there is HT MSI cap or enabled on this device */ 28238c2ecf20Sopenharmony_ci pos = pci_find_ht_capability(dev, HT_CAPTYPE_MSI_MAPPING); 28248c2ecf20Sopenharmony_ci while (pos && ttl--) { 28258c2ecf20Sopenharmony_ci u8 flags; 28268c2ecf20Sopenharmony_ci 28278c2ecf20Sopenharmony_ci if (found < 1) 28288c2ecf20Sopenharmony_ci found = 1; 28298c2ecf20Sopenharmony_ci if (pci_read_config_byte(dev, pos + HT_MSI_FLAGS, 28308c2ecf20Sopenharmony_ci &flags) == 0) { 28318c2ecf20Sopenharmony_ci if (flags & HT_MSI_FLAGS_ENABLE) { 28328c2ecf20Sopenharmony_ci if (found < 2) { 28338c2ecf20Sopenharmony_ci found = 2; 28348c2ecf20Sopenharmony_ci break; 28358c2ecf20Sopenharmony_ci } 28368c2ecf20Sopenharmony_ci } 28378c2ecf20Sopenharmony_ci } 28388c2ecf20Sopenharmony_ci pos = pci_find_next_ht_capability(dev, pos, 28398c2ecf20Sopenharmony_ci HT_CAPTYPE_MSI_MAPPING); 28408c2ecf20Sopenharmony_ci } 28418c2ecf20Sopenharmony_ci 28428c2ecf20Sopenharmony_ci return found; 28438c2ecf20Sopenharmony_ci} 28448c2ecf20Sopenharmony_ci 28458c2ecf20Sopenharmony_cistatic int host_bridge_with_leaf(struct pci_dev *host_bridge) 28468c2ecf20Sopenharmony_ci{ 28478c2ecf20Sopenharmony_ci struct pci_dev *dev; 28488c2ecf20Sopenharmony_ci int pos; 28498c2ecf20Sopenharmony_ci int i, dev_no; 28508c2ecf20Sopenharmony_ci int found = 0; 28518c2ecf20Sopenharmony_ci 28528c2ecf20Sopenharmony_ci dev_no = host_bridge->devfn >> 3; 28538c2ecf20Sopenharmony_ci for (i = dev_no + 1; i < 0x20; i++) { 28548c2ecf20Sopenharmony_ci dev = pci_get_slot(host_bridge->bus, PCI_DEVFN(i, 0)); 28558c2ecf20Sopenharmony_ci if (!dev) 28568c2ecf20Sopenharmony_ci continue; 28578c2ecf20Sopenharmony_ci 28588c2ecf20Sopenharmony_ci /* found next host bridge? */ 28598c2ecf20Sopenharmony_ci pos = pci_find_ht_capability(dev, HT_CAPTYPE_SLAVE); 28608c2ecf20Sopenharmony_ci if (pos != 0) { 28618c2ecf20Sopenharmony_ci pci_dev_put(dev); 28628c2ecf20Sopenharmony_ci break; 28638c2ecf20Sopenharmony_ci } 28648c2ecf20Sopenharmony_ci 28658c2ecf20Sopenharmony_ci if (ht_check_msi_mapping(dev)) { 28668c2ecf20Sopenharmony_ci found = 1; 28678c2ecf20Sopenharmony_ci pci_dev_put(dev); 28688c2ecf20Sopenharmony_ci break; 28698c2ecf20Sopenharmony_ci } 28708c2ecf20Sopenharmony_ci pci_dev_put(dev); 28718c2ecf20Sopenharmony_ci } 28728c2ecf20Sopenharmony_ci 28738c2ecf20Sopenharmony_ci return found; 28748c2ecf20Sopenharmony_ci} 28758c2ecf20Sopenharmony_ci 28768c2ecf20Sopenharmony_ci#define PCI_HT_CAP_SLAVE_CTRL0 4 /* link control */ 28778c2ecf20Sopenharmony_ci#define PCI_HT_CAP_SLAVE_CTRL1 8 /* link control to */ 28788c2ecf20Sopenharmony_ci 28798c2ecf20Sopenharmony_cistatic int is_end_of_ht_chain(struct pci_dev *dev) 28808c2ecf20Sopenharmony_ci{ 28818c2ecf20Sopenharmony_ci int pos, ctrl_off; 28828c2ecf20Sopenharmony_ci int end = 0; 28838c2ecf20Sopenharmony_ci u16 flags, ctrl; 28848c2ecf20Sopenharmony_ci 28858c2ecf20Sopenharmony_ci pos = pci_find_ht_capability(dev, HT_CAPTYPE_SLAVE); 28868c2ecf20Sopenharmony_ci 28878c2ecf20Sopenharmony_ci if (!pos) 28888c2ecf20Sopenharmony_ci goto out; 28898c2ecf20Sopenharmony_ci 28908c2ecf20Sopenharmony_ci pci_read_config_word(dev, pos + PCI_CAP_FLAGS, &flags); 28918c2ecf20Sopenharmony_ci 28928c2ecf20Sopenharmony_ci ctrl_off = ((flags >> 10) & 1) ? 28938c2ecf20Sopenharmony_ci PCI_HT_CAP_SLAVE_CTRL0 : PCI_HT_CAP_SLAVE_CTRL1; 28948c2ecf20Sopenharmony_ci pci_read_config_word(dev, pos + ctrl_off, &ctrl); 28958c2ecf20Sopenharmony_ci 28968c2ecf20Sopenharmony_ci if (ctrl & (1 << 6)) 28978c2ecf20Sopenharmony_ci end = 1; 28988c2ecf20Sopenharmony_ci 28998c2ecf20Sopenharmony_ciout: 29008c2ecf20Sopenharmony_ci return end; 29018c2ecf20Sopenharmony_ci} 29028c2ecf20Sopenharmony_ci 29038c2ecf20Sopenharmony_cistatic void nv_ht_enable_msi_mapping(struct pci_dev *dev) 29048c2ecf20Sopenharmony_ci{ 29058c2ecf20Sopenharmony_ci struct pci_dev *host_bridge; 29068c2ecf20Sopenharmony_ci int pos; 29078c2ecf20Sopenharmony_ci int i, dev_no; 29088c2ecf20Sopenharmony_ci int found = 0; 29098c2ecf20Sopenharmony_ci 29108c2ecf20Sopenharmony_ci dev_no = dev->devfn >> 3; 29118c2ecf20Sopenharmony_ci for (i = dev_no; i >= 0; i--) { 29128c2ecf20Sopenharmony_ci host_bridge = pci_get_slot(dev->bus, PCI_DEVFN(i, 0)); 29138c2ecf20Sopenharmony_ci if (!host_bridge) 29148c2ecf20Sopenharmony_ci continue; 29158c2ecf20Sopenharmony_ci 29168c2ecf20Sopenharmony_ci pos = pci_find_ht_capability(host_bridge, HT_CAPTYPE_SLAVE); 29178c2ecf20Sopenharmony_ci if (pos != 0) { 29188c2ecf20Sopenharmony_ci found = 1; 29198c2ecf20Sopenharmony_ci break; 29208c2ecf20Sopenharmony_ci } 29218c2ecf20Sopenharmony_ci pci_dev_put(host_bridge); 29228c2ecf20Sopenharmony_ci } 29238c2ecf20Sopenharmony_ci 29248c2ecf20Sopenharmony_ci if (!found) 29258c2ecf20Sopenharmony_ci return; 29268c2ecf20Sopenharmony_ci 29278c2ecf20Sopenharmony_ci /* don't enable end_device/host_bridge with leaf directly here */ 29288c2ecf20Sopenharmony_ci if (host_bridge == dev && is_end_of_ht_chain(host_bridge) && 29298c2ecf20Sopenharmony_ci host_bridge_with_leaf(host_bridge)) 29308c2ecf20Sopenharmony_ci goto out; 29318c2ecf20Sopenharmony_ci 29328c2ecf20Sopenharmony_ci /* root did that ! */ 29338c2ecf20Sopenharmony_ci if (msi_ht_cap_enabled(host_bridge)) 29348c2ecf20Sopenharmony_ci goto out; 29358c2ecf20Sopenharmony_ci 29368c2ecf20Sopenharmony_ci ht_enable_msi_mapping(dev); 29378c2ecf20Sopenharmony_ci 29388c2ecf20Sopenharmony_ciout: 29398c2ecf20Sopenharmony_ci pci_dev_put(host_bridge); 29408c2ecf20Sopenharmony_ci} 29418c2ecf20Sopenharmony_ci 29428c2ecf20Sopenharmony_cistatic void ht_disable_msi_mapping(struct pci_dev *dev) 29438c2ecf20Sopenharmony_ci{ 29448c2ecf20Sopenharmony_ci int pos, ttl = PCI_FIND_CAP_TTL; 29458c2ecf20Sopenharmony_ci 29468c2ecf20Sopenharmony_ci pos = pci_find_ht_capability(dev, HT_CAPTYPE_MSI_MAPPING); 29478c2ecf20Sopenharmony_ci while (pos && ttl--) { 29488c2ecf20Sopenharmony_ci u8 flags; 29498c2ecf20Sopenharmony_ci 29508c2ecf20Sopenharmony_ci if (pci_read_config_byte(dev, pos + HT_MSI_FLAGS, 29518c2ecf20Sopenharmony_ci &flags) == 0) { 29528c2ecf20Sopenharmony_ci pci_info(dev, "Disabling HT MSI Mapping\n"); 29538c2ecf20Sopenharmony_ci 29548c2ecf20Sopenharmony_ci pci_write_config_byte(dev, pos + HT_MSI_FLAGS, 29558c2ecf20Sopenharmony_ci flags & ~HT_MSI_FLAGS_ENABLE); 29568c2ecf20Sopenharmony_ci } 29578c2ecf20Sopenharmony_ci pos = pci_find_next_ht_capability(dev, pos, 29588c2ecf20Sopenharmony_ci HT_CAPTYPE_MSI_MAPPING); 29598c2ecf20Sopenharmony_ci } 29608c2ecf20Sopenharmony_ci} 29618c2ecf20Sopenharmony_ci 29628c2ecf20Sopenharmony_cistatic void __nv_msi_ht_cap_quirk(struct pci_dev *dev, int all) 29638c2ecf20Sopenharmony_ci{ 29648c2ecf20Sopenharmony_ci struct pci_dev *host_bridge; 29658c2ecf20Sopenharmony_ci int pos; 29668c2ecf20Sopenharmony_ci int found; 29678c2ecf20Sopenharmony_ci 29688c2ecf20Sopenharmony_ci if (!pci_msi_enabled()) 29698c2ecf20Sopenharmony_ci return; 29708c2ecf20Sopenharmony_ci 29718c2ecf20Sopenharmony_ci /* check if there is HT MSI cap or enabled on this device */ 29728c2ecf20Sopenharmony_ci found = ht_check_msi_mapping(dev); 29738c2ecf20Sopenharmony_ci 29748c2ecf20Sopenharmony_ci /* no HT MSI CAP */ 29758c2ecf20Sopenharmony_ci if (found == 0) 29768c2ecf20Sopenharmony_ci return; 29778c2ecf20Sopenharmony_ci 29788c2ecf20Sopenharmony_ci /* 29798c2ecf20Sopenharmony_ci * HT MSI mapping should be disabled on devices that are below 29808c2ecf20Sopenharmony_ci * a non-Hypertransport host bridge. Locate the host bridge... 29818c2ecf20Sopenharmony_ci */ 29828c2ecf20Sopenharmony_ci host_bridge = pci_get_domain_bus_and_slot(pci_domain_nr(dev->bus), 0, 29838c2ecf20Sopenharmony_ci PCI_DEVFN(0, 0)); 29848c2ecf20Sopenharmony_ci if (host_bridge == NULL) { 29858c2ecf20Sopenharmony_ci pci_warn(dev, "nv_msi_ht_cap_quirk didn't locate host bridge\n"); 29868c2ecf20Sopenharmony_ci return; 29878c2ecf20Sopenharmony_ci } 29888c2ecf20Sopenharmony_ci 29898c2ecf20Sopenharmony_ci pos = pci_find_ht_capability(host_bridge, HT_CAPTYPE_SLAVE); 29908c2ecf20Sopenharmony_ci if (pos != 0) { 29918c2ecf20Sopenharmony_ci /* Host bridge is to HT */ 29928c2ecf20Sopenharmony_ci if (found == 1) { 29938c2ecf20Sopenharmony_ci /* it is not enabled, try to enable it */ 29948c2ecf20Sopenharmony_ci if (all) 29958c2ecf20Sopenharmony_ci ht_enable_msi_mapping(dev); 29968c2ecf20Sopenharmony_ci else 29978c2ecf20Sopenharmony_ci nv_ht_enable_msi_mapping(dev); 29988c2ecf20Sopenharmony_ci } 29998c2ecf20Sopenharmony_ci goto out; 30008c2ecf20Sopenharmony_ci } 30018c2ecf20Sopenharmony_ci 30028c2ecf20Sopenharmony_ci /* HT MSI is not enabled */ 30038c2ecf20Sopenharmony_ci if (found == 1) 30048c2ecf20Sopenharmony_ci goto out; 30058c2ecf20Sopenharmony_ci 30068c2ecf20Sopenharmony_ci /* Host bridge is not to HT, disable HT MSI mapping on this device */ 30078c2ecf20Sopenharmony_ci ht_disable_msi_mapping(dev); 30088c2ecf20Sopenharmony_ci 30098c2ecf20Sopenharmony_ciout: 30108c2ecf20Sopenharmony_ci pci_dev_put(host_bridge); 30118c2ecf20Sopenharmony_ci} 30128c2ecf20Sopenharmony_ci 30138c2ecf20Sopenharmony_cistatic void nv_msi_ht_cap_quirk_all(struct pci_dev *dev) 30148c2ecf20Sopenharmony_ci{ 30158c2ecf20Sopenharmony_ci return __nv_msi_ht_cap_quirk(dev, 1); 30168c2ecf20Sopenharmony_ci} 30178c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AL, PCI_ANY_ID, nv_msi_ht_cap_quirk_all); 30188c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_AL, PCI_ANY_ID, nv_msi_ht_cap_quirk_all); 30198c2ecf20Sopenharmony_ci 30208c2ecf20Sopenharmony_cistatic void nv_msi_ht_cap_quirk_leaf(struct pci_dev *dev) 30218c2ecf20Sopenharmony_ci{ 30228c2ecf20Sopenharmony_ci return __nv_msi_ht_cap_quirk(dev, 0); 30238c2ecf20Sopenharmony_ci} 30248c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID, nv_msi_ht_cap_quirk_leaf); 30258c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID, nv_msi_ht_cap_quirk_leaf); 30268c2ecf20Sopenharmony_ci 30278c2ecf20Sopenharmony_cistatic void quirk_msi_intx_disable_bug(struct pci_dev *dev) 30288c2ecf20Sopenharmony_ci{ 30298c2ecf20Sopenharmony_ci dev->dev_flags |= PCI_DEV_FLAGS_MSI_INTX_DISABLE_BUG; 30308c2ecf20Sopenharmony_ci} 30318c2ecf20Sopenharmony_ci 30328c2ecf20Sopenharmony_cistatic void quirk_msi_intx_disable_ati_bug(struct pci_dev *dev) 30338c2ecf20Sopenharmony_ci{ 30348c2ecf20Sopenharmony_ci struct pci_dev *p; 30358c2ecf20Sopenharmony_ci 30368c2ecf20Sopenharmony_ci /* 30378c2ecf20Sopenharmony_ci * SB700 MSI issue will be fixed at HW level from revision A21; 30388c2ecf20Sopenharmony_ci * we need check PCI REVISION ID of SMBus controller to get SB700 30398c2ecf20Sopenharmony_ci * revision. 30408c2ecf20Sopenharmony_ci */ 30418c2ecf20Sopenharmony_ci p = pci_get_device(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_SBX00_SMBUS, 30428c2ecf20Sopenharmony_ci NULL); 30438c2ecf20Sopenharmony_ci if (!p) 30448c2ecf20Sopenharmony_ci return; 30458c2ecf20Sopenharmony_ci 30468c2ecf20Sopenharmony_ci if ((p->revision < 0x3B) && (p->revision >= 0x30)) 30478c2ecf20Sopenharmony_ci dev->dev_flags |= PCI_DEV_FLAGS_MSI_INTX_DISABLE_BUG; 30488c2ecf20Sopenharmony_ci pci_dev_put(p); 30498c2ecf20Sopenharmony_ci} 30508c2ecf20Sopenharmony_ci 30518c2ecf20Sopenharmony_cistatic void quirk_msi_intx_disable_qca_bug(struct pci_dev *dev) 30528c2ecf20Sopenharmony_ci{ 30538c2ecf20Sopenharmony_ci /* AR816X/AR817X/E210X MSI is fixed at HW level from revision 0x18 */ 30548c2ecf20Sopenharmony_ci if (dev->revision < 0x18) { 30558c2ecf20Sopenharmony_ci pci_info(dev, "set MSI_INTX_DISABLE_BUG flag\n"); 30568c2ecf20Sopenharmony_ci dev->dev_flags |= PCI_DEV_FLAGS_MSI_INTX_DISABLE_BUG; 30578c2ecf20Sopenharmony_ci } 30588c2ecf20Sopenharmony_ci} 30598c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_BROADCOM, 30608c2ecf20Sopenharmony_ci PCI_DEVICE_ID_TIGON3_5780, 30618c2ecf20Sopenharmony_ci quirk_msi_intx_disable_bug); 30628c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_BROADCOM, 30638c2ecf20Sopenharmony_ci PCI_DEVICE_ID_TIGON3_5780S, 30648c2ecf20Sopenharmony_ci quirk_msi_intx_disable_bug); 30658c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_BROADCOM, 30668c2ecf20Sopenharmony_ci PCI_DEVICE_ID_TIGON3_5714, 30678c2ecf20Sopenharmony_ci quirk_msi_intx_disable_bug); 30688c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_BROADCOM, 30698c2ecf20Sopenharmony_ci PCI_DEVICE_ID_TIGON3_5714S, 30708c2ecf20Sopenharmony_ci quirk_msi_intx_disable_bug); 30718c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_BROADCOM, 30728c2ecf20Sopenharmony_ci PCI_DEVICE_ID_TIGON3_5715, 30738c2ecf20Sopenharmony_ci quirk_msi_intx_disable_bug); 30748c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_BROADCOM, 30758c2ecf20Sopenharmony_ci PCI_DEVICE_ID_TIGON3_5715S, 30768c2ecf20Sopenharmony_ci quirk_msi_intx_disable_bug); 30778c2ecf20Sopenharmony_ci 30788c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x4390, 30798c2ecf20Sopenharmony_ci quirk_msi_intx_disable_ati_bug); 30808c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x4391, 30818c2ecf20Sopenharmony_ci quirk_msi_intx_disable_ati_bug); 30828c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x4392, 30838c2ecf20Sopenharmony_ci quirk_msi_intx_disable_ati_bug); 30848c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x4393, 30858c2ecf20Sopenharmony_ci quirk_msi_intx_disable_ati_bug); 30868c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x4394, 30878c2ecf20Sopenharmony_ci quirk_msi_intx_disable_ati_bug); 30888c2ecf20Sopenharmony_ci 30898c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x4373, 30908c2ecf20Sopenharmony_ci quirk_msi_intx_disable_bug); 30918c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x4374, 30928c2ecf20Sopenharmony_ci quirk_msi_intx_disable_bug); 30938c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x4375, 30948c2ecf20Sopenharmony_ci quirk_msi_intx_disable_bug); 30958c2ecf20Sopenharmony_ci 30968c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATTANSIC, 0x1062, 30978c2ecf20Sopenharmony_ci quirk_msi_intx_disable_bug); 30988c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATTANSIC, 0x1063, 30998c2ecf20Sopenharmony_ci quirk_msi_intx_disable_bug); 31008c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATTANSIC, 0x2060, 31018c2ecf20Sopenharmony_ci quirk_msi_intx_disable_bug); 31028c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATTANSIC, 0x2062, 31038c2ecf20Sopenharmony_ci quirk_msi_intx_disable_bug); 31048c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATTANSIC, 0x1073, 31058c2ecf20Sopenharmony_ci quirk_msi_intx_disable_bug); 31068c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATTANSIC, 0x1083, 31078c2ecf20Sopenharmony_ci quirk_msi_intx_disable_bug); 31088c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATTANSIC, 0x1090, 31098c2ecf20Sopenharmony_ci quirk_msi_intx_disable_qca_bug); 31108c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATTANSIC, 0x1091, 31118c2ecf20Sopenharmony_ci quirk_msi_intx_disable_qca_bug); 31128c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATTANSIC, 0x10a0, 31138c2ecf20Sopenharmony_ci quirk_msi_intx_disable_qca_bug); 31148c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATTANSIC, 0x10a1, 31158c2ecf20Sopenharmony_ci quirk_msi_intx_disable_qca_bug); 31168c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATTANSIC, 0xe091, 31178c2ecf20Sopenharmony_ci quirk_msi_intx_disable_qca_bug); 31188c2ecf20Sopenharmony_ci 31198c2ecf20Sopenharmony_ci/* 31208c2ecf20Sopenharmony_ci * Amazon's Annapurna Labs 1c36:0031 Root Ports don't support MSI-X, so it 31218c2ecf20Sopenharmony_ci * should be disabled on platforms where the device (mistakenly) advertises it. 31228c2ecf20Sopenharmony_ci * 31238c2ecf20Sopenharmony_ci * Notice that this quirk also disables MSI (which may work, but hasn't been 31248c2ecf20Sopenharmony_ci * tested), since currently there is no standard way to disable only MSI-X. 31258c2ecf20Sopenharmony_ci * 31268c2ecf20Sopenharmony_ci * The 0031 device id is reused for other non Root Port device types, 31278c2ecf20Sopenharmony_ci * therefore the quirk is registered for the PCI_CLASS_BRIDGE_PCI class. 31288c2ecf20Sopenharmony_ci */ 31298c2ecf20Sopenharmony_cistatic void quirk_al_msi_disable(struct pci_dev *dev) 31308c2ecf20Sopenharmony_ci{ 31318c2ecf20Sopenharmony_ci dev->no_msi = 1; 31328c2ecf20Sopenharmony_ci pci_warn(dev, "Disabling MSI/MSI-X\n"); 31338c2ecf20Sopenharmony_ci} 31348c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_AMAZON_ANNAPURNA_LABS, 0x0031, 31358c2ecf20Sopenharmony_ci PCI_CLASS_BRIDGE_PCI, 8, quirk_al_msi_disable); 31368c2ecf20Sopenharmony_ci#endif /* CONFIG_PCI_MSI */ 31378c2ecf20Sopenharmony_ci 31388c2ecf20Sopenharmony_ci/* 31398c2ecf20Sopenharmony_ci * Allow manual resource allocation for PCI hotplug bridges via 31408c2ecf20Sopenharmony_ci * pci=hpmemsize=nnM and pci=hpiosize=nnM parameters. For some PCI-PCI 31418c2ecf20Sopenharmony_ci * hotplug bridges, like PLX 6254 (former HINT HB6), kernel fails to 31428c2ecf20Sopenharmony_ci * allocate resources when hotplug device is inserted and PCI bus is 31438c2ecf20Sopenharmony_ci * rescanned. 31448c2ecf20Sopenharmony_ci */ 31458c2ecf20Sopenharmony_cistatic void quirk_hotplug_bridge(struct pci_dev *dev) 31468c2ecf20Sopenharmony_ci{ 31478c2ecf20Sopenharmony_ci dev->is_hotplug_bridge = 1; 31488c2ecf20Sopenharmony_ci} 31498c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_HINT, 0x0020, quirk_hotplug_bridge); 31508c2ecf20Sopenharmony_ci 31518c2ecf20Sopenharmony_ci/* 31528c2ecf20Sopenharmony_ci * This is a quirk for the Ricoh MMC controller found as a part of some 31538c2ecf20Sopenharmony_ci * multifunction chips. 31548c2ecf20Sopenharmony_ci * 31558c2ecf20Sopenharmony_ci * This is very similar and based on the ricoh_mmc driver written by 31568c2ecf20Sopenharmony_ci * Philip Langdale. Thank you for these magic sequences. 31578c2ecf20Sopenharmony_ci * 31588c2ecf20Sopenharmony_ci * These chips implement the four main memory card controllers (SD, MMC, 31598c2ecf20Sopenharmony_ci * MS, xD) and one or both of CardBus or FireWire. 31608c2ecf20Sopenharmony_ci * 31618c2ecf20Sopenharmony_ci * It happens that they implement SD and MMC support as separate 31628c2ecf20Sopenharmony_ci * controllers (and PCI functions). The Linux SDHCI driver supports MMC 31638c2ecf20Sopenharmony_ci * cards but the chip detects MMC cards in hardware and directs them to the 31648c2ecf20Sopenharmony_ci * MMC controller - so the SDHCI driver never sees them. 31658c2ecf20Sopenharmony_ci * 31668c2ecf20Sopenharmony_ci * To get around this, we must disable the useless MMC controller. At that 31678c2ecf20Sopenharmony_ci * point, the SDHCI controller will start seeing them. It seems to be the 31688c2ecf20Sopenharmony_ci * case that the relevant PCI registers to deactivate the MMC controller 31698c2ecf20Sopenharmony_ci * live on PCI function 0, which might be the CardBus controller or the 31708c2ecf20Sopenharmony_ci * FireWire controller, depending on the particular chip in question 31718c2ecf20Sopenharmony_ci * 31728c2ecf20Sopenharmony_ci * This has to be done early, because as soon as we disable the MMC controller 31738c2ecf20Sopenharmony_ci * other PCI functions shift up one level, e.g. function #2 becomes function 31748c2ecf20Sopenharmony_ci * #1, and this will confuse the PCI core. 31758c2ecf20Sopenharmony_ci */ 31768c2ecf20Sopenharmony_ci#ifdef CONFIG_MMC_RICOH_MMC 31778c2ecf20Sopenharmony_cistatic void ricoh_mmc_fixup_rl5c476(struct pci_dev *dev) 31788c2ecf20Sopenharmony_ci{ 31798c2ecf20Sopenharmony_ci u8 write_enable; 31808c2ecf20Sopenharmony_ci u8 write_target; 31818c2ecf20Sopenharmony_ci u8 disable; 31828c2ecf20Sopenharmony_ci 31838c2ecf20Sopenharmony_ci /* 31848c2ecf20Sopenharmony_ci * Disable via CardBus interface 31858c2ecf20Sopenharmony_ci * 31868c2ecf20Sopenharmony_ci * This must be done via function #0 31878c2ecf20Sopenharmony_ci */ 31888c2ecf20Sopenharmony_ci if (PCI_FUNC(dev->devfn)) 31898c2ecf20Sopenharmony_ci return; 31908c2ecf20Sopenharmony_ci 31918c2ecf20Sopenharmony_ci pci_read_config_byte(dev, 0xB7, &disable); 31928c2ecf20Sopenharmony_ci if (disable & 0x02) 31938c2ecf20Sopenharmony_ci return; 31948c2ecf20Sopenharmony_ci 31958c2ecf20Sopenharmony_ci pci_read_config_byte(dev, 0x8E, &write_enable); 31968c2ecf20Sopenharmony_ci pci_write_config_byte(dev, 0x8E, 0xAA); 31978c2ecf20Sopenharmony_ci pci_read_config_byte(dev, 0x8D, &write_target); 31988c2ecf20Sopenharmony_ci pci_write_config_byte(dev, 0x8D, 0xB7); 31998c2ecf20Sopenharmony_ci pci_write_config_byte(dev, 0xB7, disable | 0x02); 32008c2ecf20Sopenharmony_ci pci_write_config_byte(dev, 0x8E, write_enable); 32018c2ecf20Sopenharmony_ci pci_write_config_byte(dev, 0x8D, write_target); 32028c2ecf20Sopenharmony_ci 32038c2ecf20Sopenharmony_ci pci_notice(dev, "proprietary Ricoh MMC controller disabled (via CardBus function)\n"); 32048c2ecf20Sopenharmony_ci pci_notice(dev, "MMC cards are now supported by standard SDHCI controller\n"); 32058c2ecf20Sopenharmony_ci} 32068c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C476, ricoh_mmc_fixup_rl5c476); 32078c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C476, ricoh_mmc_fixup_rl5c476); 32088c2ecf20Sopenharmony_ci 32098c2ecf20Sopenharmony_cistatic void ricoh_mmc_fixup_r5c832(struct pci_dev *dev) 32108c2ecf20Sopenharmony_ci{ 32118c2ecf20Sopenharmony_ci u8 write_enable; 32128c2ecf20Sopenharmony_ci u8 disable; 32138c2ecf20Sopenharmony_ci 32148c2ecf20Sopenharmony_ci /* 32158c2ecf20Sopenharmony_ci * Disable via FireWire interface 32168c2ecf20Sopenharmony_ci * 32178c2ecf20Sopenharmony_ci * This must be done via function #0 32188c2ecf20Sopenharmony_ci */ 32198c2ecf20Sopenharmony_ci if (PCI_FUNC(dev->devfn)) 32208c2ecf20Sopenharmony_ci return; 32218c2ecf20Sopenharmony_ci /* 32228c2ecf20Sopenharmony_ci * RICOH 0xe822 and 0xe823 SD/MMC card readers fail to recognize 32238c2ecf20Sopenharmony_ci * certain types of SD/MMC cards. Lowering the SD base clock 32248c2ecf20Sopenharmony_ci * frequency from 200Mhz to 50Mhz fixes this issue. 32258c2ecf20Sopenharmony_ci * 32268c2ecf20Sopenharmony_ci * 0x150 - SD2.0 mode enable for changing base clock 32278c2ecf20Sopenharmony_ci * frequency to 50Mhz 32288c2ecf20Sopenharmony_ci * 0xe1 - Base clock frequency 32298c2ecf20Sopenharmony_ci * 0x32 - 50Mhz new clock frequency 32308c2ecf20Sopenharmony_ci * 0xf9 - Key register for 0x150 32318c2ecf20Sopenharmony_ci * 0xfc - key register for 0xe1 32328c2ecf20Sopenharmony_ci */ 32338c2ecf20Sopenharmony_ci if (dev->device == PCI_DEVICE_ID_RICOH_R5CE822 || 32348c2ecf20Sopenharmony_ci dev->device == PCI_DEVICE_ID_RICOH_R5CE823) { 32358c2ecf20Sopenharmony_ci pci_write_config_byte(dev, 0xf9, 0xfc); 32368c2ecf20Sopenharmony_ci pci_write_config_byte(dev, 0x150, 0x10); 32378c2ecf20Sopenharmony_ci pci_write_config_byte(dev, 0xf9, 0x00); 32388c2ecf20Sopenharmony_ci pci_write_config_byte(dev, 0xfc, 0x01); 32398c2ecf20Sopenharmony_ci pci_write_config_byte(dev, 0xe1, 0x32); 32408c2ecf20Sopenharmony_ci pci_write_config_byte(dev, 0xfc, 0x00); 32418c2ecf20Sopenharmony_ci 32428c2ecf20Sopenharmony_ci pci_notice(dev, "MMC controller base frequency changed to 50Mhz.\n"); 32438c2ecf20Sopenharmony_ci } 32448c2ecf20Sopenharmony_ci 32458c2ecf20Sopenharmony_ci pci_read_config_byte(dev, 0xCB, &disable); 32468c2ecf20Sopenharmony_ci 32478c2ecf20Sopenharmony_ci if (disable & 0x02) 32488c2ecf20Sopenharmony_ci return; 32498c2ecf20Sopenharmony_ci 32508c2ecf20Sopenharmony_ci pci_read_config_byte(dev, 0xCA, &write_enable); 32518c2ecf20Sopenharmony_ci pci_write_config_byte(dev, 0xCA, 0x57); 32528c2ecf20Sopenharmony_ci pci_write_config_byte(dev, 0xCB, disable | 0x02); 32538c2ecf20Sopenharmony_ci pci_write_config_byte(dev, 0xCA, write_enable); 32548c2ecf20Sopenharmony_ci 32558c2ecf20Sopenharmony_ci pci_notice(dev, "proprietary Ricoh MMC controller disabled (via FireWire function)\n"); 32568c2ecf20Sopenharmony_ci pci_notice(dev, "MMC cards are now supported by standard SDHCI controller\n"); 32578c2ecf20Sopenharmony_ci 32588c2ecf20Sopenharmony_ci} 32598c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_R5C832, ricoh_mmc_fixup_r5c832); 32608c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_R5C832, ricoh_mmc_fixup_r5c832); 32618c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_R5CE822, ricoh_mmc_fixup_r5c832); 32628c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_R5CE822, ricoh_mmc_fixup_r5c832); 32638c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_R5CE823, ricoh_mmc_fixup_r5c832); 32648c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_R5CE823, ricoh_mmc_fixup_r5c832); 32658c2ecf20Sopenharmony_ci#endif /*CONFIG_MMC_RICOH_MMC*/ 32668c2ecf20Sopenharmony_ci 32678c2ecf20Sopenharmony_ci#ifdef CONFIG_DMAR_TABLE 32688c2ecf20Sopenharmony_ci#define VTUNCERRMSK_REG 0x1ac 32698c2ecf20Sopenharmony_ci#define VTD_MSK_SPEC_ERRORS (1 << 31) 32708c2ecf20Sopenharmony_ci/* 32718c2ecf20Sopenharmony_ci * This is a quirk for masking VT-d spec-defined errors to platform error 32728c2ecf20Sopenharmony_ci * handling logic. Without this, platforms using Intel 7500, 5500 chipsets 32738c2ecf20Sopenharmony_ci * (and the derivative chipsets like X58 etc) seem to generate NMI/SMI (based 32748c2ecf20Sopenharmony_ci * on the RAS config settings of the platform) when a VT-d fault happens. 32758c2ecf20Sopenharmony_ci * The resulting SMI caused the system to hang. 32768c2ecf20Sopenharmony_ci * 32778c2ecf20Sopenharmony_ci * VT-d spec-related errors are already handled by the VT-d OS code, so no 32788c2ecf20Sopenharmony_ci * need to report the same error through other channels. 32798c2ecf20Sopenharmony_ci */ 32808c2ecf20Sopenharmony_cistatic void vtd_mask_spec_errors(struct pci_dev *dev) 32818c2ecf20Sopenharmony_ci{ 32828c2ecf20Sopenharmony_ci u32 word; 32838c2ecf20Sopenharmony_ci 32848c2ecf20Sopenharmony_ci pci_read_config_dword(dev, VTUNCERRMSK_REG, &word); 32858c2ecf20Sopenharmony_ci pci_write_config_dword(dev, VTUNCERRMSK_REG, word | VTD_MSK_SPEC_ERRORS); 32868c2ecf20Sopenharmony_ci} 32878c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x342e, vtd_mask_spec_errors); 32888c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x3c28, vtd_mask_spec_errors); 32898c2ecf20Sopenharmony_ci#endif 32908c2ecf20Sopenharmony_ci 32918c2ecf20Sopenharmony_cistatic void fixup_ti816x_class(struct pci_dev *dev) 32928c2ecf20Sopenharmony_ci{ 32938c2ecf20Sopenharmony_ci u32 class = dev->class; 32948c2ecf20Sopenharmony_ci 32958c2ecf20Sopenharmony_ci /* TI 816x devices do not have class code set when in PCIe boot mode */ 32968c2ecf20Sopenharmony_ci dev->class = PCI_CLASS_MULTIMEDIA_VIDEO << 8; 32978c2ecf20Sopenharmony_ci pci_info(dev, "PCI class overridden (%#08x -> %#08x)\n", 32988c2ecf20Sopenharmony_ci class, dev->class); 32998c2ecf20Sopenharmony_ci} 33008c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_TI, 0xb800, 33018c2ecf20Sopenharmony_ci PCI_CLASS_NOT_DEFINED, 8, fixup_ti816x_class); 33028c2ecf20Sopenharmony_ci 33038c2ecf20Sopenharmony_ci/* 33048c2ecf20Sopenharmony_ci * Some PCIe devices do not work reliably with the claimed maximum 33058c2ecf20Sopenharmony_ci * payload size supported. 33068c2ecf20Sopenharmony_ci */ 33078c2ecf20Sopenharmony_cistatic void fixup_mpss_256(struct pci_dev *dev) 33088c2ecf20Sopenharmony_ci{ 33098c2ecf20Sopenharmony_ci dev->pcie_mpss = 1; /* 256 bytes */ 33108c2ecf20Sopenharmony_ci} 33118c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SOLARFLARE, 33128c2ecf20Sopenharmony_ci PCI_DEVICE_ID_SOLARFLARE_SFC4000A_0, fixup_mpss_256); 33138c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SOLARFLARE, 33148c2ecf20Sopenharmony_ci PCI_DEVICE_ID_SOLARFLARE_SFC4000A_1, fixup_mpss_256); 33158c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SOLARFLARE, 33168c2ecf20Sopenharmony_ci PCI_DEVICE_ID_SOLARFLARE_SFC4000B, fixup_mpss_256); 33178c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_ASMEDIA, 0x0612, fixup_mpss_256); 33188c2ecf20Sopenharmony_ci 33198c2ecf20Sopenharmony_ci/* 33208c2ecf20Sopenharmony_ci * Intel 5000 and 5100 Memory controllers have an erratum with read completion 33218c2ecf20Sopenharmony_ci * coalescing (which is enabled by default on some BIOSes) and MPS of 256B. 33228c2ecf20Sopenharmony_ci * Since there is no way of knowing what the PCIe MPS on each fabric will be 33238c2ecf20Sopenharmony_ci * until all of the devices are discovered and buses walked, read completion 33248c2ecf20Sopenharmony_ci * coalescing must be disabled. Unfortunately, it cannot be re-enabled because 33258c2ecf20Sopenharmony_ci * it is possible to hotplug a device with MPS of 256B. 33268c2ecf20Sopenharmony_ci */ 33278c2ecf20Sopenharmony_cistatic void quirk_intel_mc_errata(struct pci_dev *dev) 33288c2ecf20Sopenharmony_ci{ 33298c2ecf20Sopenharmony_ci int err; 33308c2ecf20Sopenharmony_ci u16 rcc; 33318c2ecf20Sopenharmony_ci 33328c2ecf20Sopenharmony_ci if (pcie_bus_config == PCIE_BUS_TUNE_OFF || 33338c2ecf20Sopenharmony_ci pcie_bus_config == PCIE_BUS_DEFAULT) 33348c2ecf20Sopenharmony_ci return; 33358c2ecf20Sopenharmony_ci 33368c2ecf20Sopenharmony_ci /* 33378c2ecf20Sopenharmony_ci * Intel erratum specifies bits to change but does not say what 33388c2ecf20Sopenharmony_ci * they are. Keeping them magical until such time as the registers 33398c2ecf20Sopenharmony_ci * and values can be explained. 33408c2ecf20Sopenharmony_ci */ 33418c2ecf20Sopenharmony_ci err = pci_read_config_word(dev, 0x48, &rcc); 33428c2ecf20Sopenharmony_ci if (err) { 33438c2ecf20Sopenharmony_ci pci_err(dev, "Error attempting to read the read completion coalescing register\n"); 33448c2ecf20Sopenharmony_ci return; 33458c2ecf20Sopenharmony_ci } 33468c2ecf20Sopenharmony_ci 33478c2ecf20Sopenharmony_ci if (!(rcc & (1 << 10))) 33488c2ecf20Sopenharmony_ci return; 33498c2ecf20Sopenharmony_ci 33508c2ecf20Sopenharmony_ci rcc &= ~(1 << 10); 33518c2ecf20Sopenharmony_ci 33528c2ecf20Sopenharmony_ci err = pci_write_config_word(dev, 0x48, rcc); 33538c2ecf20Sopenharmony_ci if (err) { 33548c2ecf20Sopenharmony_ci pci_err(dev, "Error attempting to write the read completion coalescing register\n"); 33558c2ecf20Sopenharmony_ci return; 33568c2ecf20Sopenharmony_ci } 33578c2ecf20Sopenharmony_ci 33588c2ecf20Sopenharmony_ci pr_info_once("Read completion coalescing disabled due to hardware erratum relating to 256B MPS\n"); 33598c2ecf20Sopenharmony_ci} 33608c2ecf20Sopenharmony_ci/* Intel 5000 series memory controllers and ports 2-7 */ 33618c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x25c0, quirk_intel_mc_errata); 33628c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x25d0, quirk_intel_mc_errata); 33638c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x25d4, quirk_intel_mc_errata); 33648c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x25d8, quirk_intel_mc_errata); 33658c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x25e2, quirk_intel_mc_errata); 33668c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x25e3, quirk_intel_mc_errata); 33678c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x25e4, quirk_intel_mc_errata); 33688c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x25e5, quirk_intel_mc_errata); 33698c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x25e6, quirk_intel_mc_errata); 33708c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x25e7, quirk_intel_mc_errata); 33718c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x25f7, quirk_intel_mc_errata); 33728c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x25f8, quirk_intel_mc_errata); 33738c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x25f9, quirk_intel_mc_errata); 33748c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x25fa, quirk_intel_mc_errata); 33758c2ecf20Sopenharmony_ci/* Intel 5100 series memory controllers and ports 2-7 */ 33768c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x65c0, quirk_intel_mc_errata); 33778c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x65e2, quirk_intel_mc_errata); 33788c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x65e3, quirk_intel_mc_errata); 33798c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x65e4, quirk_intel_mc_errata); 33808c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x65e5, quirk_intel_mc_errata); 33818c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x65e6, quirk_intel_mc_errata); 33828c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x65e7, quirk_intel_mc_errata); 33838c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x65f7, quirk_intel_mc_errata); 33848c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x65f8, quirk_intel_mc_errata); 33858c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x65f9, quirk_intel_mc_errata); 33868c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x65fa, quirk_intel_mc_errata); 33878c2ecf20Sopenharmony_ci 33888c2ecf20Sopenharmony_ci/* 33898c2ecf20Sopenharmony_ci * Ivytown NTB BAR sizes are misreported by the hardware due to an erratum. 33908c2ecf20Sopenharmony_ci * To work around this, query the size it should be configured to by the 33918c2ecf20Sopenharmony_ci * device and modify the resource end to correspond to this new size. 33928c2ecf20Sopenharmony_ci */ 33938c2ecf20Sopenharmony_cistatic void quirk_intel_ntb(struct pci_dev *dev) 33948c2ecf20Sopenharmony_ci{ 33958c2ecf20Sopenharmony_ci int rc; 33968c2ecf20Sopenharmony_ci u8 val; 33978c2ecf20Sopenharmony_ci 33988c2ecf20Sopenharmony_ci rc = pci_read_config_byte(dev, 0x00D0, &val); 33998c2ecf20Sopenharmony_ci if (rc) 34008c2ecf20Sopenharmony_ci return; 34018c2ecf20Sopenharmony_ci 34028c2ecf20Sopenharmony_ci dev->resource[2].end = dev->resource[2].start + ((u64) 1 << val) - 1; 34038c2ecf20Sopenharmony_ci 34048c2ecf20Sopenharmony_ci rc = pci_read_config_byte(dev, 0x00D1, &val); 34058c2ecf20Sopenharmony_ci if (rc) 34068c2ecf20Sopenharmony_ci return; 34078c2ecf20Sopenharmony_ci 34088c2ecf20Sopenharmony_ci dev->resource[4].end = dev->resource[4].start + ((u64) 1 << val) - 1; 34098c2ecf20Sopenharmony_ci} 34108c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x0e08, quirk_intel_ntb); 34118c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x0e0d, quirk_intel_ntb); 34128c2ecf20Sopenharmony_ci 34138c2ecf20Sopenharmony_ci/* 34148c2ecf20Sopenharmony_ci * Some BIOS implementations leave the Intel GPU interrupts enabled, even 34158c2ecf20Sopenharmony_ci * though no one is handling them (e.g., if the i915 driver is never 34168c2ecf20Sopenharmony_ci * loaded). Additionally the interrupt destination is not set up properly 34178c2ecf20Sopenharmony_ci * and the interrupt ends up -somewhere-. 34188c2ecf20Sopenharmony_ci * 34198c2ecf20Sopenharmony_ci * These spurious interrupts are "sticky" and the kernel disables the 34208c2ecf20Sopenharmony_ci * (shared) interrupt line after 100,000+ generated interrupts. 34218c2ecf20Sopenharmony_ci * 34228c2ecf20Sopenharmony_ci * Fix it by disabling the still enabled interrupts. This resolves crashes 34238c2ecf20Sopenharmony_ci * often seen on monitor unplug. 34248c2ecf20Sopenharmony_ci */ 34258c2ecf20Sopenharmony_ci#define I915_DEIER_REG 0x4400c 34268c2ecf20Sopenharmony_cistatic void disable_igfx_irq(struct pci_dev *dev) 34278c2ecf20Sopenharmony_ci{ 34288c2ecf20Sopenharmony_ci void __iomem *regs = pci_iomap(dev, 0, 0); 34298c2ecf20Sopenharmony_ci if (regs == NULL) { 34308c2ecf20Sopenharmony_ci pci_warn(dev, "igfx quirk: Can't iomap PCI device\n"); 34318c2ecf20Sopenharmony_ci return; 34328c2ecf20Sopenharmony_ci } 34338c2ecf20Sopenharmony_ci 34348c2ecf20Sopenharmony_ci /* Check if any interrupt line is still enabled */ 34358c2ecf20Sopenharmony_ci if (readl(regs + I915_DEIER_REG) != 0) { 34368c2ecf20Sopenharmony_ci pci_warn(dev, "BIOS left Intel GPU interrupts enabled; disabling\n"); 34378c2ecf20Sopenharmony_ci 34388c2ecf20Sopenharmony_ci writel(0, regs + I915_DEIER_REG); 34398c2ecf20Sopenharmony_ci } 34408c2ecf20Sopenharmony_ci 34418c2ecf20Sopenharmony_ci pci_iounmap(dev, regs); 34428c2ecf20Sopenharmony_ci} 34438c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x0042, disable_igfx_irq); 34448c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x0046, disable_igfx_irq); 34458c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x004a, disable_igfx_irq); 34468c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x0102, disable_igfx_irq); 34478c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x0106, disable_igfx_irq); 34488c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x010a, disable_igfx_irq); 34498c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x0152, disable_igfx_irq); 34508c2ecf20Sopenharmony_ci 34518c2ecf20Sopenharmony_ci/* 34528c2ecf20Sopenharmony_ci * PCI devices which are on Intel chips can skip the 10ms delay 34538c2ecf20Sopenharmony_ci * before entering D3 mode. 34548c2ecf20Sopenharmony_ci */ 34558c2ecf20Sopenharmony_cistatic void quirk_remove_d3hot_delay(struct pci_dev *dev) 34568c2ecf20Sopenharmony_ci{ 34578c2ecf20Sopenharmony_ci dev->d3hot_delay = 0; 34588c2ecf20Sopenharmony_ci} 34598c2ecf20Sopenharmony_ci/* C600 Series devices do not need 10ms d3hot_delay */ 34608c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x0412, quirk_remove_d3hot_delay); 34618c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x0c00, quirk_remove_d3hot_delay); 34628c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x0c0c, quirk_remove_d3hot_delay); 34638c2ecf20Sopenharmony_ci/* Lynxpoint-H PCH devices do not need 10ms d3hot_delay */ 34648c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x8c02, quirk_remove_d3hot_delay); 34658c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x8c18, quirk_remove_d3hot_delay); 34668c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x8c1c, quirk_remove_d3hot_delay); 34678c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x8c20, quirk_remove_d3hot_delay); 34688c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x8c22, quirk_remove_d3hot_delay); 34698c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x8c26, quirk_remove_d3hot_delay); 34708c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x8c2d, quirk_remove_d3hot_delay); 34718c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x8c31, quirk_remove_d3hot_delay); 34728c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x8c3a, quirk_remove_d3hot_delay); 34738c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x8c3d, quirk_remove_d3hot_delay); 34748c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x8c4e, quirk_remove_d3hot_delay); 34758c2ecf20Sopenharmony_ci/* Intel Cherrytrail devices do not need 10ms d3hot_delay */ 34768c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x2280, quirk_remove_d3hot_delay); 34778c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x2298, quirk_remove_d3hot_delay); 34788c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x229c, quirk_remove_d3hot_delay); 34798c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x22b0, quirk_remove_d3hot_delay); 34808c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x22b5, quirk_remove_d3hot_delay); 34818c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x22b7, quirk_remove_d3hot_delay); 34828c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x22b8, quirk_remove_d3hot_delay); 34838c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x22d8, quirk_remove_d3hot_delay); 34848c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x22dc, quirk_remove_d3hot_delay); 34858c2ecf20Sopenharmony_ci 34868c2ecf20Sopenharmony_ci/* 34878c2ecf20Sopenharmony_ci * Some devices may pass our check in pci_intx_mask_supported() if 34888c2ecf20Sopenharmony_ci * PCI_COMMAND_INTX_DISABLE works though they actually do not properly 34898c2ecf20Sopenharmony_ci * support this feature. 34908c2ecf20Sopenharmony_ci */ 34918c2ecf20Sopenharmony_cistatic void quirk_broken_intx_masking(struct pci_dev *dev) 34928c2ecf20Sopenharmony_ci{ 34938c2ecf20Sopenharmony_ci dev->broken_intx_masking = 1; 34948c2ecf20Sopenharmony_ci} 34958c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CHELSIO, 0x0030, 34968c2ecf20Sopenharmony_ci quirk_broken_intx_masking); 34978c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(0x1814, 0x0601, /* Ralink RT2800 802.11n PCI */ 34988c2ecf20Sopenharmony_ci quirk_broken_intx_masking); 34998c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(0x1b7c, 0x0004, /* Ceton InfiniTV4 */ 35008c2ecf20Sopenharmony_ci quirk_broken_intx_masking); 35018c2ecf20Sopenharmony_ci 35028c2ecf20Sopenharmony_ci/* 35038c2ecf20Sopenharmony_ci * Realtek RTL8169 PCI Gigabit Ethernet Controller (rev 10) 35048c2ecf20Sopenharmony_ci * Subsystem: Realtek RTL8169/8110 Family PCI Gigabit Ethernet NIC 35058c2ecf20Sopenharmony_ci * 35068c2ecf20Sopenharmony_ci * RTL8110SC - Fails under PCI device assignment using DisINTx masking. 35078c2ecf20Sopenharmony_ci */ 35088c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_REALTEK, 0x8169, 35098c2ecf20Sopenharmony_ci quirk_broken_intx_masking); 35108c2ecf20Sopenharmony_ci 35118c2ecf20Sopenharmony_ci/* 35128c2ecf20Sopenharmony_ci * Intel i40e (XL710/X710) 10/20/40GbE NICs all have broken INTx masking, 35138c2ecf20Sopenharmony_ci * DisINTx can be set but the interrupt status bit is non-functional. 35148c2ecf20Sopenharmony_ci */ 35158c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x1572, quirk_broken_intx_masking); 35168c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x1574, quirk_broken_intx_masking); 35178c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x1580, quirk_broken_intx_masking); 35188c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x1581, quirk_broken_intx_masking); 35198c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x1583, quirk_broken_intx_masking); 35208c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x1584, quirk_broken_intx_masking); 35218c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x1585, quirk_broken_intx_masking); 35228c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x1586, quirk_broken_intx_masking); 35238c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x1587, quirk_broken_intx_masking); 35248c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x1588, quirk_broken_intx_masking); 35258c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x1589, quirk_broken_intx_masking); 35268c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x158a, quirk_broken_intx_masking); 35278c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x158b, quirk_broken_intx_masking); 35288c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x37d0, quirk_broken_intx_masking); 35298c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x37d1, quirk_broken_intx_masking); 35308c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x37d2, quirk_broken_intx_masking); 35318c2ecf20Sopenharmony_ci 35328c2ecf20Sopenharmony_cistatic u16 mellanox_broken_intx_devs[] = { 35338c2ecf20Sopenharmony_ci PCI_DEVICE_ID_MELLANOX_HERMON_SDR, 35348c2ecf20Sopenharmony_ci PCI_DEVICE_ID_MELLANOX_HERMON_DDR, 35358c2ecf20Sopenharmony_ci PCI_DEVICE_ID_MELLANOX_HERMON_QDR, 35368c2ecf20Sopenharmony_ci PCI_DEVICE_ID_MELLANOX_HERMON_DDR_GEN2, 35378c2ecf20Sopenharmony_ci PCI_DEVICE_ID_MELLANOX_HERMON_QDR_GEN2, 35388c2ecf20Sopenharmony_ci PCI_DEVICE_ID_MELLANOX_HERMON_EN, 35398c2ecf20Sopenharmony_ci PCI_DEVICE_ID_MELLANOX_HERMON_EN_GEN2, 35408c2ecf20Sopenharmony_ci PCI_DEVICE_ID_MELLANOX_CONNECTX_EN, 35418c2ecf20Sopenharmony_ci PCI_DEVICE_ID_MELLANOX_CONNECTX_EN_T_GEN2, 35428c2ecf20Sopenharmony_ci PCI_DEVICE_ID_MELLANOX_CONNECTX_EN_GEN2, 35438c2ecf20Sopenharmony_ci PCI_DEVICE_ID_MELLANOX_CONNECTX_EN_5_GEN2, 35448c2ecf20Sopenharmony_ci PCI_DEVICE_ID_MELLANOX_CONNECTX2, 35458c2ecf20Sopenharmony_ci PCI_DEVICE_ID_MELLANOX_CONNECTX3, 35468c2ecf20Sopenharmony_ci PCI_DEVICE_ID_MELLANOX_CONNECTX3_PRO, 35478c2ecf20Sopenharmony_ci}; 35488c2ecf20Sopenharmony_ci 35498c2ecf20Sopenharmony_ci#define CONNECTX_4_CURR_MAX_MINOR 99 35508c2ecf20Sopenharmony_ci#define CONNECTX_4_INTX_SUPPORT_MINOR 14 35518c2ecf20Sopenharmony_ci 35528c2ecf20Sopenharmony_ci/* 35538c2ecf20Sopenharmony_ci * Check ConnectX-4/LX FW version to see if it supports legacy interrupts. 35548c2ecf20Sopenharmony_ci * If so, don't mark it as broken. 35558c2ecf20Sopenharmony_ci * FW minor > 99 means older FW version format and no INTx masking support. 35568c2ecf20Sopenharmony_ci * FW minor < 14 means new FW version format and no INTx masking support. 35578c2ecf20Sopenharmony_ci */ 35588c2ecf20Sopenharmony_cistatic void mellanox_check_broken_intx_masking(struct pci_dev *pdev) 35598c2ecf20Sopenharmony_ci{ 35608c2ecf20Sopenharmony_ci __be32 __iomem *fw_ver; 35618c2ecf20Sopenharmony_ci u16 fw_major; 35628c2ecf20Sopenharmony_ci u16 fw_minor; 35638c2ecf20Sopenharmony_ci u16 fw_subminor; 35648c2ecf20Sopenharmony_ci u32 fw_maj_min; 35658c2ecf20Sopenharmony_ci u32 fw_sub_min; 35668c2ecf20Sopenharmony_ci int i; 35678c2ecf20Sopenharmony_ci 35688c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(mellanox_broken_intx_devs); i++) { 35698c2ecf20Sopenharmony_ci if (pdev->device == mellanox_broken_intx_devs[i]) { 35708c2ecf20Sopenharmony_ci pdev->broken_intx_masking = 1; 35718c2ecf20Sopenharmony_ci return; 35728c2ecf20Sopenharmony_ci } 35738c2ecf20Sopenharmony_ci } 35748c2ecf20Sopenharmony_ci 35758c2ecf20Sopenharmony_ci /* 35768c2ecf20Sopenharmony_ci * Getting here means Connect-IB cards and up. Connect-IB has no INTx 35778c2ecf20Sopenharmony_ci * support so shouldn't be checked further 35788c2ecf20Sopenharmony_ci */ 35798c2ecf20Sopenharmony_ci if (pdev->device == PCI_DEVICE_ID_MELLANOX_CONNECTIB) 35808c2ecf20Sopenharmony_ci return; 35818c2ecf20Sopenharmony_ci 35828c2ecf20Sopenharmony_ci if (pdev->device != PCI_DEVICE_ID_MELLANOX_CONNECTX4 && 35838c2ecf20Sopenharmony_ci pdev->device != PCI_DEVICE_ID_MELLANOX_CONNECTX4_LX) 35848c2ecf20Sopenharmony_ci return; 35858c2ecf20Sopenharmony_ci 35868c2ecf20Sopenharmony_ci /* For ConnectX-4 and ConnectX-4LX, need to check FW support */ 35878c2ecf20Sopenharmony_ci if (pci_enable_device_mem(pdev)) { 35888c2ecf20Sopenharmony_ci pci_warn(pdev, "Can't enable device memory\n"); 35898c2ecf20Sopenharmony_ci return; 35908c2ecf20Sopenharmony_ci } 35918c2ecf20Sopenharmony_ci 35928c2ecf20Sopenharmony_ci fw_ver = ioremap(pci_resource_start(pdev, 0), 4); 35938c2ecf20Sopenharmony_ci if (!fw_ver) { 35948c2ecf20Sopenharmony_ci pci_warn(pdev, "Can't map ConnectX-4 initialization segment\n"); 35958c2ecf20Sopenharmony_ci goto out; 35968c2ecf20Sopenharmony_ci } 35978c2ecf20Sopenharmony_ci 35988c2ecf20Sopenharmony_ci /* Reading from resource space should be 32b aligned */ 35998c2ecf20Sopenharmony_ci fw_maj_min = ioread32be(fw_ver); 36008c2ecf20Sopenharmony_ci fw_sub_min = ioread32be(fw_ver + 1); 36018c2ecf20Sopenharmony_ci fw_major = fw_maj_min & 0xffff; 36028c2ecf20Sopenharmony_ci fw_minor = fw_maj_min >> 16; 36038c2ecf20Sopenharmony_ci fw_subminor = fw_sub_min & 0xffff; 36048c2ecf20Sopenharmony_ci if (fw_minor > CONNECTX_4_CURR_MAX_MINOR || 36058c2ecf20Sopenharmony_ci fw_minor < CONNECTX_4_INTX_SUPPORT_MINOR) { 36068c2ecf20Sopenharmony_ci pci_warn(pdev, "ConnectX-4: FW %u.%u.%u doesn't support INTx masking, disabling. Please upgrade FW to %d.14.1100 and up for INTx support\n", 36078c2ecf20Sopenharmony_ci fw_major, fw_minor, fw_subminor, pdev->device == 36088c2ecf20Sopenharmony_ci PCI_DEVICE_ID_MELLANOX_CONNECTX4 ? 12 : 14); 36098c2ecf20Sopenharmony_ci pdev->broken_intx_masking = 1; 36108c2ecf20Sopenharmony_ci } 36118c2ecf20Sopenharmony_ci 36128c2ecf20Sopenharmony_ci iounmap(fw_ver); 36138c2ecf20Sopenharmony_ci 36148c2ecf20Sopenharmony_ciout: 36158c2ecf20Sopenharmony_ci pci_disable_device(pdev); 36168c2ecf20Sopenharmony_ci} 36178c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_MELLANOX, PCI_ANY_ID, 36188c2ecf20Sopenharmony_ci mellanox_check_broken_intx_masking); 36198c2ecf20Sopenharmony_ci 36208c2ecf20Sopenharmony_cistatic void quirk_no_bus_reset(struct pci_dev *dev) 36218c2ecf20Sopenharmony_ci{ 36228c2ecf20Sopenharmony_ci dev->dev_flags |= PCI_DEV_FLAGS_NO_BUS_RESET; 36238c2ecf20Sopenharmony_ci} 36248c2ecf20Sopenharmony_ci 36258c2ecf20Sopenharmony_ci/* 36268c2ecf20Sopenharmony_ci * Some NVIDIA GPU devices do not work with bus reset, SBR needs to be 36278c2ecf20Sopenharmony_ci * prevented for those affected devices. 36288c2ecf20Sopenharmony_ci */ 36298c2ecf20Sopenharmony_cistatic void quirk_nvidia_no_bus_reset(struct pci_dev *dev) 36308c2ecf20Sopenharmony_ci{ 36318c2ecf20Sopenharmony_ci if ((dev->device & 0xffc0) == 0x2340) 36328c2ecf20Sopenharmony_ci quirk_no_bus_reset(dev); 36338c2ecf20Sopenharmony_ci} 36348c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID, 36358c2ecf20Sopenharmony_ci quirk_nvidia_no_bus_reset); 36368c2ecf20Sopenharmony_ci 36378c2ecf20Sopenharmony_ci/* 36388c2ecf20Sopenharmony_ci * Some Atheros AR9xxx and QCA988x chips do not behave after a bus reset. 36398c2ecf20Sopenharmony_ci * The device will throw a Link Down error on AER-capable systems and 36408c2ecf20Sopenharmony_ci * regardless of AER, config space of the device is never accessible again 36418c2ecf20Sopenharmony_ci * and typically causes the system to hang or reset when access is attempted. 36428c2ecf20Sopenharmony_ci * https://lore.kernel.org/r/20140923210318.498dacbd@dualc.maya.org/ 36438c2ecf20Sopenharmony_ci */ 36448c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATHEROS, 0x0030, quirk_no_bus_reset); 36458c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATHEROS, 0x0032, quirk_no_bus_reset); 36468c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATHEROS, 0x003c, quirk_no_bus_reset); 36478c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATHEROS, 0x0033, quirk_no_bus_reset); 36488c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATHEROS, 0x0034, quirk_no_bus_reset); 36498c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATHEROS, 0x003e, quirk_no_bus_reset); 36508c2ecf20Sopenharmony_ci 36518c2ecf20Sopenharmony_ci/* 36528c2ecf20Sopenharmony_ci * Root port on some Cavium CN8xxx chips do not successfully complete a bus 36538c2ecf20Sopenharmony_ci * reset when used with certain child devices. After the reset, config 36548c2ecf20Sopenharmony_ci * accesses to the child may fail. 36558c2ecf20Sopenharmony_ci */ 36568c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_CAVIUM, 0xa100, quirk_no_bus_reset); 36578c2ecf20Sopenharmony_ci 36588c2ecf20Sopenharmony_ci/* 36598c2ecf20Sopenharmony_ci * Some TI KeyStone C667X devices do not support bus/hot reset. The PCIESS 36608c2ecf20Sopenharmony_ci * automatically disables LTSSM when Secondary Bus Reset is received and 36618c2ecf20Sopenharmony_ci * the device stops working. Prevent bus reset for these devices. With 36628c2ecf20Sopenharmony_ci * this change, the device can be assigned to VMs with VFIO, but it will 36638c2ecf20Sopenharmony_ci * leak state between VMs. Reference 36648c2ecf20Sopenharmony_ci * https://e2e.ti.com/support/processors/f/791/t/954382 36658c2ecf20Sopenharmony_ci */ 36668c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_TI, 0xb005, quirk_no_bus_reset); 36678c2ecf20Sopenharmony_ci 36688c2ecf20Sopenharmony_cistatic void quirk_no_pm_reset(struct pci_dev *dev) 36698c2ecf20Sopenharmony_ci{ 36708c2ecf20Sopenharmony_ci /* 36718c2ecf20Sopenharmony_ci * We can't do a bus reset on root bus devices, but an ineffective 36728c2ecf20Sopenharmony_ci * PM reset may be better than nothing. 36738c2ecf20Sopenharmony_ci */ 36748c2ecf20Sopenharmony_ci if (!pci_is_root_bus(dev->bus)) 36758c2ecf20Sopenharmony_ci dev->dev_flags |= PCI_DEV_FLAGS_NO_PM_RESET; 36768c2ecf20Sopenharmony_ci} 36778c2ecf20Sopenharmony_ci 36788c2ecf20Sopenharmony_ci/* 36798c2ecf20Sopenharmony_ci * Some AMD/ATI GPUS (HD8570 - Oland) report that a D3hot->D0 transition 36808c2ecf20Sopenharmony_ci * causes a reset (i.e., they advertise NoSoftRst-). This transition seems 36818c2ecf20Sopenharmony_ci * to have no effect on the device: it retains the framebuffer contents and 36828c2ecf20Sopenharmony_ci * monitor sync. Advertising this support makes other layers, like VFIO, 36838c2ecf20Sopenharmony_ci * assume pci_reset_function() is viable for this device. Mark it as 36848c2ecf20Sopenharmony_ci * unavailable to skip it when testing reset methods. 36858c2ecf20Sopenharmony_ci */ 36868c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_HEADER(PCI_VENDOR_ID_ATI, PCI_ANY_ID, 36878c2ecf20Sopenharmony_ci PCI_CLASS_DISPLAY_VGA, 8, quirk_no_pm_reset); 36888c2ecf20Sopenharmony_ci 36898c2ecf20Sopenharmony_ci/* 36908c2ecf20Sopenharmony_ci * Spectrum-{1,2,3,4} devices report that a D3hot->D0 transition causes a reset 36918c2ecf20Sopenharmony_ci * (i.e., they advertise NoSoftRst-). However, this transition does not have 36928c2ecf20Sopenharmony_ci * any effect on the device: It continues to be operational and network ports 36938c2ecf20Sopenharmony_ci * remain up. Advertising this support makes it seem as if a PM reset is viable 36948c2ecf20Sopenharmony_ci * for these devices. Mark it as unavailable to skip it when testing reset 36958c2ecf20Sopenharmony_ci * methods. 36968c2ecf20Sopenharmony_ci */ 36978c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MELLANOX, 0xcb84, quirk_no_pm_reset); 36988c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MELLANOX, 0xcf6c, quirk_no_pm_reset); 36998c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MELLANOX, 0xcf70, quirk_no_pm_reset); 37008c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MELLANOX, 0xcf80, quirk_no_pm_reset); 37018c2ecf20Sopenharmony_ci 37028c2ecf20Sopenharmony_ci/* 37038c2ecf20Sopenharmony_ci * Thunderbolt controllers with broken MSI hotplug signaling: 37048c2ecf20Sopenharmony_ci * Entire 1st generation (Light Ridge, Eagle Ridge, Light Peak) and part 37058c2ecf20Sopenharmony_ci * of the 2nd generation (Cactus Ridge 4C up to revision 1, Port Ridge). 37068c2ecf20Sopenharmony_ci */ 37078c2ecf20Sopenharmony_cistatic void quirk_thunderbolt_hotplug_msi(struct pci_dev *pdev) 37088c2ecf20Sopenharmony_ci{ 37098c2ecf20Sopenharmony_ci if (pdev->is_hotplug_bridge && 37108c2ecf20Sopenharmony_ci (pdev->device != PCI_DEVICE_ID_INTEL_CACTUS_RIDGE_4C || 37118c2ecf20Sopenharmony_ci pdev->revision <= 1)) 37128c2ecf20Sopenharmony_ci pdev->no_msi = 1; 37138c2ecf20Sopenharmony_ci} 37148c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_LIGHT_RIDGE, 37158c2ecf20Sopenharmony_ci quirk_thunderbolt_hotplug_msi); 37168c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_EAGLE_RIDGE, 37178c2ecf20Sopenharmony_ci quirk_thunderbolt_hotplug_msi); 37188c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_LIGHT_PEAK, 37198c2ecf20Sopenharmony_ci quirk_thunderbolt_hotplug_msi); 37208c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CACTUS_RIDGE_4C, 37218c2ecf20Sopenharmony_ci quirk_thunderbolt_hotplug_msi); 37228c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PORT_RIDGE, 37238c2ecf20Sopenharmony_ci quirk_thunderbolt_hotplug_msi); 37248c2ecf20Sopenharmony_ci 37258c2ecf20Sopenharmony_ci#ifdef CONFIG_ACPI 37268c2ecf20Sopenharmony_ci/* 37278c2ecf20Sopenharmony_ci * Apple: Shutdown Cactus Ridge Thunderbolt controller. 37288c2ecf20Sopenharmony_ci * 37298c2ecf20Sopenharmony_ci * On Apple hardware the Cactus Ridge Thunderbolt controller needs to be 37308c2ecf20Sopenharmony_ci * shutdown before suspend. Otherwise the native host interface (NHI) will not 37318c2ecf20Sopenharmony_ci * be present after resume if a device was plugged in before suspend. 37328c2ecf20Sopenharmony_ci * 37338c2ecf20Sopenharmony_ci * The Thunderbolt controller consists of a PCIe switch with downstream 37348c2ecf20Sopenharmony_ci * bridges leading to the NHI and to the tunnel PCI bridges. 37358c2ecf20Sopenharmony_ci * 37368c2ecf20Sopenharmony_ci * This quirk cuts power to the whole chip. Therefore we have to apply it 37378c2ecf20Sopenharmony_ci * during suspend_noirq of the upstream bridge. 37388c2ecf20Sopenharmony_ci * 37398c2ecf20Sopenharmony_ci * Power is automagically restored before resume. No action is needed. 37408c2ecf20Sopenharmony_ci */ 37418c2ecf20Sopenharmony_cistatic void quirk_apple_poweroff_thunderbolt(struct pci_dev *dev) 37428c2ecf20Sopenharmony_ci{ 37438c2ecf20Sopenharmony_ci acpi_handle bridge, SXIO, SXFP, SXLV; 37448c2ecf20Sopenharmony_ci 37458c2ecf20Sopenharmony_ci if (!x86_apple_machine) 37468c2ecf20Sopenharmony_ci return; 37478c2ecf20Sopenharmony_ci if (pci_pcie_type(dev) != PCI_EXP_TYPE_UPSTREAM) 37488c2ecf20Sopenharmony_ci return; 37498c2ecf20Sopenharmony_ci 37508c2ecf20Sopenharmony_ci /* 37518c2ecf20Sopenharmony_ci * SXIO/SXFP/SXLF turns off power to the Thunderbolt controller. 37528c2ecf20Sopenharmony_ci * We don't know how to turn it back on again, but firmware does, 37538c2ecf20Sopenharmony_ci * so we can only use SXIO/SXFP/SXLF if we're suspending via 37548c2ecf20Sopenharmony_ci * firmware. 37558c2ecf20Sopenharmony_ci */ 37568c2ecf20Sopenharmony_ci if (!pm_suspend_via_firmware()) 37578c2ecf20Sopenharmony_ci return; 37588c2ecf20Sopenharmony_ci 37598c2ecf20Sopenharmony_ci bridge = ACPI_HANDLE(&dev->dev); 37608c2ecf20Sopenharmony_ci if (!bridge) 37618c2ecf20Sopenharmony_ci return; 37628c2ecf20Sopenharmony_ci 37638c2ecf20Sopenharmony_ci /* 37648c2ecf20Sopenharmony_ci * SXIO and SXLV are present only on machines requiring this quirk. 37658c2ecf20Sopenharmony_ci * Thunderbolt bridges in external devices might have the same 37668c2ecf20Sopenharmony_ci * device ID as those on the host, but they will not have the 37678c2ecf20Sopenharmony_ci * associated ACPI methods. This implicitly checks that we are at 37688c2ecf20Sopenharmony_ci * the right bridge. 37698c2ecf20Sopenharmony_ci */ 37708c2ecf20Sopenharmony_ci if (ACPI_FAILURE(acpi_get_handle(bridge, "DSB0.NHI0.SXIO", &SXIO)) 37718c2ecf20Sopenharmony_ci || ACPI_FAILURE(acpi_get_handle(bridge, "DSB0.NHI0.SXFP", &SXFP)) 37728c2ecf20Sopenharmony_ci || ACPI_FAILURE(acpi_get_handle(bridge, "DSB0.NHI0.SXLV", &SXLV))) 37738c2ecf20Sopenharmony_ci return; 37748c2ecf20Sopenharmony_ci pci_info(dev, "quirk: cutting power to Thunderbolt controller...\n"); 37758c2ecf20Sopenharmony_ci 37768c2ecf20Sopenharmony_ci /* magic sequence */ 37778c2ecf20Sopenharmony_ci acpi_execute_simple_method(SXIO, NULL, 1); 37788c2ecf20Sopenharmony_ci acpi_execute_simple_method(SXFP, NULL, 0); 37798c2ecf20Sopenharmony_ci msleep(300); 37808c2ecf20Sopenharmony_ci acpi_execute_simple_method(SXLV, NULL, 0); 37818c2ecf20Sopenharmony_ci acpi_execute_simple_method(SXIO, NULL, 0); 37828c2ecf20Sopenharmony_ci acpi_execute_simple_method(SXLV, NULL, 0); 37838c2ecf20Sopenharmony_ci} 37848c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_SUSPEND_LATE(PCI_VENDOR_ID_INTEL, 37858c2ecf20Sopenharmony_ci PCI_DEVICE_ID_INTEL_CACTUS_RIDGE_4C, 37868c2ecf20Sopenharmony_ci quirk_apple_poweroff_thunderbolt); 37878c2ecf20Sopenharmony_ci#endif 37888c2ecf20Sopenharmony_ci 37898c2ecf20Sopenharmony_ci/* 37908c2ecf20Sopenharmony_ci * Following are device-specific reset methods which can be used to 37918c2ecf20Sopenharmony_ci * reset a single function if other methods (e.g. FLR, PM D0->D3) are 37928c2ecf20Sopenharmony_ci * not available. 37938c2ecf20Sopenharmony_ci */ 37948c2ecf20Sopenharmony_cistatic int reset_intel_82599_sfp_virtfn(struct pci_dev *dev, int probe) 37958c2ecf20Sopenharmony_ci{ 37968c2ecf20Sopenharmony_ci /* 37978c2ecf20Sopenharmony_ci * http://www.intel.com/content/dam/doc/datasheet/82599-10-gbe-controller-datasheet.pdf 37988c2ecf20Sopenharmony_ci * 37998c2ecf20Sopenharmony_ci * The 82599 supports FLR on VFs, but FLR support is reported only 38008c2ecf20Sopenharmony_ci * in the PF DEVCAP (sec 9.3.10.4), not in the VF DEVCAP (sec 9.5). 38018c2ecf20Sopenharmony_ci * Thus we must call pcie_flr() directly without first checking if it is 38028c2ecf20Sopenharmony_ci * supported. 38038c2ecf20Sopenharmony_ci */ 38048c2ecf20Sopenharmony_ci if (!probe) 38058c2ecf20Sopenharmony_ci pcie_flr(dev); 38068c2ecf20Sopenharmony_ci return 0; 38078c2ecf20Sopenharmony_ci} 38088c2ecf20Sopenharmony_ci 38098c2ecf20Sopenharmony_ci#define SOUTH_CHICKEN2 0xc2004 38108c2ecf20Sopenharmony_ci#define PCH_PP_STATUS 0xc7200 38118c2ecf20Sopenharmony_ci#define PCH_PP_CONTROL 0xc7204 38128c2ecf20Sopenharmony_ci#define MSG_CTL 0x45010 38138c2ecf20Sopenharmony_ci#define NSDE_PWR_STATE 0xd0100 38148c2ecf20Sopenharmony_ci#define IGD_OPERATION_TIMEOUT 10000 /* set timeout 10 seconds */ 38158c2ecf20Sopenharmony_ci 38168c2ecf20Sopenharmony_cistatic int reset_ivb_igd(struct pci_dev *dev, int probe) 38178c2ecf20Sopenharmony_ci{ 38188c2ecf20Sopenharmony_ci void __iomem *mmio_base; 38198c2ecf20Sopenharmony_ci unsigned long timeout; 38208c2ecf20Sopenharmony_ci u32 val; 38218c2ecf20Sopenharmony_ci 38228c2ecf20Sopenharmony_ci if (probe) 38238c2ecf20Sopenharmony_ci return 0; 38248c2ecf20Sopenharmony_ci 38258c2ecf20Sopenharmony_ci mmio_base = pci_iomap(dev, 0, 0); 38268c2ecf20Sopenharmony_ci if (!mmio_base) 38278c2ecf20Sopenharmony_ci return -ENOMEM; 38288c2ecf20Sopenharmony_ci 38298c2ecf20Sopenharmony_ci iowrite32(0x00000002, mmio_base + MSG_CTL); 38308c2ecf20Sopenharmony_ci 38318c2ecf20Sopenharmony_ci /* 38328c2ecf20Sopenharmony_ci * Clobbering SOUTH_CHICKEN2 register is fine only if the next 38338c2ecf20Sopenharmony_ci * driver loaded sets the right bits. However, this's a reset and 38348c2ecf20Sopenharmony_ci * the bits have been set by i915 previously, so we clobber 38358c2ecf20Sopenharmony_ci * SOUTH_CHICKEN2 register directly here. 38368c2ecf20Sopenharmony_ci */ 38378c2ecf20Sopenharmony_ci iowrite32(0x00000005, mmio_base + SOUTH_CHICKEN2); 38388c2ecf20Sopenharmony_ci 38398c2ecf20Sopenharmony_ci val = ioread32(mmio_base + PCH_PP_CONTROL) & 0xfffffffe; 38408c2ecf20Sopenharmony_ci iowrite32(val, mmio_base + PCH_PP_CONTROL); 38418c2ecf20Sopenharmony_ci 38428c2ecf20Sopenharmony_ci timeout = jiffies + msecs_to_jiffies(IGD_OPERATION_TIMEOUT); 38438c2ecf20Sopenharmony_ci do { 38448c2ecf20Sopenharmony_ci val = ioread32(mmio_base + PCH_PP_STATUS); 38458c2ecf20Sopenharmony_ci if ((val & 0xb0000000) == 0) 38468c2ecf20Sopenharmony_ci goto reset_complete; 38478c2ecf20Sopenharmony_ci msleep(10); 38488c2ecf20Sopenharmony_ci } while (time_before(jiffies, timeout)); 38498c2ecf20Sopenharmony_ci pci_warn(dev, "timeout during reset\n"); 38508c2ecf20Sopenharmony_ci 38518c2ecf20Sopenharmony_cireset_complete: 38528c2ecf20Sopenharmony_ci iowrite32(0x00000002, mmio_base + NSDE_PWR_STATE); 38538c2ecf20Sopenharmony_ci 38548c2ecf20Sopenharmony_ci pci_iounmap(dev, mmio_base); 38558c2ecf20Sopenharmony_ci return 0; 38568c2ecf20Sopenharmony_ci} 38578c2ecf20Sopenharmony_ci 38588c2ecf20Sopenharmony_ci/* Device-specific reset method for Chelsio T4-based adapters */ 38598c2ecf20Sopenharmony_cistatic int reset_chelsio_generic_dev(struct pci_dev *dev, int probe) 38608c2ecf20Sopenharmony_ci{ 38618c2ecf20Sopenharmony_ci u16 old_command; 38628c2ecf20Sopenharmony_ci u16 msix_flags; 38638c2ecf20Sopenharmony_ci 38648c2ecf20Sopenharmony_ci /* 38658c2ecf20Sopenharmony_ci * If this isn't a Chelsio T4-based device, return -ENOTTY indicating 38668c2ecf20Sopenharmony_ci * that we have no device-specific reset method. 38678c2ecf20Sopenharmony_ci */ 38688c2ecf20Sopenharmony_ci if ((dev->device & 0xf000) != 0x4000) 38698c2ecf20Sopenharmony_ci return -ENOTTY; 38708c2ecf20Sopenharmony_ci 38718c2ecf20Sopenharmony_ci /* 38728c2ecf20Sopenharmony_ci * If this is the "probe" phase, return 0 indicating that we can 38738c2ecf20Sopenharmony_ci * reset this device. 38748c2ecf20Sopenharmony_ci */ 38758c2ecf20Sopenharmony_ci if (probe) 38768c2ecf20Sopenharmony_ci return 0; 38778c2ecf20Sopenharmony_ci 38788c2ecf20Sopenharmony_ci /* 38798c2ecf20Sopenharmony_ci * T4 can wedge if there are DMAs in flight within the chip and Bus 38808c2ecf20Sopenharmony_ci * Master has been disabled. We need to have it on till the Function 38818c2ecf20Sopenharmony_ci * Level Reset completes. (BUS_MASTER is disabled in 38828c2ecf20Sopenharmony_ci * pci_reset_function()). 38838c2ecf20Sopenharmony_ci */ 38848c2ecf20Sopenharmony_ci pci_read_config_word(dev, PCI_COMMAND, &old_command); 38858c2ecf20Sopenharmony_ci pci_write_config_word(dev, PCI_COMMAND, 38868c2ecf20Sopenharmony_ci old_command | PCI_COMMAND_MASTER); 38878c2ecf20Sopenharmony_ci 38888c2ecf20Sopenharmony_ci /* 38898c2ecf20Sopenharmony_ci * Perform the actual device function reset, saving and restoring 38908c2ecf20Sopenharmony_ci * configuration information around the reset. 38918c2ecf20Sopenharmony_ci */ 38928c2ecf20Sopenharmony_ci pci_save_state(dev); 38938c2ecf20Sopenharmony_ci 38948c2ecf20Sopenharmony_ci /* 38958c2ecf20Sopenharmony_ci * T4 also suffers a Head-Of-Line blocking problem if MSI-X interrupts 38968c2ecf20Sopenharmony_ci * are disabled when an MSI-X interrupt message needs to be delivered. 38978c2ecf20Sopenharmony_ci * So we briefly re-enable MSI-X interrupts for the duration of the 38988c2ecf20Sopenharmony_ci * FLR. The pci_restore_state() below will restore the original 38998c2ecf20Sopenharmony_ci * MSI-X state. 39008c2ecf20Sopenharmony_ci */ 39018c2ecf20Sopenharmony_ci pci_read_config_word(dev, dev->msix_cap+PCI_MSIX_FLAGS, &msix_flags); 39028c2ecf20Sopenharmony_ci if ((msix_flags & PCI_MSIX_FLAGS_ENABLE) == 0) 39038c2ecf20Sopenharmony_ci pci_write_config_word(dev, dev->msix_cap+PCI_MSIX_FLAGS, 39048c2ecf20Sopenharmony_ci msix_flags | 39058c2ecf20Sopenharmony_ci PCI_MSIX_FLAGS_ENABLE | 39068c2ecf20Sopenharmony_ci PCI_MSIX_FLAGS_MASKALL); 39078c2ecf20Sopenharmony_ci 39088c2ecf20Sopenharmony_ci pcie_flr(dev); 39098c2ecf20Sopenharmony_ci 39108c2ecf20Sopenharmony_ci /* 39118c2ecf20Sopenharmony_ci * Restore the configuration information (BAR values, etc.) including 39128c2ecf20Sopenharmony_ci * the original PCI Configuration Space Command word, and return 39138c2ecf20Sopenharmony_ci * success. 39148c2ecf20Sopenharmony_ci */ 39158c2ecf20Sopenharmony_ci pci_restore_state(dev); 39168c2ecf20Sopenharmony_ci pci_write_config_word(dev, PCI_COMMAND, old_command); 39178c2ecf20Sopenharmony_ci return 0; 39188c2ecf20Sopenharmony_ci} 39198c2ecf20Sopenharmony_ci 39208c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_INTEL_82599_SFP_VF 0x10ed 39218c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_INTEL_IVB_M_VGA 0x0156 39228c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_INTEL_IVB_M2_VGA 0x0166 39238c2ecf20Sopenharmony_ci 39248c2ecf20Sopenharmony_ci/* 39258c2ecf20Sopenharmony_ci * The Samsung SM961/PM961 controller can sometimes enter a fatal state after 39268c2ecf20Sopenharmony_ci * FLR where config space reads from the device return -1. We seem to be 39278c2ecf20Sopenharmony_ci * able to avoid this condition if we disable the NVMe controller prior to 39288c2ecf20Sopenharmony_ci * FLR. This quirk is generic for any NVMe class device requiring similar 39298c2ecf20Sopenharmony_ci * assistance to quiesce the device prior to FLR. 39308c2ecf20Sopenharmony_ci * 39318c2ecf20Sopenharmony_ci * NVMe specification: https://nvmexpress.org/resources/specifications/ 39328c2ecf20Sopenharmony_ci * Revision 1.0e: 39338c2ecf20Sopenharmony_ci * Chapter 2: Required and optional PCI config registers 39348c2ecf20Sopenharmony_ci * Chapter 3: NVMe control registers 39358c2ecf20Sopenharmony_ci * Chapter 7.3: Reset behavior 39368c2ecf20Sopenharmony_ci */ 39378c2ecf20Sopenharmony_cistatic int nvme_disable_and_flr(struct pci_dev *dev, int probe) 39388c2ecf20Sopenharmony_ci{ 39398c2ecf20Sopenharmony_ci void __iomem *bar; 39408c2ecf20Sopenharmony_ci u16 cmd; 39418c2ecf20Sopenharmony_ci u32 cfg; 39428c2ecf20Sopenharmony_ci 39438c2ecf20Sopenharmony_ci if (dev->class != PCI_CLASS_STORAGE_EXPRESS || 39448c2ecf20Sopenharmony_ci !pcie_has_flr(dev) || !pci_resource_start(dev, 0)) 39458c2ecf20Sopenharmony_ci return -ENOTTY; 39468c2ecf20Sopenharmony_ci 39478c2ecf20Sopenharmony_ci if (probe) 39488c2ecf20Sopenharmony_ci return 0; 39498c2ecf20Sopenharmony_ci 39508c2ecf20Sopenharmony_ci bar = pci_iomap(dev, 0, NVME_REG_CC + sizeof(cfg)); 39518c2ecf20Sopenharmony_ci if (!bar) 39528c2ecf20Sopenharmony_ci return -ENOTTY; 39538c2ecf20Sopenharmony_ci 39548c2ecf20Sopenharmony_ci pci_read_config_word(dev, PCI_COMMAND, &cmd); 39558c2ecf20Sopenharmony_ci pci_write_config_word(dev, PCI_COMMAND, cmd | PCI_COMMAND_MEMORY); 39568c2ecf20Sopenharmony_ci 39578c2ecf20Sopenharmony_ci cfg = readl(bar + NVME_REG_CC); 39588c2ecf20Sopenharmony_ci 39598c2ecf20Sopenharmony_ci /* Disable controller if enabled */ 39608c2ecf20Sopenharmony_ci if (cfg & NVME_CC_ENABLE) { 39618c2ecf20Sopenharmony_ci u32 cap = readl(bar + NVME_REG_CAP); 39628c2ecf20Sopenharmony_ci unsigned long timeout; 39638c2ecf20Sopenharmony_ci 39648c2ecf20Sopenharmony_ci /* 39658c2ecf20Sopenharmony_ci * Per nvme_disable_ctrl() skip shutdown notification as it 39668c2ecf20Sopenharmony_ci * could complete commands to the admin queue. We only intend 39678c2ecf20Sopenharmony_ci * to quiesce the device before reset. 39688c2ecf20Sopenharmony_ci */ 39698c2ecf20Sopenharmony_ci cfg &= ~(NVME_CC_SHN_MASK | NVME_CC_ENABLE); 39708c2ecf20Sopenharmony_ci 39718c2ecf20Sopenharmony_ci writel(cfg, bar + NVME_REG_CC); 39728c2ecf20Sopenharmony_ci 39738c2ecf20Sopenharmony_ci /* 39748c2ecf20Sopenharmony_ci * Some controllers require an additional delay here, see 39758c2ecf20Sopenharmony_ci * NVME_QUIRK_DELAY_BEFORE_CHK_RDY. None of those are yet 39768c2ecf20Sopenharmony_ci * supported by this quirk. 39778c2ecf20Sopenharmony_ci */ 39788c2ecf20Sopenharmony_ci 39798c2ecf20Sopenharmony_ci /* Cap register provides max timeout in 500ms increments */ 39808c2ecf20Sopenharmony_ci timeout = ((NVME_CAP_TIMEOUT(cap) + 1) * HZ / 2) + jiffies; 39818c2ecf20Sopenharmony_ci 39828c2ecf20Sopenharmony_ci for (;;) { 39838c2ecf20Sopenharmony_ci u32 status = readl(bar + NVME_REG_CSTS); 39848c2ecf20Sopenharmony_ci 39858c2ecf20Sopenharmony_ci /* Ready status becomes zero on disable complete */ 39868c2ecf20Sopenharmony_ci if (!(status & NVME_CSTS_RDY)) 39878c2ecf20Sopenharmony_ci break; 39888c2ecf20Sopenharmony_ci 39898c2ecf20Sopenharmony_ci msleep(100); 39908c2ecf20Sopenharmony_ci 39918c2ecf20Sopenharmony_ci if (time_after(jiffies, timeout)) { 39928c2ecf20Sopenharmony_ci pci_warn(dev, "Timeout waiting for NVMe ready status to clear after disable\n"); 39938c2ecf20Sopenharmony_ci break; 39948c2ecf20Sopenharmony_ci } 39958c2ecf20Sopenharmony_ci } 39968c2ecf20Sopenharmony_ci } 39978c2ecf20Sopenharmony_ci 39988c2ecf20Sopenharmony_ci pci_iounmap(dev, bar); 39998c2ecf20Sopenharmony_ci 40008c2ecf20Sopenharmony_ci pcie_flr(dev); 40018c2ecf20Sopenharmony_ci 40028c2ecf20Sopenharmony_ci return 0; 40038c2ecf20Sopenharmony_ci} 40048c2ecf20Sopenharmony_ci 40058c2ecf20Sopenharmony_ci/* 40068c2ecf20Sopenharmony_ci * Intel DC P3700 NVMe controller will timeout waiting for ready status 40078c2ecf20Sopenharmony_ci * to change after NVMe enable if the driver starts interacting with the 40088c2ecf20Sopenharmony_ci * device too soon after FLR. A 250ms delay after FLR has heuristically 40098c2ecf20Sopenharmony_ci * proven to produce reliably working results for device assignment cases. 40108c2ecf20Sopenharmony_ci */ 40118c2ecf20Sopenharmony_cistatic int delay_250ms_after_flr(struct pci_dev *dev, int probe) 40128c2ecf20Sopenharmony_ci{ 40138c2ecf20Sopenharmony_ci if (!pcie_has_flr(dev)) 40148c2ecf20Sopenharmony_ci return -ENOTTY; 40158c2ecf20Sopenharmony_ci 40168c2ecf20Sopenharmony_ci if (probe) 40178c2ecf20Sopenharmony_ci return 0; 40188c2ecf20Sopenharmony_ci 40198c2ecf20Sopenharmony_ci pcie_flr(dev); 40208c2ecf20Sopenharmony_ci 40218c2ecf20Sopenharmony_ci msleep(250); 40228c2ecf20Sopenharmony_ci 40238c2ecf20Sopenharmony_ci return 0; 40248c2ecf20Sopenharmony_ci} 40258c2ecf20Sopenharmony_ci 40268c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_HINIC_VF 0x375E 40278c2ecf20Sopenharmony_ci#define HINIC_VF_FLR_TYPE 0x1000 40288c2ecf20Sopenharmony_ci#define HINIC_VF_FLR_CAP_BIT (1UL << 30) 40298c2ecf20Sopenharmony_ci#define HINIC_VF_OP 0xE80 40308c2ecf20Sopenharmony_ci#define HINIC_VF_FLR_PROC_BIT (1UL << 18) 40318c2ecf20Sopenharmony_ci#define HINIC_OPERATION_TIMEOUT 15000 /* 15 seconds */ 40328c2ecf20Sopenharmony_ci 40338c2ecf20Sopenharmony_ci/* Device-specific reset method for Huawei Intelligent NIC virtual functions */ 40348c2ecf20Sopenharmony_cistatic int reset_hinic_vf_dev(struct pci_dev *pdev, int probe) 40358c2ecf20Sopenharmony_ci{ 40368c2ecf20Sopenharmony_ci unsigned long timeout; 40378c2ecf20Sopenharmony_ci void __iomem *bar; 40388c2ecf20Sopenharmony_ci u32 val; 40398c2ecf20Sopenharmony_ci 40408c2ecf20Sopenharmony_ci if (probe) 40418c2ecf20Sopenharmony_ci return 0; 40428c2ecf20Sopenharmony_ci 40438c2ecf20Sopenharmony_ci bar = pci_iomap(pdev, 0, 0); 40448c2ecf20Sopenharmony_ci if (!bar) 40458c2ecf20Sopenharmony_ci return -ENOTTY; 40468c2ecf20Sopenharmony_ci 40478c2ecf20Sopenharmony_ci /* Get and check firmware capabilities */ 40488c2ecf20Sopenharmony_ci val = ioread32be(bar + HINIC_VF_FLR_TYPE); 40498c2ecf20Sopenharmony_ci if (!(val & HINIC_VF_FLR_CAP_BIT)) { 40508c2ecf20Sopenharmony_ci pci_iounmap(pdev, bar); 40518c2ecf20Sopenharmony_ci return -ENOTTY; 40528c2ecf20Sopenharmony_ci } 40538c2ecf20Sopenharmony_ci 40548c2ecf20Sopenharmony_ci /* Set HINIC_VF_FLR_PROC_BIT for the start of FLR */ 40558c2ecf20Sopenharmony_ci val = ioread32be(bar + HINIC_VF_OP); 40568c2ecf20Sopenharmony_ci val = val | HINIC_VF_FLR_PROC_BIT; 40578c2ecf20Sopenharmony_ci iowrite32be(val, bar + HINIC_VF_OP); 40588c2ecf20Sopenharmony_ci 40598c2ecf20Sopenharmony_ci pcie_flr(pdev); 40608c2ecf20Sopenharmony_ci 40618c2ecf20Sopenharmony_ci /* 40628c2ecf20Sopenharmony_ci * The device must recapture its Bus and Device Numbers after FLR 40638c2ecf20Sopenharmony_ci * in order generate Completions. Issue a config write to let the 40648c2ecf20Sopenharmony_ci * device capture this information. 40658c2ecf20Sopenharmony_ci */ 40668c2ecf20Sopenharmony_ci pci_write_config_word(pdev, PCI_VENDOR_ID, 0); 40678c2ecf20Sopenharmony_ci 40688c2ecf20Sopenharmony_ci /* Firmware clears HINIC_VF_FLR_PROC_BIT when reset is complete */ 40698c2ecf20Sopenharmony_ci timeout = jiffies + msecs_to_jiffies(HINIC_OPERATION_TIMEOUT); 40708c2ecf20Sopenharmony_ci do { 40718c2ecf20Sopenharmony_ci val = ioread32be(bar + HINIC_VF_OP); 40728c2ecf20Sopenharmony_ci if (!(val & HINIC_VF_FLR_PROC_BIT)) 40738c2ecf20Sopenharmony_ci goto reset_complete; 40748c2ecf20Sopenharmony_ci msleep(20); 40758c2ecf20Sopenharmony_ci } while (time_before(jiffies, timeout)); 40768c2ecf20Sopenharmony_ci 40778c2ecf20Sopenharmony_ci val = ioread32be(bar + HINIC_VF_OP); 40788c2ecf20Sopenharmony_ci if (!(val & HINIC_VF_FLR_PROC_BIT)) 40798c2ecf20Sopenharmony_ci goto reset_complete; 40808c2ecf20Sopenharmony_ci 40818c2ecf20Sopenharmony_ci pci_warn(pdev, "Reset dev timeout, FLR ack reg: %#010x\n", val); 40828c2ecf20Sopenharmony_ci 40838c2ecf20Sopenharmony_cireset_complete: 40848c2ecf20Sopenharmony_ci pci_iounmap(pdev, bar); 40858c2ecf20Sopenharmony_ci 40868c2ecf20Sopenharmony_ci return 0; 40878c2ecf20Sopenharmony_ci} 40888c2ecf20Sopenharmony_ci 40898c2ecf20Sopenharmony_cistatic const struct pci_dev_reset_methods pci_dev_reset_methods[] = { 40908c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82599_SFP_VF, 40918c2ecf20Sopenharmony_ci reset_intel_82599_sfp_virtfn }, 40928c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_IVB_M_VGA, 40938c2ecf20Sopenharmony_ci reset_ivb_igd }, 40948c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_IVB_M2_VGA, 40958c2ecf20Sopenharmony_ci reset_ivb_igd }, 40968c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_SAMSUNG, 0xa804, nvme_disable_and_flr }, 40978c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x0953, delay_250ms_after_flr }, 40988c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_CHELSIO, PCI_ANY_ID, 40998c2ecf20Sopenharmony_ci reset_chelsio_generic_dev }, 41008c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_HUAWEI, PCI_DEVICE_ID_HINIC_VF, 41018c2ecf20Sopenharmony_ci reset_hinic_vf_dev }, 41028c2ecf20Sopenharmony_ci { 0 } 41038c2ecf20Sopenharmony_ci}; 41048c2ecf20Sopenharmony_ci 41058c2ecf20Sopenharmony_ci/* 41068c2ecf20Sopenharmony_ci * These device-specific reset methods are here rather than in a driver 41078c2ecf20Sopenharmony_ci * because when a host assigns a device to a guest VM, the host may need 41088c2ecf20Sopenharmony_ci * to reset the device but probably doesn't have a driver for it. 41098c2ecf20Sopenharmony_ci */ 41108c2ecf20Sopenharmony_ciint pci_dev_specific_reset(struct pci_dev *dev, int probe) 41118c2ecf20Sopenharmony_ci{ 41128c2ecf20Sopenharmony_ci const struct pci_dev_reset_methods *i; 41138c2ecf20Sopenharmony_ci 41148c2ecf20Sopenharmony_ci for (i = pci_dev_reset_methods; i->reset; i++) { 41158c2ecf20Sopenharmony_ci if ((i->vendor == dev->vendor || 41168c2ecf20Sopenharmony_ci i->vendor == (u16)PCI_ANY_ID) && 41178c2ecf20Sopenharmony_ci (i->device == dev->device || 41188c2ecf20Sopenharmony_ci i->device == (u16)PCI_ANY_ID)) 41198c2ecf20Sopenharmony_ci return i->reset(dev, probe); 41208c2ecf20Sopenharmony_ci } 41218c2ecf20Sopenharmony_ci 41228c2ecf20Sopenharmony_ci return -ENOTTY; 41238c2ecf20Sopenharmony_ci} 41248c2ecf20Sopenharmony_ci 41258c2ecf20Sopenharmony_cistatic void quirk_dma_func0_alias(struct pci_dev *dev) 41268c2ecf20Sopenharmony_ci{ 41278c2ecf20Sopenharmony_ci if (PCI_FUNC(dev->devfn) != 0) 41288c2ecf20Sopenharmony_ci pci_add_dma_alias(dev, PCI_DEVFN(PCI_SLOT(dev->devfn), 0), 1); 41298c2ecf20Sopenharmony_ci} 41308c2ecf20Sopenharmony_ci 41318c2ecf20Sopenharmony_ci/* 41328c2ecf20Sopenharmony_ci * https://bugzilla.redhat.com/show_bug.cgi?id=605888 41338c2ecf20Sopenharmony_ci * 41348c2ecf20Sopenharmony_ci * Some Ricoh devices use function 0 as the PCIe requester ID for DMA. 41358c2ecf20Sopenharmony_ci */ 41368c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_RICOH, 0xe832, quirk_dma_func0_alias); 41378c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_RICOH, 0xe476, quirk_dma_func0_alias); 41388c2ecf20Sopenharmony_ci 41398c2ecf20Sopenharmony_cistatic void quirk_dma_func1_alias(struct pci_dev *dev) 41408c2ecf20Sopenharmony_ci{ 41418c2ecf20Sopenharmony_ci if (PCI_FUNC(dev->devfn) != 1) 41428c2ecf20Sopenharmony_ci pci_add_dma_alias(dev, PCI_DEVFN(PCI_SLOT(dev->devfn), 1), 1); 41438c2ecf20Sopenharmony_ci} 41448c2ecf20Sopenharmony_ci 41458c2ecf20Sopenharmony_ci/* 41468c2ecf20Sopenharmony_ci * Marvell 88SE9123 uses function 1 as the requester ID for DMA. In some 41478c2ecf20Sopenharmony_ci * SKUs function 1 is present and is a legacy IDE controller, in other 41488c2ecf20Sopenharmony_ci * SKUs this function is not present, making this a ghost requester. 41498c2ecf20Sopenharmony_ci * https://bugzilla.kernel.org/show_bug.cgi?id=42679 41508c2ecf20Sopenharmony_ci */ 41518c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9120, 41528c2ecf20Sopenharmony_ci quirk_dma_func1_alias); 41538c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9123, 41548c2ecf20Sopenharmony_ci quirk_dma_func1_alias); 41558c2ecf20Sopenharmony_ci/* https://bugzilla.kernel.org/show_bug.cgi?id=42679#c136 */ 41568c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9125, 41578c2ecf20Sopenharmony_ci quirk_dma_func1_alias); 41588c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9128, 41598c2ecf20Sopenharmony_ci quirk_dma_func1_alias); 41608c2ecf20Sopenharmony_ci/* https://bugzilla.kernel.org/show_bug.cgi?id=42679#c14 */ 41618c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9130, 41628c2ecf20Sopenharmony_ci quirk_dma_func1_alias); 41638c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9170, 41648c2ecf20Sopenharmony_ci quirk_dma_func1_alias); 41658c2ecf20Sopenharmony_ci/* https://bugzilla.kernel.org/show_bug.cgi?id=42679#c47 + c57 */ 41668c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9172, 41678c2ecf20Sopenharmony_ci quirk_dma_func1_alias); 41688c2ecf20Sopenharmony_ci/* https://bugzilla.kernel.org/show_bug.cgi?id=42679#c59 */ 41698c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x917a, 41708c2ecf20Sopenharmony_ci quirk_dma_func1_alias); 41718c2ecf20Sopenharmony_ci/* https://bugzilla.kernel.org/show_bug.cgi?id=42679#c78 */ 41728c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9182, 41738c2ecf20Sopenharmony_ci quirk_dma_func1_alias); 41748c2ecf20Sopenharmony_ci/* https://bugzilla.kernel.org/show_bug.cgi?id=42679#c134 */ 41758c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9183, 41768c2ecf20Sopenharmony_ci quirk_dma_func1_alias); 41778c2ecf20Sopenharmony_ci/* https://bugzilla.kernel.org/show_bug.cgi?id=42679#c46 */ 41788c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x91a0, 41798c2ecf20Sopenharmony_ci quirk_dma_func1_alias); 41808c2ecf20Sopenharmony_ci/* https://bugzilla.kernel.org/show_bug.cgi?id=42679#c135 */ 41818c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9215, 41828c2ecf20Sopenharmony_ci quirk_dma_func1_alias); 41838c2ecf20Sopenharmony_ci/* https://bugzilla.kernel.org/show_bug.cgi?id=42679#c127 */ 41848c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9220, 41858c2ecf20Sopenharmony_ci quirk_dma_func1_alias); 41868c2ecf20Sopenharmony_ci/* https://bugzilla.kernel.org/show_bug.cgi?id=42679#c49 */ 41878c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9230, 41888c2ecf20Sopenharmony_ci quirk_dma_func1_alias); 41898c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9235, 41908c2ecf20Sopenharmony_ci quirk_dma_func1_alias); 41918c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_TTI, 0x0642, 41928c2ecf20Sopenharmony_ci quirk_dma_func1_alias); 41938c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_TTI, 0x0645, 41948c2ecf20Sopenharmony_ci quirk_dma_func1_alias); 41958c2ecf20Sopenharmony_ci/* https://bugs.gentoo.org/show_bug.cgi?id=497630 */ 41968c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_JMICRON, 41978c2ecf20Sopenharmony_ci PCI_DEVICE_ID_JMICRON_JMB388_ESD, 41988c2ecf20Sopenharmony_ci quirk_dma_func1_alias); 41998c2ecf20Sopenharmony_ci/* https://bugzilla.kernel.org/show_bug.cgi?id=42679#c117 */ 42008c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(0x1c28, /* Lite-On */ 42018c2ecf20Sopenharmony_ci 0x0122, /* Plextor M6E (Marvell 88SS9183)*/ 42028c2ecf20Sopenharmony_ci quirk_dma_func1_alias); 42038c2ecf20Sopenharmony_ci 42048c2ecf20Sopenharmony_ci/* 42058c2ecf20Sopenharmony_ci * Some devices DMA with the wrong devfn, not just the wrong function. 42068c2ecf20Sopenharmony_ci * quirk_fixed_dma_alias() uses this table to create fixed aliases, where 42078c2ecf20Sopenharmony_ci * the alias is "fixed" and independent of the device devfn. 42088c2ecf20Sopenharmony_ci * 42098c2ecf20Sopenharmony_ci * For example, the Adaptec 3405 is a PCIe card with an Intel 80333 I/O 42108c2ecf20Sopenharmony_ci * processor. To software, this appears as a PCIe-to-PCI/X bridge with a 42118c2ecf20Sopenharmony_ci * single device on the secondary bus. In reality, the single exposed 42128c2ecf20Sopenharmony_ci * device at 0e.0 is the Address Translation Unit (ATU) of the controller 42138c2ecf20Sopenharmony_ci * that provides a bridge to the internal bus of the I/O processor. The 42148c2ecf20Sopenharmony_ci * controller supports private devices, which can be hidden from PCI config 42158c2ecf20Sopenharmony_ci * space. In the case of the Adaptec 3405, a private device at 01.0 42168c2ecf20Sopenharmony_ci * appears to be the DMA engine, which therefore needs to become a DMA 42178c2ecf20Sopenharmony_ci * alias for the device. 42188c2ecf20Sopenharmony_ci */ 42198c2ecf20Sopenharmony_cistatic const struct pci_device_id fixed_dma_alias_tbl[] = { 42208c2ecf20Sopenharmony_ci { PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x0285, 42218c2ecf20Sopenharmony_ci PCI_VENDOR_ID_ADAPTEC2, 0x02bb), /* Adaptec 3405 */ 42228c2ecf20Sopenharmony_ci .driver_data = PCI_DEVFN(1, 0) }, 42238c2ecf20Sopenharmony_ci { PCI_DEVICE_SUB(PCI_VENDOR_ID_ADAPTEC2, 0x0285, 42248c2ecf20Sopenharmony_ci PCI_VENDOR_ID_ADAPTEC2, 0x02bc), /* Adaptec 3805 */ 42258c2ecf20Sopenharmony_ci .driver_data = PCI_DEVFN(1, 0) }, 42268c2ecf20Sopenharmony_ci { 0 } 42278c2ecf20Sopenharmony_ci}; 42288c2ecf20Sopenharmony_ci 42298c2ecf20Sopenharmony_cistatic void quirk_fixed_dma_alias(struct pci_dev *dev) 42308c2ecf20Sopenharmony_ci{ 42318c2ecf20Sopenharmony_ci const struct pci_device_id *id; 42328c2ecf20Sopenharmony_ci 42338c2ecf20Sopenharmony_ci id = pci_match_id(fixed_dma_alias_tbl, dev); 42348c2ecf20Sopenharmony_ci if (id) 42358c2ecf20Sopenharmony_ci pci_add_dma_alias(dev, id->driver_data, 1); 42368c2ecf20Sopenharmony_ci} 42378c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ADAPTEC2, 0x0285, quirk_fixed_dma_alias); 42388c2ecf20Sopenharmony_ci 42398c2ecf20Sopenharmony_ci/* 42408c2ecf20Sopenharmony_ci * A few PCIe-to-PCI bridges fail to expose a PCIe capability, resulting in 42418c2ecf20Sopenharmony_ci * using the wrong DMA alias for the device. Some of these devices can be 42428c2ecf20Sopenharmony_ci * used as either forward or reverse bridges, so we need to test whether the 42438c2ecf20Sopenharmony_ci * device is operating in the correct mode. We could probably apply this 42448c2ecf20Sopenharmony_ci * quirk to PCI_ANY_ID, but for now we'll just use known offenders. The test 42458c2ecf20Sopenharmony_ci * is for a non-root, non-PCIe bridge where the upstream device is PCIe and 42468c2ecf20Sopenharmony_ci * is not a PCIe-to-PCI bridge, then @pdev is actually a PCIe-to-PCI bridge. 42478c2ecf20Sopenharmony_ci */ 42488c2ecf20Sopenharmony_cistatic void quirk_use_pcie_bridge_dma_alias(struct pci_dev *pdev) 42498c2ecf20Sopenharmony_ci{ 42508c2ecf20Sopenharmony_ci if (!pci_is_root_bus(pdev->bus) && 42518c2ecf20Sopenharmony_ci pdev->hdr_type == PCI_HEADER_TYPE_BRIDGE && 42528c2ecf20Sopenharmony_ci !pci_is_pcie(pdev) && pci_is_pcie(pdev->bus->self) && 42538c2ecf20Sopenharmony_ci pci_pcie_type(pdev->bus->self) != PCI_EXP_TYPE_PCI_BRIDGE) 42548c2ecf20Sopenharmony_ci pdev->dev_flags |= PCI_DEV_FLAG_PCIE_BRIDGE_ALIAS; 42558c2ecf20Sopenharmony_ci} 42568c2ecf20Sopenharmony_ci/* ASM1083/1085, https://bugzilla.kernel.org/show_bug.cgi?id=44881#c46 */ 42578c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ASMEDIA, 0x1080, 42588c2ecf20Sopenharmony_ci quirk_use_pcie_bridge_dma_alias); 42598c2ecf20Sopenharmony_ci/* Tundra 8113, https://bugzilla.kernel.org/show_bug.cgi?id=44881#c43 */ 42608c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(0x10e3, 0x8113, quirk_use_pcie_bridge_dma_alias); 42618c2ecf20Sopenharmony_ci/* ITE 8892, https://bugzilla.kernel.org/show_bug.cgi?id=73551 */ 42628c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(0x1283, 0x8892, quirk_use_pcie_bridge_dma_alias); 42638c2ecf20Sopenharmony_ci/* ITE 8893 has the same problem as the 8892 */ 42648c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(0x1283, 0x8893, quirk_use_pcie_bridge_dma_alias); 42658c2ecf20Sopenharmony_ci/* Intel 82801, https://bugzilla.kernel.org/show_bug.cgi?id=44881#c49 */ 42668c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(0x8086, 0x244e, quirk_use_pcie_bridge_dma_alias); 42678c2ecf20Sopenharmony_ci 42688c2ecf20Sopenharmony_ci/* 42698c2ecf20Sopenharmony_ci * MIC x200 NTB forwards PCIe traffic using multiple alien RIDs. They have to 42708c2ecf20Sopenharmony_ci * be added as aliases to the DMA device in order to allow buffer access 42718c2ecf20Sopenharmony_ci * when IOMMU is enabled. Following devfns have to match RIT-LUT table 42728c2ecf20Sopenharmony_ci * programmed in the EEPROM. 42738c2ecf20Sopenharmony_ci */ 42748c2ecf20Sopenharmony_cistatic void quirk_mic_x200_dma_alias(struct pci_dev *pdev) 42758c2ecf20Sopenharmony_ci{ 42768c2ecf20Sopenharmony_ci pci_add_dma_alias(pdev, PCI_DEVFN(0x10, 0x0), 1); 42778c2ecf20Sopenharmony_ci pci_add_dma_alias(pdev, PCI_DEVFN(0x11, 0x0), 1); 42788c2ecf20Sopenharmony_ci pci_add_dma_alias(pdev, PCI_DEVFN(0x12, 0x3), 1); 42798c2ecf20Sopenharmony_ci} 42808c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2260, quirk_mic_x200_dma_alias); 42818c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2264, quirk_mic_x200_dma_alias); 42828c2ecf20Sopenharmony_ci 42838c2ecf20Sopenharmony_ci/* 42848c2ecf20Sopenharmony_ci * Intel Visual Compute Accelerator (VCA) is a family of PCIe add-in devices 42858c2ecf20Sopenharmony_ci * exposing computational units via Non Transparent Bridges (NTB, PEX 87xx). 42868c2ecf20Sopenharmony_ci * 42878c2ecf20Sopenharmony_ci * Similarly to MIC x200, we need to add DMA aliases to allow buffer access 42888c2ecf20Sopenharmony_ci * when IOMMU is enabled. These aliases allow computational unit access to 42898c2ecf20Sopenharmony_ci * host memory. These aliases mark the whole VCA device as one IOMMU 42908c2ecf20Sopenharmony_ci * group. 42918c2ecf20Sopenharmony_ci * 42928c2ecf20Sopenharmony_ci * All possible slot numbers (0x20) are used, since we are unable to tell 42938c2ecf20Sopenharmony_ci * what slot is used on other side. This quirk is intended for both host 42948c2ecf20Sopenharmony_ci * and computational unit sides. The VCA devices have up to five functions 42958c2ecf20Sopenharmony_ci * (four for DMA channels and one additional). 42968c2ecf20Sopenharmony_ci */ 42978c2ecf20Sopenharmony_cistatic void quirk_pex_vca_alias(struct pci_dev *pdev) 42988c2ecf20Sopenharmony_ci{ 42998c2ecf20Sopenharmony_ci const unsigned int num_pci_slots = 0x20; 43008c2ecf20Sopenharmony_ci unsigned int slot; 43018c2ecf20Sopenharmony_ci 43028c2ecf20Sopenharmony_ci for (slot = 0; slot < num_pci_slots; slot++) 43038c2ecf20Sopenharmony_ci pci_add_dma_alias(pdev, PCI_DEVFN(slot, 0x0), 5); 43048c2ecf20Sopenharmony_ci} 43058c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2954, quirk_pex_vca_alias); 43068c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2955, quirk_pex_vca_alias); 43078c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2956, quirk_pex_vca_alias); 43088c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2958, quirk_pex_vca_alias); 43098c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2959, quirk_pex_vca_alias); 43108c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x295A, quirk_pex_vca_alias); 43118c2ecf20Sopenharmony_ci 43128c2ecf20Sopenharmony_ci/* 43138c2ecf20Sopenharmony_ci * The IOMMU and interrupt controller on Broadcom Vulcan/Cavium ThunderX2 are 43148c2ecf20Sopenharmony_ci * associated not at the root bus, but at a bridge below. This quirk avoids 43158c2ecf20Sopenharmony_ci * generating invalid DMA aliases. 43168c2ecf20Sopenharmony_ci */ 43178c2ecf20Sopenharmony_cistatic void quirk_bridge_cavm_thrx2_pcie_root(struct pci_dev *pdev) 43188c2ecf20Sopenharmony_ci{ 43198c2ecf20Sopenharmony_ci pdev->dev_flags |= PCI_DEV_FLAGS_BRIDGE_XLATE_ROOT; 43208c2ecf20Sopenharmony_ci} 43218c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_BROADCOM, 0x9000, 43228c2ecf20Sopenharmony_ci quirk_bridge_cavm_thrx2_pcie_root); 43238c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_BROADCOM, 0x9084, 43248c2ecf20Sopenharmony_ci quirk_bridge_cavm_thrx2_pcie_root); 43258c2ecf20Sopenharmony_ci 43268c2ecf20Sopenharmony_ci/* 43278c2ecf20Sopenharmony_ci * Intersil/Techwell TW686[4589]-based video capture cards have an empty (zero) 43288c2ecf20Sopenharmony_ci * class code. Fix it. 43298c2ecf20Sopenharmony_ci */ 43308c2ecf20Sopenharmony_cistatic void quirk_tw686x_class(struct pci_dev *pdev) 43318c2ecf20Sopenharmony_ci{ 43328c2ecf20Sopenharmony_ci u32 class = pdev->class; 43338c2ecf20Sopenharmony_ci 43348c2ecf20Sopenharmony_ci /* Use "Multimedia controller" class */ 43358c2ecf20Sopenharmony_ci pdev->class = (PCI_CLASS_MULTIMEDIA_OTHER << 8) | 0x01; 43368c2ecf20Sopenharmony_ci pci_info(pdev, "TW686x PCI class overridden (%#08x -> %#08x)\n", 43378c2ecf20Sopenharmony_ci class, pdev->class); 43388c2ecf20Sopenharmony_ci} 43398c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(0x1797, 0x6864, PCI_CLASS_NOT_DEFINED, 8, 43408c2ecf20Sopenharmony_ci quirk_tw686x_class); 43418c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(0x1797, 0x6865, PCI_CLASS_NOT_DEFINED, 8, 43428c2ecf20Sopenharmony_ci quirk_tw686x_class); 43438c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(0x1797, 0x6868, PCI_CLASS_NOT_DEFINED, 8, 43448c2ecf20Sopenharmony_ci quirk_tw686x_class); 43458c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(0x1797, 0x6869, PCI_CLASS_NOT_DEFINED, 8, 43468c2ecf20Sopenharmony_ci quirk_tw686x_class); 43478c2ecf20Sopenharmony_ci 43488c2ecf20Sopenharmony_ci/* 43498c2ecf20Sopenharmony_ci * Some devices have problems with Transaction Layer Packets with the Relaxed 43508c2ecf20Sopenharmony_ci * Ordering Attribute set. Such devices should mark themselves and other 43518c2ecf20Sopenharmony_ci * device drivers should check before sending TLPs with RO set. 43528c2ecf20Sopenharmony_ci */ 43538c2ecf20Sopenharmony_cistatic void quirk_relaxedordering_disable(struct pci_dev *dev) 43548c2ecf20Sopenharmony_ci{ 43558c2ecf20Sopenharmony_ci dev->dev_flags |= PCI_DEV_FLAGS_NO_RELAXED_ORDERING; 43568c2ecf20Sopenharmony_ci pci_info(dev, "Disable Relaxed Ordering Attributes to avoid PCIe Completion erratum\n"); 43578c2ecf20Sopenharmony_ci} 43588c2ecf20Sopenharmony_ci 43598c2ecf20Sopenharmony_ci/* 43608c2ecf20Sopenharmony_ci * Intel Xeon processors based on Broadwell/Haswell microarchitecture Root 43618c2ecf20Sopenharmony_ci * Complex have a Flow Control Credit issue which can cause performance 43628c2ecf20Sopenharmony_ci * problems with Upstream Transaction Layer Packets with Relaxed Ordering set. 43638c2ecf20Sopenharmony_ci */ 43648c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f01, PCI_CLASS_NOT_DEFINED, 8, 43658c2ecf20Sopenharmony_ci quirk_relaxedordering_disable); 43668c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f02, PCI_CLASS_NOT_DEFINED, 8, 43678c2ecf20Sopenharmony_ci quirk_relaxedordering_disable); 43688c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f03, PCI_CLASS_NOT_DEFINED, 8, 43698c2ecf20Sopenharmony_ci quirk_relaxedordering_disable); 43708c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f04, PCI_CLASS_NOT_DEFINED, 8, 43718c2ecf20Sopenharmony_ci quirk_relaxedordering_disable); 43728c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f05, PCI_CLASS_NOT_DEFINED, 8, 43738c2ecf20Sopenharmony_ci quirk_relaxedordering_disable); 43748c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f06, PCI_CLASS_NOT_DEFINED, 8, 43758c2ecf20Sopenharmony_ci quirk_relaxedordering_disable); 43768c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f07, PCI_CLASS_NOT_DEFINED, 8, 43778c2ecf20Sopenharmony_ci quirk_relaxedordering_disable); 43788c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f08, PCI_CLASS_NOT_DEFINED, 8, 43798c2ecf20Sopenharmony_ci quirk_relaxedordering_disable); 43808c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f09, PCI_CLASS_NOT_DEFINED, 8, 43818c2ecf20Sopenharmony_ci quirk_relaxedordering_disable); 43828c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f0a, PCI_CLASS_NOT_DEFINED, 8, 43838c2ecf20Sopenharmony_ci quirk_relaxedordering_disable); 43848c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f0b, PCI_CLASS_NOT_DEFINED, 8, 43858c2ecf20Sopenharmony_ci quirk_relaxedordering_disable); 43868c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f0c, PCI_CLASS_NOT_DEFINED, 8, 43878c2ecf20Sopenharmony_ci quirk_relaxedordering_disable); 43888c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f0d, PCI_CLASS_NOT_DEFINED, 8, 43898c2ecf20Sopenharmony_ci quirk_relaxedordering_disable); 43908c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x6f0e, PCI_CLASS_NOT_DEFINED, 8, 43918c2ecf20Sopenharmony_ci quirk_relaxedordering_disable); 43928c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f01, PCI_CLASS_NOT_DEFINED, 8, 43938c2ecf20Sopenharmony_ci quirk_relaxedordering_disable); 43948c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f02, PCI_CLASS_NOT_DEFINED, 8, 43958c2ecf20Sopenharmony_ci quirk_relaxedordering_disable); 43968c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f03, PCI_CLASS_NOT_DEFINED, 8, 43978c2ecf20Sopenharmony_ci quirk_relaxedordering_disable); 43988c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f04, PCI_CLASS_NOT_DEFINED, 8, 43998c2ecf20Sopenharmony_ci quirk_relaxedordering_disable); 44008c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f05, PCI_CLASS_NOT_DEFINED, 8, 44018c2ecf20Sopenharmony_ci quirk_relaxedordering_disable); 44028c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f06, PCI_CLASS_NOT_DEFINED, 8, 44038c2ecf20Sopenharmony_ci quirk_relaxedordering_disable); 44048c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f07, PCI_CLASS_NOT_DEFINED, 8, 44058c2ecf20Sopenharmony_ci quirk_relaxedordering_disable); 44068c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f08, PCI_CLASS_NOT_DEFINED, 8, 44078c2ecf20Sopenharmony_ci quirk_relaxedordering_disable); 44088c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f09, PCI_CLASS_NOT_DEFINED, 8, 44098c2ecf20Sopenharmony_ci quirk_relaxedordering_disable); 44108c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f0a, PCI_CLASS_NOT_DEFINED, 8, 44118c2ecf20Sopenharmony_ci quirk_relaxedordering_disable); 44128c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f0b, PCI_CLASS_NOT_DEFINED, 8, 44138c2ecf20Sopenharmony_ci quirk_relaxedordering_disable); 44148c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f0c, PCI_CLASS_NOT_DEFINED, 8, 44158c2ecf20Sopenharmony_ci quirk_relaxedordering_disable); 44168c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f0d, PCI_CLASS_NOT_DEFINED, 8, 44178c2ecf20Sopenharmony_ci quirk_relaxedordering_disable); 44188c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_INTEL, 0x2f0e, PCI_CLASS_NOT_DEFINED, 8, 44198c2ecf20Sopenharmony_ci quirk_relaxedordering_disable); 44208c2ecf20Sopenharmony_ci 44218c2ecf20Sopenharmony_ci/* 44228c2ecf20Sopenharmony_ci * The AMD ARM A1100 (aka "SEATTLE") SoC has a bug in its PCIe Root Complex 44238c2ecf20Sopenharmony_ci * where Upstream Transaction Layer Packets with the Relaxed Ordering 44248c2ecf20Sopenharmony_ci * Attribute clear are allowed to bypass earlier TLPs with Relaxed Ordering 44258c2ecf20Sopenharmony_ci * set. This is a violation of the PCIe 3.0 Transaction Ordering Rules 44268c2ecf20Sopenharmony_ci * outlined in Section 2.4.1 (PCI Express(r) Base Specification Revision 3.0 44278c2ecf20Sopenharmony_ci * November 10, 2010). As a result, on this platform we can't use Relaxed 44288c2ecf20Sopenharmony_ci * Ordering for Upstream TLPs. 44298c2ecf20Sopenharmony_ci */ 44308c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_AMD, 0x1a00, PCI_CLASS_NOT_DEFINED, 8, 44318c2ecf20Sopenharmony_ci quirk_relaxedordering_disable); 44328c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_AMD, 0x1a01, PCI_CLASS_NOT_DEFINED, 8, 44338c2ecf20Sopenharmony_ci quirk_relaxedordering_disable); 44348c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_EARLY(PCI_VENDOR_ID_AMD, 0x1a02, PCI_CLASS_NOT_DEFINED, 8, 44358c2ecf20Sopenharmony_ci quirk_relaxedordering_disable); 44368c2ecf20Sopenharmony_ci 44378c2ecf20Sopenharmony_ci/* 44388c2ecf20Sopenharmony_ci * Per PCIe r3.0, sec 2.2.9, "Completion headers must supply the same 44398c2ecf20Sopenharmony_ci * values for the Attribute as were supplied in the header of the 44408c2ecf20Sopenharmony_ci * corresponding Request, except as explicitly allowed when IDO is used." 44418c2ecf20Sopenharmony_ci * 44428c2ecf20Sopenharmony_ci * If a non-compliant device generates a completion with a different 44438c2ecf20Sopenharmony_ci * attribute than the request, the receiver may accept it (which itself 44448c2ecf20Sopenharmony_ci * seems non-compliant based on sec 2.3.2), or it may handle it as a 44458c2ecf20Sopenharmony_ci * Malformed TLP or an Unexpected Completion, which will probably lead to a 44468c2ecf20Sopenharmony_ci * device access timeout. 44478c2ecf20Sopenharmony_ci * 44488c2ecf20Sopenharmony_ci * If the non-compliant device generates completions with zero attributes 44498c2ecf20Sopenharmony_ci * (instead of copying the attributes from the request), we can work around 44508c2ecf20Sopenharmony_ci * this by disabling the "Relaxed Ordering" and "No Snoop" attributes in 44518c2ecf20Sopenharmony_ci * upstream devices so they always generate requests with zero attributes. 44528c2ecf20Sopenharmony_ci * 44538c2ecf20Sopenharmony_ci * This affects other devices under the same Root Port, but since these 44548c2ecf20Sopenharmony_ci * attributes are performance hints, there should be no functional problem. 44558c2ecf20Sopenharmony_ci * 44568c2ecf20Sopenharmony_ci * Note that Configuration Space accesses are never supposed to have TLP 44578c2ecf20Sopenharmony_ci * Attributes, so we're safe waiting till after any Configuration Space 44588c2ecf20Sopenharmony_ci * accesses to do the Root Port fixup. 44598c2ecf20Sopenharmony_ci */ 44608c2ecf20Sopenharmony_cistatic void quirk_disable_root_port_attributes(struct pci_dev *pdev) 44618c2ecf20Sopenharmony_ci{ 44628c2ecf20Sopenharmony_ci struct pci_dev *root_port = pcie_find_root_port(pdev); 44638c2ecf20Sopenharmony_ci 44648c2ecf20Sopenharmony_ci if (!root_port) { 44658c2ecf20Sopenharmony_ci pci_warn(pdev, "PCIe Completion erratum may cause device errors\n"); 44668c2ecf20Sopenharmony_ci return; 44678c2ecf20Sopenharmony_ci } 44688c2ecf20Sopenharmony_ci 44698c2ecf20Sopenharmony_ci pci_info(root_port, "Disabling No Snoop/Relaxed Ordering Attributes to avoid PCIe Completion erratum in %s\n", 44708c2ecf20Sopenharmony_ci dev_name(&pdev->dev)); 44718c2ecf20Sopenharmony_ci pcie_capability_clear_and_set_word(root_port, PCI_EXP_DEVCTL, 44728c2ecf20Sopenharmony_ci PCI_EXP_DEVCTL_RELAX_EN | 44738c2ecf20Sopenharmony_ci PCI_EXP_DEVCTL_NOSNOOP_EN, 0); 44748c2ecf20Sopenharmony_ci} 44758c2ecf20Sopenharmony_ci 44768c2ecf20Sopenharmony_ci/* 44778c2ecf20Sopenharmony_ci * The Chelsio T5 chip fails to copy TLP Attributes from a Request to the 44788c2ecf20Sopenharmony_ci * Completion it generates. 44798c2ecf20Sopenharmony_ci */ 44808c2ecf20Sopenharmony_cistatic void quirk_chelsio_T5_disable_root_port_attributes(struct pci_dev *pdev) 44818c2ecf20Sopenharmony_ci{ 44828c2ecf20Sopenharmony_ci /* 44838c2ecf20Sopenharmony_ci * This mask/compare operation selects for Physical Function 4 on a 44848c2ecf20Sopenharmony_ci * T5. We only need to fix up the Root Port once for any of the 44858c2ecf20Sopenharmony_ci * PFs. PF[0..3] have PCI Device IDs of 0x50xx, but PF4 is uniquely 44868c2ecf20Sopenharmony_ci * 0x54xx so we use that one. 44878c2ecf20Sopenharmony_ci */ 44888c2ecf20Sopenharmony_ci if ((pdev->device & 0xff00) == 0x5400) 44898c2ecf20Sopenharmony_ci quirk_disable_root_port_attributes(pdev); 44908c2ecf20Sopenharmony_ci} 44918c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_CHELSIO, PCI_ANY_ID, 44928c2ecf20Sopenharmony_ci quirk_chelsio_T5_disable_root_port_attributes); 44938c2ecf20Sopenharmony_ci 44948c2ecf20Sopenharmony_ci/* 44958c2ecf20Sopenharmony_ci * pci_acs_ctrl_enabled - compare desired ACS controls with those provided 44968c2ecf20Sopenharmony_ci * by a device 44978c2ecf20Sopenharmony_ci * @acs_ctrl_req: Bitmask of desired ACS controls 44988c2ecf20Sopenharmony_ci * @acs_ctrl_ena: Bitmask of ACS controls enabled or provided implicitly by 44998c2ecf20Sopenharmony_ci * the hardware design 45008c2ecf20Sopenharmony_ci * 45018c2ecf20Sopenharmony_ci * Return 1 if all ACS controls in the @acs_ctrl_req bitmask are included 45028c2ecf20Sopenharmony_ci * in @acs_ctrl_ena, i.e., the device provides all the access controls the 45038c2ecf20Sopenharmony_ci * caller desires. Return 0 otherwise. 45048c2ecf20Sopenharmony_ci */ 45058c2ecf20Sopenharmony_cistatic int pci_acs_ctrl_enabled(u16 acs_ctrl_req, u16 acs_ctrl_ena) 45068c2ecf20Sopenharmony_ci{ 45078c2ecf20Sopenharmony_ci if ((acs_ctrl_req & acs_ctrl_ena) == acs_ctrl_req) 45088c2ecf20Sopenharmony_ci return 1; 45098c2ecf20Sopenharmony_ci return 0; 45108c2ecf20Sopenharmony_ci} 45118c2ecf20Sopenharmony_ci 45128c2ecf20Sopenharmony_ci/* 45138c2ecf20Sopenharmony_ci * AMD has indicated that the devices below do not support peer-to-peer 45148c2ecf20Sopenharmony_ci * in any system where they are found in the southbridge with an AMD 45158c2ecf20Sopenharmony_ci * IOMMU in the system. Multifunction devices that do not support 45168c2ecf20Sopenharmony_ci * peer-to-peer between functions can claim to support a subset of ACS. 45178c2ecf20Sopenharmony_ci * Such devices effectively enable request redirect (RR) and completion 45188c2ecf20Sopenharmony_ci * redirect (CR) since all transactions are redirected to the upstream 45198c2ecf20Sopenharmony_ci * root complex. 45208c2ecf20Sopenharmony_ci * 45218c2ecf20Sopenharmony_ci * https://lore.kernel.org/r/201207111426.q6BEQTbh002928@mail.maya.org/ 45228c2ecf20Sopenharmony_ci * https://lore.kernel.org/r/20120711165854.GM25282@amd.com/ 45238c2ecf20Sopenharmony_ci * https://lore.kernel.org/r/20121005130857.GX4009@amd.com/ 45248c2ecf20Sopenharmony_ci * 45258c2ecf20Sopenharmony_ci * 1002:4385 SBx00 SMBus Controller 45268c2ecf20Sopenharmony_ci * 1002:439c SB7x0/SB8x0/SB9x0 IDE Controller 45278c2ecf20Sopenharmony_ci * 1002:4383 SBx00 Azalia (Intel HDA) 45288c2ecf20Sopenharmony_ci * 1002:439d SB7x0/SB8x0/SB9x0 LPC host controller 45298c2ecf20Sopenharmony_ci * 1002:4384 SBx00 PCI to PCI Bridge 45308c2ecf20Sopenharmony_ci * 1002:4399 SB7x0/SB8x0/SB9x0 USB OHCI2 Controller 45318c2ecf20Sopenharmony_ci * 45328c2ecf20Sopenharmony_ci * https://bugzilla.kernel.org/show_bug.cgi?id=81841#c15 45338c2ecf20Sopenharmony_ci * 45348c2ecf20Sopenharmony_ci * 1022:780f [AMD] FCH PCI Bridge 45358c2ecf20Sopenharmony_ci * 1022:7809 [AMD] FCH USB OHCI Controller 45368c2ecf20Sopenharmony_ci */ 45378c2ecf20Sopenharmony_cistatic int pci_quirk_amd_sb_acs(struct pci_dev *dev, u16 acs_flags) 45388c2ecf20Sopenharmony_ci{ 45398c2ecf20Sopenharmony_ci#ifdef CONFIG_ACPI 45408c2ecf20Sopenharmony_ci struct acpi_table_header *header = NULL; 45418c2ecf20Sopenharmony_ci acpi_status status; 45428c2ecf20Sopenharmony_ci 45438c2ecf20Sopenharmony_ci /* Targeting multifunction devices on the SB (appears on root bus) */ 45448c2ecf20Sopenharmony_ci if (!dev->multifunction || !pci_is_root_bus(dev->bus)) 45458c2ecf20Sopenharmony_ci return -ENODEV; 45468c2ecf20Sopenharmony_ci 45478c2ecf20Sopenharmony_ci /* The IVRS table describes the AMD IOMMU */ 45488c2ecf20Sopenharmony_ci status = acpi_get_table("IVRS", 0, &header); 45498c2ecf20Sopenharmony_ci if (ACPI_FAILURE(status)) 45508c2ecf20Sopenharmony_ci return -ENODEV; 45518c2ecf20Sopenharmony_ci 45528c2ecf20Sopenharmony_ci acpi_put_table(header); 45538c2ecf20Sopenharmony_ci 45548c2ecf20Sopenharmony_ci /* Filter out flags not applicable to multifunction */ 45558c2ecf20Sopenharmony_ci acs_flags &= (PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_EC | PCI_ACS_DT); 45568c2ecf20Sopenharmony_ci 45578c2ecf20Sopenharmony_ci return pci_acs_ctrl_enabled(acs_flags, PCI_ACS_RR | PCI_ACS_CR); 45588c2ecf20Sopenharmony_ci#else 45598c2ecf20Sopenharmony_ci return -ENODEV; 45608c2ecf20Sopenharmony_ci#endif 45618c2ecf20Sopenharmony_ci} 45628c2ecf20Sopenharmony_ci 45638c2ecf20Sopenharmony_cistatic bool pci_quirk_cavium_acs_match(struct pci_dev *dev) 45648c2ecf20Sopenharmony_ci{ 45658c2ecf20Sopenharmony_ci if (!pci_is_pcie(dev) || pci_pcie_type(dev) != PCI_EXP_TYPE_ROOT_PORT) 45668c2ecf20Sopenharmony_ci return false; 45678c2ecf20Sopenharmony_ci 45688c2ecf20Sopenharmony_ci switch (dev->device) { 45698c2ecf20Sopenharmony_ci /* 45708c2ecf20Sopenharmony_ci * Effectively selects all downstream ports for whole ThunderX1 45718c2ecf20Sopenharmony_ci * (which represents 8 SoCs). 45728c2ecf20Sopenharmony_ci */ 45738c2ecf20Sopenharmony_ci case 0xa000 ... 0xa7ff: /* ThunderX1 */ 45748c2ecf20Sopenharmony_ci case 0xaf84: /* ThunderX2 */ 45758c2ecf20Sopenharmony_ci case 0xb884: /* ThunderX3 */ 45768c2ecf20Sopenharmony_ci return true; 45778c2ecf20Sopenharmony_ci default: 45788c2ecf20Sopenharmony_ci return false; 45798c2ecf20Sopenharmony_ci } 45808c2ecf20Sopenharmony_ci} 45818c2ecf20Sopenharmony_ci 45828c2ecf20Sopenharmony_cistatic int pci_quirk_cavium_acs(struct pci_dev *dev, u16 acs_flags) 45838c2ecf20Sopenharmony_ci{ 45848c2ecf20Sopenharmony_ci if (!pci_quirk_cavium_acs_match(dev)) 45858c2ecf20Sopenharmony_ci return -ENOTTY; 45868c2ecf20Sopenharmony_ci 45878c2ecf20Sopenharmony_ci /* 45888c2ecf20Sopenharmony_ci * Cavium Root Ports don't advertise an ACS capability. However, 45898c2ecf20Sopenharmony_ci * the RTL internally implements similar protection as if ACS had 45908c2ecf20Sopenharmony_ci * Source Validation, Request Redirection, Completion Redirection, 45918c2ecf20Sopenharmony_ci * and Upstream Forwarding features enabled. Assert that the 45928c2ecf20Sopenharmony_ci * hardware implements and enables equivalent ACS functionality for 45938c2ecf20Sopenharmony_ci * these flags. 45948c2ecf20Sopenharmony_ci */ 45958c2ecf20Sopenharmony_ci return pci_acs_ctrl_enabled(acs_flags, 45968c2ecf20Sopenharmony_ci PCI_ACS_SV | PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF); 45978c2ecf20Sopenharmony_ci} 45988c2ecf20Sopenharmony_ci 45998c2ecf20Sopenharmony_cistatic int pci_quirk_xgene_acs(struct pci_dev *dev, u16 acs_flags) 46008c2ecf20Sopenharmony_ci{ 46018c2ecf20Sopenharmony_ci /* 46028c2ecf20Sopenharmony_ci * X-Gene Root Ports matching this quirk do not allow peer-to-peer 46038c2ecf20Sopenharmony_ci * transactions with others, allowing masking out these bits as if they 46048c2ecf20Sopenharmony_ci * were unimplemented in the ACS capability. 46058c2ecf20Sopenharmony_ci */ 46068c2ecf20Sopenharmony_ci return pci_acs_ctrl_enabled(acs_flags, 46078c2ecf20Sopenharmony_ci PCI_ACS_SV | PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF); 46088c2ecf20Sopenharmony_ci} 46098c2ecf20Sopenharmony_ci 46108c2ecf20Sopenharmony_ci/* 46118c2ecf20Sopenharmony_ci * Many Zhaoxin Root Ports and Switch Downstream Ports have no ACS capability. 46128c2ecf20Sopenharmony_ci * But the implementation could block peer-to-peer transactions between them 46138c2ecf20Sopenharmony_ci * and provide ACS-like functionality. 46148c2ecf20Sopenharmony_ci */ 46158c2ecf20Sopenharmony_cistatic int pci_quirk_zhaoxin_pcie_ports_acs(struct pci_dev *dev, u16 acs_flags) 46168c2ecf20Sopenharmony_ci{ 46178c2ecf20Sopenharmony_ci if (!pci_is_pcie(dev) || 46188c2ecf20Sopenharmony_ci ((pci_pcie_type(dev) != PCI_EXP_TYPE_ROOT_PORT) && 46198c2ecf20Sopenharmony_ci (pci_pcie_type(dev) != PCI_EXP_TYPE_DOWNSTREAM))) 46208c2ecf20Sopenharmony_ci return -ENOTTY; 46218c2ecf20Sopenharmony_ci 46228c2ecf20Sopenharmony_ci /* 46238c2ecf20Sopenharmony_ci * Future Zhaoxin Root Ports and Switch Downstream Ports will 46248c2ecf20Sopenharmony_ci * implement ACS capability in accordance with the PCIe Spec. 46258c2ecf20Sopenharmony_ci */ 46268c2ecf20Sopenharmony_ci switch (dev->device) { 46278c2ecf20Sopenharmony_ci case 0x0710 ... 0x071e: 46288c2ecf20Sopenharmony_ci case 0x0721: 46298c2ecf20Sopenharmony_ci case 0x0723 ... 0x0752: 46308c2ecf20Sopenharmony_ci return pci_acs_ctrl_enabled(acs_flags, 46318c2ecf20Sopenharmony_ci PCI_ACS_SV | PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF); 46328c2ecf20Sopenharmony_ci } 46338c2ecf20Sopenharmony_ci 46348c2ecf20Sopenharmony_ci return false; 46358c2ecf20Sopenharmony_ci} 46368c2ecf20Sopenharmony_ci 46378c2ecf20Sopenharmony_ci/* 46388c2ecf20Sopenharmony_ci * Many Intel PCH Root Ports do provide ACS-like features to disable peer 46398c2ecf20Sopenharmony_ci * transactions and validate bus numbers in requests, but do not provide an 46408c2ecf20Sopenharmony_ci * actual PCIe ACS capability. This is the list of device IDs known to fall 46418c2ecf20Sopenharmony_ci * into that category as provided by Intel in Red Hat bugzilla 1037684. 46428c2ecf20Sopenharmony_ci */ 46438c2ecf20Sopenharmony_cistatic const u16 pci_quirk_intel_pch_acs_ids[] = { 46448c2ecf20Sopenharmony_ci /* Ibexpeak PCH */ 46458c2ecf20Sopenharmony_ci 0x3b42, 0x3b43, 0x3b44, 0x3b45, 0x3b46, 0x3b47, 0x3b48, 0x3b49, 46468c2ecf20Sopenharmony_ci 0x3b4a, 0x3b4b, 0x3b4c, 0x3b4d, 0x3b4e, 0x3b4f, 0x3b50, 0x3b51, 46478c2ecf20Sopenharmony_ci /* Cougarpoint PCH */ 46488c2ecf20Sopenharmony_ci 0x1c10, 0x1c11, 0x1c12, 0x1c13, 0x1c14, 0x1c15, 0x1c16, 0x1c17, 46498c2ecf20Sopenharmony_ci 0x1c18, 0x1c19, 0x1c1a, 0x1c1b, 0x1c1c, 0x1c1d, 0x1c1e, 0x1c1f, 46508c2ecf20Sopenharmony_ci /* Pantherpoint PCH */ 46518c2ecf20Sopenharmony_ci 0x1e10, 0x1e11, 0x1e12, 0x1e13, 0x1e14, 0x1e15, 0x1e16, 0x1e17, 46528c2ecf20Sopenharmony_ci 0x1e18, 0x1e19, 0x1e1a, 0x1e1b, 0x1e1c, 0x1e1d, 0x1e1e, 0x1e1f, 46538c2ecf20Sopenharmony_ci /* Lynxpoint-H PCH */ 46548c2ecf20Sopenharmony_ci 0x8c10, 0x8c11, 0x8c12, 0x8c13, 0x8c14, 0x8c15, 0x8c16, 0x8c17, 46558c2ecf20Sopenharmony_ci 0x8c18, 0x8c19, 0x8c1a, 0x8c1b, 0x8c1c, 0x8c1d, 0x8c1e, 0x8c1f, 46568c2ecf20Sopenharmony_ci /* Lynxpoint-LP PCH */ 46578c2ecf20Sopenharmony_ci 0x9c10, 0x9c11, 0x9c12, 0x9c13, 0x9c14, 0x9c15, 0x9c16, 0x9c17, 46588c2ecf20Sopenharmony_ci 0x9c18, 0x9c19, 0x9c1a, 0x9c1b, 46598c2ecf20Sopenharmony_ci /* Wildcat PCH */ 46608c2ecf20Sopenharmony_ci 0x9c90, 0x9c91, 0x9c92, 0x9c93, 0x9c94, 0x9c95, 0x9c96, 0x9c97, 46618c2ecf20Sopenharmony_ci 0x9c98, 0x9c99, 0x9c9a, 0x9c9b, 46628c2ecf20Sopenharmony_ci /* Patsburg (X79) PCH */ 46638c2ecf20Sopenharmony_ci 0x1d10, 0x1d12, 0x1d14, 0x1d16, 0x1d18, 0x1d1a, 0x1d1c, 0x1d1e, 46648c2ecf20Sopenharmony_ci /* Wellsburg (X99) PCH */ 46658c2ecf20Sopenharmony_ci 0x8d10, 0x8d11, 0x8d12, 0x8d13, 0x8d14, 0x8d15, 0x8d16, 0x8d17, 46668c2ecf20Sopenharmony_ci 0x8d18, 0x8d19, 0x8d1a, 0x8d1b, 0x8d1c, 0x8d1d, 0x8d1e, 46678c2ecf20Sopenharmony_ci /* Lynx Point (9 series) PCH */ 46688c2ecf20Sopenharmony_ci 0x8c90, 0x8c92, 0x8c94, 0x8c96, 0x8c98, 0x8c9a, 0x8c9c, 0x8c9e, 46698c2ecf20Sopenharmony_ci}; 46708c2ecf20Sopenharmony_ci 46718c2ecf20Sopenharmony_cistatic bool pci_quirk_intel_pch_acs_match(struct pci_dev *dev) 46728c2ecf20Sopenharmony_ci{ 46738c2ecf20Sopenharmony_ci int i; 46748c2ecf20Sopenharmony_ci 46758c2ecf20Sopenharmony_ci /* Filter out a few obvious non-matches first */ 46768c2ecf20Sopenharmony_ci if (!pci_is_pcie(dev) || pci_pcie_type(dev) != PCI_EXP_TYPE_ROOT_PORT) 46778c2ecf20Sopenharmony_ci return false; 46788c2ecf20Sopenharmony_ci 46798c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(pci_quirk_intel_pch_acs_ids); i++) 46808c2ecf20Sopenharmony_ci if (pci_quirk_intel_pch_acs_ids[i] == dev->device) 46818c2ecf20Sopenharmony_ci return true; 46828c2ecf20Sopenharmony_ci 46838c2ecf20Sopenharmony_ci return false; 46848c2ecf20Sopenharmony_ci} 46858c2ecf20Sopenharmony_ci 46868c2ecf20Sopenharmony_cistatic int pci_quirk_intel_pch_acs(struct pci_dev *dev, u16 acs_flags) 46878c2ecf20Sopenharmony_ci{ 46888c2ecf20Sopenharmony_ci if (!pci_quirk_intel_pch_acs_match(dev)) 46898c2ecf20Sopenharmony_ci return -ENOTTY; 46908c2ecf20Sopenharmony_ci 46918c2ecf20Sopenharmony_ci if (dev->dev_flags & PCI_DEV_FLAGS_ACS_ENABLED_QUIRK) 46928c2ecf20Sopenharmony_ci return pci_acs_ctrl_enabled(acs_flags, 46938c2ecf20Sopenharmony_ci PCI_ACS_SV | PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF); 46948c2ecf20Sopenharmony_ci 46958c2ecf20Sopenharmony_ci return pci_acs_ctrl_enabled(acs_flags, 0); 46968c2ecf20Sopenharmony_ci} 46978c2ecf20Sopenharmony_ci 46988c2ecf20Sopenharmony_ci/* 46998c2ecf20Sopenharmony_ci * These QCOM Root Ports do provide ACS-like features to disable peer 47008c2ecf20Sopenharmony_ci * transactions and validate bus numbers in requests, but do not provide an 47018c2ecf20Sopenharmony_ci * actual PCIe ACS capability. Hardware supports source validation but it 47028c2ecf20Sopenharmony_ci * will report the issue as Completer Abort instead of ACS Violation. 47038c2ecf20Sopenharmony_ci * Hardware doesn't support peer-to-peer and each Root Port is a Root 47048c2ecf20Sopenharmony_ci * Complex with unique segment numbers. It is not possible for one Root 47058c2ecf20Sopenharmony_ci * Port to pass traffic to another Root Port. All PCIe transactions are 47068c2ecf20Sopenharmony_ci * terminated inside the Root Port. 47078c2ecf20Sopenharmony_ci */ 47088c2ecf20Sopenharmony_cistatic int pci_quirk_qcom_rp_acs(struct pci_dev *dev, u16 acs_flags) 47098c2ecf20Sopenharmony_ci{ 47108c2ecf20Sopenharmony_ci return pci_acs_ctrl_enabled(acs_flags, 47118c2ecf20Sopenharmony_ci PCI_ACS_SV | PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF); 47128c2ecf20Sopenharmony_ci} 47138c2ecf20Sopenharmony_ci 47148c2ecf20Sopenharmony_ci/* 47158c2ecf20Sopenharmony_ci * Each of these NXP Root Ports is in a Root Complex with a unique segment 47168c2ecf20Sopenharmony_ci * number and does provide isolation features to disable peer transactions 47178c2ecf20Sopenharmony_ci * and validate bus numbers in requests, but does not provide an ACS 47188c2ecf20Sopenharmony_ci * capability. 47198c2ecf20Sopenharmony_ci */ 47208c2ecf20Sopenharmony_cistatic int pci_quirk_nxp_rp_acs(struct pci_dev *dev, u16 acs_flags) 47218c2ecf20Sopenharmony_ci{ 47228c2ecf20Sopenharmony_ci return pci_acs_ctrl_enabled(acs_flags, 47238c2ecf20Sopenharmony_ci PCI_ACS_SV | PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF); 47248c2ecf20Sopenharmony_ci} 47258c2ecf20Sopenharmony_ci 47268c2ecf20Sopenharmony_cistatic int pci_quirk_al_acs(struct pci_dev *dev, u16 acs_flags) 47278c2ecf20Sopenharmony_ci{ 47288c2ecf20Sopenharmony_ci if (pci_pcie_type(dev) != PCI_EXP_TYPE_ROOT_PORT) 47298c2ecf20Sopenharmony_ci return -ENOTTY; 47308c2ecf20Sopenharmony_ci 47318c2ecf20Sopenharmony_ci /* 47328c2ecf20Sopenharmony_ci * Amazon's Annapurna Labs root ports don't include an ACS capability, 47338c2ecf20Sopenharmony_ci * but do include ACS-like functionality. The hardware doesn't support 47348c2ecf20Sopenharmony_ci * peer-to-peer transactions via the root port and each has a unique 47358c2ecf20Sopenharmony_ci * segment number. 47368c2ecf20Sopenharmony_ci * 47378c2ecf20Sopenharmony_ci * Additionally, the root ports cannot send traffic to each other. 47388c2ecf20Sopenharmony_ci */ 47398c2ecf20Sopenharmony_ci acs_flags &= ~(PCI_ACS_SV | PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF); 47408c2ecf20Sopenharmony_ci 47418c2ecf20Sopenharmony_ci return acs_flags ? 0 : 1; 47428c2ecf20Sopenharmony_ci} 47438c2ecf20Sopenharmony_ci 47448c2ecf20Sopenharmony_ci/* 47458c2ecf20Sopenharmony_ci * Sunrise Point PCH root ports implement ACS, but unfortunately as shown in 47468c2ecf20Sopenharmony_ci * the datasheet (Intel 100 Series Chipset Family PCH Datasheet, Vol. 2, 47478c2ecf20Sopenharmony_ci * 12.1.46, 12.1.47)[1] this chipset uses dwords for the ACS capability and 47488c2ecf20Sopenharmony_ci * control registers whereas the PCIe spec packs them into words (Rev 3.0, 47498c2ecf20Sopenharmony_ci * 7.16 ACS Extended Capability). The bit definitions are correct, but the 47508c2ecf20Sopenharmony_ci * control register is at offset 8 instead of 6 and we should probably use 47518c2ecf20Sopenharmony_ci * dword accesses to them. This applies to the following PCI Device IDs, as 47528c2ecf20Sopenharmony_ci * found in volume 1 of the datasheet[2]: 47538c2ecf20Sopenharmony_ci * 47548c2ecf20Sopenharmony_ci * 0xa110-0xa11f Sunrise Point-H PCI Express Root Port #{0-16} 47558c2ecf20Sopenharmony_ci * 0xa167-0xa16a Sunrise Point-H PCI Express Root Port #{17-20} 47568c2ecf20Sopenharmony_ci * 47578c2ecf20Sopenharmony_ci * N.B. This doesn't fix what lspci shows. 47588c2ecf20Sopenharmony_ci * 47598c2ecf20Sopenharmony_ci * The 100 series chipset specification update includes this as errata #23[3]. 47608c2ecf20Sopenharmony_ci * 47618c2ecf20Sopenharmony_ci * The 200 series chipset (Union Point) has the same bug according to the 47628c2ecf20Sopenharmony_ci * specification update (Intel 200 Series Chipset Family Platform Controller 47638c2ecf20Sopenharmony_ci * Hub, Specification Update, January 2017, Revision 001, Document# 335194-001, 47648c2ecf20Sopenharmony_ci * Errata 22)[4]. Per the datasheet[5], root port PCI Device IDs for this 47658c2ecf20Sopenharmony_ci * chipset include: 47668c2ecf20Sopenharmony_ci * 47678c2ecf20Sopenharmony_ci * 0xa290-0xa29f PCI Express Root port #{0-16} 47688c2ecf20Sopenharmony_ci * 0xa2e7-0xa2ee PCI Express Root port #{17-24} 47698c2ecf20Sopenharmony_ci * 47708c2ecf20Sopenharmony_ci * Mobile chipsets are also affected, 7th & 8th Generation 47718c2ecf20Sopenharmony_ci * Specification update confirms ACS errata 22, status no fix: (7th Generation 47728c2ecf20Sopenharmony_ci * Intel Processor Family I/O for U/Y Platforms and 8th Generation Intel 47738c2ecf20Sopenharmony_ci * Processor Family I/O for U Quad Core Platforms Specification Update, 47748c2ecf20Sopenharmony_ci * August 2017, Revision 002, Document#: 334660-002)[6] 47758c2ecf20Sopenharmony_ci * Device IDs from I/O datasheet: (7th Generation Intel Processor Family I/O 47768c2ecf20Sopenharmony_ci * for U/Y Platforms and 8th Generation Intel ® Processor Family I/O for U 47778c2ecf20Sopenharmony_ci * Quad Core Platforms, Vol 1 of 2, August 2017, Document#: 334658-003)[7] 47788c2ecf20Sopenharmony_ci * 47798c2ecf20Sopenharmony_ci * 0x9d10-0x9d1b PCI Express Root port #{1-12} 47808c2ecf20Sopenharmony_ci * 47818c2ecf20Sopenharmony_ci * [1] https://www.intel.com/content/www/us/en/chipsets/100-series-chipset-datasheet-vol-2.html 47828c2ecf20Sopenharmony_ci * [2] https://www.intel.com/content/www/us/en/chipsets/100-series-chipset-datasheet-vol-1.html 47838c2ecf20Sopenharmony_ci * [3] https://www.intel.com/content/www/us/en/chipsets/100-series-chipset-spec-update.html 47848c2ecf20Sopenharmony_ci * [4] https://www.intel.com/content/www/us/en/chipsets/200-series-chipset-pch-spec-update.html 47858c2ecf20Sopenharmony_ci * [5] https://www.intel.com/content/www/us/en/chipsets/200-series-chipset-pch-datasheet-vol-1.html 47868c2ecf20Sopenharmony_ci * [6] https://www.intel.com/content/www/us/en/processors/core/7th-gen-core-family-mobile-u-y-processor-lines-i-o-spec-update.html 47878c2ecf20Sopenharmony_ci * [7] https://www.intel.com/content/www/us/en/processors/core/7th-gen-core-family-mobile-u-y-processor-lines-i-o-datasheet-vol-1.html 47888c2ecf20Sopenharmony_ci */ 47898c2ecf20Sopenharmony_cistatic bool pci_quirk_intel_spt_pch_acs_match(struct pci_dev *dev) 47908c2ecf20Sopenharmony_ci{ 47918c2ecf20Sopenharmony_ci if (!pci_is_pcie(dev) || pci_pcie_type(dev) != PCI_EXP_TYPE_ROOT_PORT) 47928c2ecf20Sopenharmony_ci return false; 47938c2ecf20Sopenharmony_ci 47948c2ecf20Sopenharmony_ci switch (dev->device) { 47958c2ecf20Sopenharmony_ci case 0xa110 ... 0xa11f: case 0xa167 ... 0xa16a: /* Sunrise Point */ 47968c2ecf20Sopenharmony_ci case 0xa290 ... 0xa29f: case 0xa2e7 ... 0xa2ee: /* Union Point */ 47978c2ecf20Sopenharmony_ci case 0x9d10 ... 0x9d1b: /* 7th & 8th Gen Mobile */ 47988c2ecf20Sopenharmony_ci return true; 47998c2ecf20Sopenharmony_ci } 48008c2ecf20Sopenharmony_ci 48018c2ecf20Sopenharmony_ci return false; 48028c2ecf20Sopenharmony_ci} 48038c2ecf20Sopenharmony_ci 48048c2ecf20Sopenharmony_ci#define INTEL_SPT_ACS_CTRL (PCI_ACS_CAP + 4) 48058c2ecf20Sopenharmony_ci 48068c2ecf20Sopenharmony_cistatic int pci_quirk_intel_spt_pch_acs(struct pci_dev *dev, u16 acs_flags) 48078c2ecf20Sopenharmony_ci{ 48088c2ecf20Sopenharmony_ci int pos; 48098c2ecf20Sopenharmony_ci u32 cap, ctrl; 48108c2ecf20Sopenharmony_ci 48118c2ecf20Sopenharmony_ci if (!pci_quirk_intel_spt_pch_acs_match(dev)) 48128c2ecf20Sopenharmony_ci return -ENOTTY; 48138c2ecf20Sopenharmony_ci 48148c2ecf20Sopenharmony_ci pos = dev->acs_cap; 48158c2ecf20Sopenharmony_ci if (!pos) 48168c2ecf20Sopenharmony_ci return -ENOTTY; 48178c2ecf20Sopenharmony_ci 48188c2ecf20Sopenharmony_ci /* see pci_acs_flags_enabled() */ 48198c2ecf20Sopenharmony_ci pci_read_config_dword(dev, pos + PCI_ACS_CAP, &cap); 48208c2ecf20Sopenharmony_ci acs_flags &= (cap | PCI_ACS_EC); 48218c2ecf20Sopenharmony_ci 48228c2ecf20Sopenharmony_ci pci_read_config_dword(dev, pos + INTEL_SPT_ACS_CTRL, &ctrl); 48238c2ecf20Sopenharmony_ci 48248c2ecf20Sopenharmony_ci return pci_acs_ctrl_enabled(acs_flags, ctrl); 48258c2ecf20Sopenharmony_ci} 48268c2ecf20Sopenharmony_ci 48278c2ecf20Sopenharmony_cistatic int pci_quirk_mf_endpoint_acs(struct pci_dev *dev, u16 acs_flags) 48288c2ecf20Sopenharmony_ci{ 48298c2ecf20Sopenharmony_ci /* 48308c2ecf20Sopenharmony_ci * SV, TB, and UF are not relevant to multifunction endpoints. 48318c2ecf20Sopenharmony_ci * 48328c2ecf20Sopenharmony_ci * Multifunction devices are only required to implement RR, CR, and DT 48338c2ecf20Sopenharmony_ci * in their ACS capability if they support peer-to-peer transactions. 48348c2ecf20Sopenharmony_ci * Devices matching this quirk have been verified by the vendor to not 48358c2ecf20Sopenharmony_ci * perform peer-to-peer with other functions, allowing us to mask out 48368c2ecf20Sopenharmony_ci * these bits as if they were unimplemented in the ACS capability. 48378c2ecf20Sopenharmony_ci */ 48388c2ecf20Sopenharmony_ci return pci_acs_ctrl_enabled(acs_flags, 48398c2ecf20Sopenharmony_ci PCI_ACS_SV | PCI_ACS_TB | PCI_ACS_RR | 48408c2ecf20Sopenharmony_ci PCI_ACS_CR | PCI_ACS_UF | PCI_ACS_DT); 48418c2ecf20Sopenharmony_ci} 48428c2ecf20Sopenharmony_ci 48438c2ecf20Sopenharmony_cistatic int pci_quirk_rciep_acs(struct pci_dev *dev, u16 acs_flags) 48448c2ecf20Sopenharmony_ci{ 48458c2ecf20Sopenharmony_ci /* 48468c2ecf20Sopenharmony_ci * Intel RCiEP's are required to allow p2p only on translated 48478c2ecf20Sopenharmony_ci * addresses. Refer to Intel VT-d specification, r3.1, sec 3.16, 48488c2ecf20Sopenharmony_ci * "Root-Complex Peer to Peer Considerations". 48498c2ecf20Sopenharmony_ci */ 48508c2ecf20Sopenharmony_ci if (pci_pcie_type(dev) != PCI_EXP_TYPE_RC_END) 48518c2ecf20Sopenharmony_ci return -ENOTTY; 48528c2ecf20Sopenharmony_ci 48538c2ecf20Sopenharmony_ci return pci_acs_ctrl_enabled(acs_flags, 48548c2ecf20Sopenharmony_ci PCI_ACS_SV | PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF); 48558c2ecf20Sopenharmony_ci} 48568c2ecf20Sopenharmony_ci 48578c2ecf20Sopenharmony_cistatic int pci_quirk_brcm_acs(struct pci_dev *dev, u16 acs_flags) 48588c2ecf20Sopenharmony_ci{ 48598c2ecf20Sopenharmony_ci /* 48608c2ecf20Sopenharmony_ci * iProc PAXB Root Ports don't advertise an ACS capability, but 48618c2ecf20Sopenharmony_ci * they do not allow peer-to-peer transactions between Root Ports. 48628c2ecf20Sopenharmony_ci * Allow each Root Port to be in a separate IOMMU group by masking 48638c2ecf20Sopenharmony_ci * SV/RR/CR/UF bits. 48648c2ecf20Sopenharmony_ci */ 48658c2ecf20Sopenharmony_ci return pci_acs_ctrl_enabled(acs_flags, 48668c2ecf20Sopenharmony_ci PCI_ACS_SV | PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF); 48678c2ecf20Sopenharmony_ci} 48688c2ecf20Sopenharmony_ci 48698c2ecf20Sopenharmony_ci/* 48708c2ecf20Sopenharmony_ci * Wangxun 10G/1G NICs have no ACS capability, and on multi-function 48718c2ecf20Sopenharmony_ci * devices, peer-to-peer transactions are not be used between the functions. 48728c2ecf20Sopenharmony_ci * So add an ACS quirk for below devices to isolate functions. 48738c2ecf20Sopenharmony_ci * SFxxx 1G NICs(em). 48748c2ecf20Sopenharmony_ci * RP1000/RP2000 10G NICs(sp). 48758c2ecf20Sopenharmony_ci */ 48768c2ecf20Sopenharmony_cistatic int pci_quirk_wangxun_nic_acs(struct pci_dev *dev, u16 acs_flags) 48778c2ecf20Sopenharmony_ci{ 48788c2ecf20Sopenharmony_ci switch (dev->device) { 48798c2ecf20Sopenharmony_ci case 0x0100 ... 0x010F: 48808c2ecf20Sopenharmony_ci case 0x1001: 48818c2ecf20Sopenharmony_ci case 0x2001: 48828c2ecf20Sopenharmony_ci return pci_acs_ctrl_enabled(acs_flags, 48838c2ecf20Sopenharmony_ci PCI_ACS_SV | PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF); 48848c2ecf20Sopenharmony_ci } 48858c2ecf20Sopenharmony_ci 48868c2ecf20Sopenharmony_ci return false; 48878c2ecf20Sopenharmony_ci} 48888c2ecf20Sopenharmony_ci 48898c2ecf20Sopenharmony_cistatic const struct pci_dev_acs_enabled { 48908c2ecf20Sopenharmony_ci u16 vendor; 48918c2ecf20Sopenharmony_ci u16 device; 48928c2ecf20Sopenharmony_ci int (*acs_enabled)(struct pci_dev *dev, u16 acs_flags); 48938c2ecf20Sopenharmony_ci} pci_dev_acs_enabled[] = { 48948c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_ATI, 0x4385, pci_quirk_amd_sb_acs }, 48958c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_ATI, 0x439c, pci_quirk_amd_sb_acs }, 48968c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_ATI, 0x4383, pci_quirk_amd_sb_acs }, 48978c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_ATI, 0x439d, pci_quirk_amd_sb_acs }, 48988c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_ATI, 0x4384, pci_quirk_amd_sb_acs }, 48998c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_ATI, 0x4399, pci_quirk_amd_sb_acs }, 49008c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_AMD, 0x780f, pci_quirk_amd_sb_acs }, 49018c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_AMD, 0x7809, pci_quirk_amd_sb_acs }, 49028c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_SOLARFLARE, 0x0903, pci_quirk_mf_endpoint_acs }, 49038c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_SOLARFLARE, 0x0923, pci_quirk_mf_endpoint_acs }, 49048c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_SOLARFLARE, 0x0A03, pci_quirk_mf_endpoint_acs }, 49058c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x10C6, pci_quirk_mf_endpoint_acs }, 49068c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x10DB, pci_quirk_mf_endpoint_acs }, 49078c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x10DD, pci_quirk_mf_endpoint_acs }, 49088c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x10E1, pci_quirk_mf_endpoint_acs }, 49098c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x10F1, pci_quirk_mf_endpoint_acs }, 49108c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x10F7, pci_quirk_mf_endpoint_acs }, 49118c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x10F8, pci_quirk_mf_endpoint_acs }, 49128c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x10F9, pci_quirk_mf_endpoint_acs }, 49138c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x10FA, pci_quirk_mf_endpoint_acs }, 49148c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x10FB, pci_quirk_mf_endpoint_acs }, 49158c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x10FC, pci_quirk_mf_endpoint_acs }, 49168c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x1507, pci_quirk_mf_endpoint_acs }, 49178c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x1514, pci_quirk_mf_endpoint_acs }, 49188c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x151C, pci_quirk_mf_endpoint_acs }, 49198c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x1529, pci_quirk_mf_endpoint_acs }, 49208c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x152A, pci_quirk_mf_endpoint_acs }, 49218c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x154D, pci_quirk_mf_endpoint_acs }, 49228c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x154F, pci_quirk_mf_endpoint_acs }, 49238c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x1551, pci_quirk_mf_endpoint_acs }, 49248c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x1558, pci_quirk_mf_endpoint_acs }, 49258c2ecf20Sopenharmony_ci /* 82580 */ 49268c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x1509, pci_quirk_mf_endpoint_acs }, 49278c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x150E, pci_quirk_mf_endpoint_acs }, 49288c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x150F, pci_quirk_mf_endpoint_acs }, 49298c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x1510, pci_quirk_mf_endpoint_acs }, 49308c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x1511, pci_quirk_mf_endpoint_acs }, 49318c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x1516, pci_quirk_mf_endpoint_acs }, 49328c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x1527, pci_quirk_mf_endpoint_acs }, 49338c2ecf20Sopenharmony_ci /* 82576 */ 49348c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x10C9, pci_quirk_mf_endpoint_acs }, 49358c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x10E6, pci_quirk_mf_endpoint_acs }, 49368c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x10E7, pci_quirk_mf_endpoint_acs }, 49378c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x10E8, pci_quirk_mf_endpoint_acs }, 49388c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x150A, pci_quirk_mf_endpoint_acs }, 49398c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x150D, pci_quirk_mf_endpoint_acs }, 49408c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x1518, pci_quirk_mf_endpoint_acs }, 49418c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x1526, pci_quirk_mf_endpoint_acs }, 49428c2ecf20Sopenharmony_ci /* 82575 */ 49438c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x10A7, pci_quirk_mf_endpoint_acs }, 49448c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x10A9, pci_quirk_mf_endpoint_acs }, 49458c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x10D6, pci_quirk_mf_endpoint_acs }, 49468c2ecf20Sopenharmony_ci /* I350 */ 49478c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x1521, pci_quirk_mf_endpoint_acs }, 49488c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x1522, pci_quirk_mf_endpoint_acs }, 49498c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x1523, pci_quirk_mf_endpoint_acs }, 49508c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x1524, pci_quirk_mf_endpoint_acs }, 49518c2ecf20Sopenharmony_ci /* 82571 (Quads omitted due to non-ACS switch) */ 49528c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x105E, pci_quirk_mf_endpoint_acs }, 49538c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x105F, pci_quirk_mf_endpoint_acs }, 49548c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x1060, pci_quirk_mf_endpoint_acs }, 49558c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x10D9, pci_quirk_mf_endpoint_acs }, 49568c2ecf20Sopenharmony_ci /* I219 */ 49578c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x15b7, pci_quirk_mf_endpoint_acs }, 49588c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, 0x15b8, pci_quirk_mf_endpoint_acs }, 49598c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, PCI_ANY_ID, pci_quirk_rciep_acs }, 49608c2ecf20Sopenharmony_ci /* QCOM QDF2xxx root ports */ 49618c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_QCOM, 0x0400, pci_quirk_qcom_rp_acs }, 49628c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_QCOM, 0x0401, pci_quirk_qcom_rp_acs }, 49638c2ecf20Sopenharmony_ci /* HXT SD4800 root ports. The ACS design is same as QCOM QDF2xxx */ 49648c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_HXT, 0x0401, pci_quirk_qcom_rp_acs }, 49658c2ecf20Sopenharmony_ci /* Intel PCH root ports */ 49668c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, PCI_ANY_ID, pci_quirk_intel_pch_acs }, 49678c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, PCI_ANY_ID, pci_quirk_intel_spt_pch_acs }, 49688c2ecf20Sopenharmony_ci { 0x19a2, 0x710, pci_quirk_mf_endpoint_acs }, /* Emulex BE3-R */ 49698c2ecf20Sopenharmony_ci { 0x10df, 0x720, pci_quirk_mf_endpoint_acs }, /* Emulex Skyhawk-R */ 49708c2ecf20Sopenharmony_ci /* Cavium ThunderX */ 49718c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_CAVIUM, PCI_ANY_ID, pci_quirk_cavium_acs }, 49728c2ecf20Sopenharmony_ci /* Cavium multi-function devices */ 49738c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_CAVIUM, 0xA026, pci_quirk_mf_endpoint_acs }, 49748c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_CAVIUM, 0xA059, pci_quirk_mf_endpoint_acs }, 49758c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_CAVIUM, 0xA060, pci_quirk_mf_endpoint_acs }, 49768c2ecf20Sopenharmony_ci /* APM X-Gene */ 49778c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_AMCC, 0xE004, pci_quirk_xgene_acs }, 49788c2ecf20Sopenharmony_ci /* Ampere Computing */ 49798c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_AMPERE, 0xE005, pci_quirk_xgene_acs }, 49808c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_AMPERE, 0xE006, pci_quirk_xgene_acs }, 49818c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_AMPERE, 0xE007, pci_quirk_xgene_acs }, 49828c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_AMPERE, 0xE008, pci_quirk_xgene_acs }, 49838c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_AMPERE, 0xE009, pci_quirk_xgene_acs }, 49848c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_AMPERE, 0xE00A, pci_quirk_xgene_acs }, 49858c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_AMPERE, 0xE00B, pci_quirk_xgene_acs }, 49868c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_AMPERE, 0xE00C, pci_quirk_xgene_acs }, 49878c2ecf20Sopenharmony_ci /* Broadcom multi-function device */ 49888c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_BROADCOM, 0x16D7, pci_quirk_mf_endpoint_acs }, 49898c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_BROADCOM, 0x1750, pci_quirk_mf_endpoint_acs }, 49908c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_BROADCOM, 0x1751, pci_quirk_mf_endpoint_acs }, 49918c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_BROADCOM, 0x1752, pci_quirk_mf_endpoint_acs }, 49928c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_BROADCOM, 0xD714, pci_quirk_brcm_acs }, 49938c2ecf20Sopenharmony_ci /* Amazon Annapurna Labs */ 49948c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_AMAZON_ANNAPURNA_LABS, 0x0031, pci_quirk_al_acs }, 49958c2ecf20Sopenharmony_ci /* Zhaoxin multi-function devices */ 49968c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_ZHAOXIN, 0x3038, pci_quirk_mf_endpoint_acs }, 49978c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_ZHAOXIN, 0x3104, pci_quirk_mf_endpoint_acs }, 49988c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_ZHAOXIN, 0x9083, pci_quirk_mf_endpoint_acs }, 49998c2ecf20Sopenharmony_ci /* NXP root ports, xx=16, 12, or 08 cores */ 50008c2ecf20Sopenharmony_ci /* LX2xx0A : without security features + CAN-FD */ 50018c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_NXP, 0x8d81, pci_quirk_nxp_rp_acs }, 50028c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_NXP, 0x8da1, pci_quirk_nxp_rp_acs }, 50038c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_NXP, 0x8d83, pci_quirk_nxp_rp_acs }, 50048c2ecf20Sopenharmony_ci /* LX2xx0C : security features + CAN-FD */ 50058c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_NXP, 0x8d80, pci_quirk_nxp_rp_acs }, 50068c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_NXP, 0x8da0, pci_quirk_nxp_rp_acs }, 50078c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_NXP, 0x8d82, pci_quirk_nxp_rp_acs }, 50088c2ecf20Sopenharmony_ci /* LX2xx0E : security features + CAN */ 50098c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_NXP, 0x8d90, pci_quirk_nxp_rp_acs }, 50108c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_NXP, 0x8db0, pci_quirk_nxp_rp_acs }, 50118c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_NXP, 0x8d92, pci_quirk_nxp_rp_acs }, 50128c2ecf20Sopenharmony_ci /* LX2xx0N : without security features + CAN */ 50138c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_NXP, 0x8d91, pci_quirk_nxp_rp_acs }, 50148c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_NXP, 0x8db1, pci_quirk_nxp_rp_acs }, 50158c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_NXP, 0x8d93, pci_quirk_nxp_rp_acs }, 50168c2ecf20Sopenharmony_ci /* LX2xx2A : without security features + CAN-FD */ 50178c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_NXP, 0x8d89, pci_quirk_nxp_rp_acs }, 50188c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_NXP, 0x8da9, pci_quirk_nxp_rp_acs }, 50198c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_NXP, 0x8d8b, pci_quirk_nxp_rp_acs }, 50208c2ecf20Sopenharmony_ci /* LX2xx2C : security features + CAN-FD */ 50218c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_NXP, 0x8d88, pci_quirk_nxp_rp_acs }, 50228c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_NXP, 0x8da8, pci_quirk_nxp_rp_acs }, 50238c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_NXP, 0x8d8a, pci_quirk_nxp_rp_acs }, 50248c2ecf20Sopenharmony_ci /* LX2xx2E : security features + CAN */ 50258c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_NXP, 0x8d98, pci_quirk_nxp_rp_acs }, 50268c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_NXP, 0x8db8, pci_quirk_nxp_rp_acs }, 50278c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_NXP, 0x8d9a, pci_quirk_nxp_rp_acs }, 50288c2ecf20Sopenharmony_ci /* LX2xx2N : without security features + CAN */ 50298c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_NXP, 0x8d99, pci_quirk_nxp_rp_acs }, 50308c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_NXP, 0x8db9, pci_quirk_nxp_rp_acs }, 50318c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_NXP, 0x8d9b, pci_quirk_nxp_rp_acs }, 50328c2ecf20Sopenharmony_ci /* Zhaoxin Root/Downstream Ports */ 50338c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_ZHAOXIN, PCI_ANY_ID, pci_quirk_zhaoxin_pcie_ports_acs }, 50348c2ecf20Sopenharmony_ci /* Wangxun nics */ 50358c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_WANGXUN, PCI_ANY_ID, pci_quirk_wangxun_nic_acs }, 50368c2ecf20Sopenharmony_ci { 0 } 50378c2ecf20Sopenharmony_ci}; 50388c2ecf20Sopenharmony_ci 50398c2ecf20Sopenharmony_ci/* 50408c2ecf20Sopenharmony_ci * pci_dev_specific_acs_enabled - check whether device provides ACS controls 50418c2ecf20Sopenharmony_ci * @dev: PCI device 50428c2ecf20Sopenharmony_ci * @acs_flags: Bitmask of desired ACS controls 50438c2ecf20Sopenharmony_ci * 50448c2ecf20Sopenharmony_ci * Returns: 50458c2ecf20Sopenharmony_ci * -ENOTTY: No quirk applies to this device; we can't tell whether the 50468c2ecf20Sopenharmony_ci * device provides the desired controls 50478c2ecf20Sopenharmony_ci * 0: Device does not provide all the desired controls 50488c2ecf20Sopenharmony_ci * >0: Device provides all the controls in @acs_flags 50498c2ecf20Sopenharmony_ci */ 50508c2ecf20Sopenharmony_ciint pci_dev_specific_acs_enabled(struct pci_dev *dev, u16 acs_flags) 50518c2ecf20Sopenharmony_ci{ 50528c2ecf20Sopenharmony_ci const struct pci_dev_acs_enabled *i; 50538c2ecf20Sopenharmony_ci int ret; 50548c2ecf20Sopenharmony_ci 50558c2ecf20Sopenharmony_ci /* 50568c2ecf20Sopenharmony_ci * Allow devices that do not expose standard PCIe ACS capabilities 50578c2ecf20Sopenharmony_ci * or control to indicate their support here. Multi-function express 50588c2ecf20Sopenharmony_ci * devices which do not allow internal peer-to-peer between functions, 50598c2ecf20Sopenharmony_ci * but do not implement PCIe ACS may wish to return true here. 50608c2ecf20Sopenharmony_ci */ 50618c2ecf20Sopenharmony_ci for (i = pci_dev_acs_enabled; i->acs_enabled; i++) { 50628c2ecf20Sopenharmony_ci if ((i->vendor == dev->vendor || 50638c2ecf20Sopenharmony_ci i->vendor == (u16)PCI_ANY_ID) && 50648c2ecf20Sopenharmony_ci (i->device == dev->device || 50658c2ecf20Sopenharmony_ci i->device == (u16)PCI_ANY_ID)) { 50668c2ecf20Sopenharmony_ci ret = i->acs_enabled(dev, acs_flags); 50678c2ecf20Sopenharmony_ci if (ret >= 0) 50688c2ecf20Sopenharmony_ci return ret; 50698c2ecf20Sopenharmony_ci } 50708c2ecf20Sopenharmony_ci } 50718c2ecf20Sopenharmony_ci 50728c2ecf20Sopenharmony_ci return -ENOTTY; 50738c2ecf20Sopenharmony_ci} 50748c2ecf20Sopenharmony_ci 50758c2ecf20Sopenharmony_ci/* Config space offset of Root Complex Base Address register */ 50768c2ecf20Sopenharmony_ci#define INTEL_LPC_RCBA_REG 0xf0 50778c2ecf20Sopenharmony_ci/* 31:14 RCBA address */ 50788c2ecf20Sopenharmony_ci#define INTEL_LPC_RCBA_MASK 0xffffc000 50798c2ecf20Sopenharmony_ci/* RCBA Enable */ 50808c2ecf20Sopenharmony_ci#define INTEL_LPC_RCBA_ENABLE (1 << 0) 50818c2ecf20Sopenharmony_ci 50828c2ecf20Sopenharmony_ci/* Backbone Scratch Pad Register */ 50838c2ecf20Sopenharmony_ci#define INTEL_BSPR_REG 0x1104 50848c2ecf20Sopenharmony_ci/* Backbone Peer Non-Posted Disable */ 50858c2ecf20Sopenharmony_ci#define INTEL_BSPR_REG_BPNPD (1 << 8) 50868c2ecf20Sopenharmony_ci/* Backbone Peer Posted Disable */ 50878c2ecf20Sopenharmony_ci#define INTEL_BSPR_REG_BPPD (1 << 9) 50888c2ecf20Sopenharmony_ci 50898c2ecf20Sopenharmony_ci/* Upstream Peer Decode Configuration Register */ 50908c2ecf20Sopenharmony_ci#define INTEL_UPDCR_REG 0x1014 50918c2ecf20Sopenharmony_ci/* 5:0 Peer Decode Enable bits */ 50928c2ecf20Sopenharmony_ci#define INTEL_UPDCR_REG_MASK 0x3f 50938c2ecf20Sopenharmony_ci 50948c2ecf20Sopenharmony_cistatic int pci_quirk_enable_intel_lpc_acs(struct pci_dev *dev) 50958c2ecf20Sopenharmony_ci{ 50968c2ecf20Sopenharmony_ci u32 rcba, bspr, updcr; 50978c2ecf20Sopenharmony_ci void __iomem *rcba_mem; 50988c2ecf20Sopenharmony_ci 50998c2ecf20Sopenharmony_ci /* 51008c2ecf20Sopenharmony_ci * Read the RCBA register from the LPC (D31:F0). PCH root ports 51018c2ecf20Sopenharmony_ci * are D28:F* and therefore get probed before LPC, thus we can't 51028c2ecf20Sopenharmony_ci * use pci_get_slot()/pci_read_config_dword() here. 51038c2ecf20Sopenharmony_ci */ 51048c2ecf20Sopenharmony_ci pci_bus_read_config_dword(dev->bus, PCI_DEVFN(31, 0), 51058c2ecf20Sopenharmony_ci INTEL_LPC_RCBA_REG, &rcba); 51068c2ecf20Sopenharmony_ci if (!(rcba & INTEL_LPC_RCBA_ENABLE)) 51078c2ecf20Sopenharmony_ci return -EINVAL; 51088c2ecf20Sopenharmony_ci 51098c2ecf20Sopenharmony_ci rcba_mem = ioremap(rcba & INTEL_LPC_RCBA_MASK, 51108c2ecf20Sopenharmony_ci PAGE_ALIGN(INTEL_UPDCR_REG)); 51118c2ecf20Sopenharmony_ci if (!rcba_mem) 51128c2ecf20Sopenharmony_ci return -ENOMEM; 51138c2ecf20Sopenharmony_ci 51148c2ecf20Sopenharmony_ci /* 51158c2ecf20Sopenharmony_ci * The BSPR can disallow peer cycles, but it's set by soft strap and 51168c2ecf20Sopenharmony_ci * therefore read-only. If both posted and non-posted peer cycles are 51178c2ecf20Sopenharmony_ci * disallowed, we're ok. If either are allowed, then we need to use 51188c2ecf20Sopenharmony_ci * the UPDCR to disable peer decodes for each port. This provides the 51198c2ecf20Sopenharmony_ci * PCIe ACS equivalent of PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF 51208c2ecf20Sopenharmony_ci */ 51218c2ecf20Sopenharmony_ci bspr = readl(rcba_mem + INTEL_BSPR_REG); 51228c2ecf20Sopenharmony_ci bspr &= INTEL_BSPR_REG_BPNPD | INTEL_BSPR_REG_BPPD; 51238c2ecf20Sopenharmony_ci if (bspr != (INTEL_BSPR_REG_BPNPD | INTEL_BSPR_REG_BPPD)) { 51248c2ecf20Sopenharmony_ci updcr = readl(rcba_mem + INTEL_UPDCR_REG); 51258c2ecf20Sopenharmony_ci if (updcr & INTEL_UPDCR_REG_MASK) { 51268c2ecf20Sopenharmony_ci pci_info(dev, "Disabling UPDCR peer decodes\n"); 51278c2ecf20Sopenharmony_ci updcr &= ~INTEL_UPDCR_REG_MASK; 51288c2ecf20Sopenharmony_ci writel(updcr, rcba_mem + INTEL_UPDCR_REG); 51298c2ecf20Sopenharmony_ci } 51308c2ecf20Sopenharmony_ci } 51318c2ecf20Sopenharmony_ci 51328c2ecf20Sopenharmony_ci iounmap(rcba_mem); 51338c2ecf20Sopenharmony_ci return 0; 51348c2ecf20Sopenharmony_ci} 51358c2ecf20Sopenharmony_ci 51368c2ecf20Sopenharmony_ci/* Miscellaneous Port Configuration register */ 51378c2ecf20Sopenharmony_ci#define INTEL_MPC_REG 0xd8 51388c2ecf20Sopenharmony_ci/* MPC: Invalid Receive Bus Number Check Enable */ 51398c2ecf20Sopenharmony_ci#define INTEL_MPC_REG_IRBNCE (1 << 26) 51408c2ecf20Sopenharmony_ci 51418c2ecf20Sopenharmony_cistatic void pci_quirk_enable_intel_rp_mpc_acs(struct pci_dev *dev) 51428c2ecf20Sopenharmony_ci{ 51438c2ecf20Sopenharmony_ci u32 mpc; 51448c2ecf20Sopenharmony_ci 51458c2ecf20Sopenharmony_ci /* 51468c2ecf20Sopenharmony_ci * When enabled, the IRBNCE bit of the MPC register enables the 51478c2ecf20Sopenharmony_ci * equivalent of PCI ACS Source Validation (PCI_ACS_SV), which 51488c2ecf20Sopenharmony_ci * ensures that requester IDs fall within the bus number range 51498c2ecf20Sopenharmony_ci * of the bridge. Enable if not already. 51508c2ecf20Sopenharmony_ci */ 51518c2ecf20Sopenharmony_ci pci_read_config_dword(dev, INTEL_MPC_REG, &mpc); 51528c2ecf20Sopenharmony_ci if (!(mpc & INTEL_MPC_REG_IRBNCE)) { 51538c2ecf20Sopenharmony_ci pci_info(dev, "Enabling MPC IRBNCE\n"); 51548c2ecf20Sopenharmony_ci mpc |= INTEL_MPC_REG_IRBNCE; 51558c2ecf20Sopenharmony_ci pci_write_config_word(dev, INTEL_MPC_REG, mpc); 51568c2ecf20Sopenharmony_ci } 51578c2ecf20Sopenharmony_ci} 51588c2ecf20Sopenharmony_ci 51598c2ecf20Sopenharmony_ci/* 51608c2ecf20Sopenharmony_ci * Currently this quirk does the equivalent of 51618c2ecf20Sopenharmony_ci * PCI_ACS_SV | PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF 51628c2ecf20Sopenharmony_ci * 51638c2ecf20Sopenharmony_ci * TODO: This quirk also needs to do equivalent of PCI_ACS_TB, 51648c2ecf20Sopenharmony_ci * if dev->external_facing || dev->untrusted 51658c2ecf20Sopenharmony_ci */ 51668c2ecf20Sopenharmony_cistatic int pci_quirk_enable_intel_pch_acs(struct pci_dev *dev) 51678c2ecf20Sopenharmony_ci{ 51688c2ecf20Sopenharmony_ci if (!pci_quirk_intel_pch_acs_match(dev)) 51698c2ecf20Sopenharmony_ci return -ENOTTY; 51708c2ecf20Sopenharmony_ci 51718c2ecf20Sopenharmony_ci if (pci_quirk_enable_intel_lpc_acs(dev)) { 51728c2ecf20Sopenharmony_ci pci_warn(dev, "Failed to enable Intel PCH ACS quirk\n"); 51738c2ecf20Sopenharmony_ci return 0; 51748c2ecf20Sopenharmony_ci } 51758c2ecf20Sopenharmony_ci 51768c2ecf20Sopenharmony_ci pci_quirk_enable_intel_rp_mpc_acs(dev); 51778c2ecf20Sopenharmony_ci 51788c2ecf20Sopenharmony_ci dev->dev_flags |= PCI_DEV_FLAGS_ACS_ENABLED_QUIRK; 51798c2ecf20Sopenharmony_ci 51808c2ecf20Sopenharmony_ci pci_info(dev, "Intel PCH root port ACS workaround enabled\n"); 51818c2ecf20Sopenharmony_ci 51828c2ecf20Sopenharmony_ci return 0; 51838c2ecf20Sopenharmony_ci} 51848c2ecf20Sopenharmony_ci 51858c2ecf20Sopenharmony_cistatic int pci_quirk_enable_intel_spt_pch_acs(struct pci_dev *dev) 51868c2ecf20Sopenharmony_ci{ 51878c2ecf20Sopenharmony_ci int pos; 51888c2ecf20Sopenharmony_ci u32 cap, ctrl; 51898c2ecf20Sopenharmony_ci 51908c2ecf20Sopenharmony_ci if (!pci_quirk_intel_spt_pch_acs_match(dev)) 51918c2ecf20Sopenharmony_ci return -ENOTTY; 51928c2ecf20Sopenharmony_ci 51938c2ecf20Sopenharmony_ci pos = dev->acs_cap; 51948c2ecf20Sopenharmony_ci if (!pos) 51958c2ecf20Sopenharmony_ci return -ENOTTY; 51968c2ecf20Sopenharmony_ci 51978c2ecf20Sopenharmony_ci pci_read_config_dword(dev, pos + PCI_ACS_CAP, &cap); 51988c2ecf20Sopenharmony_ci pci_read_config_dword(dev, pos + INTEL_SPT_ACS_CTRL, &ctrl); 51998c2ecf20Sopenharmony_ci 52008c2ecf20Sopenharmony_ci ctrl |= (cap & PCI_ACS_SV); 52018c2ecf20Sopenharmony_ci ctrl |= (cap & PCI_ACS_RR); 52028c2ecf20Sopenharmony_ci ctrl |= (cap & PCI_ACS_CR); 52038c2ecf20Sopenharmony_ci ctrl |= (cap & PCI_ACS_UF); 52048c2ecf20Sopenharmony_ci 52058c2ecf20Sopenharmony_ci if (dev->external_facing || dev->untrusted) 52068c2ecf20Sopenharmony_ci ctrl |= (cap & PCI_ACS_TB); 52078c2ecf20Sopenharmony_ci 52088c2ecf20Sopenharmony_ci pci_write_config_dword(dev, pos + INTEL_SPT_ACS_CTRL, ctrl); 52098c2ecf20Sopenharmony_ci 52108c2ecf20Sopenharmony_ci pci_info(dev, "Intel SPT PCH root port ACS workaround enabled\n"); 52118c2ecf20Sopenharmony_ci 52128c2ecf20Sopenharmony_ci return 0; 52138c2ecf20Sopenharmony_ci} 52148c2ecf20Sopenharmony_ci 52158c2ecf20Sopenharmony_cistatic int pci_quirk_disable_intel_spt_pch_acs_redir(struct pci_dev *dev) 52168c2ecf20Sopenharmony_ci{ 52178c2ecf20Sopenharmony_ci int pos; 52188c2ecf20Sopenharmony_ci u32 cap, ctrl; 52198c2ecf20Sopenharmony_ci 52208c2ecf20Sopenharmony_ci if (!pci_quirk_intel_spt_pch_acs_match(dev)) 52218c2ecf20Sopenharmony_ci return -ENOTTY; 52228c2ecf20Sopenharmony_ci 52238c2ecf20Sopenharmony_ci pos = dev->acs_cap; 52248c2ecf20Sopenharmony_ci if (!pos) 52258c2ecf20Sopenharmony_ci return -ENOTTY; 52268c2ecf20Sopenharmony_ci 52278c2ecf20Sopenharmony_ci pci_read_config_dword(dev, pos + PCI_ACS_CAP, &cap); 52288c2ecf20Sopenharmony_ci pci_read_config_dword(dev, pos + INTEL_SPT_ACS_CTRL, &ctrl); 52298c2ecf20Sopenharmony_ci 52308c2ecf20Sopenharmony_ci ctrl &= ~(PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_EC); 52318c2ecf20Sopenharmony_ci 52328c2ecf20Sopenharmony_ci pci_write_config_dword(dev, pos + INTEL_SPT_ACS_CTRL, ctrl); 52338c2ecf20Sopenharmony_ci 52348c2ecf20Sopenharmony_ci pci_info(dev, "Intel SPT PCH root port workaround: disabled ACS redirect\n"); 52358c2ecf20Sopenharmony_ci 52368c2ecf20Sopenharmony_ci return 0; 52378c2ecf20Sopenharmony_ci} 52388c2ecf20Sopenharmony_ci 52398c2ecf20Sopenharmony_cistatic const struct pci_dev_acs_ops { 52408c2ecf20Sopenharmony_ci u16 vendor; 52418c2ecf20Sopenharmony_ci u16 device; 52428c2ecf20Sopenharmony_ci int (*enable_acs)(struct pci_dev *dev); 52438c2ecf20Sopenharmony_ci int (*disable_acs_redir)(struct pci_dev *dev); 52448c2ecf20Sopenharmony_ci} pci_dev_acs_ops[] = { 52458c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, PCI_ANY_ID, 52468c2ecf20Sopenharmony_ci .enable_acs = pci_quirk_enable_intel_pch_acs, 52478c2ecf20Sopenharmony_ci }, 52488c2ecf20Sopenharmony_ci { PCI_VENDOR_ID_INTEL, PCI_ANY_ID, 52498c2ecf20Sopenharmony_ci .enable_acs = pci_quirk_enable_intel_spt_pch_acs, 52508c2ecf20Sopenharmony_ci .disable_acs_redir = pci_quirk_disable_intel_spt_pch_acs_redir, 52518c2ecf20Sopenharmony_ci }, 52528c2ecf20Sopenharmony_ci}; 52538c2ecf20Sopenharmony_ci 52548c2ecf20Sopenharmony_ciint pci_dev_specific_enable_acs(struct pci_dev *dev) 52558c2ecf20Sopenharmony_ci{ 52568c2ecf20Sopenharmony_ci const struct pci_dev_acs_ops *p; 52578c2ecf20Sopenharmony_ci int i, ret; 52588c2ecf20Sopenharmony_ci 52598c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(pci_dev_acs_ops); i++) { 52608c2ecf20Sopenharmony_ci p = &pci_dev_acs_ops[i]; 52618c2ecf20Sopenharmony_ci if ((p->vendor == dev->vendor || 52628c2ecf20Sopenharmony_ci p->vendor == (u16)PCI_ANY_ID) && 52638c2ecf20Sopenharmony_ci (p->device == dev->device || 52648c2ecf20Sopenharmony_ci p->device == (u16)PCI_ANY_ID) && 52658c2ecf20Sopenharmony_ci p->enable_acs) { 52668c2ecf20Sopenharmony_ci ret = p->enable_acs(dev); 52678c2ecf20Sopenharmony_ci if (ret >= 0) 52688c2ecf20Sopenharmony_ci return ret; 52698c2ecf20Sopenharmony_ci } 52708c2ecf20Sopenharmony_ci } 52718c2ecf20Sopenharmony_ci 52728c2ecf20Sopenharmony_ci return -ENOTTY; 52738c2ecf20Sopenharmony_ci} 52748c2ecf20Sopenharmony_ci 52758c2ecf20Sopenharmony_ciint pci_dev_specific_disable_acs_redir(struct pci_dev *dev) 52768c2ecf20Sopenharmony_ci{ 52778c2ecf20Sopenharmony_ci const struct pci_dev_acs_ops *p; 52788c2ecf20Sopenharmony_ci int i, ret; 52798c2ecf20Sopenharmony_ci 52808c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(pci_dev_acs_ops); i++) { 52818c2ecf20Sopenharmony_ci p = &pci_dev_acs_ops[i]; 52828c2ecf20Sopenharmony_ci if ((p->vendor == dev->vendor || 52838c2ecf20Sopenharmony_ci p->vendor == (u16)PCI_ANY_ID) && 52848c2ecf20Sopenharmony_ci (p->device == dev->device || 52858c2ecf20Sopenharmony_ci p->device == (u16)PCI_ANY_ID) && 52868c2ecf20Sopenharmony_ci p->disable_acs_redir) { 52878c2ecf20Sopenharmony_ci ret = p->disable_acs_redir(dev); 52888c2ecf20Sopenharmony_ci if (ret >= 0) 52898c2ecf20Sopenharmony_ci return ret; 52908c2ecf20Sopenharmony_ci } 52918c2ecf20Sopenharmony_ci } 52928c2ecf20Sopenharmony_ci 52938c2ecf20Sopenharmony_ci return -ENOTTY; 52948c2ecf20Sopenharmony_ci} 52958c2ecf20Sopenharmony_ci 52968c2ecf20Sopenharmony_ci/* 52978c2ecf20Sopenharmony_ci * The PCI capabilities list for Intel DH895xCC VFs (device ID 0x0443) with 52988c2ecf20Sopenharmony_ci * QuickAssist Technology (QAT) is prematurely terminated in hardware. The 52998c2ecf20Sopenharmony_ci * Next Capability pointer in the MSI Capability Structure should point to 53008c2ecf20Sopenharmony_ci * the PCIe Capability Structure but is incorrectly hardwired as 0 terminating 53018c2ecf20Sopenharmony_ci * the list. 53028c2ecf20Sopenharmony_ci */ 53038c2ecf20Sopenharmony_cistatic void quirk_intel_qat_vf_cap(struct pci_dev *pdev) 53048c2ecf20Sopenharmony_ci{ 53058c2ecf20Sopenharmony_ci int pos, i = 0; 53068c2ecf20Sopenharmony_ci u8 next_cap; 53078c2ecf20Sopenharmony_ci u16 reg16, *cap; 53088c2ecf20Sopenharmony_ci struct pci_cap_saved_state *state; 53098c2ecf20Sopenharmony_ci 53108c2ecf20Sopenharmony_ci /* Bail if the hardware bug is fixed */ 53118c2ecf20Sopenharmony_ci if (pdev->pcie_cap || pci_find_capability(pdev, PCI_CAP_ID_EXP)) 53128c2ecf20Sopenharmony_ci return; 53138c2ecf20Sopenharmony_ci 53148c2ecf20Sopenharmony_ci /* Bail if MSI Capability Structure is not found for some reason */ 53158c2ecf20Sopenharmony_ci pos = pci_find_capability(pdev, PCI_CAP_ID_MSI); 53168c2ecf20Sopenharmony_ci if (!pos) 53178c2ecf20Sopenharmony_ci return; 53188c2ecf20Sopenharmony_ci 53198c2ecf20Sopenharmony_ci /* 53208c2ecf20Sopenharmony_ci * Bail if Next Capability pointer in the MSI Capability Structure 53218c2ecf20Sopenharmony_ci * is not the expected incorrect 0x00. 53228c2ecf20Sopenharmony_ci */ 53238c2ecf20Sopenharmony_ci pci_read_config_byte(pdev, pos + 1, &next_cap); 53248c2ecf20Sopenharmony_ci if (next_cap) 53258c2ecf20Sopenharmony_ci return; 53268c2ecf20Sopenharmony_ci 53278c2ecf20Sopenharmony_ci /* 53288c2ecf20Sopenharmony_ci * PCIe Capability Structure is expected to be at 0x50 and should 53298c2ecf20Sopenharmony_ci * terminate the list (Next Capability pointer is 0x00). Verify 53308c2ecf20Sopenharmony_ci * Capability Id and Next Capability pointer is as expected. 53318c2ecf20Sopenharmony_ci * Open-code some of set_pcie_port_type() and pci_cfg_space_size_ext() 53328c2ecf20Sopenharmony_ci * to correctly set kernel data structures which have already been 53338c2ecf20Sopenharmony_ci * set incorrectly due to the hardware bug. 53348c2ecf20Sopenharmony_ci */ 53358c2ecf20Sopenharmony_ci pos = 0x50; 53368c2ecf20Sopenharmony_ci pci_read_config_word(pdev, pos, ®16); 53378c2ecf20Sopenharmony_ci if (reg16 == (0x0000 | PCI_CAP_ID_EXP)) { 53388c2ecf20Sopenharmony_ci u32 status; 53398c2ecf20Sopenharmony_ci#ifndef PCI_EXP_SAVE_REGS 53408c2ecf20Sopenharmony_ci#define PCI_EXP_SAVE_REGS 7 53418c2ecf20Sopenharmony_ci#endif 53428c2ecf20Sopenharmony_ci int size = PCI_EXP_SAVE_REGS * sizeof(u16); 53438c2ecf20Sopenharmony_ci 53448c2ecf20Sopenharmony_ci pdev->pcie_cap = pos; 53458c2ecf20Sopenharmony_ci pci_read_config_word(pdev, pos + PCI_EXP_FLAGS, ®16); 53468c2ecf20Sopenharmony_ci pdev->pcie_flags_reg = reg16; 53478c2ecf20Sopenharmony_ci pci_read_config_word(pdev, pos + PCI_EXP_DEVCAP, ®16); 53488c2ecf20Sopenharmony_ci pdev->pcie_mpss = reg16 & PCI_EXP_DEVCAP_PAYLOAD; 53498c2ecf20Sopenharmony_ci 53508c2ecf20Sopenharmony_ci pdev->cfg_size = PCI_CFG_SPACE_EXP_SIZE; 53518c2ecf20Sopenharmony_ci if (pci_read_config_dword(pdev, PCI_CFG_SPACE_SIZE, &status) != 53528c2ecf20Sopenharmony_ci PCIBIOS_SUCCESSFUL || (status == 0xffffffff)) 53538c2ecf20Sopenharmony_ci pdev->cfg_size = PCI_CFG_SPACE_SIZE; 53548c2ecf20Sopenharmony_ci 53558c2ecf20Sopenharmony_ci if (pci_find_saved_cap(pdev, PCI_CAP_ID_EXP)) 53568c2ecf20Sopenharmony_ci return; 53578c2ecf20Sopenharmony_ci 53588c2ecf20Sopenharmony_ci /* Save PCIe cap */ 53598c2ecf20Sopenharmony_ci state = kzalloc(sizeof(*state) + size, GFP_KERNEL); 53608c2ecf20Sopenharmony_ci if (!state) 53618c2ecf20Sopenharmony_ci return; 53628c2ecf20Sopenharmony_ci 53638c2ecf20Sopenharmony_ci state->cap.cap_nr = PCI_CAP_ID_EXP; 53648c2ecf20Sopenharmony_ci state->cap.cap_extended = 0; 53658c2ecf20Sopenharmony_ci state->cap.size = size; 53668c2ecf20Sopenharmony_ci cap = (u16 *)&state->cap.data[0]; 53678c2ecf20Sopenharmony_ci pcie_capability_read_word(pdev, PCI_EXP_DEVCTL, &cap[i++]); 53688c2ecf20Sopenharmony_ci pcie_capability_read_word(pdev, PCI_EXP_LNKCTL, &cap[i++]); 53698c2ecf20Sopenharmony_ci pcie_capability_read_word(pdev, PCI_EXP_SLTCTL, &cap[i++]); 53708c2ecf20Sopenharmony_ci pcie_capability_read_word(pdev, PCI_EXP_RTCTL, &cap[i++]); 53718c2ecf20Sopenharmony_ci pcie_capability_read_word(pdev, PCI_EXP_DEVCTL2, &cap[i++]); 53728c2ecf20Sopenharmony_ci pcie_capability_read_word(pdev, PCI_EXP_LNKCTL2, &cap[i++]); 53738c2ecf20Sopenharmony_ci pcie_capability_read_word(pdev, PCI_EXP_SLTCTL2, &cap[i++]); 53748c2ecf20Sopenharmony_ci hlist_add_head(&state->next, &pdev->saved_cap_space); 53758c2ecf20Sopenharmony_ci } 53768c2ecf20Sopenharmony_ci} 53778c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x443, quirk_intel_qat_vf_cap); 53788c2ecf20Sopenharmony_ci 53798c2ecf20Sopenharmony_ci/* 53808c2ecf20Sopenharmony_ci * FLR may cause the following to devices to hang: 53818c2ecf20Sopenharmony_ci * 53828c2ecf20Sopenharmony_ci * AMD Starship/Matisse HD Audio Controller 0x1487 53838c2ecf20Sopenharmony_ci * AMD Starship USB 3.0 Host Controller 0x148c 53848c2ecf20Sopenharmony_ci * AMD Matisse USB 3.0 Host Controller 0x149c 53858c2ecf20Sopenharmony_ci * Intel 82579LM Gigabit Ethernet Controller 0x1502 53868c2ecf20Sopenharmony_ci * Intel 82579V Gigabit Ethernet Controller 0x1503 53878c2ecf20Sopenharmony_ci * 53888c2ecf20Sopenharmony_ci */ 53898c2ecf20Sopenharmony_cistatic void quirk_no_flr(struct pci_dev *dev) 53908c2ecf20Sopenharmony_ci{ 53918c2ecf20Sopenharmony_ci dev->dev_flags |= PCI_DEV_FLAGS_NO_FLR_RESET; 53928c2ecf20Sopenharmony_ci} 53938c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_AMD, 0x1487, quirk_no_flr); 53948c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_AMD, 0x148c, quirk_no_flr); 53958c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_AMD, 0x149c, quirk_no_flr); 53968c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_AMD, 0x7901, quirk_no_flr); 53978c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x1502, quirk_no_flr); 53988c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x1503, quirk_no_flr); 53998c2ecf20Sopenharmony_ci 54008c2ecf20Sopenharmony_cistatic void quirk_no_ext_tags(struct pci_dev *pdev) 54018c2ecf20Sopenharmony_ci{ 54028c2ecf20Sopenharmony_ci struct pci_host_bridge *bridge = pci_find_host_bridge(pdev->bus); 54038c2ecf20Sopenharmony_ci 54048c2ecf20Sopenharmony_ci if (!bridge) 54058c2ecf20Sopenharmony_ci return; 54068c2ecf20Sopenharmony_ci 54078c2ecf20Sopenharmony_ci bridge->no_ext_tags = 1; 54088c2ecf20Sopenharmony_ci pci_info(pdev, "disabling Extended Tags (this device can't handle them)\n"); 54098c2ecf20Sopenharmony_ci 54108c2ecf20Sopenharmony_ci pci_walk_bus(bridge->bus, pci_configure_extended_tags, NULL); 54118c2ecf20Sopenharmony_ci} 54128c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SERVERWORKS, 0x0132, quirk_no_ext_tags); 54138c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SERVERWORKS, 0x0140, quirk_no_ext_tags); 54148c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SERVERWORKS, 0x0141, quirk_no_ext_tags); 54158c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SERVERWORKS, 0x0142, quirk_no_ext_tags); 54168c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SERVERWORKS, 0x0144, quirk_no_ext_tags); 54178c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SERVERWORKS, 0x0420, quirk_no_ext_tags); 54188c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SERVERWORKS, 0x0422, quirk_no_ext_tags); 54198c2ecf20Sopenharmony_ci 54208c2ecf20Sopenharmony_ci#ifdef CONFIG_PCI_ATS 54218c2ecf20Sopenharmony_cistatic void quirk_no_ats(struct pci_dev *pdev) 54228c2ecf20Sopenharmony_ci{ 54238c2ecf20Sopenharmony_ci pci_info(pdev, "disabling ATS\n"); 54248c2ecf20Sopenharmony_ci pdev->ats_cap = 0; 54258c2ecf20Sopenharmony_ci} 54268c2ecf20Sopenharmony_ci 54278c2ecf20Sopenharmony_ci/* 54288c2ecf20Sopenharmony_ci * Some devices require additional driver setup to enable ATS. Don't use 54298c2ecf20Sopenharmony_ci * ATS for those devices as ATS will be enabled before the driver has had a 54308c2ecf20Sopenharmony_ci * chance to load and configure the device. 54318c2ecf20Sopenharmony_ci */ 54328c2ecf20Sopenharmony_cistatic void quirk_amd_harvest_no_ats(struct pci_dev *pdev) 54338c2ecf20Sopenharmony_ci{ 54348c2ecf20Sopenharmony_ci if ((pdev->device == 0x7312 && pdev->revision != 0x00) || 54358c2ecf20Sopenharmony_ci (pdev->device == 0x7340 && pdev->revision != 0xc5) || 54368c2ecf20Sopenharmony_ci (pdev->device == 0x7341 && pdev->revision != 0x00)) 54378c2ecf20Sopenharmony_ci return; 54388c2ecf20Sopenharmony_ci 54398c2ecf20Sopenharmony_ci quirk_no_ats(pdev); 54408c2ecf20Sopenharmony_ci} 54418c2ecf20Sopenharmony_ci 54428c2ecf20Sopenharmony_ci/* AMD Stoney platform GPU */ 54438c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x98e4, quirk_amd_harvest_no_ats); 54448c2ecf20Sopenharmony_ci/* AMD Iceland dGPU */ 54458c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x6900, quirk_amd_harvest_no_ats); 54468c2ecf20Sopenharmony_ci/* AMD Navi10 dGPU */ 54478c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x7312, quirk_amd_harvest_no_ats); 54488c2ecf20Sopenharmony_ci/* AMD Navi14 dGPU */ 54498c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x7340, quirk_amd_harvest_no_ats); 54508c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x7341, quirk_amd_harvest_no_ats); 54518c2ecf20Sopenharmony_ci 54528c2ecf20Sopenharmony_ci/* 54538c2ecf20Sopenharmony_ci * Intel IPU E2000 revisions before C0 implement incorrect endianness 54548c2ecf20Sopenharmony_ci * in ATS Invalidate Request message body. Disable ATS for those devices. 54558c2ecf20Sopenharmony_ci */ 54568c2ecf20Sopenharmony_cistatic void quirk_intel_e2000_no_ats(struct pci_dev *pdev) 54578c2ecf20Sopenharmony_ci{ 54588c2ecf20Sopenharmony_ci if (pdev->revision < 0x20) 54598c2ecf20Sopenharmony_ci quirk_no_ats(pdev); 54608c2ecf20Sopenharmony_ci} 54618c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x1451, quirk_intel_e2000_no_ats); 54628c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x1452, quirk_intel_e2000_no_ats); 54638c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x1453, quirk_intel_e2000_no_ats); 54648c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x1454, quirk_intel_e2000_no_ats); 54658c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x1455, quirk_intel_e2000_no_ats); 54668c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x1457, quirk_intel_e2000_no_ats); 54678c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x1459, quirk_intel_e2000_no_ats); 54688c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x145a, quirk_intel_e2000_no_ats); 54698c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x145c, quirk_intel_e2000_no_ats); 54708c2ecf20Sopenharmony_ci#endif /* CONFIG_PCI_ATS */ 54718c2ecf20Sopenharmony_ci 54728c2ecf20Sopenharmony_ci/* Freescale PCIe doesn't support MSI in RC mode */ 54738c2ecf20Sopenharmony_cistatic void quirk_fsl_no_msi(struct pci_dev *pdev) 54748c2ecf20Sopenharmony_ci{ 54758c2ecf20Sopenharmony_ci if (pci_pcie_type(pdev) == PCI_EXP_TYPE_ROOT_PORT) 54768c2ecf20Sopenharmony_ci pdev->no_msi = 1; 54778c2ecf20Sopenharmony_ci} 54788c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_FREESCALE, PCI_ANY_ID, quirk_fsl_no_msi); 54798c2ecf20Sopenharmony_ci 54808c2ecf20Sopenharmony_ci/* 54818c2ecf20Sopenharmony_ci * Although not allowed by the spec, some multi-function devices have 54828c2ecf20Sopenharmony_ci * dependencies of one function (consumer) on another (supplier). For the 54838c2ecf20Sopenharmony_ci * consumer to work in D0, the supplier must also be in D0. Create a 54848c2ecf20Sopenharmony_ci * device link from the consumer to the supplier to enforce this 54858c2ecf20Sopenharmony_ci * dependency. Runtime PM is allowed by default on the consumer to prevent 54868c2ecf20Sopenharmony_ci * it from permanently keeping the supplier awake. 54878c2ecf20Sopenharmony_ci */ 54888c2ecf20Sopenharmony_cistatic void pci_create_device_link(struct pci_dev *pdev, unsigned int consumer, 54898c2ecf20Sopenharmony_ci unsigned int supplier, unsigned int class, 54908c2ecf20Sopenharmony_ci unsigned int class_shift) 54918c2ecf20Sopenharmony_ci{ 54928c2ecf20Sopenharmony_ci struct pci_dev *supplier_pdev; 54938c2ecf20Sopenharmony_ci 54948c2ecf20Sopenharmony_ci if (PCI_FUNC(pdev->devfn) != consumer) 54958c2ecf20Sopenharmony_ci return; 54968c2ecf20Sopenharmony_ci 54978c2ecf20Sopenharmony_ci supplier_pdev = pci_get_domain_bus_and_slot(pci_domain_nr(pdev->bus), 54988c2ecf20Sopenharmony_ci pdev->bus->number, 54998c2ecf20Sopenharmony_ci PCI_DEVFN(PCI_SLOT(pdev->devfn), supplier)); 55008c2ecf20Sopenharmony_ci if (!supplier_pdev || (supplier_pdev->class >> class_shift) != class) { 55018c2ecf20Sopenharmony_ci pci_dev_put(supplier_pdev); 55028c2ecf20Sopenharmony_ci return; 55038c2ecf20Sopenharmony_ci } 55048c2ecf20Sopenharmony_ci 55058c2ecf20Sopenharmony_ci if (device_link_add(&pdev->dev, &supplier_pdev->dev, 55068c2ecf20Sopenharmony_ci DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME)) 55078c2ecf20Sopenharmony_ci pci_info(pdev, "D0 power state depends on %s\n", 55088c2ecf20Sopenharmony_ci pci_name(supplier_pdev)); 55098c2ecf20Sopenharmony_ci else 55108c2ecf20Sopenharmony_ci pci_err(pdev, "Cannot enforce power dependency on %s\n", 55118c2ecf20Sopenharmony_ci pci_name(supplier_pdev)); 55128c2ecf20Sopenharmony_ci 55138c2ecf20Sopenharmony_ci pm_runtime_allow(&pdev->dev); 55148c2ecf20Sopenharmony_ci pci_dev_put(supplier_pdev); 55158c2ecf20Sopenharmony_ci} 55168c2ecf20Sopenharmony_ci 55178c2ecf20Sopenharmony_ci/* 55188c2ecf20Sopenharmony_ci * Create device link for GPUs with integrated HDA controller for streaming 55198c2ecf20Sopenharmony_ci * audio to attached displays. 55208c2ecf20Sopenharmony_ci */ 55218c2ecf20Sopenharmony_cistatic void quirk_gpu_hda(struct pci_dev *hda) 55228c2ecf20Sopenharmony_ci{ 55238c2ecf20Sopenharmony_ci pci_create_device_link(hda, 1, 0, PCI_BASE_CLASS_DISPLAY, 16); 55248c2ecf20Sopenharmony_ci} 55258c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_ATI, PCI_ANY_ID, 55268c2ecf20Sopenharmony_ci PCI_CLASS_MULTIMEDIA_HD_AUDIO, 8, quirk_gpu_hda); 55278c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_AMD, PCI_ANY_ID, 55288c2ecf20Sopenharmony_ci PCI_CLASS_MULTIMEDIA_HD_AUDIO, 8, quirk_gpu_hda); 55298c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID, 55308c2ecf20Sopenharmony_ci PCI_CLASS_MULTIMEDIA_HD_AUDIO, 8, quirk_gpu_hda); 55318c2ecf20Sopenharmony_ci 55328c2ecf20Sopenharmony_ci/* 55338c2ecf20Sopenharmony_ci * Create device link for GPUs with integrated USB xHCI Host 55348c2ecf20Sopenharmony_ci * controller to VGA. 55358c2ecf20Sopenharmony_ci */ 55368c2ecf20Sopenharmony_cistatic void quirk_gpu_usb(struct pci_dev *usb) 55378c2ecf20Sopenharmony_ci{ 55388c2ecf20Sopenharmony_ci pci_create_device_link(usb, 2, 0, PCI_BASE_CLASS_DISPLAY, 16); 55398c2ecf20Sopenharmony_ci} 55408c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID, 55418c2ecf20Sopenharmony_ci PCI_CLASS_SERIAL_USB, 8, quirk_gpu_usb); 55428c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_ATI, PCI_ANY_ID, 55438c2ecf20Sopenharmony_ci PCI_CLASS_SERIAL_USB, 8, quirk_gpu_usb); 55448c2ecf20Sopenharmony_ci 55458c2ecf20Sopenharmony_ci/* 55468c2ecf20Sopenharmony_ci * Create device link for GPUs with integrated Type-C UCSI controller 55478c2ecf20Sopenharmony_ci * to VGA. Currently there is no class code defined for UCSI device over PCI 55488c2ecf20Sopenharmony_ci * so using UNKNOWN class for now and it will be updated when UCSI 55498c2ecf20Sopenharmony_ci * over PCI gets a class code. 55508c2ecf20Sopenharmony_ci */ 55518c2ecf20Sopenharmony_ci#define PCI_CLASS_SERIAL_UNKNOWN 0x0c80 55528c2ecf20Sopenharmony_cistatic void quirk_gpu_usb_typec_ucsi(struct pci_dev *ucsi) 55538c2ecf20Sopenharmony_ci{ 55548c2ecf20Sopenharmony_ci pci_create_device_link(ucsi, 3, 0, PCI_BASE_CLASS_DISPLAY, 16); 55558c2ecf20Sopenharmony_ci} 55568c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID, 55578c2ecf20Sopenharmony_ci PCI_CLASS_SERIAL_UNKNOWN, 8, 55588c2ecf20Sopenharmony_ci quirk_gpu_usb_typec_ucsi); 55598c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_ATI, PCI_ANY_ID, 55608c2ecf20Sopenharmony_ci PCI_CLASS_SERIAL_UNKNOWN, 8, 55618c2ecf20Sopenharmony_ci quirk_gpu_usb_typec_ucsi); 55628c2ecf20Sopenharmony_ci 55638c2ecf20Sopenharmony_ci/* 55648c2ecf20Sopenharmony_ci * Enable the NVIDIA GPU integrated HDA controller if the BIOS left it 55658c2ecf20Sopenharmony_ci * disabled. https://devtalk.nvidia.com/default/topic/1024022 55668c2ecf20Sopenharmony_ci */ 55678c2ecf20Sopenharmony_cistatic void quirk_nvidia_hda(struct pci_dev *gpu) 55688c2ecf20Sopenharmony_ci{ 55698c2ecf20Sopenharmony_ci u8 hdr_type; 55708c2ecf20Sopenharmony_ci u32 val; 55718c2ecf20Sopenharmony_ci 55728c2ecf20Sopenharmony_ci /* There was no integrated HDA controller before MCP89 */ 55738c2ecf20Sopenharmony_ci if (gpu->device < PCI_DEVICE_ID_NVIDIA_GEFORCE_320M) 55748c2ecf20Sopenharmony_ci return; 55758c2ecf20Sopenharmony_ci 55768c2ecf20Sopenharmony_ci /* Bit 25 at offset 0x488 enables the HDA controller */ 55778c2ecf20Sopenharmony_ci pci_read_config_dword(gpu, 0x488, &val); 55788c2ecf20Sopenharmony_ci if (val & BIT(25)) 55798c2ecf20Sopenharmony_ci return; 55808c2ecf20Sopenharmony_ci 55818c2ecf20Sopenharmony_ci pci_info(gpu, "Enabling HDA controller\n"); 55828c2ecf20Sopenharmony_ci pci_write_config_dword(gpu, 0x488, val | BIT(25)); 55838c2ecf20Sopenharmony_ci 55848c2ecf20Sopenharmony_ci /* The GPU becomes a multi-function device when the HDA is enabled */ 55858c2ecf20Sopenharmony_ci pci_read_config_byte(gpu, PCI_HEADER_TYPE, &hdr_type); 55868c2ecf20Sopenharmony_ci gpu->multifunction = !!(hdr_type & 0x80); 55878c2ecf20Sopenharmony_ci} 55888c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_HEADER(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID, 55898c2ecf20Sopenharmony_ci PCI_BASE_CLASS_DISPLAY, 16, quirk_nvidia_hda); 55908c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_RESUME_EARLY(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID, 55918c2ecf20Sopenharmony_ci PCI_BASE_CLASS_DISPLAY, 16, quirk_nvidia_hda); 55928c2ecf20Sopenharmony_ci 55938c2ecf20Sopenharmony_ci/* 55948c2ecf20Sopenharmony_ci * Some IDT switches incorrectly flag an ACS Source Validation error on 55958c2ecf20Sopenharmony_ci * completions for config read requests even though PCIe r4.0, sec 55968c2ecf20Sopenharmony_ci * 6.12.1.1, says that completions are never affected by ACS Source 55978c2ecf20Sopenharmony_ci * Validation. Here's the text of IDT 89H32H8G3-YC, erratum #36: 55988c2ecf20Sopenharmony_ci * 55998c2ecf20Sopenharmony_ci * Item #36 - Downstream port applies ACS Source Validation to Completions 56008c2ecf20Sopenharmony_ci * Section 6.12.1.1 of the PCI Express Base Specification 3.1 states that 56018c2ecf20Sopenharmony_ci * completions are never affected by ACS Source Validation. However, 56028c2ecf20Sopenharmony_ci * completions received by a downstream port of the PCIe switch from a 56038c2ecf20Sopenharmony_ci * device that has not yet captured a PCIe bus number are incorrectly 56048c2ecf20Sopenharmony_ci * dropped by ACS Source Validation by the switch downstream port. 56058c2ecf20Sopenharmony_ci * 56068c2ecf20Sopenharmony_ci * The workaround suggested by IDT is to issue a config write to the 56078c2ecf20Sopenharmony_ci * downstream device before issuing the first config read. This allows the 56088c2ecf20Sopenharmony_ci * downstream device to capture its bus and device numbers (see PCIe r4.0, 56098c2ecf20Sopenharmony_ci * sec 2.2.9), thus avoiding the ACS error on the completion. 56108c2ecf20Sopenharmony_ci * 56118c2ecf20Sopenharmony_ci * However, we don't know when the device is ready to accept the config 56128c2ecf20Sopenharmony_ci * write, so we do config reads until we receive a non-Config Request Retry 56138c2ecf20Sopenharmony_ci * Status, then do the config write. 56148c2ecf20Sopenharmony_ci * 56158c2ecf20Sopenharmony_ci * To avoid hitting the erratum when doing the config reads, we disable ACS 56168c2ecf20Sopenharmony_ci * SV around this process. 56178c2ecf20Sopenharmony_ci */ 56188c2ecf20Sopenharmony_ciint pci_idt_bus_quirk(struct pci_bus *bus, int devfn, u32 *l, int timeout) 56198c2ecf20Sopenharmony_ci{ 56208c2ecf20Sopenharmony_ci int pos; 56218c2ecf20Sopenharmony_ci u16 ctrl = 0; 56228c2ecf20Sopenharmony_ci bool found; 56238c2ecf20Sopenharmony_ci struct pci_dev *bridge = bus->self; 56248c2ecf20Sopenharmony_ci 56258c2ecf20Sopenharmony_ci pos = bridge->acs_cap; 56268c2ecf20Sopenharmony_ci 56278c2ecf20Sopenharmony_ci /* Disable ACS SV before initial config reads */ 56288c2ecf20Sopenharmony_ci if (pos) { 56298c2ecf20Sopenharmony_ci pci_read_config_word(bridge, pos + PCI_ACS_CTRL, &ctrl); 56308c2ecf20Sopenharmony_ci if (ctrl & PCI_ACS_SV) 56318c2ecf20Sopenharmony_ci pci_write_config_word(bridge, pos + PCI_ACS_CTRL, 56328c2ecf20Sopenharmony_ci ctrl & ~PCI_ACS_SV); 56338c2ecf20Sopenharmony_ci } 56348c2ecf20Sopenharmony_ci 56358c2ecf20Sopenharmony_ci found = pci_bus_generic_read_dev_vendor_id(bus, devfn, l, timeout); 56368c2ecf20Sopenharmony_ci 56378c2ecf20Sopenharmony_ci /* Write Vendor ID (read-only) so the endpoint latches its bus/dev */ 56388c2ecf20Sopenharmony_ci if (found) 56398c2ecf20Sopenharmony_ci pci_bus_write_config_word(bus, devfn, PCI_VENDOR_ID, 0); 56408c2ecf20Sopenharmony_ci 56418c2ecf20Sopenharmony_ci /* Re-enable ACS_SV if it was previously enabled */ 56428c2ecf20Sopenharmony_ci if (ctrl & PCI_ACS_SV) 56438c2ecf20Sopenharmony_ci pci_write_config_word(bridge, pos + PCI_ACS_CTRL, ctrl); 56448c2ecf20Sopenharmony_ci 56458c2ecf20Sopenharmony_ci return found; 56468c2ecf20Sopenharmony_ci} 56478c2ecf20Sopenharmony_ci 56488c2ecf20Sopenharmony_ci/* 56498c2ecf20Sopenharmony_ci * Microsemi Switchtec NTB uses devfn proxy IDs to move TLPs between 56508c2ecf20Sopenharmony_ci * NT endpoints via the internal switch fabric. These IDs replace the 56518c2ecf20Sopenharmony_ci * originating requestor ID TLPs which access host memory on peer NTB 56528c2ecf20Sopenharmony_ci * ports. Therefore, all proxy IDs must be aliased to the NTB device 56538c2ecf20Sopenharmony_ci * to permit access when the IOMMU is turned on. 56548c2ecf20Sopenharmony_ci */ 56558c2ecf20Sopenharmony_cistatic void quirk_switchtec_ntb_dma_alias(struct pci_dev *pdev) 56568c2ecf20Sopenharmony_ci{ 56578c2ecf20Sopenharmony_ci void __iomem *mmio; 56588c2ecf20Sopenharmony_ci struct ntb_info_regs __iomem *mmio_ntb; 56598c2ecf20Sopenharmony_ci struct ntb_ctrl_regs __iomem *mmio_ctrl; 56608c2ecf20Sopenharmony_ci u64 partition_map; 56618c2ecf20Sopenharmony_ci u8 partition; 56628c2ecf20Sopenharmony_ci int pp; 56638c2ecf20Sopenharmony_ci 56648c2ecf20Sopenharmony_ci if (pci_enable_device(pdev)) { 56658c2ecf20Sopenharmony_ci pci_err(pdev, "Cannot enable Switchtec device\n"); 56668c2ecf20Sopenharmony_ci return; 56678c2ecf20Sopenharmony_ci } 56688c2ecf20Sopenharmony_ci 56698c2ecf20Sopenharmony_ci mmio = pci_iomap(pdev, 0, 0); 56708c2ecf20Sopenharmony_ci if (mmio == NULL) { 56718c2ecf20Sopenharmony_ci pci_disable_device(pdev); 56728c2ecf20Sopenharmony_ci pci_err(pdev, "Cannot iomap Switchtec device\n"); 56738c2ecf20Sopenharmony_ci return; 56748c2ecf20Sopenharmony_ci } 56758c2ecf20Sopenharmony_ci 56768c2ecf20Sopenharmony_ci pci_info(pdev, "Setting Switchtec proxy ID aliases\n"); 56778c2ecf20Sopenharmony_ci 56788c2ecf20Sopenharmony_ci mmio_ntb = mmio + SWITCHTEC_GAS_NTB_OFFSET; 56798c2ecf20Sopenharmony_ci mmio_ctrl = (void __iomem *) mmio_ntb + SWITCHTEC_NTB_REG_CTRL_OFFSET; 56808c2ecf20Sopenharmony_ci 56818c2ecf20Sopenharmony_ci partition = ioread8(&mmio_ntb->partition_id); 56828c2ecf20Sopenharmony_ci 56838c2ecf20Sopenharmony_ci partition_map = ioread32(&mmio_ntb->ep_map); 56848c2ecf20Sopenharmony_ci partition_map |= ((u64) ioread32(&mmio_ntb->ep_map + 4)) << 32; 56858c2ecf20Sopenharmony_ci partition_map &= ~(1ULL << partition); 56868c2ecf20Sopenharmony_ci 56878c2ecf20Sopenharmony_ci for (pp = 0; pp < (sizeof(partition_map) * 8); pp++) { 56888c2ecf20Sopenharmony_ci struct ntb_ctrl_regs __iomem *mmio_peer_ctrl; 56898c2ecf20Sopenharmony_ci u32 table_sz = 0; 56908c2ecf20Sopenharmony_ci int te; 56918c2ecf20Sopenharmony_ci 56928c2ecf20Sopenharmony_ci if (!(partition_map & (1ULL << pp))) 56938c2ecf20Sopenharmony_ci continue; 56948c2ecf20Sopenharmony_ci 56958c2ecf20Sopenharmony_ci pci_dbg(pdev, "Processing partition %d\n", pp); 56968c2ecf20Sopenharmony_ci 56978c2ecf20Sopenharmony_ci mmio_peer_ctrl = &mmio_ctrl[pp]; 56988c2ecf20Sopenharmony_ci 56998c2ecf20Sopenharmony_ci table_sz = ioread16(&mmio_peer_ctrl->req_id_table_size); 57008c2ecf20Sopenharmony_ci if (!table_sz) { 57018c2ecf20Sopenharmony_ci pci_warn(pdev, "Partition %d table_sz 0\n", pp); 57028c2ecf20Sopenharmony_ci continue; 57038c2ecf20Sopenharmony_ci } 57048c2ecf20Sopenharmony_ci 57058c2ecf20Sopenharmony_ci if (table_sz > 512) { 57068c2ecf20Sopenharmony_ci pci_warn(pdev, 57078c2ecf20Sopenharmony_ci "Invalid Switchtec partition %d table_sz %d\n", 57088c2ecf20Sopenharmony_ci pp, table_sz); 57098c2ecf20Sopenharmony_ci continue; 57108c2ecf20Sopenharmony_ci } 57118c2ecf20Sopenharmony_ci 57128c2ecf20Sopenharmony_ci for (te = 0; te < table_sz; te++) { 57138c2ecf20Sopenharmony_ci u32 rid_entry; 57148c2ecf20Sopenharmony_ci u8 devfn; 57158c2ecf20Sopenharmony_ci 57168c2ecf20Sopenharmony_ci rid_entry = ioread32(&mmio_peer_ctrl->req_id_table[te]); 57178c2ecf20Sopenharmony_ci devfn = (rid_entry >> 1) & 0xFF; 57188c2ecf20Sopenharmony_ci pci_dbg(pdev, 57198c2ecf20Sopenharmony_ci "Aliasing Partition %d Proxy ID %02x.%d\n", 57208c2ecf20Sopenharmony_ci pp, PCI_SLOT(devfn), PCI_FUNC(devfn)); 57218c2ecf20Sopenharmony_ci pci_add_dma_alias(pdev, devfn, 1); 57228c2ecf20Sopenharmony_ci } 57238c2ecf20Sopenharmony_ci } 57248c2ecf20Sopenharmony_ci 57258c2ecf20Sopenharmony_ci pci_iounmap(pdev, mmio); 57268c2ecf20Sopenharmony_ci pci_disable_device(pdev); 57278c2ecf20Sopenharmony_ci} 57288c2ecf20Sopenharmony_ci#define SWITCHTEC_QUIRK(vid) \ 57298c2ecf20Sopenharmony_ci DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_MICROSEMI, vid, \ 57308c2ecf20Sopenharmony_ci PCI_CLASS_BRIDGE_OTHER, 8, quirk_switchtec_ntb_dma_alias) 57318c2ecf20Sopenharmony_ci 57328c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x8531); /* PFX 24xG3 */ 57338c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x8532); /* PFX 32xG3 */ 57348c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x8533); /* PFX 48xG3 */ 57358c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x8534); /* PFX 64xG3 */ 57368c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x8535); /* PFX 80xG3 */ 57378c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x8536); /* PFX 96xG3 */ 57388c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x8541); /* PSX 24xG3 */ 57398c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x8542); /* PSX 32xG3 */ 57408c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x8543); /* PSX 48xG3 */ 57418c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x8544); /* PSX 64xG3 */ 57428c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x8545); /* PSX 80xG3 */ 57438c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x8546); /* PSX 96xG3 */ 57448c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x8551); /* PAX 24XG3 */ 57458c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x8552); /* PAX 32XG3 */ 57468c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x8553); /* PAX 48XG3 */ 57478c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x8554); /* PAX 64XG3 */ 57488c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x8555); /* PAX 80XG3 */ 57498c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x8556); /* PAX 96XG3 */ 57508c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x8561); /* PFXL 24XG3 */ 57518c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x8562); /* PFXL 32XG3 */ 57528c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x8563); /* PFXL 48XG3 */ 57538c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x8564); /* PFXL 64XG3 */ 57548c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x8565); /* PFXL 80XG3 */ 57558c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x8566); /* PFXL 96XG3 */ 57568c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x8571); /* PFXI 24XG3 */ 57578c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x8572); /* PFXI 32XG3 */ 57588c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x8573); /* PFXI 48XG3 */ 57598c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x8574); /* PFXI 64XG3 */ 57608c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x8575); /* PFXI 80XG3 */ 57618c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x8576); /* PFXI 96XG3 */ 57628c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x4000); /* PFX 100XG4 */ 57638c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x4084); /* PFX 84XG4 */ 57648c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x4068); /* PFX 68XG4 */ 57658c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x4052); /* PFX 52XG4 */ 57668c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x4036); /* PFX 36XG4 */ 57678c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x4028); /* PFX 28XG4 */ 57688c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x4100); /* PSX 100XG4 */ 57698c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x4184); /* PSX 84XG4 */ 57708c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x4168); /* PSX 68XG4 */ 57718c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x4152); /* PSX 52XG4 */ 57728c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x4136); /* PSX 36XG4 */ 57738c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x4128); /* PSX 28XG4 */ 57748c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x4200); /* PAX 100XG4 */ 57758c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x4284); /* PAX 84XG4 */ 57768c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x4268); /* PAX 68XG4 */ 57778c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x4252); /* PAX 52XG4 */ 57788c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x4236); /* PAX 36XG4 */ 57798c2ecf20Sopenharmony_ciSWITCHTEC_QUIRK(0x4228); /* PAX 28XG4 */ 57808c2ecf20Sopenharmony_ci 57818c2ecf20Sopenharmony_ci/* 57828c2ecf20Sopenharmony_ci * The PLX NTB uses devfn proxy IDs to move TLPs between NT endpoints. 57838c2ecf20Sopenharmony_ci * These IDs are used to forward responses to the originator on the other 57848c2ecf20Sopenharmony_ci * side of the NTB. Alias all possible IDs to the NTB to permit access when 57858c2ecf20Sopenharmony_ci * the IOMMU is turned on. 57868c2ecf20Sopenharmony_ci */ 57878c2ecf20Sopenharmony_cistatic void quirk_plx_ntb_dma_alias(struct pci_dev *pdev) 57888c2ecf20Sopenharmony_ci{ 57898c2ecf20Sopenharmony_ci pci_info(pdev, "Setting PLX NTB proxy ID aliases\n"); 57908c2ecf20Sopenharmony_ci /* PLX NTB may use all 256 devfns */ 57918c2ecf20Sopenharmony_ci pci_add_dma_alias(pdev, 0, 256); 57928c2ecf20Sopenharmony_ci} 57938c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_PLX, 0x87b0, quirk_plx_ntb_dma_alias); 57948c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_PLX, 0x87b1, quirk_plx_ntb_dma_alias); 57958c2ecf20Sopenharmony_ci 57968c2ecf20Sopenharmony_ci/* 57978c2ecf20Sopenharmony_ci * On Lenovo Thinkpad P50 SKUs with a Nvidia Quadro M1000M, the BIOS does 57988c2ecf20Sopenharmony_ci * not always reset the secondary Nvidia GPU between reboots if the system 57998c2ecf20Sopenharmony_ci * is configured to use Hybrid Graphics mode. This results in the GPU 58008c2ecf20Sopenharmony_ci * being left in whatever state it was in during the *previous* boot, which 58018c2ecf20Sopenharmony_ci * causes spurious interrupts from the GPU, which in turn causes us to 58028c2ecf20Sopenharmony_ci * disable the wrong IRQ and end up breaking the touchpad. Unsurprisingly, 58038c2ecf20Sopenharmony_ci * this also completely breaks nouveau. 58048c2ecf20Sopenharmony_ci * 58058c2ecf20Sopenharmony_ci * Luckily, it seems a simple reset of the Nvidia GPU brings it back to a 58068c2ecf20Sopenharmony_ci * clean state and fixes all these issues. 58078c2ecf20Sopenharmony_ci * 58088c2ecf20Sopenharmony_ci * When the machine is configured in Dedicated display mode, the issue 58098c2ecf20Sopenharmony_ci * doesn't occur. Fortunately the GPU advertises NoReset+ when in this 58108c2ecf20Sopenharmony_ci * mode, so we can detect that and avoid resetting it. 58118c2ecf20Sopenharmony_ci */ 58128c2ecf20Sopenharmony_cistatic void quirk_reset_lenovo_thinkpad_p50_nvgpu(struct pci_dev *pdev) 58138c2ecf20Sopenharmony_ci{ 58148c2ecf20Sopenharmony_ci void __iomem *map; 58158c2ecf20Sopenharmony_ci int ret; 58168c2ecf20Sopenharmony_ci 58178c2ecf20Sopenharmony_ci if (pdev->subsystem_vendor != PCI_VENDOR_ID_LENOVO || 58188c2ecf20Sopenharmony_ci pdev->subsystem_device != 0x222e || 58198c2ecf20Sopenharmony_ci !pdev->reset_fn) 58208c2ecf20Sopenharmony_ci return; 58218c2ecf20Sopenharmony_ci 58228c2ecf20Sopenharmony_ci if (pci_enable_device_mem(pdev)) 58238c2ecf20Sopenharmony_ci return; 58248c2ecf20Sopenharmony_ci 58258c2ecf20Sopenharmony_ci /* 58268c2ecf20Sopenharmony_ci * Based on nvkm_device_ctor() in 58278c2ecf20Sopenharmony_ci * drivers/gpu/drm/nouveau/nvkm/engine/device/base.c 58288c2ecf20Sopenharmony_ci */ 58298c2ecf20Sopenharmony_ci map = pci_iomap(pdev, 0, 0x23000); 58308c2ecf20Sopenharmony_ci if (!map) { 58318c2ecf20Sopenharmony_ci pci_err(pdev, "Can't map MMIO space\n"); 58328c2ecf20Sopenharmony_ci goto out_disable; 58338c2ecf20Sopenharmony_ci } 58348c2ecf20Sopenharmony_ci 58358c2ecf20Sopenharmony_ci /* 58368c2ecf20Sopenharmony_ci * Make sure the GPU looks like it's been POSTed before resetting 58378c2ecf20Sopenharmony_ci * it. 58388c2ecf20Sopenharmony_ci */ 58398c2ecf20Sopenharmony_ci if (ioread32(map + 0x2240c) & 0x2) { 58408c2ecf20Sopenharmony_ci pci_info(pdev, FW_BUG "GPU left initialized by EFI, resetting\n"); 58418c2ecf20Sopenharmony_ci ret = pci_reset_bus(pdev); 58428c2ecf20Sopenharmony_ci if (ret < 0) 58438c2ecf20Sopenharmony_ci pci_err(pdev, "Failed to reset GPU: %d\n", ret); 58448c2ecf20Sopenharmony_ci } 58458c2ecf20Sopenharmony_ci 58468c2ecf20Sopenharmony_ci iounmap(map); 58478c2ecf20Sopenharmony_ciout_disable: 58488c2ecf20Sopenharmony_ci pci_disable_device(pdev); 58498c2ecf20Sopenharmony_ci} 58508c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_FINAL(PCI_VENDOR_ID_NVIDIA, 0x13b1, 58518c2ecf20Sopenharmony_ci PCI_CLASS_DISPLAY_VGA, 8, 58528c2ecf20Sopenharmony_ci quirk_reset_lenovo_thinkpad_p50_nvgpu); 58538c2ecf20Sopenharmony_ci 58548c2ecf20Sopenharmony_ci/* 58558c2ecf20Sopenharmony_ci * Device [1b21:2142] 58568c2ecf20Sopenharmony_ci * When in D0, PME# doesn't get asserted when plugging USB 3.0 device. 58578c2ecf20Sopenharmony_ci */ 58588c2ecf20Sopenharmony_cistatic void pci_fixup_no_d0_pme(struct pci_dev *dev) 58598c2ecf20Sopenharmony_ci{ 58608c2ecf20Sopenharmony_ci pci_info(dev, "PME# does not work under D0, disabling it\n"); 58618c2ecf20Sopenharmony_ci dev->pme_support &= ~(PCI_PM_CAP_PME_D0 >> PCI_PM_CAP_PME_SHIFT); 58628c2ecf20Sopenharmony_ci} 58638c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ASMEDIA, 0x2142, pci_fixup_no_d0_pme); 58648c2ecf20Sopenharmony_ci 58658c2ecf20Sopenharmony_ci/* 58668c2ecf20Sopenharmony_ci * Device 12d8:0x400e [OHCI] and 12d8:0x400f [EHCI] 58678c2ecf20Sopenharmony_ci * 58688c2ecf20Sopenharmony_ci * These devices advertise PME# support in all power states but don't 58698c2ecf20Sopenharmony_ci * reliably assert it. 58708c2ecf20Sopenharmony_ci * 58718c2ecf20Sopenharmony_ci * These devices also advertise MSI, but documentation (PI7C9X440SL.pdf) 58728c2ecf20Sopenharmony_ci * says "The MSI Function is not implemented on this device" in chapters 58738c2ecf20Sopenharmony_ci * 7.3.27, 7.3.29-7.3.31. 58748c2ecf20Sopenharmony_ci */ 58758c2ecf20Sopenharmony_cistatic void pci_fixup_no_msi_no_pme(struct pci_dev *dev) 58768c2ecf20Sopenharmony_ci{ 58778c2ecf20Sopenharmony_ci#ifdef CONFIG_PCI_MSI 58788c2ecf20Sopenharmony_ci pci_info(dev, "MSI is not implemented on this device, disabling it\n"); 58798c2ecf20Sopenharmony_ci dev->no_msi = 1; 58808c2ecf20Sopenharmony_ci#endif 58818c2ecf20Sopenharmony_ci pci_info(dev, "PME# is unreliable, disabling it\n"); 58828c2ecf20Sopenharmony_ci dev->pme_support = 0; 58838c2ecf20Sopenharmony_ci} 58848c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_PERICOM, 0x400e, pci_fixup_no_msi_no_pme); 58858c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_PERICOM, 0x400f, pci_fixup_no_msi_no_pme); 58868c2ecf20Sopenharmony_ci 58878c2ecf20Sopenharmony_cistatic void apex_pci_fixup_class(struct pci_dev *pdev) 58888c2ecf20Sopenharmony_ci{ 58898c2ecf20Sopenharmony_ci pdev->class = (PCI_CLASS_SYSTEM_OTHER << 8) | pdev->class; 58908c2ecf20Sopenharmony_ci} 58918c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_CLASS_HEADER(0x1ac1, 0x089a, 58928c2ecf20Sopenharmony_ci PCI_CLASS_NOT_DEFINED, 8, apex_pci_fixup_class); 58938c2ecf20Sopenharmony_ci 58948c2ecf20Sopenharmony_cistatic void nvidia_ion_ahci_fixup(struct pci_dev *pdev) 58958c2ecf20Sopenharmony_ci{ 58968c2ecf20Sopenharmony_ci pdev->dev_flags |= PCI_DEV_FLAGS_HAS_MSI_MASKING; 58978c2ecf20Sopenharmony_ci} 58988c2ecf20Sopenharmony_ciDECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NVIDIA, 0x0ab8, nvidia_ion_ahci_fixup); 5899