Zaolin | a823f9b | 2014-05-06 21:31:45 +0200 | [diff] [blame] | 1 | /* |
| 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. |
Zaolin | a823f9b | 2014-05-06 21:31:45 +0200 | [diff] [blame] | 16 | */ |
| 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> |
| 27 | #include <pc80/mc146818rtc.h> |
Kyösti Mälkki | 6722f8d | 2014-06-16 09:14:49 +0300 | [diff] [blame] | 28 | #include <arch/acpi.h> |
Zaolin | a823f9b | 2014-05-06 21:31:45 +0200 | [diff] [blame] | 29 | #include <cbmem.h> |
| 30 | #include <console/console.h> |
| 31 | #include <northbridge/intel/sandybridge/sandybridge.h> |
Nicolas Reinecke | 30d0aa9 | 2014-10-17 12:08:05 +0200 | [diff] [blame] | 32 | #include <northbridge/intel/sandybridge/raminit_native.h> |
Zaolin | a823f9b | 2014-05-06 21:31:45 +0200 | [diff] [blame] | 33 | #include <southbridge/intel/bd82x6x/pch.h> |
Patrick Rudolph | e8e66f4 | 2016-02-06 17:42:42 +0100 | [diff] [blame] | 34 | #include <southbridge/intel/common/gpio.h> |
Zaolin | a823f9b | 2014-05-06 21:31:45 +0200 | [diff] [blame] | 35 | #include <arch/cpu.h> |
Zaolin | a823f9b | 2014-05-06 21:31:45 +0200 | [diff] [blame] | 36 | #include <cpu/x86/msr.h> |
| 37 | #include <cbfs.h> |
Patrick Rudolph | db27e338 | 2017-07-27 18:00:59 +0200 | [diff] [blame^] | 38 | #include <drivers/lenovo/hybrid_graphics/hybrid_graphics.h> |
| 39 | #include <device/device.h> |
| 40 | #include <device/pci.h> |
| 41 | |
| 42 | static void hybrid_graphics_init(void) |
| 43 | { |
| 44 | bool peg, igd; |
| 45 | u32 reg32; |
| 46 | |
| 47 | early_hybrid_graphics(&igd, &peg); |
| 48 | |
| 49 | /* Hide disabled devices */ |
| 50 | reg32 = pci_read_config32(PCI_DEV(0, 0, 0), DEVEN); |
| 51 | reg32 &= ~(DEVEN_PEG10 | DEVEN_IGD); |
| 52 | |
| 53 | if (peg) |
| 54 | reg32 |= DEVEN_PEG10; |
| 55 | |
| 56 | if (igd) |
| 57 | reg32 |= DEVEN_IGD; |
| 58 | else |
| 59 | /* Disable IGD VGA decode, no GTT or GFX stolen */ |
| 60 | pci_write_config16(PCI_DEV(0, 0, 0), GGC, 2); |
| 61 | |
| 62 | pci_write_config32(PCI_DEV(0, 0, 0), DEVEN, reg32); |
| 63 | } |
Zaolin | a823f9b | 2014-05-06 21:31:45 +0200 | [diff] [blame] | 64 | |
Vladimir Serbinenko | fa1d688 | 2014-10-19 02:50:45 +0200 | [diff] [blame] | 65 | void pch_enable_lpc(void) |
Zaolin | a823f9b | 2014-05-06 21:31:45 +0200 | [diff] [blame] | 66 | { |
| 67 | /* T520 EC Decode Range Port60/64, Port62/66 */ |
| 68 | /* Enable EC, PS/2 Keyboard/Mouse */ |
| 69 | pci_write_config16(PCH_LPC_DEV, LPC_EN, |
Patrick Rudolph | 93eac6a | 2017-05-04 19:10:50 +0200 | [diff] [blame] | 70 | CNF2_LPC_EN | CNF1_LPC_EN | MC_LPC_EN | KBC_LPC_EN); |
Zaolin | a823f9b | 2014-05-06 21:31:45 +0200 | [diff] [blame] | 71 | |
| 72 | pci_write_config32(PCH_LPC_DEV, LPC_GEN1_DEC, 0x7c1601); |
| 73 | pci_write_config32(PCH_LPC_DEV, LPC_GEN2_DEC, 0xc15e1); |
| 74 | pci_write_config32(PCH_LPC_DEV, LPC_GEN4_DEC, 0x0c06a1); |
| 75 | |
Patrick Rudolph | ac27d36 | 2017-05-04 19:00:33 +0200 | [diff] [blame] | 76 | pci_write_config32(PCH_LPC_DEV, ETR3, 0x10000); |
Zaolin | a823f9b | 2014-05-06 21:31:45 +0200 | [diff] [blame] | 77 | } |
| 78 | |
Vladimir Serbinenko | fa1d688 | 2014-10-19 02:50:45 +0200 | [diff] [blame] | 79 | void rcba_config(void) |
Zaolin | a823f9b | 2014-05-06 21:31:45 +0200 | [diff] [blame] | 80 | { |
Zaolin | a823f9b | 2014-05-06 21:31:45 +0200 | [diff] [blame] | 81 | /* Disable unused devices (board specific) */ |
Nicolas Reinecke | a41e5c7 | 2014-08-24 19:49:35 +0200 | [diff] [blame] | 82 | RCBA32(FD) = 0x1ee51fe3; |
Zaolin | a823f9b | 2014-05-06 21:31:45 +0200 | [diff] [blame] | 83 | RCBA32(BUC) = 0; |
| 84 | } |
| 85 | |
Vladimir Serbinenko | fa1d688 | 2014-10-19 02:50:45 +0200 | [diff] [blame] | 86 | const struct southbridge_usb_port mainboard_usb_ports[] = { |
| 87 | { 1, 1, 0 }, /* P0 left dual conn, OC 0 */ |
| 88 | { 1, 1, 1 }, /* P1 system onboard USB port (eSATA), (EHCI debug), OC 1 */ |
| 89 | { 1, 2, -1 }, /* P2: wimax / WLAN */ |
| 90 | { 1, 1, -1 }, /* P3: WWAN, no OC */ |
| 91 | { 1, 1, -1 }, /* P4: smartcard, no OC */ |
| 92 | { 1, 1, -1 }, /* P5: ExpressCard, no OC */ |
| 93 | { 0, 2, -1 }, /* P6: empty */ |
| 94 | { 0, 2, -1 }, /* P7: to touch panel, no OC */ |
| 95 | { 1, 1, 4 }, /* P8: left dual conn, OC4 */ |
| 96 | { 1, 4, 5 }, /* P9: to system subcard back right, (EHCI debug), OC 5 */ |
| 97 | { 1, 1, -1 }, /* P10: fingerprint reader, no OC */ |
| 98 | { 1, 2, -1 }, /* P11: bluetooth, no OC. */ |
| 99 | { 1, 1, -1 }, /* P12: docking, no OC */ |
| 100 | { 1, 1, -1 }, /* P13: CAMERA (LCD), no OC */ |
| 101 | }; |
Zaolin | a823f9b | 2014-05-06 21:31:45 +0200 | [diff] [blame] | 102 | |
Kyösti Mälkki | e258b9a | 2016-11-18 19:59:23 +0200 | [diff] [blame] | 103 | void mainboard_get_spd(spd_raw_data *spd, bool id_only) { |
| 104 | read_spd (&spd[0], 0x50, id_only); |
| 105 | read_spd (&spd[2], 0x51, id_only); |
Zaolin | a823f9b | 2014-05-06 21:31:45 +0200 | [diff] [blame] | 106 | } |
Vladimir Serbinenko | 609bd94 | 2016-01-31 14:00:54 +0100 | [diff] [blame] | 107 | |
Patrick Rudolph | db27e338 | 2017-07-27 18:00:59 +0200 | [diff] [blame^] | 108 | void mainboard_early_init(int s3resume) |
| 109 | { |
| 110 | hybrid_graphics_init(); |
Vladimir Serbinenko | 609bd94 | 2016-01-31 14:00:54 +0100 | [diff] [blame] | 111 | } |
Vladimir Serbinenko | ffbb3c0 | 2016-02-10 01:36:25 +0100 | [diff] [blame] | 112 | |
| 113 | void mainboard_config_superio(void) |
| 114 | { |
| 115 | } |