aboutsummaryrefslogtreecommitdiff
path: root/src/drivers/apple/hybrid_graphics/romstage.c
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.com>2019-05-10 01:50:45 +0300
committerEvgeny Zinoviev <me@ch1p.io>2021-02-03 22:04:21 +0300
commit4908440ccf6f7c2ae281a3e5b3163440cc7f45ef (patch)
tree30a7996174b7c26da6d2d0b42dc4a26319101f87 /src/drivers/apple/hybrid_graphics/romstage.c
parent952830607c23c861991b1e9a1250bf1e6827af90 (diff)
drivers/apple: Add hybrid graphics driver
A hybrid graphics driver for Apple MacBook Pro. The driver logic is based on lenovo/hybrid_graphics. It is splitted into romstage and ramstage parts. The mainboard code calls the driver from romstage to get the GPU state. The driver reads the state from the `hybrid_grapihcs_mode` nvram option, switches dGPU power on or off according to the state and returns the state to the mainboard code. The mainboard code then has to hide the disabled PCI device. The ramstage part handles the graphics muxes. The muxes code is based on the apple-gmux linux driver, originally written by: * Canonical Ltd. <seth.forshee@canonical.com> * Andreas Heider, 2010-2012 <andreas@meetr.de> * Lukas Wunner, 2015 <lukas@wunner.de> Tested on MacBook Pro Retina 15 Mid 2012 (MacBook Pro 10,1). Change-Id: I22b66622cd2da0e9951ee726d650d204fbb8a5bc Signed-off-by: Evgeny Zinoviev <me@ch1p.io>
Diffstat (limited to 'src/drivers/apple/hybrid_graphics/romstage.c')
-rw-r--r--src/drivers/apple/hybrid_graphics/romstage.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/drivers/apple/hybrid_graphics/romstage.c b/src/drivers/apple/hybrid_graphics/romstage.c
new file mode 100644
index 0000000000..8f2667111b
--- /dev/null
+++ b/src/drivers/apple/hybrid_graphics/romstage.c
@@ -0,0 +1,43 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#include <types.h>
+#include <option.h>
+#include <device/device.h>
+#include <console/console.h>
+#include "hybrid_graphics.h"
+#include "chip.h"
+#include "gmux.h"
+
+void early_hybrid_graphics(bool *enable_igd, bool *enable_peg)
+{
+ const struct device *dev;
+ enum hybrid_graphics_req mode = HYBRID_GRAPHICS_DEFAULT_GPU;
+
+ /* TODO: Use generic device instead of dummy PNP device */
+ dev = dev_find_slot_pnp(HYBRID_GRAPHICS_PORT, HYBRID_GRAPHICS_DEVICE);
+
+ if (!dev || !dev->chip_info) {
+ printk(BIOS_ERR, "Hybrid graphics: ERROR\n");
+ *enable_igd = true;
+ *enable_peg = false;
+ return;
+ }
+
+ get_option(&mode, "hybrid_graphics_mode");
+
+ if (mode == HYBRID_GRAPHICS_DISCRETE) {
+ printk(BIOS_DEBUG, "Hybrid graphics:"
+ " Disabling integrated GPU.\n");
+
+ *enable_igd = false;
+ *enable_peg = true;
+ } else if (mode == HYBRID_GRAPHICS_INTEGRATED) {
+ printk(BIOS_DEBUG, "Hybrid graphics:"
+ " Disabling discrete GPU.\n");
+
+ *enable_igd = true;
+ *enable_peg = false;
+ }
+
+ gmux_dgpu_power_enable(dev, *enable_peg);
+}