fixup.c 2.1 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 <asm/machvec.h>
  8. /*
  9. * Fixup to mark boot BIOS video selected by BIOS before it changes
  10. *
  11. * From information provided by "Jon Smirl" <jonsmirl@gmail.com>
  12. *
  13. * The standard boot ROM sequence for an x86 machine uses the BIOS
  14. * to select an initial video card for boot display. This boot video
  15. * card will have it's BIOS copied to C0000 in system RAM.
  16. * IORESOURCE_ROM_SHADOW is used to associate the boot video
  17. * card with this copy. On laptops this copy has to be used since
  18. * the main ROM may be compressed or combined with another image.
  19. * See pci_map_rom() for use of this flag. IORESOURCE_ROM_SHADOW
  20. * is marked here since the boot video device will be the only enabled
  21. * video device at this point.
  22. */
  23. static void __devinit pci_fixup_video(struct pci_dev *pdev)
  24. {
  25. struct pci_dev *bridge;
  26. struct pci_bus *bus;
  27. u16 config;
  28. if ((strcmp(platform_name, "dig") != 0)
  29. && (strcmp(platform_name, "hpzx1") != 0))
  30. return;
  31. /* Maybe, this machine supports legacy memory map. */
  32. if ((pdev->class >> 8) != PCI_CLASS_DISPLAY_VGA)
  33. return;
  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
  46. &&((bridge->hdr_type == PCI_HEADER_TYPE_BRIDGE)
  47. ||(bridge->hdr_type == PCI_HEADER_TYPE_CARDBUS))) {
  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. 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, "Boot video device\n");
  59. }
  60. }
  61. DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, pci_fixup_video);