drivers/system76/dgpu: Support GPU device on different PEG

Change-Id: I4386e89c6af8b1c0a2512f96f1c972685400d006
This commit is contained in:
Jeremy Soller
2020-12-29 11:09:32 -07:00
committed by Jeremy Soller
parent 688d22d133
commit ead3af013e
3 changed files with 14 additions and 6 deletions

View File

@@ -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

View File

@@ -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,

View File

@@ -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++) {