1 // SPDX-License-Identifier: GPL-2.0
3 * Exceptions for specific devices. Usually work-arounds for fatal design flaws.
4 * Derived from fixup.c of i386 tree.
8 #include <linux/init.h>
9 #include <linux/vgaarb.h>
10 #include <linux/screen_info.h>
12 #include <asm/machvec.h>
15 * Fixup to mark boot BIOS video selected by BIOS before it changes
17 * From information provided by "Jon Smirl" <jonsmirl@gmail.com>
19 * The standard boot ROM sequence for an x86 machine uses the BIOS
20 * to select an initial video card for boot display. This boot video
21 * card will have its BIOS copied to 0xC0000 in system RAM.
22 * IORESOURCE_ROM_SHADOW is used to associate the boot video
23 * card with this copy. On laptops this copy has to be used since
24 * the main ROM may be compressed or combined with another image.
25 * See pci_map_rom() for use of this flag. Before marking the device
26 * with IORESOURCE_ROM_SHADOW check if a vga_default_device is already set
27 * by either arch code or vga-arbitration; if so only apply the fixup to this
28 * already-determined primary video card.
31 static void pci_fixup_video(struct pci_dev *pdev)
33 struct pci_dev *bridge;
38 if ((strcmp(ia64_platform_name, "dig") != 0)
39 && (strcmp(ia64_platform_name, "hpzx1") != 0))
41 /* Maybe, this machine supports legacy memory map. */
43 /* Is VGA routed to us? */
49 * From information provided by
50 * "David Miller" <davem@davemloft.net>
51 * The bridge control register is valid for PCI header
52 * type BRIDGE, or CARDBUS. Host to PCI controllers use
53 * PCI header type NORMAL.
55 if (bridge && (pci_is_bridge(bridge))) {
56 pci_read_config_word(bridge, PCI_BRIDGE_CONTROL,
58 if (!(config & PCI_BRIDGE_CTL_VGA))
63 if (!vga_default_device() || pdev == vga_default_device()) {
64 pci_read_config_word(pdev, PCI_COMMAND, &config);
65 if (config & (PCI_COMMAND_IO | PCI_COMMAND_MEMORY)) {
66 res = &pdev->resource[PCI_ROM_RESOURCE];
68 pci_disable_rom(pdev);
70 release_resource(res);
73 res->end = res->start + 0x20000 - 1;
74 res->flags = IORESOURCE_MEM | IORESOURCE_ROM_SHADOW |
76 dev_info(&pdev->dev, "Video device with shadowed ROM at %pR\n",
81 DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_ANY_ID, PCI_ANY_ID,
82 PCI_CLASS_DISPLAY_VGA, 8, pci_fixup_video);