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> |
Yinghai Lu | f2cf8e0 | 2007-07-21 17:11:31 +0200 | [diff] [blame^] | 17 | #include <asm/iommu.h> |
Andi Kleen | dfa4698 | 2006-09-26 10:52:30 +0200 | [diff] [blame] | 18 | #include <asm/dma.h> |
| 19 | |
Sam Ravnborg | 43999d9 | 2007-03-16 21:07:36 +0100 | [diff] [blame] | 20 | static void __init via_bugs(void) |
Andi Kleen | dfa4698 | 2006-09-26 10:52:30 +0200 | [diff] [blame] | 21 | { |
| 22 | #ifdef CONFIG_IOMMU |
| 23 | if ((end_pfn > MAX_DMA32_PFN || force_iommu) && |
| 24 | !iommu_aperture_allowed) { |
| 25 | printk(KERN_INFO |
| 26 | "Looks like a VIA chipset. Disabling IOMMU. Override with iommu=allowed\n"); |
| 27 | iommu_aperture_disabled = 1; |
| 28 | } |
| 29 | #endif |
| 30 | } |
| 31 | |
| 32 | #ifdef CONFIG_ACPI |
| 33 | |
Alexey Starikovskiy | 15a58ed | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 34 | static int __init nvidia_hpet_check(struct acpi_table_header *header) |
Andi Kleen | dfa4698 | 2006-09-26 10:52:30 +0200 | [diff] [blame] | 35 | { |
Andi Kleen | dfa4698 | 2006-09-26 10:52:30 +0200 | [diff] [blame] | 36 | return 0; |
| 37 | } |
| 38 | #endif |
| 39 | |
Sam Ravnborg | 43999d9 | 2007-03-16 21:07:36 +0100 | [diff] [blame] | 40 | static void __init nvidia_bugs(void) |
Andi Kleen | dfa4698 | 2006-09-26 10:52:30 +0200 | [diff] [blame] | 41 | { |
| 42 | #ifdef CONFIG_ACPI |
| 43 | /* |
| 44 | * All timer overrides on Nvidia are |
| 45 | * wrong unless HPET is enabled. |
Andi Kleen | fa18f47 | 2006-11-14 16:57:46 +0100 | [diff] [blame] | 46 | * Unfortunately that's not true on many Asus boards. |
| 47 | * We don't know yet how to detect this automatically, but |
| 48 | * at least allow a command line override. |
Andi Kleen | dfa4698 | 2006-09-26 10:52:30 +0200 | [diff] [blame] | 49 | */ |
Andi Kleen | fa18f47 | 2006-11-14 16:57:46 +0100 | [diff] [blame] | 50 | if (acpi_use_timer_override) |
| 51 | return; |
| 52 | |
Len Brown | fe69933 | 2007-03-08 18:28:32 -0500 | [diff] [blame] | 53 | if (acpi_table_parse(ACPI_SIG_HPET, nvidia_hpet_check)) { |
Andi Kleen | dfa4698 | 2006-09-26 10:52:30 +0200 | [diff] [blame] | 54 | acpi_skip_timer_override = 1; |
| 55 | printk(KERN_INFO "Nvidia board " |
| 56 | "detected. Ignoring ACPI " |
| 57 | "timer override.\n"); |
Andi Kleen | fa18f47 | 2006-11-14 16:57:46 +0100 | [diff] [blame] | 58 | printk(KERN_INFO "If you got timer trouble " |
| 59 | "try acpi_use_timer_override\n"); |
Andi Kleen | dfa4698 | 2006-09-26 10:52:30 +0200 | [diff] [blame] | 60 | } |
| 61 | #endif |
| 62 | /* RED-PEN skip them on mptables too? */ |
| 63 | |
| 64 | } |
| 65 | |
Sam Ravnborg | 43999d9 | 2007-03-16 21:07:36 +0100 | [diff] [blame] | 66 | static void __init ati_bugs(void) |
Andi Kleen | dfa4698 | 2006-09-26 10:52:30 +0200 | [diff] [blame] | 67 | { |
Linus Torvalds | fea5f1e | 2007-01-08 15:04:46 -0800 | [diff] [blame] | 68 | if (timer_over_8254 == 1) { |
| 69 | timer_over_8254 = 0; |
| 70 | printk(KERN_INFO |
| 71 | "ATI board detected. Disabling timer routing over 8254.\n"); |
| 72 | } |
Andi Kleen | dfa4698 | 2006-09-26 10:52:30 +0200 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | struct chipset { |
| 76 | u16 vendor; |
| 77 | void (*f)(void); |
| 78 | }; |
| 79 | |
Andrew Morton | c993c73 | 2007-04-08 16:04:03 -0700 | [diff] [blame] | 80 | static struct chipset early_qrk[] __initdata = { |
Andi Kleen | dfa4698 | 2006-09-26 10:52:30 +0200 | [diff] [blame] | 81 | { PCI_VENDOR_ID_NVIDIA, nvidia_bugs }, |
| 82 | { PCI_VENDOR_ID_VIA, via_bugs }, |
| 83 | { PCI_VENDOR_ID_ATI, ati_bugs }, |
| 84 | {} |
| 85 | }; |
| 86 | |
| 87 | void __init early_quirks(void) |
| 88 | { |
| 89 | int num, slot, func; |
Andi Kleen | 0637a70 | 2006-09-26 10:52:41 +0200 | [diff] [blame] | 90 | |
| 91 | if (!early_pci_allowed()) |
| 92 | return; |
| 93 | |
Andi Kleen | dfa4698 | 2006-09-26 10:52:30 +0200 | [diff] [blame] | 94 | /* Poor man's PCI discovery */ |
| 95 | for (num = 0; num < 32; num++) { |
| 96 | for (slot = 0; slot < 32; slot++) { |
| 97 | for (func = 0; func < 8; func++) { |
| 98 | u32 class; |
| 99 | u32 vendor; |
| 100 | u8 type; |
| 101 | int i; |
| 102 | class = read_pci_config(num,slot,func, |
| 103 | PCI_CLASS_REVISION); |
| 104 | if (class == 0xffffffff) |
| 105 | break; |
| 106 | |
| 107 | if ((class >> 16) != PCI_CLASS_BRIDGE_PCI) |
| 108 | continue; |
| 109 | |
| 110 | vendor = read_pci_config(num, slot, func, |
| 111 | PCI_VENDOR_ID); |
| 112 | vendor &= 0xffff; |
| 113 | |
| 114 | for (i = 0; early_qrk[i].f; i++) |
| 115 | if (early_qrk[i].vendor == vendor) { |
| 116 | early_qrk[i].f(); |
| 117 | return; |
| 118 | } |
| 119 | |
| 120 | type = read_pci_config_byte(num, slot, func, |
| 121 | PCI_HEADER_TYPE); |
| 122 | if (!(type & 0x80)) |
| 123 | break; |
| 124 | } |
| 125 | } |
| 126 | } |
| 127 | } |