mb/google/brya: Create rull variant
[coreboot2.git] / src / drivers / lenovo / hybrid_graphics / hybrid_graphics.c
blob1fda1fd7eae641c1eb90c90416354f818ac5dc03
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <option.h>
4 #include <device/device.h>
6 #include <southbridge/intel/common/gpio.h>
7 #include <console/console.h>
8 #include "chip.h"
11 * Switch panel mux or backlight mux to active GPU.
12 * In case both GPUs are active switch panel mux to integrated.
14 static void lenovo_hybrid_graphics_enable(struct device *dev)
16 const struct drivers_lenovo_hybrid_graphics_config *config;
17 enum hybrid_graphics_req mode;
19 /* Don't confuse anyone else and disable the fake device */
20 dev->enabled = 0;
22 config = dev->chip_info;
23 if (!config || (get_gpio(config->detect_gpio) == DGPU_NOT_INSTALLED)) {
24 printk(BIOS_DEBUG, "Hybrid graphics: Not installed\n");
25 return;
28 mode = get_uint_option("hybrid_graphics_mode", HYBRID_GRAPHICS_DEFAULT_GPU);
30 if (mode == HYBRID_GRAPHICS_DISCRETE) {
31 printk(BIOS_DEBUG, "Hybrid graphics:"
32 " Switching panel to discrete GPU.\n");
34 if (config->has_panel_hybrid_gpio)
35 set_gpio(config->panel_hybrid_gpio,
36 !config->panel_integrated_lvl);
38 if (config->has_backlight_gpio)
39 set_gpio(config->backlight_gpio,
40 !config->backlight_integrated_lvl);
41 } else {
42 printk(BIOS_DEBUG, "Hybrid graphics:"
43 " Switching panel to integrated GPU.\n");
45 if (config->has_panel_hybrid_gpio)
46 set_gpio(config->panel_hybrid_gpio,
47 config->panel_integrated_lvl);
49 if (config->has_backlight_gpio)
50 set_gpio(config->backlight_gpio,
51 config->backlight_integrated_lvl);
55 struct chip_operations drivers_lenovo_hybrid_graphics_ops = {
56 .name = "Lenovo hybrid graphics driver",
57 .enable_dev = lenovo_hybrid_graphics_enable