From 0e06f5bd70b45fd330d8dfb1dc77cce043caf841 Mon Sep 17 00:00:00 2001 From: Patrick Rudolph Date: Mon, 28 Dec 2015 12:59:47 +0100 Subject: northbridge/intel/peg: Disable unused ports Walk the bus and try to find enabled devices. Disable the PEG port if no devices are attached. Change-Id: I67fcc831fd78ecc6dba83f4e0662ec7549cc2591 Signed-off-by: Patrick Rudolph Reviewed-on: https://review.coreboot.org/12894 Tested-by: build bot (Jenkins) Reviewed-by: Martin Roth --- src/northbridge/intel/sandybridge/northbridge.c | 26 ++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'src/northbridge/intel/sandybridge') diff --git a/src/northbridge/intel/sandybridge/northbridge.c b/src/northbridge/intel/sandybridge/northbridge.c index 53d93a2501..3974fe895c 100644 --- a/src/northbridge/intel/sandybridge/northbridge.c +++ b/src/northbridge/intel/sandybridge/northbridge.c @@ -368,6 +368,17 @@ static void northbridge_dmi_init(struct device *dev) DMIBAR32(0x88) = reg32; } +static u8 scan_bus_unused(struct bus *link) +{ + struct device *dev; + + for (dev = link->children; dev; dev = dev->sibling) { + if (dev->enabled) + return 0; + } + return 1; +} + /* Disable unused PEG devices based on devicetree */ static void disable_peg(void) { @@ -378,27 +389,32 @@ static void disable_peg(void) reg = pci_read_config32(dev, DEVEN); dev = dev_find_slot(0, PCI_DEVFN(1, 2)); - if (!dev || !dev->enabled) { + if (!dev || !dev->enabled || + (dev->link_list && scan_bus_unused(dev->link_list))) { printk(BIOS_DEBUG, "Disabling PEG12.\n"); reg &= ~DEVEN_PEG12; } dev = dev_find_slot(0, PCI_DEVFN(1, 1)); - if (!dev || !dev->enabled) { + if (!dev || !dev->enabled || + (dev->link_list && scan_bus_unused(dev->link_list))) { printk(BIOS_DEBUG, "Disabling PEG11.\n"); reg &= ~DEVEN_PEG11; } dev = dev_find_slot(0, PCI_DEVFN(1, 0)); - if (!dev || !dev->enabled) { + if (!dev || !dev->enabled || + (dev->link_list && scan_bus_unused(dev->link_list))) { printk(BIOS_DEBUG, "Disabling PEG10.\n"); reg &= ~DEVEN_PEG10; } dev = dev_find_slot(0, PCI_DEVFN(2, 0)); - if (!dev || !dev->enabled) { + if (!dev || !dev->enabled || + (dev->link_list && scan_bus_unused(dev->link_list))) { printk(BIOS_DEBUG, "Disabling IGD.\n"); reg &= ~DEVEN_IGD; } dev = dev_find_slot(0, PCI_DEVFN(6, 0)); - if (!dev || !dev->enabled) { + if (!dev || !dev->enabled || + (dev->link_list && scan_bus_unused(dev->link_list))) { printk(BIOS_DEBUG, "Disabling PEG60.\n"); reg &= ~DEVEN_PEG60; } -- cgit v1.2.3