aboutsummaryrefslogtreecommitdiff
path: root/src/drivers/apple/hybrid_graphics/romstage.c
blob: 8f2667111b2f856eb5d56aa0cab7933ee5ddf635 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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);
}