1- From 52bafd0431f225b5d887222e93bc2398a56402a3 Mon Sep 17 00:00:00 2001
1+ From 954697c4622471d63fe037b9d1029cada4caa303 Mon Sep 17 00:00:00 2001
22From: Atharva Tiwari <atharvatiwarilinuxdev@gmail.com>
33Date: Mon, 16 Feb 2026 05:07:01 +0530
44Subject: [PATCH] apple-gmux: fix power for t2
55
66Signed-off-by: Atharva Tiwari <atharvatiwarilinuxdev@gmail.com>
77---
8- drivers/platform/x86/apple-gmux.c | 56 ++++++++++++++++++++++++++++---
9- 1 file changed, 51 insertions(+), 5 deletions(-)
8+ drivers/platform/x86/apple-gmux.c | 68 ++++++++++++++++++++++++++++---
9+ 1 file changed, 63 insertions(+), 5 deletions(-)
1010
1111diff --git a/drivers/platform/x86/apple-gmux.c b/drivers/platform/x86/apple-gmux.c
12- index e69785af8e1d..6cc99eb68caf 100644
12+ index e69785af8e1d..8769415a2a5d 100644
1313--- a/drivers/platform/x86/apple-gmux.c
1414+++ b/drivers/platform/x86/apple-gmux.c
15- @@ -79,6 +79,9 @@ struct apple_gmux_data {
15+ @@ -79,6 +79,11 @@ struct apple_gmux_data {
1616 /* debugfs data */
1717 u8 selected_port;
1818 struct dentry *debug_dentry;
1919+
2020+ struct pci_dev *dgpu_pdev;
21+ + u8 *dgpu_pci_config;
22+ +
2123+ enum apple_gmux_type type;
2224 };
2325
2426 static struct apple_gmux_data *apple_gmux_data;
25- @@ -517,13 +520,51 @@ static int gmux_set_discrete_state(struct apple_gmux_data *gmux_data,
27+ @@ -517,13 +522,61 @@ static int gmux_set_discrete_state(struct apple_gmux_data *gmux_data,
2628 {
2729 reinit_completion(&gmux_data->powerchange_done);
2830
@@ -45,6 +47,8 @@ index e69785af8e1d..6cc99eb68caf 100644
4547+ msleep(1000);
4648+
4749+ pci_restore_state(gmux_data->dgpu_pdev);
50+ + for (u16 i = 0; i < 4096; i++)
51+ + pci_write_config_byte(gmux_data->dgpu_pdev, i, gmux_data->dgpu_pci_config[i]);
4852+
4953+ bar = pci_iomap(gmux_data->dgpu_pdev, 0, 0);
5054+ if (WARN_ON(!bar))
@@ -65,6 +69,14 @@ index e69785af8e1d..6cc99eb68caf 100644
6569+ if (gmux_data->type == APPLE_GMUX_TYPE_MMIO) {
6670+ acpi_handle dgpu_handle = ACPI_HANDLE(&gmux_data->dgpu_pdev->dev);
6771+
72+ + //TODO: make this better
73+ + gmux_data->dgpu_pci_config = kcalloc(4096, 1, GFP_KERNEL);
74+ + if (!gmux_data->dgpu_pci_config)
75+ + return -ENOMEM;
76+ +
77+ + for (u16 i = 0; i < 4096; i++)
78+ + pci_read_config_byte(gmux_data->dgpu_pdev, i, &gmux_data->dgpu_pci_config[i]);
79+ +
6880+ pci_save_state(gmux_data->dgpu_pdev);
6981+
7082+ acpi_evaluate_object(dgpu_handle, "PWG1", NULL, NULL);
@@ -78,7 +90,7 @@ index e69785af8e1d..6cc99eb68caf 100644
7890 pr_debug("Discrete card powered down\n");
7991 }
8092
81- @@ -557,8 +598 ,12 @@ static enum vga_switcheroo_client_id gmux_get_client_id(struct pci_dev *pdev)
93+ @@ -557,8 +610 ,12 @@ static enum vga_switcheroo_client_id gmux_get_client_id(struct pci_dev *pdev)
8294 else if (pdev->vendor == PCI_VENDOR_ID_NVIDIA &&
8395 pdev->device == 0x0863)
8496 return VGA_SWITCHEROO_IGD;
@@ -92,7 +104,7 @@ index e69785af8e1d..6cc99eb68caf 100644
92104 }
93105
94106 static const struct vga_switcheroo_handler gmux_handler_no_ddc = {
95- @@ -809,6 +854 ,7 @@ static int gmux_probe(struct pnp_dev *pnp, const struct pnp_device_id *id)
107+ @@ -809,6 +866 ,7 @@ static int gmux_probe(struct pnp_dev *pnp, const struct pnp_device_id *id)
96108 return -ENOMEM;
97109 pnp_set_drvdata(pnp, gmux_data);
98110
0 commit comments