Angel Pons | 8a3453f | 2020-04-02 23:48:19 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Patrick Rudolph | d7dcc44 | 2017-07-25 17:40:36 +0200 | [diff] [blame] | 2 | |
Patrick Rudolph | d7dcc44 | 2017-07-25 17:40:36 +0200 | [diff] [blame] | 3 | #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 | */ |
| 14 | static void lenovo_hybrid_graphics_enable(struct device *dev) |
| 15 | { |
| 16 | const struct drivers_lenovo_hybrid_graphics_config *config; |
| 17 | enum hybrid_graphics_req mode = HYBRID_GRAPHICS_DEFAULT_GPU; |
| 18 | |
| 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 | |
| 28 | get_option(&mode, "hybrid_graphics_mode"); |
| 29 | |
| 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 | |
| 55 | struct chip_operations drivers_lenovo_hybrid_graphics_ops = { |
| 56 | CHIP_NAME("Lenovo hybrid graphics driver") |
Elyes HAOUAS | 2aa3b16 | 2018-11-27 17:02:10 +0100 | [diff] [blame] | 57 | .enable_dev = lenovo_hybrid_graphics_enable |
Patrick Rudolph | d7dcc44 | 2017-07-25 17:40:36 +0200 | [diff] [blame] | 58 | }; |