Merge branch 'linus' into perf/core
[safe/jmp/linux-2.6] / arch / x86 / kernel / early-quirks.c
index 24bb5fa..ebdb85c 100644 (file)
@@ -17,6 +17,7 @@
 #include <asm/io_apic.h>
 #include <asm/apic.h>
 #include <asm/iommu.h>
+#include <asm/gart.h>
 
 static void __init fix_hypertransport_config(int num, int slot, int func)
 {
@@ -95,17 +96,98 @@ static void __init nvidia_bugs(int num, int slot, int func)
 
 }
 
-#ifdef CONFIG_DMAR
-static void __init intel_g33_dmar(int num, int slot, int func)
+#if defined(CONFIG_ACPI) && defined(CONFIG_X86_IO_APIC)
+#if defined(CONFIG_ACPI) && defined(CONFIG_X86_IO_APIC)
+static u32 __init ati_ixp4x0_rev(int num, int slot, int func)
 {
-       struct acpi_table_header *dmar_tbl;
-       acpi_status status;
+       u32 d;
+       u8  b;
 
-       status = acpi_get_table(ACPI_SIG_DMAR, 0, &dmar_tbl);
-       if (ACPI_SUCCESS(status)) {
-               printk(KERN_INFO "BIOS BUG: DMAR advertised on Intel G31/G33 chipset -- ignoring\n");
-               dmar_disabled = 1;
+       b = read_pci_config_byte(num, slot, func, 0xac);
+       b &= ~(1<<5);
+       write_pci_config_byte(num, slot, func, 0xac, b);
+
+       d = read_pci_config(num, slot, func, 0x70);
+       d |= 1<<8;
+       write_pci_config(num, slot, func, 0x70, d);
+
+       d = read_pci_config(num, slot, func, 0x8);
+       d &= 0xff;
+       return d;
+}
+#endif
+
+static void __init ati_bugs(int num, int slot, int func)
+{
+       u32 d;
+       u8  b;
+
+       if (acpi_use_timer_override)
+               return;
+
+       d = ati_ixp4x0_rev(num, slot, func);
+       if (d  < 0x82)
+               acpi_skip_timer_override = 1;
+       else {
+               /* check for IRQ0 interrupt swap */
+               outb(0x72, 0xcd6); b = inb(0xcd7);
+               if (!(b & 0x2))
+                       acpi_skip_timer_override = 1;
        }
+
+       if (acpi_skip_timer_override) {
+               printk(KERN_INFO "SB4X0 revision 0x%x\n", d);
+               printk(KERN_INFO "Ignoring ACPI timer override.\n");
+               printk(KERN_INFO "If you got timer trouble "
+                      "try acpi_use_timer_override\n");
+       }
+}
+
+static u32 __init ati_sbx00_rev(int num, int slot, int func)
+{
+       u32 old, d;
+
+       d = read_pci_config(num, slot, func, 0x70);
+       old = d;
+       d &= ~(1<<8);
+       write_pci_config(num, slot, func, 0x70, d);
+       d = read_pci_config(num, slot, func, 0x8);
+       d &= 0xff;
+       write_pci_config(num, slot, func, 0x70, old);
+
+       return d;
+}
+
+static void __init ati_bugs_contd(int num, int slot, int func)
+{
+       u32 d, rev;
+
+       if (acpi_use_timer_override)
+               return;
+
+       rev = ati_sbx00_rev(num, slot, func);
+       if (rev > 0x13)
+               return;
+
+       /* check for IRQ0 interrupt swap */
+       d = read_pci_config(num, slot, func, 0x64);
+       if (!(d & (1<<14)))
+               acpi_skip_timer_override = 1;
+
+       if (acpi_skip_timer_override) {
+               printk(KERN_INFO "SB600 revision 0x%x\n", rev);
+               printk(KERN_INFO "Ignoring ACPI timer override.\n");
+               printk(KERN_INFO "If you got timer trouble "
+                      "try acpi_use_timer_override\n");
+       }
+}
+#else
+static void __init ati_bugs(int num, int slot, int func)
+{
+}
+
+static void __init ati_bugs_contd(int num, int slot, int func)
+{
 }
 #endif
 
@@ -121,6 +203,12 @@ struct chipset {
        void (*f)(int num, int slot, int func);
 };
 
+/*
+ * Only works for devices on the root bus. If you add any devices
+ * not on bus 0 readd another loop level in early_quirks(). But
+ * be careful because at least the Nvidia quirk here relies on
+ * only matching on bus 0.
+ */
 static struct chipset early_qrk[] __initdata = {
        { PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID,
          PCI_CLASS_BRIDGE_PCI, PCI_ANY_ID, QFLAG_APPLY_ONCE, nvidia_bugs },
@@ -128,10 +216,10 @@ static struct chipset early_qrk[] __initdata = {
          PCI_CLASS_BRIDGE_PCI, PCI_ANY_ID, QFLAG_APPLY_ONCE, via_bugs },
        { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_K8_NB,
          PCI_CLASS_BRIDGE_HOST, PCI_ANY_ID, 0, fix_hypertransport_config },
-#ifdef CONFIG_DMAR
-       { PCI_VENDOR_ID_INTEL, 0x29c0,
-         PCI_CLASS_BRIDGE_HOST, PCI_ANY_ID, 0, intel_g33_dmar },
-#endif
+       { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP400_SMBUS,
+         PCI_CLASS_SERIAL_SMBUS, PCI_ANY_ID, 0, ati_bugs },
+       { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_SBX00_SMBUS,
+         PCI_CLASS_SERIAL_SMBUS, PCI_ANY_ID, 0, ati_bugs_contd },
        {}
 };
 
@@ -187,17 +275,17 @@ static int __init check_dev_quirk(int num, int slot, int func)
 
 void __init early_quirks(void)
 {
-       int num, slot, func;
+       int slot, func;
 
        if (!early_pci_allowed())
                return;
 
        /* Poor man's PCI discovery */
-       for (num = 0; num < 32; num++)
-               for (slot = 0; slot < 32; slot++)
-                       for (func = 0; func < 8; func++) {
-                               /* Only probe function 0 on single fn devices */
-                               if (check_dev_quirk(num, slot, func))
-                                       break;
-                       }
+       /* Only scan the root bus */
+       for (slot = 0; slot < 32; slot++)
+               for (func = 0; func < 8; func++) {
+                       /* Only probe function 0 on single fn devices */
+                       if (check_dev_quirk(0, slot, func))
+                               break;
+               }
 }