1 /* SPDX-License-Identifier: GPL-2.0-only */
4 #include <device/device.h>
6 #include <southbridge/intel/common/gpio.h>
7 #include <console/console.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 */
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");
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
);
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