Angel Pons | 89ab250 | 2020-04-03 01:22:28 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Philipp Deppenwiese | 714baa1 | 2017-01-02 17:58:09 +0100 | [diff] [blame] | 2 | |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 3 | #include <device/pci_ops.h> |
Philipp Deppenwiese | 714baa1 | 2017-01-02 17:58:09 +0100 | [diff] [blame] | 4 | #include <device/pci_def.h> |
Philipp Deppenwiese | 714baa1 | 2017-01-02 17:58:09 +0100 | [diff] [blame] | 5 | #include <southbridge/intel/bd82x6x/pch.h> |
| 6 | #include <ec/lenovo/pmh7/pmh7.h> |
Patrick Rudolph | db27e338 | 2017-07-27 18:00:59 +0200 | [diff] [blame] | 7 | #include <drivers/lenovo/hybrid_graphics/hybrid_graphics.h> |
| 8 | #include <northbridge/intel/sandybridge/sandybridge.h> |
Patrick Rudolph | db27e338 | 2017-07-27 18:00:59 +0200 | [diff] [blame] | 9 | |
| 10 | static void hybrid_graphics_init(void) |
| 11 | { |
| 12 | bool peg, igd; |
| 13 | u32 reg32; |
| 14 | |
| 15 | early_hybrid_graphics(&igd, &peg); |
| 16 | |
Evgeny Zinoviev | 384e9ae | 2018-08-30 02:18:48 +0300 | [diff] [blame] | 17 | if (peg && igd) |
| 18 | return; |
| 19 | |
Patrick Rudolph | db27e338 | 2017-07-27 18:00:59 +0200 | [diff] [blame] | 20 | /* Hide disabled devices */ |
| 21 | reg32 = pci_read_config32(PCI_DEV(0, 0, 0), DEVEN); |
| 22 | reg32 &= ~(DEVEN_PEG10 | DEVEN_IGD); |
| 23 | |
| 24 | if (peg) |
| 25 | reg32 |= DEVEN_PEG10; |
| 26 | |
| 27 | if (igd) |
| 28 | reg32 |= DEVEN_IGD; |
| 29 | else |
| 30 | /* Disable IGD VGA decode, no GTT or GFX stolen */ |
| 31 | pci_write_config16(PCI_DEV(0, 0, 0), GGC, 2); |
| 32 | |
| 33 | pci_write_config32(PCI_DEV(0, 0, 0), DEVEN, reg32); |
| 34 | } |
Philipp Deppenwiese | 714baa1 | 2017-01-02 17:58:09 +0100 | [diff] [blame] | 35 | |
Philipp Deppenwiese | 714baa1 | 2017-01-02 17:58:09 +0100 | [diff] [blame] | 36 | void mainboard_early_init(int s3resume) |
| 37 | { |
Patrick Rudolph | db27e338 | 2017-07-27 18:00:59 +0200 | [diff] [blame] | 38 | hybrid_graphics_init(); |
Philipp Deppenwiese | 714baa1 | 2017-01-02 17:58:09 +0100 | [diff] [blame] | 39 | } |