Andi Kleen | dfa4698 | 2006-09-26 10:52:30 +0200 | [diff] [blame] | 1 | /* Various workarounds for chipset bugs. |
| 2 | This code runs very early and can't use the regular PCI subsystem |
| 3 | The entries are keyed to PCI bridges which usually identify chipsets |
| 4 | uniquely. |
| 5 | This is only for whole classes of chipsets with specific problems which |
| 6 | need early invasive action (e.g. before the timers are initialized). |
| 7 | Most PCI device specific workarounds can be done later and should be |
| 8 | in standard PCI quirks |
| 9 | Mainboard specific bugs should be handled by DMI entries. |
| 10 | CPU specific bugs in setup.c */ |
| 11 | |
| 12 | #include <linux/pci.h> |
| 13 | #include <linux/acpi.h> |
| 14 | #include <linux/pci_ids.h> |
| 15 | #include <asm/pci-direct.h> |
| 16 | #include <asm/proto.h> |
| 17 | #include <asm/dma.h> |
| 18 | |
| 19 | static void via_bugs(void) |
| 20 | { |
| 21 | #ifdef CONFIG_IOMMU |
| 22 | if ((end_pfn > MAX_DMA32_PFN || force_iommu) && |
| 23 | !iommu_aperture_allowed) { |
| 24 | printk(KERN_INFO |
| 25 | "Looks like a VIA chipset. Disabling IOMMU. Override with iommu=allowed\n"); |
| 26 | iommu_aperture_disabled = 1; |
| 27 | } |
| 28 | #endif |
| 29 | } |
| 30 | |
| 31 | #ifdef CONFIG_ACPI |
| 32 | |
Alexey Starikovskiy | 15a58ed | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 33 | static int __init nvidia_hpet_check(struct acpi_table_header *header) |
Andi Kleen | dfa4698 | 2006-09-26 10:52:30 +0200 | [diff] [blame] | 34 | { |
Andi Kleen | dfa4698 | 2006-09-26 10:52:30 +0200 | [diff] [blame] | 35 | return 0; |
| 36 | } |
| 37 | #endif |
| 38 | |
| 39 | static void nvidia_bugs(void) |
| 40 | { |
| 41 | #ifdef CONFIG_ACPI |
| 42 | /* |
| 43 | * All timer overrides on Nvidia are |
| 44 | * wrong unless HPET is enabled. |
Andi Kleen | fa18f47 | 2006-11-14 16:57:46 +0100 | [diff] [blame] | 45 | * Unfortunately that's not true on many Asus boards. |
| 46 | * We don't know yet how to detect this automatically, but |
| 47 | * at least allow a command line override. |
Andi Kleen | dfa4698 | 2006-09-26 10:52:30 +0200 | [diff] [blame] | 48 | */ |
Andi Kleen | fa18f47 | 2006-11-14 16:57:46 +0100 | [diff] [blame] | 49 | if (acpi_use_timer_override) |
| 50 | return; |
| 51 | |
Len Brown | fe69933 | 2007-03-08 18:28:32 -0500 | [diff] [blame^] | 52 | if (acpi_table_parse(ACPI_SIG_HPET, nvidia_hpet_check)) { |
Andi Kleen | dfa4698 | 2006-09-26 10:52:30 +0200 | [diff] [blame] | 53 | acpi_skip_timer_override = 1; |
| 54 | printk(KERN_INFO "Nvidia board " |
| 55 | "detected. Ignoring ACPI " |
| 56 | "timer override.\n"); |
Andi Kleen | fa18f47 | 2006-11-14 16:57:46 +0100 | [diff] [blame] | 57 | printk(KERN_INFO "If you got timer trouble " |
| 58 | "try acpi_use_timer_override\n"); |
Andi Kleen | dfa4698 | 2006-09-26 10:52:30 +0200 | [diff] [blame] | 59 | } |
| 60 | #endif |
| 61 | /* RED-PEN skip them on mptables too? */ |
| 62 | |
| 63 | } |
| 64 | |
| 65 | static void ati_bugs(void) |
| 66 | { |
Linus Torvalds | fea5f1e | 2007-01-08 15:04:46 -0800 | [diff] [blame] | 67 | if (timer_over_8254 == 1) { |
| 68 | timer_over_8254 = 0; |
| 69 | printk(KERN_INFO |
| 70 | "ATI board detected. Disabling timer routing over 8254.\n"); |
| 71 | } |
Andi Kleen | dfa4698 | 2006-09-26 10:52:30 +0200 | [diff] [blame] | 72 | } |
| 73 | |
Siddha, Suresh B | b0d0a4b | 2006-12-07 02:14:10 +0100 | [diff] [blame] | 74 | static void intel_bugs(void) |
| 75 | { |
| 76 | u16 device = read_pci_config_16(0, 0, 0, PCI_DEVICE_ID); |
| 77 | |
| 78 | #ifdef CONFIG_SMP |
| 79 | if (device == PCI_DEVICE_ID_INTEL_E7320_MCH || |
| 80 | device == PCI_DEVICE_ID_INTEL_E7520_MCH || |
| 81 | device == PCI_DEVICE_ID_INTEL_E7525_MCH) |
| 82 | quirk_intel_irqbalance(); |
| 83 | #endif |
| 84 | } |
| 85 | |
Andi Kleen | dfa4698 | 2006-09-26 10:52:30 +0200 | [diff] [blame] | 86 | struct chipset { |
| 87 | u16 vendor; |
| 88 | void (*f)(void); |
| 89 | }; |
| 90 | |
| 91 | static struct chipset early_qrk[] = { |
| 92 | { PCI_VENDOR_ID_NVIDIA, nvidia_bugs }, |
| 93 | { PCI_VENDOR_ID_VIA, via_bugs }, |
| 94 | { PCI_VENDOR_ID_ATI, ati_bugs }, |
Siddha, Suresh B | b0d0a4b | 2006-12-07 02:14:10 +0100 | [diff] [blame] | 95 | { PCI_VENDOR_ID_INTEL, intel_bugs}, |
Andi Kleen | dfa4698 | 2006-09-26 10:52:30 +0200 | [diff] [blame] | 96 | {} |
| 97 | }; |
| 98 | |
| 99 | void __init early_quirks(void) |
| 100 | { |
| 101 | int num, slot, func; |
Andi Kleen | 0637a70 | 2006-09-26 10:52:41 +0200 | [diff] [blame] | 102 | |
| 103 | if (!early_pci_allowed()) |
| 104 | return; |
| 105 | |
Andi Kleen | dfa4698 | 2006-09-26 10:52:30 +0200 | [diff] [blame] | 106 | /* Poor man's PCI discovery */ |
| 107 | for (num = 0; num < 32; num++) { |
| 108 | for (slot = 0; slot < 32; slot++) { |
| 109 | for (func = 0; func < 8; func++) { |
| 110 | u32 class; |
| 111 | u32 vendor; |
| 112 | u8 type; |
| 113 | int i; |
| 114 | class = read_pci_config(num,slot,func, |
| 115 | PCI_CLASS_REVISION); |
| 116 | if (class == 0xffffffff) |
| 117 | break; |
| 118 | |
| 119 | if ((class >> 16) != PCI_CLASS_BRIDGE_PCI) |
| 120 | continue; |
| 121 | |
| 122 | vendor = read_pci_config(num, slot, func, |
| 123 | PCI_VENDOR_ID); |
| 124 | vendor &= 0xffff; |
| 125 | |
| 126 | for (i = 0; early_qrk[i].f; i++) |
| 127 | if (early_qrk[i].vendor == vendor) { |
| 128 | early_qrk[i].f(); |
| 129 | return; |
| 130 | } |
| 131 | |
| 132 | type = read_pci_config_byte(num, slot, func, |
| 133 | PCI_HEADER_TYPE); |
| 134 | if (!(type & 0x80)) |
| 135 | break; |
| 136 | } |
| 137 | } |
| 138 | } |
| 139 | } |