Stefan Reinauer | 6651da3 | 2012-04-27 23:16:30 +0200 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2007-2009 coresystems GmbH |
| 5 | * Copyright (C) 2011 The ChromiumOS Authors. All rights reserved. |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; version 2 of the License. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 19 | */ |
| 20 | |
| 21 | #include <types.h> |
| 22 | #include <string.h> |
| 23 | #include <device/device.h> |
| 24 | #include <device/device.h> |
| 25 | #include <device/pci_def.h> |
| 26 | #include <device/pci_ops.h> |
| 27 | #include <console/console.h> |
Patrick Georgi | 199b09c | 2012-11-22 12:46:12 +0100 | [diff] [blame] | 28 | #if CONFIG_PCI_ROM_RUN || CONFIG_VGA_ROM_RUN |
Stefan Reinauer | 6651da3 | 2012-04-27 23:16:30 +0200 | [diff] [blame] | 29 | #include <x86emu/x86emu.h> |
| 30 | #endif |
| 31 | #include <pc80/mc146818rtc.h> |
| 32 | #include <arch/acpi.h> |
| 33 | #include <arch/io.h> |
| 34 | #include <arch/interrupt.h> |
| 35 | #include <arch/coreboot_tables.h> |
| 36 | #include "hda_verb.h" |
Stefan Reinauer | 6651da3 | 2012-04-27 23:16:30 +0200 | [diff] [blame] | 37 | #include <southbridge/intel/bd82x6x/pch.h> |
| 38 | |
| 39 | void mainboard_suspend_resume(void) |
| 40 | { |
| 41 | /* Call SMM finalize() handlers before resume */ |
| 42 | outb(0xcb, 0xb2); |
| 43 | } |
| 44 | |
Patrick Georgi | d5d3406 | 2012-11-22 15:37:47 +0100 | [diff] [blame] | 45 | #if CONFIG_PCI_ROM_RUN || CONFIG_VGA_ROM_RUN |
Patrick Georgi | 199b09c | 2012-11-22 12:46:12 +0100 | [diff] [blame] | 46 | static int int15_handler(void) |
Stefan Reinauer | 6651da3 | 2012-04-27 23:16:30 +0200 | [diff] [blame] | 47 | { |
Patrick Georgi | 503af72 | 2012-11-22 10:48:18 +0100 | [diff] [blame] | 48 | int res=0; |
Stefan Reinauer | 6651da3 | 2012-04-27 23:16:30 +0200 | [diff] [blame] | 49 | |
Patrick Georgi | d5d3406 | 2012-11-22 15:37:47 +0100 | [diff] [blame] | 50 | printk(BIOS_DEBUG, "%s: AX=%04x BX=%04x CX=%04x DX=%04x\n", |
| 51 | __func__, X86_AX, X86_BX, X86_CX, X86_DX); |
Stefan Reinauer | 6651da3 | 2012-04-27 23:16:30 +0200 | [diff] [blame] | 52 | |
Patrick Georgi | 199b09c | 2012-11-22 12:46:12 +0100 | [diff] [blame] | 53 | switch(X86_EAX & 0xffff) { |
Stefan Reinauer | 6651da3 | 2012-04-27 23:16:30 +0200 | [diff] [blame] | 54 | case 0x5f34: |
| 55 | /* |
| 56 | * Set Panel Fitting Hook: |
| 57 | * bit 2 = Graphics Stretching |
| 58 | * bit 1 = Text Stretching |
| 59 | * bit 0 = Centering (do not set with bit1 or bit2) |
| 60 | * 0 = video bios default |
| 61 | */ |
Patrick Georgi | 199b09c | 2012-11-22 12:46:12 +0100 | [diff] [blame] | 62 | X86_EAX &= 0xffff0000; |
| 63 | X86_EAX |= 0x005f; |
| 64 | X86_ECX &= 0xffffff00; |
| 65 | X86_ECX |= 0x01; |
Patrick Georgi | 503af72 | 2012-11-22 10:48:18 +0100 | [diff] [blame] | 66 | res = 1; |
Stefan Reinauer | 6651da3 | 2012-04-27 23:16:30 +0200 | [diff] [blame] | 67 | break; |
| 68 | case 0x5f35: |
| 69 | /* |
| 70 | * Boot Display Device Hook: |
| 71 | * bit 0 = CRT |
| 72 | * bit 1 = TV (eDP) * |
| 73 | * bit 2 = EFP * |
| 74 | * bit 3 = LFP |
| 75 | * bit 4 = CRT2 |
| 76 | * bit 5 = TV2 (eDP) * |
| 77 | * bit 6 = EFP2 * |
| 78 | * bit 7 = LFP2 |
| 79 | */ |
Patrick Georgi | 199b09c | 2012-11-22 12:46:12 +0100 | [diff] [blame] | 80 | X86_EAX &= 0xffff0000; |
| 81 | X86_EAX |= 0x005f; |
| 82 | X86_ECX &= 0xffff0000; |
| 83 | X86_ECX |= 0x0000; |
Patrick Georgi | 503af72 | 2012-11-22 10:48:18 +0100 | [diff] [blame] | 84 | res = 1; |
Stefan Reinauer | 6651da3 | 2012-04-27 23:16:30 +0200 | [diff] [blame] | 85 | break; |
| 86 | case 0x5f51: |
| 87 | /* |
| 88 | * Hook to select active LFP configuration: |
| 89 | * 00h = No LVDS, VBIOS does not enable LVDS |
| 90 | * 01h = Int-LVDS, LFP driven by integrated LVDS decoder |
| 91 | * 02h = SVDO-LVDS, LFP driven by SVDO decoder |
| 92 | * 03h = eDP, LFP Driven by Int-DisplayPort encoder |
| 93 | */ |
Patrick Georgi | 199b09c | 2012-11-22 12:46:12 +0100 | [diff] [blame] | 94 | X86_EAX &= 0xffff0000; |
| 95 | X86_EAX |= 0x005f; |
| 96 | X86_ECX &= 0xffff0000; |
| 97 | X86_ECX |= 0x0003; |
Patrick Georgi | 503af72 | 2012-11-22 10:48:18 +0100 | [diff] [blame] | 98 | res = 1; |
Stefan Reinauer | 6651da3 | 2012-04-27 23:16:30 +0200 | [diff] [blame] | 99 | break; |
| 100 | case 0x5f70: |
Patrick Georgi | 199b09c | 2012-11-22 12:46:12 +0100 | [diff] [blame] | 101 | switch ((X86_ECX >> 8) & 0xff) { |
Stefan Reinauer | 6651da3 | 2012-04-27 23:16:30 +0200 | [diff] [blame] | 102 | case 0: |
| 103 | /* Get Mux */ |
Patrick Georgi | 199b09c | 2012-11-22 12:46:12 +0100 | [diff] [blame] | 104 | X86_EAX &= 0xffff0000; |
| 105 | X86_EAX |= 0x005f; |
| 106 | X86_ECX &= 0xffff0000; |
| 107 | X86_ECX |= 0x0000; |
Patrick Georgi | 503af72 | 2012-11-22 10:48:18 +0100 | [diff] [blame] | 108 | res = 1; |
Stefan Reinauer | 6651da3 | 2012-04-27 23:16:30 +0200 | [diff] [blame] | 109 | break; |
| 110 | case 1: |
| 111 | /* Set Mux */ |
Patrick Georgi | 199b09c | 2012-11-22 12:46:12 +0100 | [diff] [blame] | 112 | X86_EAX &= 0xffff0000; |
| 113 | X86_EAX |= 0x005f; |
| 114 | X86_ECX &= 0xffff0000; |
| 115 | X86_ECX |= 0x0000; |
Patrick Georgi | 503af72 | 2012-11-22 10:48:18 +0100 | [diff] [blame] | 116 | res = 1; |
Stefan Reinauer | 6651da3 | 2012-04-27 23:16:30 +0200 | [diff] [blame] | 117 | break; |
| 118 | case 2: |
| 119 | /* Get SG/Non-SG mode */ |
Patrick Georgi | 199b09c | 2012-11-22 12:46:12 +0100 | [diff] [blame] | 120 | X86_EAX &= 0xffff0000; |
| 121 | X86_EAX |= 0x005f; |
| 122 | X86_ECX &= 0xffff0000; |
| 123 | X86_ECX |= 0x0000; |
Patrick Georgi | 503af72 | 2012-11-22 10:48:18 +0100 | [diff] [blame] | 124 | res = 1; |
Stefan Reinauer | 6651da3 | 2012-04-27 23:16:30 +0200 | [diff] [blame] | 125 | break; |
| 126 | default: |
Patrick Georgi | 503af72 | 2012-11-22 10:48:18 +0100 | [diff] [blame] | 127 | /* FIXME: Interrupt was not handled, but return success? */ |
Stefan Reinauer | 6651da3 | 2012-04-27 23:16:30 +0200 | [diff] [blame] | 128 | printk(BIOS_DEBUG, "Unknown INT15 5f70 function: 0x%02x\n", |
Patrick Georgi | 199b09c | 2012-11-22 12:46:12 +0100 | [diff] [blame] | 129 | ((X86_ECX >> 8) & 0xff)); |
Patrick Georgi | 503af72 | 2012-11-22 10:48:18 +0100 | [diff] [blame] | 130 | return 1; |
Stefan Reinauer | 6651da3 | 2012-04-27 23:16:30 +0200 | [diff] [blame] | 131 | } |
| 132 | break; |
| 133 | |
| 134 | default: |
| 135 | printk(BIOS_DEBUG, "Unknown INT15 function %04x!\n", |
Patrick Georgi | 199b09c | 2012-11-22 12:46:12 +0100 | [diff] [blame] | 136 | X86_EAX & 0xffff); |
Stefan Reinauer | 6651da3 | 2012-04-27 23:16:30 +0200 | [diff] [blame] | 137 | break; |
| 138 | } |
| 139 | return res; |
| 140 | } |
| 141 | #endif |
| 142 | |
Stefan Reinauer | 6651da3 | 2012-04-27 23:16:30 +0200 | [diff] [blame] | 143 | /* Audio Setup */ |
| 144 | |
| 145 | extern const u32 * cim_verb_data; |
| 146 | extern u32 cim_verb_data_size; |
| 147 | |
| 148 | static void verb_setup(void) |
| 149 | { |
| 150 | cim_verb_data = mainboard_cim_verb_data; |
| 151 | cim_verb_data_size = sizeof(mainboard_cim_verb_data); |
| 152 | } |
| 153 | |
| 154 | // mainboard_enable is executed as first thing after |
| 155 | // enumerate_buses(). |
| 156 | |
| 157 | static void mainboard_enable(device_t dev) |
| 158 | { |
| 159 | #if CONFIG_PCI_OPTION_ROM_RUN_YABEL || CONFIG_PCI_OPTION_ROM_RUN_REALMODE |
| 160 | /* Install custom int15 handler for VGA OPROM */ |
Patrick Georgi | 89bbcf4 | 2012-09-23 18:41:03 +0200 | [diff] [blame] | 161 | mainboard_interrupt_handlers(0x15, &int15_handler); |
Stefan Reinauer | 6651da3 | 2012-04-27 23:16:30 +0200 | [diff] [blame] | 162 | #endif |
| 163 | verb_setup(); |
| 164 | } |
| 165 | |
| 166 | struct chip_operations mainboard_ops = { |
Stefan Reinauer | 6651da3 | 2012-04-27 23:16:30 +0200 | [diff] [blame] | 167 | .enable_dev = mainboard_enable, |
| 168 | }; |
| 169 | |