[coreboot-gerrit] Patch set updated for coreboot: nb/x4x: Disable IGD when external GPU is found

Arthur Heymans (arthur@aheymans.xyz) gerrit at coreboot.org
Sun Mar 5 16:05:31 CET 2017


Arthur Heymans (arthur at aheymans.xyz) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/18504

-gerrit

commit 387b34a51e5adfba8ba4e5e610ff8f7f325aca92
Author: Arthur Heymans <arthur at aheymans.xyz>
Date:   Sun Feb 26 23:04:51 2017 +0100

    nb/x4x: Disable IGD when external GPU is found
    
    This disables IGD before raminit if an external GPU is found unless
    CONFIG_ONBOARD_VGA_IS_PRIMARY is set.
    This adds a disable function for IGD to allow set_vga_bridge_bits() in
    device.c to disable the integrated GPU when an external GPU is
    detected.
    
    TESTED on ga-g41m-es2l
    
    Change-Id: I74890918feb0f1ff6b971c4aaa96f1f7b75266ac
    Signed-off-by: Arthur Heymans <arthur at aheymans.xyz>
---
 src/northbridge/intel/x4x/early_init.c | 25 +++++++++++++++++++++++++
 src/northbridge/intel/x4x/gma.c        | 17 +++++++++++++++++
 src/northbridge/intel/x4x/x4x.h        |  1 +
 3 files changed, 43 insertions(+)

diff --git a/src/northbridge/intel/x4x/early_init.c b/src/northbridge/intel/x4x/early_init.c
index 7d6afc9..dfa90cc 100644
--- a/src/northbridge/intel/x4x/early_init.c
+++ b/src/northbridge/intel/x4x/early_init.c
@@ -24,10 +24,12 @@
 #include <console/console.h>
 #include <halt.h>
 #include <romstage_handoff.h>
+#include <device/pci_def.h>
 
 void x4x_early_init(void)
 {
 	const pci_devfn_t d0f0 = PCI_DEV(0, 0, 0);
+	u32 reg32;
 
 	/* Setup MCHBAR. */
 	pci_write_config32(d0f0, D0F0_MCHBAR_LO, (uintptr_t)DEFAULT_MCHBAR | 1);
@@ -64,6 +66,29 @@ void x4x_early_init(void)
 		gfxsize = 6;
 	}
 	pci_write_config16(d0f0, D0F0_GGC, 0x0100 | ((gfxsize + 1) << 4));
+
+	/*
+	 * Disabling IGD later is possible but somehow reclaiming its UMA
+	 * resources fails so enable/disable IGD before raminit if external
+	 * GPU is found.
+	 * NOTE: PCI specifies that one needs to wait at least 100msec after
+	 * reset. In practise GPUs seem to get detected fine without this.
+	 */
+	if (pci_read_config16(PCI_DEV(0, 0x01, 0), SLOTSTS) & (1 << 6) &&
+		!IS_ENABLED(CONFIG_ONBOARD_VGA_IS_PRIMARY)) {
+		pci_write_config8(PCI_DEV(0, 0x01, 0), PCI_SECONDARY_BUS, 0x0a);
+		pci_write_config8(PCI_DEV(0, 0x01, 0),
+				PCI_SUBORDINATE_BUS, 0x0a);
+		reg32 = (pci_read_config32(PCI_DEV(0xa, 0, 0), 0x8) >> 8);
+		if (reg32 == 0x030000) {
+			printk(BIOS_DEBUG,"External GPU is found."
+				" xDisabling IGD before raminit\n");
+			reg32 = pci_read_config32(d0f0, D0F0_DEVEN);
+			pci_write_config32(d0f0, D0F0_DEVEN,
+					reg32 & ~(IGD0EN | IGD1EN));
+			pci_write_config16(d0f0, D0F0_GGC, (1 << 1));
+		}
+	}
 }
 
 static void init_egress(void)
diff --git a/src/northbridge/intel/x4x/gma.c b/src/northbridge/intel/x4x/gma.c
index 74250fe..4bf8125 100644
--- a/src/northbridge/intel/x4x/gma.c
+++ b/src/northbridge/intel/x4x/gma.c
@@ -376,6 +376,22 @@ static void gma_func0_init(struct device *dev)
 		pci_dev_init(dev);
 }
 
+static void gma_func0_disable(struct device *dev)
+{
+	struct device *dev_host = dev_find_slot(0, PCI_DEVFN(0x0, 0));
+	u16 ggc;
+
+	ggc = pci_read_config16(dev_host, D0F0_GGC);
+	ggc |= (1 << 1);
+	pci_write_config16(dev_host, D0F0_GGC, ggc);
+
+	unsigned int reg32 = pci_read_config32(dev_host, D0F0_DEVEN);
+	reg32 &= ~(IGD0EN | IGD1EN);
+	pci_write_config32(dev_host, D0F0_DEVEN, reg32);
+
+	dev->enabled = 0;
+}
+
 static void gma_set_subsystem(device_t dev, unsigned vendor, unsigned device)
 {
 	if (!vendor || !device) {
@@ -420,6 +436,7 @@ static struct device_operations gma_func0_ops = {
 	.acpi_fill_ssdt_generator = gma_ssdt,
 	.init = gma_func0_init,
 	.ops_pci = &gma_pci_ops,
+	.disable = gma_func0_disable,
 };
 
 static const unsigned short pci_device_ids[] =
diff --git a/src/northbridge/intel/x4x/x4x.h b/src/northbridge/intel/x4x/x4x.h
index faae775..834128b 100644
--- a/src/northbridge/intel/x4x/x4x.h
+++ b/src/northbridge/intel/x4x/x4x.h
@@ -60,6 +60,7 @@
  */
 #define PEG_CAP 0xa2
 #define SLOTCAP 0xb4
+#define SLOTSTS 0xba
 #define PEGLC 0xec
 #define D1F0_VCCAP 0x104
 #define D1F0_VC0RCTL 0x114



More information about the coreboot-gerrit mailing list