aboutsummaryrefslogtreecommitdiff
path: root/src/drivers/apple/hybrid_graphics/romstage.c
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2021-02-07 01:49:19 +0300
committerEvgeny Zinoviev <me@ch1p.io>2021-02-07 01:49:19 +0300
commit8f96216188ae440be6af63af650e26f05a86fd81 (patch)
tree39fa8bc3f70ebb6041f8751982f913ab85cbf06d /src/drivers/apple/hybrid_graphics/romstage.c
parent372766f26b8d765d4a6cc58992febc957c9b4d66 (diff)
parent7cffa9ed36562be010a6bac91f2469051e33049b (diff)
Merge branch 'macbookpro10_1' into mbp101_medisable_1
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);
+}