blob: eb558ac1b80b64cc845dff58564230a1fb7ff85e [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
33 /* Hide disabled devices */
34 reg32 = pci_read_config32(PCI_DEV(0, 0, 0), DEVEN);
35 reg32 &= ~(DEVEN_PEG10 | DEVEN_IGD);
36
37 if (peg)
38 reg32 |= DEVEN_PEG10;
39
40 if (igd)
41 reg32 |= DEVEN_IGD;
42 else
43 /* Disable IGD VGA decode, no GTT or GFX stolen */
44 pci_write_config16(PCI_DEV(0, 0, 0), GGC, 2);
45
46 pci_write_config32(PCI_DEV(0, 0, 0), DEVEN, reg32);
47}
Philipp Deppenwiese714baa12017-01-02 17:58:09 +010048
49void pch_enable_lpc(void)
50{
51 /* EC Decode Range Port60/64, Port62/66 */
52 /* Enable TPM, EC, PS/2 Keyboard/Mouse */
53 pci_write_config16(PCH_LPC_DEV, LPC_EN,
54 CNF2_LPC_EN | MC_LPC_EN | KBC_LPC_EN);
55
56 pci_write_config32(PCH_LPC_DEV, LPC_GEN1_DEC,
57 (0x0c << 16) | EC_LENOVO_PMH7_BASE | 1);
58}
59
60void rcba_config(void)
61{
62 /* Disable unused devices (board specific, reserved only).
63 * FIXME: Test if reserved bits are read only. */
64 RCBA32(FD) = PCH_DISABLE_ALWAYS | 0x10001fe0;
65}
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}