Vladimir Serbinenko | 9bf05de | 2013-11-14 19:11:19 +0100 | [diff] [blame] | 1 | /* |
| 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 Serbinenko | 63acd22 | 2014-06-01 00:26:48 +0200 | [diff] [blame] | 28 | #include <string.h> |
Vladimir Serbinenko | 9bf05de | 2013-11-14 19:11:19 +0100 | [diff] [blame] | 29 | #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 Serbinenko | 6a3a8ce | 2014-08-17 23:48:42 +0200 | [diff] [blame] | 38 | #include <device/azalia_device.h> |
Vladimir Serbinenko | 9bf05de | 2013-11-14 19:11:19 +0100 | [diff] [blame] | 39 | |
| 40 | #include <pc80/mc146818rtc.h> |
| 41 | #include "dock.h" |
Vladimir Serbinenko | 517406a | 2014-01-10 01:01:42 +0100 | [diff] [blame] | 42 | #include "hda_verb.h" |
Vladimir Serbinenko | 9bf05de | 2013-11-14 19:11:19 +0100 | [diff] [blame] | 43 | #include <arch/x86/include/arch/acpigen.h> |
Vladimir Serbinenko | a2a906e | 2014-09-01 01:41:37 +0200 | [diff] [blame^] | 44 | #include <drivers/intel/gma/int15.h> |
Vladimir Serbinenko | 9bf05de | 2013-11-14 19:11:19 +0100 | [diff] [blame] | 45 | #include <arch/interrupt.h> |
Vladimir Serbinenko | 9bf05de | 2013-11-14 19:11:19 +0100 | [diff] [blame] | 46 | #include <pc80/keyboard.h> |
| 47 | #include <cpu/x86/lapic.h> |
| 48 | #include <device/pci.h> |
| 49 | #include <smbios.h> |
Vladimir Serbinenko | 63acd22 | 2014-06-01 00:26:48 +0200 | [diff] [blame] | 50 | #include <build.h> |
Vladimir Serbinenko | 9bf05de | 2013-11-14 19:11:19 +0100 | [diff] [blame] | 51 | |
| 52 | static 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 | |
| 58 | int get_cst_entries(acpi_cstate_t ** entries) |
| 59 | { |
| 60 | *entries = cst_entries; |
| 61 | return ARRAY_SIZE(cst_entries); |
| 62 | } |
| 63 | |
Vladimir Serbinenko | 63acd22 | 2014-06-01 00:26:48 +0200 | [diff] [blame] | 64 | const 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 Serbinenko | 517406a | 2014-01-10 01:01:42 +0100 | [diff] [blame] | 73 | /* Audio Setup */ |
| 74 | |
Vladimir Serbinenko | 517406a | 2014-01-10 01:01:42 +0100 | [diff] [blame] | 75 | static 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 Serbinenko | 770c71f | 2014-01-28 00:05:29 +0100 | [diff] [blame] | 81 | static void mainboard_init(device_t dev) |
Vladimir Serbinenko | 9bf05de | 2013-11-14 19:11:19 +0100 | [diff] [blame] | 82 | { |
Vladimir Serbinenko | 9bf05de | 2013-11-14 19:11:19 +0100 | [diff] [blame] | 83 | 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 Serbinenko | 9bf05de | 2013-11-14 19:11:19 +0100 | [diff] [blame] | 102 | RCBA32(0x38c8) = 0x00002005; |
Vladimir Serbinenko | ee62164 | 2014-02-08 19:00:54 +0100 | [diff] [blame] | 103 | RCBA32(0x38c4) = 0x00802005; |
| 104 | RCBA32(0x38c0) = 0x00000007; |
Vladimir Serbinenko | 9bf05de | 2013-11-14 19:11:19 +0100 | [diff] [blame] | 105 | RCBA32(0x3804) = 0x3f04e008; |
| 106 | |
| 107 | printk(BIOS_SPEW, "SPI configured\n"); |
Vladimir Serbinenko | 770c71f | 2014-01-28 00:05:29 +0100 | [diff] [blame] | 108 | /* 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'Callaghan | def00be | 2014-04-30 05:01:52 +1000 | [diff] [blame] | 111 | pc_keyboard_init(); |
Vladimir Serbinenko | 770c71f | 2014-01-28 00:05:29 +0100 | [diff] [blame] | 112 | |
| 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 | |
| 122 | static void mainboard_enable(device_t dev) |
| 123 | { |
| 124 | device_t dev0; |
| 125 | u16 pmbase; |
| 126 | |
| 127 | dev->ops->init = mainboard_init; |
Vladimir Serbinenko | 9bf05de | 2013-11-14 19:11:19 +0100 | [diff] [blame] | 128 | |
| 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 Serbinenko | a2a906e | 2014-09-01 01:41:37 +0200 | [diff] [blame^] | 147 | install_intel_vga_int15_handler(GMA_INT15_ACTIVE_LFP_INT_LVDS, GMA_INT15_PANEL_FIT_DEFAULT, GMA_INT15_BOOT_DISPLAY_LFP, 2); |
Vladimir Serbinenko | 9bf05de | 2013-11-14 19:11:19 +0100 | [diff] [blame] | 148 | |
Vladimir Serbinenko | 517406a | 2014-01-10 01:01:42 +0100 | [diff] [blame] | 149 | verb_setup(); |
Vladimir Serbinenko | 9bf05de | 2013-11-14 19:11:19 +0100 | [diff] [blame] | 150 | } |
| 151 | |
| 152 | struct chip_operations mainboard_ops = { |
| 153 | .enable_dev = mainboard_enable, |
| 154 | }; |