📄 fixup.c
字号:
* with the modified one. */static void pcie_rootport_aspm_quirk(struct pci_dev *pdev){ int cap_base, i; struct pci_bus *pbus; struct pci_dev *dev; if ((pbus = pdev->subordinate) == NULL) return; /* * Check if the DID of pdev matches one of the six root ports. This * check is needed in the case this function is called directly by the * hot-plug driver. */ if ((pdev->device < PCI_DEVICE_ID_INTEL_MCH_PA) || (pdev->device > PCI_DEVICE_ID_INTEL_MCH_PC1)) return; if (list_empty(&pbus->devices)) { /* * If no device is attached to the root port at power-up or * after hot-remove, the pbus->devices is empty and this code * will set the offsets to zero and the bus ops to parent's bus * ops, which is unmodified. */ for (i= GET_INDEX(pdev->device, 0); i <= GET_INDEX(pdev->device, 7); ++i) quirk_aspm_offset[i] = 0; pbus->ops = pbus->parent->ops; } else { /* * If devices are attached to the root port at power-up or * after hot-add, the code loops through the device list of * each root port to save the register offsets and replace the * bus ops. */ list_for_each_entry(dev, &pbus->devices, bus_list) { /* There are 0 to 8 devices attached to this bus */ cap_base = pci_find_capability(dev, PCI_CAP_ID_EXP); quirk_aspm_offset[GET_INDEX(pdev->device, dev->devfn)]= cap_base + 0x10; } pbus->ops = &quirk_pcie_aspm_ops; }}DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_MCH_PA, pcie_rootport_aspm_quirk );DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_MCH_PA1, pcie_rootport_aspm_quirk );DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_MCH_PB, pcie_rootport_aspm_quirk );DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_MCH_PB1, pcie_rootport_aspm_quirk );DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_MCH_PC, pcie_rootport_aspm_quirk );DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_MCH_PC1, pcie_rootport_aspm_quirk );/* * Fixup to mark boot BIOS video selected by BIOS before it changes * * From information provided by "Jon Smirl" <jonsmirl@gmail.com> * * The standard boot ROM sequence for an x86 machine uses the BIOS * to select an initial video card for boot display. This boot video * card will have it's BIOS copied to C0000 in system RAM. * IORESOURCE_ROM_SHADOW is used to associate the boot video * card with this copy. On laptops this copy has to be used since * the main ROM may be compressed or combined with another image. * See pci_map_rom() for use of this flag. IORESOURCE_ROM_SHADOW * is marked here since the boot video device will be the only enabled * video device at this point. */static void __devinit pci_fixup_video(struct pci_dev *pdev){ struct pci_dev *bridge; struct pci_bus *bus; u16 config; if ((pdev->class >> 8) != PCI_CLASS_DISPLAY_VGA) return; /* Is VGA routed to us? */ bus = pdev->bus; while (bus) { bridge = bus->self; /* * From information provided by * "David Miller" <davem@davemloft.net> * The bridge control register is valid for PCI header * type BRIDGE, or CARDBUS. Host to PCI controllers use * PCI header type NORMAL. */ if (bridge &&((bridge->hdr_type == PCI_HEADER_TYPE_BRIDGE) ||(bridge->hdr_type == PCI_HEADER_TYPE_CARDBUS))) { pci_read_config_word(bridge, PCI_BRIDGE_CONTROL, &config); if (!(config & PCI_BRIDGE_CTL_VGA)) return; } bus = bus->parent; } pci_read_config_word(pdev, PCI_COMMAND, &config); if (config & (PCI_COMMAND_IO | PCI_COMMAND_MEMORY)) { pdev->resource[PCI_ROM_RESOURCE].flags |= IORESOURCE_ROM_SHADOW; printk(KERN_DEBUG "Boot video device is %s\n", pci_name(pdev)); }}DECLARE_PCI_FIXUP_FINAL(PCI_ANY_ID, PCI_ANY_ID, pci_fixup_video);static struct dmi_system_id __devinitdata msi_k8t_dmi_table[] = { { .ident = "MSI-K8T-Neo2Fir", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "MSI"), DMI_MATCH(DMI_PRODUCT_NAME, "MS-6702E"), }, }, {}};/* * The AMD-Athlon64 board MSI "K8T Neo2-FIR" disables the onboard sound * card if a PCI-soundcard is added. * * The BIOS only gives options "DISABLED" and "AUTO". This code sets * the corresponding register-value to enable the soundcard. * * The soundcard is only enabled, if the mainborad is identified * via DMI-tables and the soundcard is detected to be off. */static void __devinit pci_fixup_msi_k8t_onboard_sound(struct pci_dev *dev){ unsigned char val; if (!dmi_check_system(msi_k8t_dmi_table)) return; /* only applies to MSI K8T Neo2-FIR */ pci_read_config_byte(dev, 0x50, &val); if (val & 0x40) { pci_write_config_byte(dev, 0x50, val & (~0x40)); /* verify the change for status output */ pci_read_config_byte(dev, 0x50, &val); if (val & 0x40) printk(KERN_INFO "PCI: Detected MSI K8T Neo2-FIR, " "can't enable onboard soundcard!\n"); else printk(KERN_INFO "PCI: Detected MSI K8T Neo2-FIR, " "enabled onboard soundcard.\n"); }}DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237, pci_fixup_msi_k8t_onboard_sound);DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237, pci_fixup_msi_k8t_onboard_sound);/* * 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 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 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);DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_CYRIX, PCI_DEVICE_ID_CYRIX_5530_LEGACY, pci_early_fixup_cyrix_5530);/* * Siemens Nixdorf AG FSC Multiprocessor Interrupt Controller: * prevent update of the BAR0, which doesn't look like a normal BAR. */static void __devinit pci_siemens_interrupt_controller(struct pci_dev *dev){ dev->resource[0].flags |= IORESOURCE_PCI_FIXED;}DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SIEMENS, 0x0015, pci_siemens_interrupt_controller);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -