blob: 1fda1fd7eae641c1eb90c90416354f818ac5dc03 [file] [log] [blame]
Angel Pons8a3453f2020-04-02 23:48:19 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Patrick Rudolphd7dcc442017-07-25 17:40:36 +02002
Patrick Rudolphd7dcc442017-07-25 17:40:36 +02003#include <option.h>
4#include <device/device.h>
5
6#include <southbridge/intel/common/gpio.h>
7#include <console/console.h>
8#include "chip.h"
9
10/*
11 * Switch panel mux or backlight mux to active GPU.
12 * In case both GPUs are active switch panel mux to integrated.
13 */
14static void lenovo_hybrid_graphics_enable(struct device *dev)
15{
16 const struct drivers_lenovo_hybrid_graphics_config *config;
Angel Ponse76f15f2021-04-19 15:20:28 +020017 enum hybrid_graphics_req mode;
Patrick Rudolphd7dcc442017-07-25 17:40:36 +020018
19 /* Don't confuse anyone else and disable the fake device */
20 dev->enabled = 0;
21
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;
26 }
27
Angel Pons88dcb312021-04-26 17:10:28 +020028 mode = get_uint_option("hybrid_graphics_mode", HYBRID_GRAPHICS_DEFAULT_GPU);
Patrick Rudolphd7dcc442017-07-25 17:40:36 +020029
30 if (mode == HYBRID_GRAPHICS_DISCRETE) {
31 printk(BIOS_DEBUG, "Hybrid graphics:"
32 " Switching panel to discrete GPU.\n");
33
34 if (config->has_panel_hybrid_gpio)
35 set_gpio(config->panel_hybrid_gpio,
36 !config->panel_integrated_lvl);
37
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");
44
45 if (config->has_panel_hybrid_gpio)
46 set_gpio(config->panel_hybrid_gpio,
47 config->panel_integrated_lvl);
48
49 if (config->has_backlight_gpio)
50 set_gpio(config->backlight_gpio,
51 config->backlight_integrated_lvl);
52 }
53}
54
55struct chip_operations drivers_lenovo_hybrid_graphics_ops = {
Nicholas Sudsgaardbfb11be2024-01-30 09:53:46 +090056 .name = "Lenovo hybrid graphics driver",
Elyes HAOUAS2aa3b162018-11-27 17:02:10 +010057 .enable_dev = lenovo_hybrid_graphics_enable
Patrick Rudolphd7dcc442017-07-25 17:40:36 +020058};