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