From 580e5642a8d1db1bc85c5d55dc2227f3fda8eb34 Mon Sep 17 00:00:00 2001 From: Kyösti Mälkki Date: Thu, 1 May 2014 16:31:34 +0300 Subject: device: provide option to always load PCI option roms MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Certain kernel drivers require the presence of option rom contents because the board's static configuration information is located within the blob. Therefore, allow a chipset/board to instruct the pci device handling code to always load but not necessarily run the option rom. BUG=chrome-os-partner:25885 BRANCH=baytrail TEST=Both enabling and not enabling this option shows expected behavior. Change-Id: Ib0f65ffaf1a861b543573a062c291f4ba491ffe0 Signed-off-by: Aaron Durbin Reviewed-on: https://chromium-review.googlesource.com/188720 Reviewed-by: Duncan Laurie Signed-off-by: Kyösti Mälkki Reviewed-on: http://review.coreboot.org/5594 Reviewed-by: Aaron Durbin Tested-by: build bot (Jenkins) --- src/device/pci_device.c | 50 +++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 10 deletions(-) (limited to 'src/device/pci_device.c') diff --git a/src/device/pci_device.c b/src/device/pci_device.c index aa0d954480..ca3604611d 100644 --- a/src/device/pci_device.c +++ b/src/device/pci_device.c @@ -23,6 +23,7 @@ * Copyright 1997 -- 1999 Martin Mares */ +#include #include #include #include @@ -663,15 +664,13 @@ void pci_dev_set_subsystem(struct device *dev, unsigned vendor, unsigned device) int oprom_is_loaded = 0; #endif -/** Default handler: only runs the relevant PCI BIOS. */ -void pci_dev_init(struct device *dev) -{ #if CONFIG_VGA_ROM_RUN - struct rom_header *rom, *ram; +static int should_run_oprom(struct device *dev) +{ + static int should_run = -1; - /* Only execute VGA ROMs. */ - if (((dev->class >> 8) != PCI_CLASS_DISPLAY_VGA)) - return; + if (should_run >= 0) + return should_run; #if CONFIG_CHROMEOS /* In ChromeOS we want to boot blazingly fast. Therefore @@ -680,19 +679,47 @@ void pci_dev_init(struct device *dev) */ if (!developer_mode_enabled() && !recovery_mode_enabled() && !vboot_wants_oprom()) { - printk(BIOS_DEBUG, "Not loading VGA Option ROM\n"); - return; + printk(BIOS_DEBUG, "Not running VGA Option ROM\n"); + should_run = 0; + return should_run; } #endif + should_run = 1; + + return should_run; +} +static int should_load_oprom(struct device *dev) +{ #if CONFIG_HAVE_ACPI_RESUME && !CONFIG_S3_VGA_ROM_RUN /* If S3_VGA_ROM_RUN is disabled, skip running VGA option * ROMs when coming out of an S3 resume. */ if ((acpi_slp_type == 3) && ((dev->class >> 8) == PCI_CLASS_DISPLAY_VGA)) - return; + return 0; #endif + if (IS_ENABLED(CONFIG_ALWAYS_LOAD_OPROM)) + return 1; + if (should_run_oprom(dev)) + return 1; + + return 0; +} +#endif /* CONFIG_VGA_ROM_RUN */ + +/** Default handler: only runs the relevant PCI BIOS. */ +void pci_dev_init(struct device *dev) +{ +#if CONFIG_VGA_ROM_RUN + struct rom_header *rom, *ram; + + /* Only execute VGA ROMs. */ + if (((dev->class >> 8) != PCI_CLASS_DISPLAY_VGA)) + return; + + if (!should_load_oprom(dev)) + return; rom = pci_rom_probe(dev); if (rom == NULL) @@ -702,6 +729,9 @@ void pci_dev_init(struct device *dev) if (ram == NULL) return; + if (!should_run_oprom(dev)) + return; + run_bios(dev, (unsigned long)ram); #if CONFIG_CHROMEOS oprom_is_loaded = 1; -- cgit v1.2.3