blob: 6c5f9c957f7da7e55070b233befafcea88c97dbe [file] [log] [blame]
Vladimir Serbinenko9bf05de2013-11-14 19:11:19 +01001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2007-2009 coresystems GmbH
5 * Copyright (C) 2011 Sven Schnelle <svens@stackframe.org>
6 * Copyright (C) 2013 Vladimir Serbinenko <phcoder@gmail.com>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; version 2 of
11 * the License.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
Vladimir Serbinenko9bf05de2013-11-14 19:11:19 +010017 */
18
19#include <console/console.h>
20#include <device/device.h>
Kyösti Mälkki1b7609c2016-06-25 11:40:00 +030021#include <arch/acpi.h>
Vladimir Serbinenko9bf05de2013-11-14 19:11:19 +010022#include <arch/io.h>
23#include <delay.h>
Vladimir Serbinenko63acd222014-06-01 00:26:48 +020024#include <string.h>
Vladimir Serbinenko9bf05de2013-11-14 19:11:19 +010025#include <device/pci_def.h>
26#include <device/pci_ops.h>
27#include <device/pci_ids.h>
28#include <arch/io.h>
29#include <ec/lenovo/pmh7/pmh7.h>
30#include <ec/acpi/ec.h>
31#include <ec/lenovo/h8/h8.h>
32#include <northbridge/intel/nehalem/nehalem.h>
33#include <southbridge/intel/bd82x6x/pch.h>
34
35#include <pc80/mc146818rtc.h>
36#include "dock.h"
37#include <arch/x86/include/arch/acpigen.h>
Vladimir Serbinenkoa2a906e2014-09-01 01:41:37 +020038#include <drivers/intel/gma/int15.h>
Vladimir Serbinenko9bf05de2013-11-14 19:11:19 +010039#include <arch/interrupt.h>
Vladimir Serbinenko9bf05de2013-11-14 19:11:19 +010040#include <pc80/keyboard.h>
41#include <cpu/x86/lapic.h>
42#include <device/pci.h>
43#include <smbios.h>
Vladimir Serbinenko35c0f432014-09-02 22:25:36 +020044#include "drivers/lenovo/lenovo.h"
Vladimir Serbinenko9bf05de2013-11-14 19:11:19 +010045
46static acpi_cstate_t cst_entries[] = {
47 {1, 1, 1000, {0x7f, 1, 2, {0}, 1, 0}},
48 {2, 1, 500, {0x01, 8, 0, {0}, DEFAULT_PMBASE + LV2, 0}},
49 {2, 17, 250, {0x01, 8, 0, {0}, DEFAULT_PMBASE + LV3, 0}},
50};
51
52int get_cst_entries(acpi_cstate_t ** entries)
53{
54 *entries = cst_entries;
55 return ARRAY_SIZE(cst_entries);
56}
57
Vladimir Serbinenko770c71f2014-01-28 00:05:29 +010058static void mainboard_init(device_t dev)
Vladimir Serbinenko9bf05de2013-11-14 19:11:19 +010059{
Vladimir Serbinenko9bf05de2013-11-14 19:11:19 +010060 printk(BIOS_SPEW, "starting SPI configuration\n");
61
62 /* Configure SPI. */
63 RCBA32(0x3800) = 0x07ff0500;
64 RCBA32(0x3804) = 0x3f046008;
65 RCBA32(0x3808) = 0x0058efc0;
66 RCBA32(0x384c) = 0x92000000;
67 RCBA32(0x3850) = 0x00000a0b;
68 RCBA32(0x3858) = 0x07ff0500;
69 RCBA32(0x385c) = 0x04ff0003;
70 RCBA32(0x3860) = 0x00020001;
71 RCBA32(0x3864) = 0x00000fff;
72 RCBA32(0x3874) = 0;
73 RCBA32(0x3890) = 0xf8400000;
74 RCBA32(0x3894) = 0x143b5006;
75 RCBA32(0x3898) = 0x05200302;
76 RCBA32(0x389c) = 0x0601209f;
77 RCBA32(0x38b0) = 0x00000004;
78 RCBA32(0x38b4) = 0x03040002;
Vladimir Serbinenko9bf05de2013-11-14 19:11:19 +010079 RCBA32(0x38c8) = 0x00002005;
Vladimir Serbinenkoee621642014-02-08 19:00:54 +010080 RCBA32(0x38c4) = 0x00802005;
81 RCBA32(0x38c0) = 0x00000007;
Vladimir Serbinenko9bf05de2013-11-14 19:11:19 +010082 RCBA32(0x3804) = 0x3f04e008;
83
84 printk(BIOS_SPEW, "SPI configured\n");
Vladimir Serbinenko770c71f2014-01-28 00:05:29 +010085}
86
Alexander Couzens5eea4582015-04-12 22:18:55 +020087static void fill_ssdt(device_t device)
Vladimir Serbinenko35c0f432014-09-02 22:25:36 +020088{
89 drivers_lenovo_serial_ports_ssdt_generate("\\_SB.PCI0.LPCB", 0);
Vladimir Serbinenko35c0f432014-09-02 22:25:36 +020090}
91
Vladimir Serbinenko770c71f2014-01-28 00:05:29 +010092static void mainboard_enable(device_t dev)
93{
Vladimir Serbinenko770c71f2014-01-28 00:05:29 +010094 u16 pmbase;
95
96 dev->ops->init = mainboard_init;
Vladimir Serbinenko35c0f432014-09-02 22:25:36 +020097 dev->ops->acpi_fill_ssdt_generator = fill_ssdt;
Vladimir Serbinenko9bf05de2013-11-14 19:11:19 +010098
99 pmbase = pci_read_config32(dev_find_slot(0, PCI_DEVFN(0x1f, 0)),
100 PMBASE) & 0xff80;
101
102 printk(BIOS_SPEW, " ... pmbase = 0x%04x\n", pmbase);
103
104 outl(0, pmbase + SMI_EN);
105
106 enable_lapic();
107 pci_write_config32(dev_find_slot(0, PCI_DEVFN(0x1f, 0)), GPIO_BASE,
108 DEFAULT_GPIOBASE | 1);
109 pci_write_config8(dev_find_slot(0, PCI_DEVFN(0x1f, 0)), GPIO_CNTL,
110 0x10);
111
112 /* If we're resuming from suspend, blink suspend LED */
Kyösti Mälkki1b7609c2016-06-25 11:40:00 +0300113 if (acpi_is_wakeup_s3())
Vladimir Serbinenko9bf05de2013-11-14 19:11:19 +0100114 ec_write(0x0c, 0xc7);
115
Vladimir Serbinenkoa2a906e2014-09-01 01:41:37 +0200116 install_intel_vga_int15_handler(GMA_INT15_ACTIVE_LFP_INT_LVDS, GMA_INT15_PANEL_FIT_DEFAULT, GMA_INT15_BOOT_DISPLAY_LFP, 2);
Vladimir Serbinenko9bf05de2013-11-14 19:11:19 +0100117
Vladimir Serbinenko9bf05de2013-11-14 19:11:19 +0100118}
119
120struct chip_operations mainboard_ops = {
121 .enable_dev = mainboard_enable,
122};