PCI: Add support for non-BAR ROMs

Platforms may provide their own mechanisms for obtaining ROMs. Add support
for using data provided by the platform in that case.

Signed-off-by: Matthew Garrett <mjg@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Tested-by: Seth Forshee <seth.forshee@canonical.com>
This commit is contained in:
Matthew Garrett 2012-12-05 14:33:27 -07:00 committed by Bjorn Helgaas
parent eca0d4676d
commit 84c1b80e32
2 changed files with 11 additions and 2 deletions

View File

@ -117,12 +117,18 @@ void __iomem *pci_map_rom(struct pci_dev *pdev, size_t *size)
loff_t start; loff_t start;
void __iomem *rom; void __iomem *rom;
/*
* Some devices may provide ROMs via a source other than the BAR
*/
if (pdev->rom && pdev->romlen) {
*size = pdev->romlen;
return phys_to_virt((phys_addr_t)pdev->rom);
/* /*
* IORESOURCE_ROM_SHADOW set on x86, x86_64 and IA64 supports legacy * IORESOURCE_ROM_SHADOW set on x86, x86_64 and IA64 supports legacy
* memory map if the VGA enable bit of the Bridge Control register is * memory map if the VGA enable bit of the Bridge Control register is
* set for embedded VGA. * set for embedded VGA.
*/ */
if (res->flags & IORESOURCE_ROM_SHADOW) { } else if (res->flags & IORESOURCE_ROM_SHADOW) {
/* primary video rom always starts here */ /* primary video rom always starts here */
start = (loff_t)0xC0000; start = (loff_t)0xC0000;
*size = 0x20000; /* cover C000:0 through E000:0 */ *size = 0x20000; /* cover C000:0 through E000:0 */
@ -181,7 +187,8 @@ void pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom)
if (res->flags & (IORESOURCE_ROM_COPY | IORESOURCE_ROM_BIOS_COPY)) if (res->flags & (IORESOURCE_ROM_COPY | IORESOURCE_ROM_BIOS_COPY))
return; return;
iounmap(rom); if (!pdev->rom || !pdev->romlen)
iounmap(rom);
/* Disable again before continuing, leave enabled if pci=rom */ /* Disable again before continuing, leave enabled if pci=rom */
if (!(res->flags & (IORESOURCE_ROM_ENABLE | IORESOURCE_ROM_SHADOW))) if (!(res->flags & (IORESOURCE_ROM_ENABLE | IORESOURCE_ROM_SHADOW)))

View File

@ -333,6 +333,8 @@ struct pci_dev {
}; };
struct pci_ats *ats; /* Address Translation Service */ struct pci_ats *ats; /* Address Translation Service */
#endif #endif
void *rom; /* Physical pointer to ROM if it's not from the BAR */
size_t romlen; /* Length of ROM if it's not from the BAR */
}; };
static inline struct pci_dev *pci_physfn(struct pci_dev *dev) static inline struct pci_dev *pci_physfn(struct pci_dev *dev)