blob: 86fcda8b37f0d5ba958535ece667c9912b238ea7 [file] [log] [blame]
Angel Pons89ab2502020-04-03 01:22:28 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Philipp Deppenwiese714baa12017-01-02 17:58:09 +01002
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +02003#include <device/pci_ops.h>
Philipp Deppenwiese714baa12017-01-02 17:58:09 +01004#include <device/pci_def.h>
Philipp Deppenwiese714baa12017-01-02 17:58:09 +01005#include <southbridge/intel/bd82x6x/pch.h>
6#include <ec/lenovo/pmh7/pmh7.h>
Patrick Rudolphdb27e3382017-07-27 18:00:59 +02007#include <drivers/lenovo/hybrid_graphics/hybrid_graphics.h>
8#include <northbridge/intel/sandybridge/sandybridge.h>
Patrick Rudolphdb27e3382017-07-27 18:00:59 +02009
10static void hybrid_graphics_init(void)
11{
12 bool peg, igd;
13 u32 reg32;
14
15 early_hybrid_graphics(&igd, &peg);
16
Evgeny Zinoviev384e9ae2018-08-30 02:18:48 +030017 if (peg && igd)
18 return;
19
Patrick Rudolphdb27e3382017-07-27 18:00:59 +020020 /* 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 Deppenwiese714baa12017-01-02 17:58:09 +010035
Philipp Deppenwiese714baa12017-01-02 17:58:09 +010036void mainboard_early_init(int s3resume)
37{
Patrick Rudolphdb27e3382017-07-27 18:00:59 +020038 hybrid_graphics_init();
Philipp Deppenwiese714baa12017-01-02 17:58:09 +010039}