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. |
Vladimir Serbinenko | 9bf05de | 2013-11-14 19:11:19 +0100 | [diff] [blame] | 17 | */ |
| 18 | |
| 19 | #include <console/console.h> |
| 20 | #include <device/device.h> |
| 21 | #include <arch/io.h> |
| 22 | #include <delay.h> |
Vladimir Serbinenko | 63acd22 | 2014-06-01 00:26:48 +0200 | [diff] [blame] | 23 | #include <string.h> |
Vladimir Serbinenko | 9bf05de | 2013-11-14 19:11:19 +0100 | [diff] [blame] | 24 | #include <device/pci_def.h> |
| 25 | #include <device/pci_ops.h> |
| 26 | #include <device/pci_ids.h> |
| 27 | #include <arch/io.h> |
| 28 | #include <ec/lenovo/pmh7/pmh7.h> |
| 29 | #include <ec/acpi/ec.h> |
| 30 | #include <ec/lenovo/h8/h8.h> |
| 31 | #include <northbridge/intel/nehalem/nehalem.h> |
| 32 | #include <southbridge/intel/bd82x6x/pch.h> |
| 33 | |
| 34 | #include <pc80/mc146818rtc.h> |
| 35 | #include "dock.h" |
| 36 | #include <arch/x86/include/arch/acpigen.h> |
Vladimir Serbinenko | a2a906e | 2014-09-01 01:41:37 +0200 | [diff] [blame] | 37 | #include <drivers/intel/gma/int15.h> |
Vladimir Serbinenko | 9bf05de | 2013-11-14 19:11:19 +0100 | [diff] [blame] | 38 | #include <arch/interrupt.h> |
Vladimir Serbinenko | 9bf05de | 2013-11-14 19:11:19 +0100 | [diff] [blame] | 39 | #include <pc80/keyboard.h> |
| 40 | #include <cpu/x86/lapic.h> |
| 41 | #include <device/pci.h> |
| 42 | #include <smbios.h> |
Vladimir Serbinenko | 35c0f43 | 2014-09-02 22:25:36 +0200 | [diff] [blame] | 43 | #include "drivers/lenovo/lenovo.h" |
Vladimir Serbinenko | 9bf05de | 2013-11-14 19:11:19 +0100 | [diff] [blame] | 44 | |
| 45 | static acpi_cstate_t cst_entries[] = { |
| 46 | {1, 1, 1000, {0x7f, 1, 2, {0}, 1, 0}}, |
| 47 | {2, 1, 500, {0x01, 8, 0, {0}, DEFAULT_PMBASE + LV2, 0}}, |
| 48 | {2, 17, 250, {0x01, 8, 0, {0}, DEFAULT_PMBASE + LV3, 0}}, |
| 49 | }; |
| 50 | |
| 51 | int get_cst_entries(acpi_cstate_t ** entries) |
| 52 | { |
| 53 | *entries = cst_entries; |
| 54 | return ARRAY_SIZE(cst_entries); |
| 55 | } |
| 56 | |
Vladimir Serbinenko | 770c71f | 2014-01-28 00:05:29 +0100 | [diff] [blame] | 57 | static void mainboard_init(device_t dev) |
Vladimir Serbinenko | 9bf05de | 2013-11-14 19:11:19 +0100 | [diff] [blame] | 58 | { |
Vladimir Serbinenko | 9bf05de | 2013-11-14 19:11:19 +0100 | [diff] [blame] | 59 | printk(BIOS_SPEW, "starting SPI configuration\n"); |
| 60 | |
| 61 | /* Configure SPI. */ |
| 62 | RCBA32(0x3800) = 0x07ff0500; |
| 63 | RCBA32(0x3804) = 0x3f046008; |
| 64 | RCBA32(0x3808) = 0x0058efc0; |
| 65 | RCBA32(0x384c) = 0x92000000; |
| 66 | RCBA32(0x3850) = 0x00000a0b; |
| 67 | RCBA32(0x3858) = 0x07ff0500; |
| 68 | RCBA32(0x385c) = 0x04ff0003; |
| 69 | RCBA32(0x3860) = 0x00020001; |
| 70 | RCBA32(0x3864) = 0x00000fff; |
| 71 | RCBA32(0x3874) = 0; |
| 72 | RCBA32(0x3890) = 0xf8400000; |
| 73 | RCBA32(0x3894) = 0x143b5006; |
| 74 | RCBA32(0x3898) = 0x05200302; |
| 75 | RCBA32(0x389c) = 0x0601209f; |
| 76 | RCBA32(0x38b0) = 0x00000004; |
| 77 | RCBA32(0x38b4) = 0x03040002; |
Vladimir Serbinenko | 9bf05de | 2013-11-14 19:11:19 +0100 | [diff] [blame] | 78 | RCBA32(0x38c8) = 0x00002005; |
Vladimir Serbinenko | ee62164 | 2014-02-08 19:00:54 +0100 | [diff] [blame] | 79 | RCBA32(0x38c4) = 0x00802005; |
| 80 | RCBA32(0x38c0) = 0x00000007; |
Vladimir Serbinenko | 9bf05de | 2013-11-14 19:11:19 +0100 | [diff] [blame] | 81 | RCBA32(0x3804) = 0x3f04e008; |
| 82 | |
| 83 | printk(BIOS_SPEW, "SPI configured\n"); |
Vladimir Serbinenko | 770c71f | 2014-01-28 00:05:29 +0100 | [diff] [blame] | 84 | } |
| 85 | |
Alexander Couzens | 5eea458 | 2015-04-12 22:18:55 +0200 | [diff] [blame] | 86 | static void fill_ssdt(device_t device) |
Vladimir Serbinenko | 35c0f43 | 2014-09-02 22:25:36 +0200 | [diff] [blame] | 87 | { |
| 88 | drivers_lenovo_serial_ports_ssdt_generate("\\_SB.PCI0.LPCB", 0); |
Vladimir Serbinenko | 35c0f43 | 2014-09-02 22:25:36 +0200 | [diff] [blame] | 89 | } |
| 90 | |
Vladimir Serbinenko | 770c71f | 2014-01-28 00:05:29 +0100 | [diff] [blame] | 91 | static void mainboard_enable(device_t dev) |
| 92 | { |
| 93 | device_t dev0; |
| 94 | u16 pmbase; |
| 95 | |
| 96 | dev->ops->init = mainboard_init; |
Vladimir Serbinenko | 35c0f43 | 2014-09-02 22:25:36 +0200 | [diff] [blame] | 97 | dev->ops->acpi_fill_ssdt_generator = fill_ssdt; |
Vladimir Serbinenko | 9bf05de | 2013-11-14 19:11:19 +0100 | [diff] [blame] | 98 | |
| 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 */ |
| 113 | dev0 = dev_find_slot(0, PCI_DEVFN(0, 0)); |
| 114 | if (dev0 && pci_read_config32(dev0, SKPAD) == SKPAD_ACPI_S3_MAGIC) |
| 115 | ec_write(0x0c, 0xc7); |
| 116 | |
Vladimir Serbinenko | a2a906e | 2014-09-01 01:41:37 +0200 | [diff] [blame] | 117 | 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] | 118 | |
Vladimir Serbinenko | 9bf05de | 2013-11-14 19:11:19 +0100 | [diff] [blame] | 119 | } |
| 120 | |
| 121 | struct chip_operations mainboard_ops = { |
| 122 | .enable_dev = mainboard_enable, |
| 123 | }; |