fixup.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Exceptions for specific devices. Usually work-arounds for fatal design flaws.
  3. * Derived from fixup.c of i386 tree.
  4. */
  5. #include <linux/pci.h>
  6. #include <linux/init.h>
  7. #include <linux/vgaarb.h>
  8. #include <asm/machvec.h>
  9. /*
  10. * Fixup to mark boot BIOS video selected by BIOS before it changes
  11. *
  12. * From information provided by "Jon Smirl" <jonsmirl@gmail.com>
  13. *
  14. * The standard boot ROM sequence for an x86 machine uses the BIOS
  15. * to select an initial video card for boot display. This boot video
  16. * card will have it's BIOS copied to C0000 in system RAM.
  17. * IORESOURCE_ROM_SHADOW is used to associate the boot video
  18. * card with this copy. On laptops this copy has to be used since
  19. * the main ROM may be compressed or combined with another image.
  20. * See pci_map_rom() for use of this flag. Before marking the device
  21. * with IORESOURCE_ROM_SHADOW check if a vga_default_device is already set
  22. * by either arch cde or vga-arbitration, if so only apply the fixup to this
  23. * already determined primary video card.
  24. */
  25. static void pci_fixup_video(struct pci_dev *pdev)
  26. {
  27. struct pci_dev *bridge;
  28. struct pci_bus *bus;
  29. u16 config;
  30. if ((strcmp(ia64_platform_name, "dig") != 0)
  31. && (strcmp(ia64_platform_name, "hpzx1") != 0))
  32. return;
  33. /* Maybe, this machine supports legacy memory map. */
  34. /* Is VGA routed to us? */
  35. bus = pdev->bus;
  36. while (bus) {
  37. bridge = bus->self;
  38. /*
  39. * From information provided by
  40. * "David Miller" <davem@davemloft.net>
  41. * The bridge control register is valid for PCI header
  42. * type BRIDGE, or CARDBUS. Host to PCI controllers use
  43. * PCI header type NORMAL.
  44. */
  45. if (bridge && (pci_is_bridge(bridge))) {
  46. pci_read_config_word(bridge, PCI_BRIDGE_CONTROL,
  47. &config);
  48. if (!(config & PCI_BRIDGE_CTL_VGA))
  49. return;
  50. }
  51. bus = bus->parent;
  52. }
  53. if (!vga_default_device() || pdev == vga_default_device()) {
  54. pci_read_config_word(pdev, PCI_COMMAND, &config);
  55. if (config & (PCI_COMMAND_IO | PCI_COMMAND_MEMORY)) {
  56. pdev->resource[PCI_ROM_RESOURCE].flags |= IORESOURCE_ROM_SHADOW;
  57. dev_printk(KERN_DEBUG, &pdev->dev, "Boot video device\n");
  58. vga_set_default_device(pdev);
  59. }
  60. }
  61. }
  62. DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_ANY_ID, PCI_ANY_ID,
  63. PCI_CLASS_DISPLAY_VGA, 8, pci_fixup_video);