diff --git a/src/drivers/system76/dgpu/Kconfig b/src/drivers/system76/dgpu/Kconfig index 5096671472..6baea52efd 100644 --- a/src/drivers/system76/dgpu/Kconfig +++ b/src/drivers/system76/dgpu/Kconfig @@ -3,3 +3,10 @@ config DRIVERS_SYSTEM76_DGPU default n help System76 switchable graphics support + +#TODO: make this cleaner, use device tree? +config DRIVERS_SYSTEM76_DGPU_DEVICE + hex + default 0x01 + help + System76 switchable graphics root device number diff --git a/src/drivers/system76/dgpu/acpi/dgpu.asl b/src/drivers/system76/dgpu/acpi/dgpu.asl index a721934b71..225d4d0206 100644 --- a/src/drivers/system76/dgpu/acpi/dgpu.asl +++ b/src/drivers/system76/dgpu/acpi/dgpu.asl @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */ Device (\_SB.PCI0.PEGP) { - Name (_ADR, 0x00010000) + Name (_ADR, CONFIG_DRIVERS_SYSTEM76_DGPU_DEVICE << 16) PowerResource (PWRR, 0, 0) { Name (_STA, 1) @@ -35,7 +35,8 @@ Device (\_SB.PCI0.PEGP.DEV0) { // Memory mapped PCI express registers // Not sure what this stuff is, but it is used to get into GC6 - OperationRegion (RPCX, SystemMemory, 0xE0008000, 0x1000) + //TODO: use DGPU_DEVICE to generate address + OperationRegion (RPCX, SystemMemory, CONFIG_MMCONF_BASE_ADDRESS + 0x8000, 0x1000) Field (RPCX, ByteAcc, NoLock, Preserve) { PVID, 16, PDID, 16, diff --git a/src/drivers/system76/dgpu/ramstage.c b/src/drivers/system76/dgpu/ramstage.c index eeb1607ed4..8bd102baf1 100644 --- a/src/drivers/system76/dgpu/ramstage.c +++ b/src/drivers/system76/dgpu/ramstage.c @@ -55,13 +55,13 @@ static struct device_operations dgpu_pci_ops_dev = { static void dgpu_above_4g(void *unused) { struct device *pdev; - // Find PEG0 - pdev = pcidev_on_root(1, 0); + // Find PEGP + pdev = pcidev_on_root(CONFIG_DRIVERS_SYSTEM76_DGPU_DEVICE, 0); if (!pdev) { - printk(BIOS_ERR, "system76: failed to find PEG0\n"); + printk(BIOS_ERR, "system76: failed to find PEGP\n"); return; } - printk(BIOS_INFO, "system76: PEG0 at %p, %04x:%04x\n", pdev, pdev->vendor, pdev->device); + printk(BIOS_INFO, "system76: PEGP at %p, %04x:%04x\n", pdev, pdev->vendor, pdev->device); int fn; for (fn = 0; fn < 8; fn++) {