Michael Niewöhner has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/35514 )
Change subject: device/pci: fix legacy VGA encoding ......................................................................
device/pci: fix legacy VGA encoding
Enable decoding of 16-bit legacy VGA addresses to prevent resource conflicts with other devices (like SMBus and SATA on X11SS* boards).
Tested on X11SSM-F.
Change-Id: I29e37ac69d68ef8e0f37ef02660a53101f254992 Signed-off-by: Michael Niewöhner foss@mniewoehner.de --- M src/device/cardbus_device.c M src/device/device.c M src/include/device/pci_def.h 3 files changed, 18 insertions(+), 4 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/14/35514/1
diff --git a/src/device/cardbus_device.c b/src/device/cardbus_device.c index a440746..4cd9f85 100644 --- a/src/device/cardbus_device.c +++ b/src/device/cardbus_device.c @@ -156,6 +156,7 @@ PCI_BRIDGE_CTL_SERR | PCI_BRIDGE_CTL_NO_ISA | PCI_BRIDGE_CTL_VGA | + PCI_BRIDGE_CTL_VGA16 | PCI_BRIDGE_CTL_MASTER_ABORT | PCI_BRIDGE_CTL_BUS_RESET)); /* Error check */ diff --git a/src/device/device.c b/src/device/device.c index 44d1f95..d0806ea 100644 --- a/src/device/device.c +++ b/src/device/device.c @@ -19,6 +19,7 @@ #include <device/device.h> #include <device/pci_def.h> #include <device/pci_ids.h> +#include <device/pci_ops.h> #include <stdlib.h> #include <string.h> #include <smp/spinlock.h> @@ -748,6 +749,7 @@ /* FIXME: Handle the VGA palette snooping. */ struct device *dev, *vga, *vga_onboard; struct bus *bus; + u16 ctrl;
bus = 0; vga = 0; @@ -793,11 +795,21 @@ bus = vga->bus; }
- /* Now walk up the bridges setting the VGA enable. */ + /* Now walk up the bridges setting the VGA enable if supported. */ while (bus) { - printk(BIOS_DEBUG, "Setting PCI_BRIDGE_CTL_VGA for bridge %s\n", - dev_path(bus->dev)); - bus->bridge_ctrl |= PCI_BRIDGE_CTL_VGA; + /* try to set VGA16; it will return 1 if it is supported */ + ctrl = pci_read_config16(bus->dev, PCI_CB_BRIDGE_CONTROL); + if (!(ctrl & PCI_BRIDGE_CTL_VGA16)) { // no test needed if already set + pci_or_config16(bus->dev, PCI_CB_BRIDGE_CONTROL, PCI_BRIDGE_CTL_VGA16); + ctrl = pci_read_config16(bus->dev, PCI_CB_BRIDGE_CONTROL); + /* restore */ + pci_write_config16(bus->dev, PCI_CB_BRIDGE_CONTROL, ctrl & ~PCI_BRIDGE_CTL_VGA16); + } + if (ctrl & PCI_BRIDGE_CTL_VGA16) { + printk(BIOS_DEBUG, "Setting PCI_BRIDGE_CTL_VGA(16) for bridge %s\n", dev_path(bus->dev)); + bus->bridge_ctrl |= (PCI_BRIDGE_CTL_VGA | PCI_BRIDGE_CTL_VGA16); + } + bus = (bus == bus->dev->bus) ? 0 : bus->dev->bus; } } diff --git a/src/include/device/pci_def.h b/src/include/device/pci_def.h index bc5bc79..660edcb 100644 --- a/src/include/device/pci_def.h +++ b/src/include/device/pci_def.h @@ -138,6 +138,7 @@ #define PCI_BRIDGE_CTL_SERR 0x02 /* The same for SERR forwarding */ #define PCI_BRIDGE_CTL_NO_ISA 0x04 /* Disable bridging of ISA ports */ #define PCI_BRIDGE_CTL_VGA 0x08 /* Forward VGA addresses */ +#define PCI_BRIDGE_CTL_VGA16 0x16 /* Enable VGA16 decoding */ #define PCI_BRIDGE_CTL_MASTER_ABORT 0x20 /* Report master aborts */ #define PCI_BRIDGE_CTL_BUS_RESET 0x40 /* Secondary bus reset */ /* Fast Back2Back enabled on secondary interface */