Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / arch / i386 / pci / fixup.c
index 8e8e895..83c3645 100644 (file)
@@ -2,6 +2,8 @@
  * Exceptions for specific devices. Usually work-arounds for fatal design flaws.
  */
 
+#include <linux/delay.h>
+#include <linux/dmi.h>
 #include <linux/pci.h>
 #include <linux/init.h>
 #include "pci.h"
@@ -384,3 +386,82 @@ static void __devinit pci_fixup_video(struct pci_dev *pdev)
        }
 }
 DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, pci_fixup_video);
+
+/*
+ * Some Toshiba laptops need extra code to enable their TI TSB43AB22/A.
+ *
+ * We pretend to bring them out of full D3 state, and restore the proper
+ * IRQ, PCI cache line size, and BARs, otherwise the device won't function
+ * properly.  In some cases, the device will generate an interrupt on
+ * the wrong IRQ line, causing any devices sharing the the line it's
+ * *supposed* to use to be disabled by the kernel's IRQ debug code.
+ */
+static u16 toshiba_line_size;
+
+static struct dmi_system_id __devinitdata toshiba_ohci1394_dmi_table[] = {
+       {
+               .ident = "Toshiba PS5 based laptop",
+               .matches = {
+                       DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
+                       DMI_MATCH(DMI_PRODUCT_VERSION, "PS5"),
+               },
+       },
+       {
+               .ident = "Toshiba PSM4 based laptop",
+               .matches = {
+                       DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
+                       DMI_MATCH(DMI_PRODUCT_VERSION, "PSM4"),
+               },
+       },
+       {
+               .ident = "Toshiba A40 based laptop",
+               .matches = {
+                       DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
+                       DMI_MATCH(DMI_PRODUCT_VERSION, "PSA40U"),
+               },
+       },
+       { }
+};
+
+static void __devinit pci_pre_fixup_toshiba_ohci1394(struct pci_dev *dev)
+{
+       if (!dmi_check_system(toshiba_ohci1394_dmi_table))
+               return; /* only applies to certain Toshibas (so far) */
+
+       dev->current_state = PCI_D3cold;
+       pci_read_config_word(dev, PCI_CACHE_LINE_SIZE, &toshiba_line_size);
+}
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_TI, 0x8032,
+                        pci_pre_fixup_toshiba_ohci1394);
+
+static void __devinit pci_post_fixup_toshiba_ohci1394(struct pci_dev *dev)
+{
+       if (!dmi_check_system(toshiba_ohci1394_dmi_table))
+               return; /* only applies to certain Toshibas (so far) */
+
+       /* Restore config space on Toshiba laptops */
+       pci_write_config_word(dev, PCI_CACHE_LINE_SIZE, toshiba_line_size);
+       pci_read_config_byte(dev, PCI_INTERRUPT_LINE, (u8 *)&dev->irq);
+       pci_write_config_dword(dev, PCI_BASE_ADDRESS_0,
+                              pci_resource_start(dev, 0));
+       pci_write_config_dword(dev, PCI_BASE_ADDRESS_1,
+                              pci_resource_start(dev, 1));
+}
+DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_TI, 0x8032,
+                        pci_post_fixup_toshiba_ohci1394);
+
+
+/*
+ * Prevent the BIOS trapping accesses to the Cyrix CS5530A video device
+ * configuration space.
+ */
+static void __devinit pci_early_fixup_cyrix_5530(struct pci_dev *dev)
+{
+       u8 r;
+       /* clear 'F4 Video Configuration Trap' bit */
+       pci_read_config_byte(dev, 0x42, &r);
+       r &= 0xfd;
+       pci_write_config_byte(dev, 0x42, r);
+}
+DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_CYRIX, PCI_DEVICE_ID_CYRIX_5530_LEGACY,
+                       pci_early_fixup_cyrix_5530);