Arthur Heymans | f9d5308 | 2017-01-02 16:16:45 +0100 | [diff] [blame^] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2012 secunet Security Networks AG |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License as |
| 8 | * published by the Free Software Foundation; version 2 of |
| 9 | * the License. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | */ |
| 16 | #include <stdint.h> |
| 17 | #include <string.h> |
| 18 | #include <southbridge/intel/common/gpio.h> |
| 19 | #include <northbridge/intel/gm45/gm45.h> |
| 20 | #include <console/console.h> |
| 21 | #include <option.h> |
| 22 | |
| 23 | #define HYBRID_GRAPHICS_INTEGRATED_ONLY 0 |
| 24 | #define HYBRID_GRAPHICS_DISCRETE_ONLY 1 |
| 25 | #define HYBRID_GRAPHICS_SWITCHABLE 2 |
| 26 | |
| 27 | #define MUX_GPIO 22 |
| 28 | #define BCL_CTL_GPIO 19 |
| 29 | #define GFX_PWR_EN_GPIO 49 |
| 30 | |
| 31 | #define HYBRID_DETECT_GPIO 21 |
| 32 | |
| 33 | void hybrid_graphics_init(sysinfo_t *sysinfo); |
| 34 | |
| 35 | static bool hybrid_graphics_installed(void) |
| 36 | { |
| 37 | if (get_gpio(HYBRID_DETECT_GPIO)) |
| 38 | return false; |
| 39 | else |
| 40 | return true; |
| 41 | } |
| 42 | |
| 43 | void hybrid_graphics_init(sysinfo_t *sysinfo) |
| 44 | { |
| 45 | /* Set default mode */ |
| 46 | uint8_t hybrid_graphics_mode = |
| 47 | HYBRID_GRAPHICS_INTEGRATED_ONLY; |
| 48 | |
| 49 | if (!hybrid_graphics_installed()) { |
| 50 | printk(BIOS_DEBUG, "Hybrid graphics not installed.\n"); |
| 51 | /* The display is not connected to a mux or switchable. */ |
| 52 | sysinfo->enable_igd = 1; |
| 53 | sysinfo->enable_peg = 0; |
| 54 | return; |
| 55 | } |
| 56 | |
| 57 | printk(BIOS_DEBUG, "Hybrid graphics available: "); |
| 58 | get_option(&hybrid_graphics_mode, "hybrid_graphics_mode"); |
| 59 | |
| 60 | /* Select appropriate hybrid graphics device */ |
| 61 | switch (hybrid_graphics_mode) { |
| 62 | default: |
| 63 | case HYBRID_GRAPHICS_INTEGRATED_ONLY: |
| 64 | printk(BIOS_DEBUG, "Activating Integrated Only.\n"); |
| 65 | set_gpio(MUX_GPIO, GPIO_LEVEL_LOW); |
| 66 | set_gpio(BCL_CTL_GPIO, GPIO_LEVEL_LOW); |
| 67 | set_gpio(GFX_PWR_EN_GPIO, GPIO_LEVEL_LOW); |
| 68 | |
| 69 | sysinfo->enable_igd = 1; |
| 70 | sysinfo->enable_peg = 0; |
| 71 | break; |
| 72 | case HYBRID_GRAPHICS_DISCRETE_ONLY: |
| 73 | printk(BIOS_DEBUG, "Activating Discrete Only.\n"); |
| 74 | set_gpio(MUX_GPIO, GPIO_LEVEL_HIGH); |
| 75 | set_gpio(BCL_CTL_GPIO, GPIO_LEVEL_HIGH); |
| 76 | set_gpio(GFX_PWR_EN_GPIO, GPIO_LEVEL_HIGH); |
| 77 | |
| 78 | sysinfo->enable_igd = 0; |
| 79 | sysinfo->enable_peg = 1; |
| 80 | break; |
| 81 | case HYBRID_GRAPHICS_SWITCHABLE: |
| 82 | printk(BIOS_DEBUG, "Activating Switchable (both GPUs).\n"); |
| 83 | set_gpio(MUX_GPIO, GPIO_LEVEL_LOW); |
| 84 | set_gpio(BCL_CTL_GPIO, GPIO_LEVEL_LOW); |
| 85 | set_gpio(GFX_PWR_EN_GPIO, GPIO_LEVEL_HIGH); |
| 86 | |
| 87 | sysinfo->enable_igd = 1; |
| 88 | sysinfo->enable_peg = 1; |
| 89 | break; |
| 90 | } |
| 91 | } |