blob: 4fcd651b6ac23816a2960c65c64595866626b278 [file] [log] [blame]
Zaolina823f9b2014-05-06 21:31:45 +02001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2007-2010 coresystems GmbH
5 * Copyright (C) 2011 The ChromiumOS Authors. All rights reserved.
6 * Copyright (C) 2014 Vladimir Serbinenko
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
Zaolina823f9b2014-05-06 21:31:45 +020016 */
17
18#include <stdint.h>
19#include <string.h>
20#include <lib.h>
21#include <timestamp.h>
22#include <arch/byteorder.h>
23#include <arch/io.h>
24#include <device/pci_def.h>
25#include <device/pnp_def.h>
26#include <cpu/x86/lapic.h>
Kyösti Mälkki6722f8d2014-06-16 09:14:49 +030027#include <arch/acpi.h>
Zaolina823f9b2014-05-06 21:31:45 +020028#include <northbridge/intel/sandybridge/sandybridge.h>
Nicolas Reinecke30d0aa92014-10-17 12:08:05 +020029#include <northbridge/intel/sandybridge/raminit_native.h>
Zaolina823f9b2014-05-06 21:31:45 +020030#include <southbridge/intel/bd82x6x/pch.h>
Patrick Rudolphe8e66f42016-02-06 17:42:42 +010031#include <southbridge/intel/common/gpio.h>
Zaolina823f9b2014-05-06 21:31:45 +020032#include <arch/cpu.h>
Zaolina823f9b2014-05-06 21:31:45 +020033#include <cbfs.h>
Patrick Rudolphdb27e3382017-07-27 18:00:59 +020034#include <drivers/lenovo/hybrid_graphics/hybrid_graphics.h>
35#include <device/device.h>
36#include <device/pci.h>
37
38static void hybrid_graphics_init(void)
39{
40 bool peg, igd;
41 u32 reg32;
42
43 early_hybrid_graphics(&igd, &peg);
44
Evgeny Zinoviev384e9ae2018-08-30 02:18:48 +030045 if (peg && igd)
46 return;
47
Patrick Rudolphdb27e3382017-07-27 18:00:59 +020048 /* Hide disabled devices */
49 reg32 = pci_read_config32(PCI_DEV(0, 0, 0), DEVEN);
50 reg32 &= ~(DEVEN_PEG10 | DEVEN_IGD);
51
52 if (peg)
53 reg32 |= DEVEN_PEG10;
54
55 if (igd)
56 reg32 |= DEVEN_IGD;
57 else
58 /* Disable IGD VGA decode, no GTT or GFX stolen */
59 pci_write_config16(PCI_DEV(0, 0, 0), GGC, 2);
60
61 pci_write_config32(PCI_DEV(0, 0, 0), DEVEN, reg32);
62}
Zaolina823f9b2014-05-06 21:31:45 +020063
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020064void pch_enable_lpc(void)
Zaolina823f9b2014-05-06 21:31:45 +020065{
66 /* T520 EC Decode Range Port60/64, Port62/66 */
67 /* Enable EC, PS/2 Keyboard/Mouse */
68 pci_write_config16(PCH_LPC_DEV, LPC_EN,
Patrick Rudolph93eac6a2017-05-04 19:10:50 +020069 CNF2_LPC_EN | CNF1_LPC_EN | MC_LPC_EN | KBC_LPC_EN);
Zaolina823f9b2014-05-06 21:31:45 +020070
71 pci_write_config32(PCH_LPC_DEV, LPC_GEN1_DEC, 0x7c1601);
72 pci_write_config32(PCH_LPC_DEV, LPC_GEN2_DEC, 0xc15e1);
73 pci_write_config32(PCH_LPC_DEV, LPC_GEN4_DEC, 0x0c06a1);
74
Patrick Rudolphac27d362017-05-04 19:00:33 +020075 pci_write_config32(PCH_LPC_DEV, ETR3, 0x10000);
Zaolina823f9b2014-05-06 21:31:45 +020076}
77
Nico Huberff4025c2018-01-14 12:34:43 +010078void mainboard_rcba_config(void)
Zaolina823f9b2014-05-06 21:31:45 +020079{
Zaolina823f9b2014-05-06 21:31:45 +020080 RCBA32(BUC) = 0;
81}
82
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020083const struct southbridge_usb_port mainboard_usb_ports[] = {
84 { 1, 1, 0 }, /* P0 left dual conn, OC 0 */
Nico Rikkenecea3d42018-01-30 19:00:45 +010085 { 1, 1, 1 }, /* P1 system onboard USB (eSATA), (EHCI debug), OC 1 */
Vladimir Serbinenkofa1d6882014-10-19 02:50:45 +020086 { 1, 2, -1 }, /* P2: wimax / WLAN */
87 { 1, 1, -1 }, /* P3: WWAN, no OC */
88 { 1, 1, -1 }, /* P4: smartcard, no OC */
89 { 1, 1, -1 }, /* P5: ExpressCard, no OC */
90 { 0, 2, -1 }, /* P6: empty */
91 { 0, 2, -1 }, /* P7: to touch panel, no OC */
92 { 1, 1, 4 }, /* P8: left dual conn, OC4 */
93 { 1, 4, 5 }, /* P9: to system subcard back right, (EHCI debug), OC 5 */
94 { 1, 1, -1 }, /* P10: fingerprint reader, no OC */
95 { 1, 2, -1 }, /* P11: bluetooth, no OC. */
96 { 1, 1, -1 }, /* P12: docking, no OC */
97 { 1, 1, -1 }, /* P13: CAMERA (LCD), no OC */
98};
Zaolina823f9b2014-05-06 21:31:45 +020099
Patrick Rudolphdb27e3382017-07-27 18:00:59 +0200100void mainboard_early_init(int s3resume)
101{
102 hybrid_graphics_init();
Vladimir Serbinenko609bd942016-01-31 14:00:54 +0100103}
Vladimir Serbinenkoffbb3c02016-02-10 01:36:25 +0100104
105void mainboard_config_superio(void)
106{
107}