fixup.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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" <[email protected]>
  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 its BIOS copied to 0xC0000 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 code 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. struct resource *res;
  32. if ((strcmp(ia64_platform_name, "dig") != 0)
  33. && (strcmp(ia64_platform_name, "hpzx1") != 0))
  34. return;
  35. /* Maybe, this machine supports legacy memory map. */
  36. /* Is VGA routed to us? */
  37. bus = pdev->bus;
  38. while (bus) {
  39. bridge = bus->self;
  40. /*
  41. * From information provided by
  42. * "David Miller" <[email protected]>
  43. * The bridge control register is valid for PCI header
  44. * type BRIDGE, or CARDBUS. Host to PCI controllers use
  45. * PCI header type NORMAL.
  46. */
  47. if (bridge && (pci_is_bridge(bridge))) {
  48. pci_read_config_word(bridge, PCI_BRIDGE_CONTROL,
  49. &config);
  50. if (!(config & PCI_BRIDGE_CTL_VGA))
  51. return;
  52. }
  53. bus = bus->parent;
  54. }
  55. if (!vga_default_device() || pdev == vga_default_device()) {
  56. pci_read_config_word(pdev, PCI_COMMAND, &config);
  57. if (config & (PCI_COMMAND_IO | PCI_COMMAND_MEMORY)) {
  58. res = &pdev->resource[PCI_ROM_RESOURCE];
  59. pci_disable_rom(pdev);
  60. if (res->parent)
  61. release_resource(res);
  62. res->start = 0xC0000;
  63. res->end = res->start + 0x20000 - 1;
  64. res->flags = IORESOURCE_MEM | IORESOURCE_ROM_SHADOW |
  65. IORESOURCE_PCI_FIXED;
  66. dev_info(&pdev->dev, "Video device with shadowed ROM at %pR\n",
  67. res);
  68. }
  69. }
  70. }
  71. DECLARE_PCI_FIXUP_CLASS_FINAL(PCI_ANY_ID, PCI_ANY_ID,
  72. PCI_CLASS_DISPLAY_VGA, 8, pci_fixup_video);