blob: fdeddd44023ae8eb956b59a751a88c4c2295c556 [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.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
21 * MA 02110-1301 USA
22 */
23
24#include <console/console.h>
25#include <device/device.h>
26#include <arch/io.h>
27#include <delay.h>
Vladimir Serbinenko63acd222014-06-01 00:26:48 +020028#include <string.h>
Vladimir Serbinenko9bf05de2013-11-14 19:11:19 +010029#include <device/pci_def.h>
30#include <device/pci_ops.h>
31#include <device/pci_ids.h>
32#include <arch/io.h>
33#include <ec/lenovo/pmh7/pmh7.h>
34#include <ec/acpi/ec.h>
35#include <ec/lenovo/h8/h8.h>
36#include <northbridge/intel/nehalem/nehalem.h>
37#include <southbridge/intel/bd82x6x/pch.h>
Vladimir Serbinenko6a3a8ce2014-08-17 23:48:42 +020038#include <device/azalia_device.h>
Vladimir Serbinenko9bf05de2013-11-14 19:11:19 +010039
40#include <pc80/mc146818rtc.h>
41#include "dock.h"
Vladimir Serbinenko517406a2014-01-10 01:01:42 +010042#include "hda_verb.h"
Vladimir Serbinenko9bf05de2013-11-14 19:11:19 +010043#include <arch/x86/include/arch/acpigen.h>
Vladimir Serbinenkoa2a906e2014-09-01 01:41:37 +020044#include <drivers/intel/gma/int15.h>
Vladimir Serbinenko9bf05de2013-11-14 19:11:19 +010045#include <arch/interrupt.h>
Vladimir Serbinenko9bf05de2013-11-14 19:11:19 +010046#include <pc80/keyboard.h>
47#include <cpu/x86/lapic.h>
48#include <device/pci.h>
49#include <smbios.h>
Vladimir Serbinenko63acd222014-06-01 00:26:48 +020050#include <build.h>
Vladimir Serbinenko9bf05de2013-11-14 19:11:19 +010051
52static acpi_cstate_t cst_entries[] = {
53 {1, 1, 1000, {0x7f, 1, 2, {0}, 1, 0}},
54 {2, 1, 500, {0x01, 8, 0, {0}, DEFAULT_PMBASE + LV2, 0}},
55 {2, 17, 250, {0x01, 8, 0, {0}, DEFAULT_PMBASE + LV3, 0}},
56};
57
58int get_cst_entries(acpi_cstate_t ** entries)
59{
60 *entries = cst_entries;
61 return ARRAY_SIZE(cst_entries);
62}
63
Vladimir Serbinenko63acd222014-06-01 00:26:48 +020064const char *smbios_mainboard_bios_version(void)
65{
66 /* Satisfy thinkpad_acpi. */
67 if (strlen(CONFIG_LOCALVERSION))
68 return "CBET4000 " CONFIG_LOCALVERSION;
69 else
70 return "CBET4000 " COREBOOT_VERSION;
71}
72
Vladimir Serbinenko517406a2014-01-10 01:01:42 +010073/* Audio Setup */
74
Vladimir Serbinenko517406a2014-01-10 01:01:42 +010075static void verb_setup(void)
76{
77 cim_verb_data = mainboard_cim_verb_data;
78 cim_verb_data_size = sizeof(mainboard_cim_verb_data);
79}
80
Vladimir Serbinenko770c71f2014-01-28 00:05:29 +010081static void mainboard_init(device_t dev)
Vladimir Serbinenko9bf05de2013-11-14 19:11:19 +010082{
Vladimir Serbinenko9bf05de2013-11-14 19:11:19 +010083 printk(BIOS_SPEW, "starting SPI configuration\n");
84
85 /* Configure SPI. */
86 RCBA32(0x3800) = 0x07ff0500;
87 RCBA32(0x3804) = 0x3f046008;
88 RCBA32(0x3808) = 0x0058efc0;
89 RCBA32(0x384c) = 0x92000000;
90 RCBA32(0x3850) = 0x00000a0b;
91 RCBA32(0x3858) = 0x07ff0500;
92 RCBA32(0x385c) = 0x04ff0003;
93 RCBA32(0x3860) = 0x00020001;
94 RCBA32(0x3864) = 0x00000fff;
95 RCBA32(0x3874) = 0;
96 RCBA32(0x3890) = 0xf8400000;
97 RCBA32(0x3894) = 0x143b5006;
98 RCBA32(0x3898) = 0x05200302;
99 RCBA32(0x389c) = 0x0601209f;
100 RCBA32(0x38b0) = 0x00000004;
101 RCBA32(0x38b4) = 0x03040002;
Vladimir Serbinenko9bf05de2013-11-14 19:11:19 +0100102 RCBA32(0x38c8) = 0x00002005;
Vladimir Serbinenkoee621642014-02-08 19:00:54 +0100103 RCBA32(0x38c4) = 0x00802005;
104 RCBA32(0x38c0) = 0x00000007;
Vladimir Serbinenko9bf05de2013-11-14 19:11:19 +0100105 RCBA32(0x3804) = 0x3f04e008;
106
107 printk(BIOS_SPEW, "SPI configured\n");
Vladimir Serbinenko770c71f2014-01-28 00:05:29 +0100108 /* This sneaked in here, because X201 SuperIO chip isn't really
109 connected to anything and hence we don't init it.
110 */
Edward O'Callaghandef00be2014-04-30 05:01:52 +1000111 pc_keyboard_init();
Vladimir Serbinenko770c71f2014-01-28 00:05:29 +0100112
113 /* Enable expresscard hotplug events. */
114 pci_write_config32(dev_find_slot(0, PCI_DEVFN(0x1c, 3)),
115 0xd8,
116 pci_read_config32(dev_find_slot(0, PCI_DEVFN(0x1c, 3)), 0xd8)
117 | (1 << 30));
118 pci_write_config16(dev_find_slot(0, PCI_DEVFN(0x1c, 3)),
119 0x42, 0x142);
120}
121
122static void mainboard_enable(device_t dev)
123{
124 device_t dev0;
125 u16 pmbase;
126
127 dev->ops->init = mainboard_init;
Vladimir Serbinenko9bf05de2013-11-14 19:11:19 +0100128
129 pmbase = pci_read_config32(dev_find_slot(0, PCI_DEVFN(0x1f, 0)),
130 PMBASE) & 0xff80;
131
132 printk(BIOS_SPEW, " ... pmbase = 0x%04x\n", pmbase);
133
134 outl(0, pmbase + SMI_EN);
135
136 enable_lapic();
137 pci_write_config32(dev_find_slot(0, PCI_DEVFN(0x1f, 0)), GPIO_BASE,
138 DEFAULT_GPIOBASE | 1);
139 pci_write_config8(dev_find_slot(0, PCI_DEVFN(0x1f, 0)), GPIO_CNTL,
140 0x10);
141
142 /* If we're resuming from suspend, blink suspend LED */
143 dev0 = dev_find_slot(0, PCI_DEVFN(0, 0));
144 if (dev0 && pci_read_config32(dev0, SKPAD) == SKPAD_ACPI_S3_MAGIC)
145 ec_write(0x0c, 0xc7);
146
Vladimir Serbinenkoa2a906e2014-09-01 01:41:37 +0200147 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 +0100148
Vladimir Serbinenko517406a2014-01-10 01:01:42 +0100149 verb_setup();
Vladimir Serbinenko9bf05de2013-11-14 19:11:19 +0100150}
151
152struct chip_operations mainboard_ops = {
153 .enable_dev = mainboard_enable,
154};