/*1* Exceptions for specific devices. Usually work-arounds for fatal design flaws.2* Derived from fixup.c of i386 tree.3*/45#include <linux/pci.h>6#include <linux/init.h>78#include <asm/machvec.h>910/*11* Fixup to mark boot BIOS video selected by BIOS before it changes12*13* From information provided by "Jon Smirl" <[email protected]>14*15* The standard boot ROM sequence for an x86 machine uses the BIOS16* to select an initial video card for boot display. This boot video17* card will have it's BIOS copied to C0000 in system RAM.18* IORESOURCE_ROM_SHADOW is used to associate the boot video19* card with this copy. On laptops this copy has to be used since20* the main ROM may be compressed or combined with another image.21* See pci_map_rom() for use of this flag. IORESOURCE_ROM_SHADOW22* is marked here since the boot video device will be the only enabled23* video device at this point.24*/2526static void __devinit pci_fixup_video(struct pci_dev *pdev)27{28struct pci_dev *bridge;29struct pci_bus *bus;30u16 config;3132if ((strcmp(platform_name, "dig") != 0)33&& (strcmp(platform_name, "hpzx1") != 0))34return;35/* Maybe, this machine supports legacy memory map. */3637if ((pdev->class >> 8) != PCI_CLASS_DISPLAY_VGA)38return;3940/* Is VGA routed to us? */41bus = pdev->bus;42while (bus) {43bridge = bus->self;4445/*46* From information provided by47* "David Miller" <[email protected]>48* The bridge control register is valid for PCI header49* type BRIDGE, or CARDBUS. Host to PCI controllers use50* PCI header type NORMAL.51*/52if (bridge53&&((bridge->hdr_type == PCI_HEADER_TYPE_BRIDGE)54||(bridge->hdr_type == PCI_HEADER_TYPE_CARDBUS))) {55pci_read_config_word(bridge, PCI_BRIDGE_CONTROL,56&config);57if (!(config & PCI_BRIDGE_CTL_VGA))58return;59}60bus = bus->parent;61}62pci_read_config_word(pdev, PCI_COMMAND, &config);63if (config & (PCI_COMMAND_IO | PCI_COMMAND_MEMORY)) {64pdev->resource[PCI_ROM_RESOURCE].flags |= IORESOURCE_ROM_SHADOW;65dev_printk(KERN_DEBUG, &pdev->dev, "Boot video device\n");66}67}68DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, pci_fixup_video);697071