diff options
Diffstat (limited to 'drivers/pci/quirks.c')
-rw-r--r-- | drivers/pci/quirks.c | 246 |
1 files changed, 230 insertions, 16 deletions
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index 7cfa7c38d318..3ea0b29c0104 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c | |||
@@ -25,14 +25,9 @@ | |||
25 | #include <linux/dmi.h> | 25 | #include <linux/dmi.h> |
26 | #include <linux/pci-aspm.h> | 26 | #include <linux/pci-aspm.h> |
27 | #include <linux/ioport.h> | 27 | #include <linux/ioport.h> |
28 | #include <asm/dma.h> /* isa_dma_bridge_buggy */ | ||
28 | #include "pci.h" | 29 | #include "pci.h" |
29 | 30 | ||
30 | int isa_dma_bridge_buggy; | ||
31 | EXPORT_SYMBOL(isa_dma_bridge_buggy); | ||
32 | int pci_pci_problems; | ||
33 | EXPORT_SYMBOL(pci_pci_problems); | ||
34 | |||
35 | #ifdef CONFIG_PCI_QUIRKS | ||
36 | /* | 31 | /* |
37 | * This quirk function disables memory decoding and releases memory resources | 32 | * This quirk function disables memory decoding and releases memory resources |
38 | * of the device specified by kernel's boot parameter 'pci=resource_alignment='. | 33 | * of the device specified by kernel's boot parameter 'pci=resource_alignment='. |
@@ -338,6 +333,23 @@ static void __devinit quirk_s3_64M(struct pci_dev *dev) | |||
338 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_S3, PCI_DEVICE_ID_S3_868, quirk_s3_64M); | 333 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_S3, PCI_DEVICE_ID_S3_868, quirk_s3_64M); |
339 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_S3, PCI_DEVICE_ID_S3_968, quirk_s3_64M); | 334 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_S3, PCI_DEVICE_ID_S3_968, quirk_s3_64M); |
340 | 335 | ||
336 | /* | ||
337 | * Some CS5536 BIOSes (for example, the Soekris NET5501 board w/ comBIOS | ||
338 | * ver. 1.33 20070103) don't set the correct ISA PCI region header info. | ||
339 | * BAR0 should be 8 bytes; instead, it may be set to something like 8k | ||
340 | * (which conflicts w/ BAR1's memory range). | ||
341 | */ | ||
342 | static void __devinit quirk_cs5536_vsa(struct pci_dev *dev) | ||
343 | { | ||
344 | if (pci_resource_len(dev, 0) != 8) { | ||
345 | struct resource *res = &dev->resource[0]; | ||
346 | res->end = res->start + 8 - 1; | ||
347 | dev_info(&dev->dev, "CS5536 ISA bridge bug detected " | ||
348 | "(incorrect header); workaround applied.\n"); | ||
349 | } | ||
350 | } | ||
351 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_ISA, quirk_cs5536_vsa); | ||
352 | |||
341 | static void __devinit quirk_io_region(struct pci_dev *dev, unsigned region, | 353 | static void __devinit quirk_io_region(struct pci_dev *dev, unsigned region, |
342 | unsigned size, int nr, const char *name) | 354 | unsigned size, int nr, const char *name) |
343 | { | 355 | { |
@@ -356,8 +368,9 @@ static void __devinit quirk_io_region(struct pci_dev *dev, unsigned region, | |||
356 | bus_region.end = res->end; | 368 | bus_region.end = res->end; |
357 | pcibios_bus_to_resource(dev, res, &bus_region); | 369 | pcibios_bus_to_resource(dev, res, &bus_region); |
358 | 370 | ||
359 | pci_claim_resource(dev, nr); | 371 | if (pci_claim_resource(dev, nr) == 0) |
360 | dev_info(&dev->dev, "quirk: %pR claimed by %s\n", res, name); | 372 | dev_info(&dev->dev, "quirk: %pR claimed by %s\n", |
373 | res, name); | ||
361 | } | 374 | } |
362 | } | 375 | } |
363 | 376 | ||
@@ -1965,11 +1978,25 @@ static void __devinit quirk_via_cx700_pci_parking_caching(struct pci_dev *dev) | |||
1965 | /* | 1978 | /* |
1966 | * Disable PCI Bus Parking and PCI Master read caching on CX700 | 1979 | * Disable PCI Bus Parking and PCI Master read caching on CX700 |
1967 | * which causes unspecified timing errors with a VT6212L on the PCI | 1980 | * which causes unspecified timing errors with a VT6212L on the PCI |
1968 | * bus leading to USB2.0 packet loss. The defaults are that these | 1981 | * bus leading to USB2.0 packet loss. |
1969 | * features are turned off but some BIOSes turn them on. | 1982 | * |
1983 | * This quirk is only enabled if a second (on the external PCI bus) | ||
1984 | * VT6212L is found -- the CX700 core itself also contains a USB | ||
1985 | * host controller with the same PCI ID as the VT6212L. | ||
1970 | */ | 1986 | */ |
1971 | 1987 | ||
1988 | /* Count VT6212L instances */ | ||
1989 | struct pci_dev *p = pci_get_device(PCI_VENDOR_ID_VIA, | ||
1990 | PCI_DEVICE_ID_VIA_8235_USB_2, NULL); | ||
1972 | uint8_t b; | 1991 | uint8_t b; |
1992 | |||
1993 | /* p should contain the first (internal) VT6212L -- see if we have | ||
1994 | an external one by searching again */ | ||
1995 | p = pci_get_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8235_USB_2, p); | ||
1996 | if (!p) | ||
1997 | return; | ||
1998 | pci_dev_put(p); | ||
1999 | |||
1973 | if (pci_read_config_byte(dev, 0x76, &b) == 0) { | 2000 | if (pci_read_config_byte(dev, 0x76, &b) == 0) { |
1974 | if (b & 0x40) { | 2001 | if (b & 0x40) { |
1975 | /* Turn off PCI Bus Parking */ | 2002 | /* Turn off PCI Bus Parking */ |
@@ -1996,7 +2023,7 @@ static void __devinit quirk_via_cx700_pci_parking_caching(struct pci_dev *dev) | |||
1996 | } | 2023 | } |
1997 | } | 2024 | } |
1998 | } | 2025 | } |
1999 | DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_VIA, 0x324e, quirk_via_cx700_pci_parking_caching); | 2026 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, 0x324e, quirk_via_cx700_pci_parking_caching); |
2000 | 2027 | ||
2001 | /* | 2028 | /* |
2002 | * For Broadcom 5706, 5708, 5709 rev. A nics, any read beyond the | 2029 | * For Broadcom 5706, 5708, 5709 rev. A nics, any read beyond the |
@@ -2096,6 +2123,7 @@ static void __devinit quirk_disable_msi(struct pci_dev *dev) | |||
2096 | } | 2123 | } |
2097 | } | 2124 | } |
2098 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8131_BRIDGE, quirk_disable_msi); | 2125 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8131_BRIDGE, quirk_disable_msi); |
2126 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, 0xa238, quirk_disable_msi); | ||
2099 | 2127 | ||
2100 | /* Go through the list of Hypertransport capabilities and | 2128 | /* Go through the list of Hypertransport capabilities and |
2101 | * return 1 if a HT MSI capability is found and enabled */ | 2129 | * return 1 if a HT MSI capability is found and enabled */ |
@@ -2467,6 +2495,39 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x4374, | |||
2467 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x4375, | 2495 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x4375, |
2468 | quirk_msi_intx_disable_bug); | 2496 | quirk_msi_intx_disable_bug); |
2469 | 2497 | ||
2498 | /* | ||
2499 | * MSI does not work with the AMD RS780/RS880 internal graphics and HDMI audio | ||
2500 | * devices unless the BIOS has initialized the nb_cntl.strap_msi_enable bit. | ||
2501 | */ | ||
2502 | static void __init rs780_int_gfx_disable_msi(struct pci_dev *int_gfx_bridge) | ||
2503 | { | ||
2504 | u32 nb_cntl; | ||
2505 | |||
2506 | if (!int_gfx_bridge->subordinate) | ||
2507 | return; | ||
2508 | |||
2509 | pci_bus_write_config_dword(int_gfx_bridge->bus, PCI_DEVFN(0, 0), | ||
2510 | 0x60, 0); | ||
2511 | pci_bus_read_config_dword(int_gfx_bridge->bus, PCI_DEVFN(0, 0), | ||
2512 | 0x64, &nb_cntl); | ||
2513 | |||
2514 | if (!(nb_cntl & BIT(10))) { | ||
2515 | dev_warn(&int_gfx_bridge->dev, | ||
2516 | FW_WARN "RS780: MSI for internal graphics disabled\n"); | ||
2517 | int_gfx_bridge->subordinate->bus_flags |= PCI_BUS_FLAGS_NO_MSI; | ||
2518 | } | ||
2519 | } | ||
2520 | |||
2521 | #define PCI_DEVICE_ID_AMD_RS780_P2P_INT_GFX 0x9602 | ||
2522 | |||
2523 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, | ||
2524 | PCI_DEVICE_ID_AMD_RS780_P2P_INT_GFX, | ||
2525 | rs780_int_gfx_disable_msi); | ||
2526 | /* wrong vendor ID on M4A785TD motherboard: */ | ||
2527 | DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ASUSTEK, | ||
2528 | PCI_DEVICE_ID_AMD_RS780_P2P_INT_GFX, | ||
2529 | rs780_int_gfx_disable_msi); | ||
2530 | |||
2470 | #endif /* CONFIG_PCI_MSI */ | 2531 | #endif /* CONFIG_PCI_MSI */ |
2471 | 2532 | ||
2472 | #ifdef CONFIG_PCI_IOV | 2533 | #ifdef CONFIG_PCI_IOV |
@@ -2517,9 +2578,95 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x10e7, quirk_i82576_sriov); | |||
2517 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x10e8, quirk_i82576_sriov); | 2578 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x10e8, quirk_i82576_sriov); |
2518 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x150a, quirk_i82576_sriov); | 2579 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x150a, quirk_i82576_sriov); |
2519 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x150d, quirk_i82576_sriov); | 2580 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x150d, quirk_i82576_sriov); |
2581 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x1518, quirk_i82576_sriov); | ||
2520 | 2582 | ||
2521 | #endif /* CONFIG_PCI_IOV */ | 2583 | #endif /* CONFIG_PCI_IOV */ |
2522 | 2584 | ||
2585 | /* | ||
2586 | * This is a quirk for the Ricoh MMC controller found as a part of | ||
2587 | * some mulifunction chips. | ||
2588 | |||
2589 | * This is very similiar and based on the ricoh_mmc driver written by | ||
2590 | * Philip Langdale. Thank you for these magic sequences. | ||
2591 | * | ||
2592 | * These chips implement the four main memory card controllers (SD, MMC, MS, xD) | ||
2593 | * and one or both of cardbus or firewire. | ||
2594 | * | ||
2595 | * It happens that they implement SD and MMC | ||
2596 | * support as separate controllers (and PCI functions). The linux SDHCI | ||
2597 | * driver supports MMC cards but the chip detects MMC cards in hardware | ||
2598 | * and directs them to the MMC controller - so the SDHCI driver never sees | ||
2599 | * them. | ||
2600 | * | ||
2601 | * To get around this, we must disable the useless MMC controller. | ||
2602 | * At that point, the SDHCI controller will start seeing them | ||
2603 | * It seems to be the case that the relevant PCI registers to deactivate the | ||
2604 | * MMC controller live on PCI function 0, which might be the cardbus controller | ||
2605 | * or the firewire controller, depending on the particular chip in question | ||
2606 | * | ||
2607 | * This has to be done early, because as soon as we disable the MMC controller | ||
2608 | * other pci functions shift up one level, e.g. function #2 becomes function | ||
2609 | * #1, and this will confuse the pci core. | ||
2610 | */ | ||
2611 | |||
2612 | #ifdef CONFIG_MMC_RICOH_MMC | ||
2613 | static void ricoh_mmc_fixup_rl5c476(struct pci_dev *dev) | ||
2614 | { | ||
2615 | /* disable via cardbus interface */ | ||
2616 | u8 write_enable; | ||
2617 | u8 write_target; | ||
2618 | u8 disable; | ||
2619 | |||
2620 | /* disable must be done via function #0 */ | ||
2621 | if (PCI_FUNC(dev->devfn)) | ||
2622 | return; | ||
2623 | |||
2624 | pci_read_config_byte(dev, 0xB7, &disable); | ||
2625 | if (disable & 0x02) | ||
2626 | return; | ||
2627 | |||
2628 | pci_read_config_byte(dev, 0x8E, &write_enable); | ||
2629 | pci_write_config_byte(dev, 0x8E, 0xAA); | ||
2630 | pci_read_config_byte(dev, 0x8D, &write_target); | ||
2631 | pci_write_config_byte(dev, 0x8D, 0xB7); | ||
2632 | pci_write_config_byte(dev, 0xB7, disable | 0x02); | ||
2633 | pci_write_config_byte(dev, 0x8E, write_enable); | ||
2634 | pci_write_config_byte(dev, 0x8D, write_target); | ||
2635 | |||
2636 | dev_notice(&dev->dev, "proprietary Ricoh MMC controller disabled (via cardbus function)\n"); | ||
2637 | dev_notice(&dev->dev, "MMC cards are now supported by standard SDHCI controller\n"); | ||
2638 | } | ||
2639 | DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C476, ricoh_mmc_fixup_rl5c476); | ||
2640 | DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C476, ricoh_mmc_fixup_rl5c476); | ||
2641 | |||
2642 | static void ricoh_mmc_fixup_r5c832(struct pci_dev *dev) | ||
2643 | { | ||
2644 | /* disable via firewire interface */ | ||
2645 | u8 write_enable; | ||
2646 | u8 disable; | ||
2647 | |||
2648 | /* disable must be done via function #0 */ | ||
2649 | if (PCI_FUNC(dev->devfn)) | ||
2650 | return; | ||
2651 | |||
2652 | pci_read_config_byte(dev, 0xCB, &disable); | ||
2653 | |||
2654 | if (disable & 0x02) | ||
2655 | return; | ||
2656 | |||
2657 | pci_read_config_byte(dev, 0xCA, &write_enable); | ||
2658 | pci_write_config_byte(dev, 0xCA, 0x57); | ||
2659 | pci_write_config_byte(dev, 0xCB, disable | 0x02); | ||
2660 | pci_write_config_byte(dev, 0xCA, write_enable); | ||
2661 | |||
2662 | dev_notice(&dev->dev, "proprietary Ricoh MMC controller disabled (via firewire function)\n"); | ||
2663 | dev_notice(&dev->dev, "MMC cards are now supported by standard SDHCI controller\n"); | ||
2664 | } | ||
2665 | DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_R5C832, ricoh_mmc_fixup_r5c832); | ||
2666 | DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_R5C832, ricoh_mmc_fixup_r5c832); | ||
2667 | #endif /*CONFIG_MMC_RICOH_MMC*/ | ||
2668 | |||
2669 | |||
2523 | static void pci_do_fixups(struct pci_dev *dev, struct pci_fixup *f, | 2670 | static void pci_do_fixups(struct pci_dev *dev, struct pci_fixup *f, |
2524 | struct pci_fixup *end) | 2671 | struct pci_fixup *end) |
2525 | { | 2672 | { |
@@ -2595,6 +2742,7 @@ void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev) | |||
2595 | } | 2742 | } |
2596 | pci_do_fixups(dev, start, end); | 2743 | pci_do_fixups(dev, start, end); |
2597 | } | 2744 | } |
2745 | EXPORT_SYMBOL(pci_fixup_device); | ||
2598 | 2746 | ||
2599 | static int __init pci_apply_final_quirks(void) | 2747 | static int __init pci_apply_final_quirks(void) |
2600 | { | 2748 | { |
@@ -2629,14 +2777,80 @@ static int __init pci_apply_final_quirks(void) | |||
2629 | if (!pci_cache_line_size) { | 2777 | if (!pci_cache_line_size) { |
2630 | printk(KERN_DEBUG "PCI: CLS %u bytes, default %u\n", | 2778 | printk(KERN_DEBUG "PCI: CLS %u bytes, default %u\n", |
2631 | cls << 2, pci_dfl_cache_line_size << 2); | 2779 | cls << 2, pci_dfl_cache_line_size << 2); |
2632 | pci_cache_line_size = cls; | 2780 | pci_cache_line_size = cls ? cls : pci_dfl_cache_line_size; |
2633 | } | 2781 | } |
2634 | 2782 | ||
2635 | return 0; | 2783 | return 0; |
2636 | } | 2784 | } |
2637 | 2785 | ||
2638 | fs_initcall_sync(pci_apply_final_quirks); | 2786 | fs_initcall_sync(pci_apply_final_quirks); |
2639 | #else | 2787 | |
2640 | void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev) {} | 2788 | /* |
2641 | #endif | 2789 | * Followings are device-specific reset methods which can be used to |
2642 | EXPORT_SYMBOL(pci_fixup_device); | 2790 | * reset a single function if other methods (e.g. FLR, PM D0->D3) are |
2791 | * not available. | ||
2792 | */ | ||
2793 | static int reset_intel_generic_dev(struct pci_dev *dev, int probe) | ||
2794 | { | ||
2795 | int pos; | ||
2796 | |||
2797 | /* only implement PCI_CLASS_SERIAL_USB at present */ | ||
2798 | if (dev->class == PCI_CLASS_SERIAL_USB) { | ||
2799 | pos = pci_find_capability(dev, PCI_CAP_ID_VNDR); | ||
2800 | if (!pos) | ||
2801 | return -ENOTTY; | ||
2802 | |||
2803 | if (probe) | ||
2804 | return 0; | ||
2805 | |||
2806 | pci_write_config_byte(dev, pos + 0x4, 1); | ||
2807 | msleep(100); | ||
2808 | |||
2809 | return 0; | ||
2810 | } else { | ||
2811 | return -ENOTTY; | ||
2812 | } | ||
2813 | } | ||
2814 | |||
2815 | static int reset_intel_82599_sfp_virtfn(struct pci_dev *dev, int probe) | ||
2816 | { | ||
2817 | int pos; | ||
2818 | |||
2819 | pos = pci_find_capability(dev, PCI_CAP_ID_EXP); | ||
2820 | if (!pos) | ||
2821 | return -ENOTTY; | ||
2822 | |||
2823 | if (probe) | ||
2824 | return 0; | ||
2825 | |||
2826 | pci_write_config_word(dev, pos + PCI_EXP_DEVCTL, | ||
2827 | PCI_EXP_DEVCTL_BCR_FLR); | ||
2828 | msleep(100); | ||
2829 | |||
2830 | return 0; | ||
2831 | } | ||
2832 | |||
2833 | #define PCI_DEVICE_ID_INTEL_82599_SFP_VF 0x10ed | ||
2834 | |||
2835 | static const struct pci_dev_reset_methods pci_dev_reset_methods[] = { | ||
2836 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82599_SFP_VF, | ||
2837 | reset_intel_82599_sfp_virtfn }, | ||
2838 | { PCI_VENDOR_ID_INTEL, PCI_ANY_ID, | ||
2839 | reset_intel_generic_dev }, | ||
2840 | { 0 } | ||
2841 | }; | ||
2842 | |||
2843 | int pci_dev_specific_reset(struct pci_dev *dev, int probe) | ||
2844 | { | ||
2845 | const struct pci_dev_reset_methods *i; | ||
2846 | |||
2847 | for (i = pci_dev_reset_methods; i->reset; i++) { | ||
2848 | if ((i->vendor == dev->vendor || | ||
2849 | i->vendor == (u16)PCI_ANY_ID) && | ||
2850 | (i->device == dev->device || | ||
2851 | i->device == (u16)PCI_ANY_ID)) | ||
2852 | return i->reset(dev, probe); | ||
2853 | } | ||
2854 | |||
2855 | return -ENOTTY; | ||
2856 | } | ||