blob: 90d0886af1a85c5474c180ab3f16973c01a0a864 [file] [log] [blame]
Philipp Deppenwiese714baa12017-01-02 17:58:09 +01001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2017 Patrick Rudolph <siro@das-labor.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#include <arch/io.h>
17#include <device/pci_def.h>
18#include <northbridge/intel/sandybridge/raminit_native.h>
19#include <southbridge/intel/bd82x6x/pch.h>
20#include <ec/lenovo/pmh7/pmh7.h>
Patrick Rudolphdb27e3382017-07-27 18:00:59 +020021#include <drivers/lenovo/hybrid_graphics/hybrid_graphics.h>
22#include <northbridge/intel/sandybridge/sandybridge.h>
23#include <device/device.h>
24#include <device/pci.h>
25
26static void hybrid_graphics_init(void)
27{
28 bool peg, igd;
29 u32 reg32;
30
31 early_hybrid_graphics(&igd, &peg);
32
Evgeny Zinoviev384e9ae2018-08-30 02:18:48 +030033 if (peg && igd)
34 return;
35
Patrick Rudolphdb27e3382017-07-27 18:00:59 +020036 /* Hide disabled devices */
37 reg32 = pci_read_config32(PCI_DEV(0, 0, 0), DEVEN);
38 reg32 &= ~(DEVEN_PEG10 | DEVEN_IGD);
39
40 if (peg)
41 reg32 |= DEVEN_PEG10;
42
43 if (igd)
44 reg32 |= DEVEN_IGD;
45 else
46 /* Disable IGD VGA decode, no GTT or GFX stolen */
47 pci_write_config16(PCI_DEV(0, 0, 0), GGC, 2);
48
49 pci_write_config32(PCI_DEV(0, 0, 0), DEVEN, reg32);
50}
Philipp Deppenwiese714baa12017-01-02 17:58:09 +010051
52void pch_enable_lpc(void)
53{
54 /* EC Decode Range Port60/64, Port62/66 */
55 /* Enable TPM, EC, PS/2 Keyboard/Mouse */
56 pci_write_config16(PCH_LPC_DEV, LPC_EN,
57 CNF2_LPC_EN | MC_LPC_EN | KBC_LPC_EN);
58
59 pci_write_config32(PCH_LPC_DEV, LPC_GEN1_DEC,
60 (0x0c << 16) | EC_LENOVO_PMH7_BASE | 1);
61}
62
Nico Huberff4025c2018-01-14 12:34:43 +010063void mainboard_rcba_config(void)
Philipp Deppenwiese714baa12017-01-02 17:58:09 +010064{
Philipp Deppenwiese714baa12017-01-02 17:58:09 +010065}
66
67/* FIXME: used T530 values here */
68const struct southbridge_usb_port mainboard_usb_ports[] = {
69 { 1, 1, 0 },
70 { 1, 1, 1 },
71 { 1, 2, 3 },
72 { 1, 1, -1 },
73 { 1, 1, 2 },
74 { 1, 0, -1 },
75 { 0, 0, -1 },
76 { 1, 2, -1 },
77 { 1, 0, -1 },
78 { 1, 1, 5 },
79 { 1, 0, -1 },
80 { 1, 0, -1 },
81 { 1, 3, -1 },
82 { 1, 1, -1 },
83};
84
85void mainboard_early_init(int s3resume)
86{
Patrick Rudolphdb27e3382017-07-27 18:00:59 +020087 hybrid_graphics_init();
Philipp Deppenwiese714baa12017-01-02 17:58:09 +010088}
89
90void mainboard_config_superio(void)
91{
92}
93
94void mainboard_get_spd(spd_raw_data *spd, bool id_only)
95{
96 read_spd(&spd[0], 0x50, id_only);
97 read_spd(&spd[2], 0x51, id_only);
98}