blob: 92704c984c030241e5c2e78336cb4866d957030c [file] [log] [blame]
Stefan Reinauer6651da32012-04-27 23:16:30 +02001/*
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 Georgi199b09c2012-11-22 12:46:12 +010028#if CONFIG_PCI_ROM_RUN || CONFIG_VGA_ROM_RUN
Stefan Reinauer6651da32012-04-27 23:16:30 +020029#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>
Stefan Reinauer3e4e3032013-03-20 14:08:04 -070035#include <boot/coreboot_tables.h>
Stefan Reinauer6651da32012-04-27 23:16:30 +020036#include "hda_verb.h"
Stefan Reinauer6651da32012-04-27 23:16:30 +020037#include <southbridge/intel/bd82x6x/pch.h>
38
39void mainboard_suspend_resume(void)
40{
41 /* Call SMM finalize() handlers before resume */
42 outb(0xcb, 0xb2);
43}
44
Patrick Georgid5d34062012-11-22 15:37:47 +010045#if CONFIG_PCI_ROM_RUN || CONFIG_VGA_ROM_RUN
Patrick Georgi199b09c2012-11-22 12:46:12 +010046static int int15_handler(void)
Stefan Reinauer6651da32012-04-27 23:16:30 +020047{
Patrick Georgi503af722012-11-22 10:48:18 +010048 int res=0;
Stefan Reinauer6651da32012-04-27 23:16:30 +020049
Patrick Georgid5d34062012-11-22 15:37:47 +010050 printk(BIOS_DEBUG, "%s: AX=%04x BX=%04x CX=%04x DX=%04x\n",
51 __func__, X86_AX, X86_BX, X86_CX, X86_DX);
Stefan Reinauer6651da32012-04-27 23:16:30 +020052
Patrick Georgi199b09c2012-11-22 12:46:12 +010053 switch(X86_EAX & 0xffff) {
Stefan Reinauer6651da32012-04-27 23:16:30 +020054 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 Georgi199b09c2012-11-22 12:46:12 +010062 X86_EAX &= 0xffff0000;
63 X86_EAX |= 0x005f;
64 X86_ECX &= 0xffffff00;
65 X86_ECX |= 0x01;
Patrick Georgi503af722012-11-22 10:48:18 +010066 res = 1;
Stefan Reinauer6651da32012-04-27 23:16:30 +020067 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 Georgi199b09c2012-11-22 12:46:12 +010080 X86_EAX &= 0xffff0000;
81 X86_EAX |= 0x005f;
82 X86_ECX &= 0xffff0000;
83 X86_ECX |= 0x0000;
Patrick Georgi503af722012-11-22 10:48:18 +010084 res = 1;
Stefan Reinauer6651da32012-04-27 23:16:30 +020085 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 Georgi199b09c2012-11-22 12:46:12 +010094 X86_EAX &= 0xffff0000;
95 X86_EAX |= 0x005f;
96 X86_ECX &= 0xffff0000;
97 X86_ECX |= 0x0003;
Patrick Georgi503af722012-11-22 10:48:18 +010098 res = 1;
Stefan Reinauer6651da32012-04-27 23:16:30 +020099 break;
100 case 0x5f70:
Patrick Georgi199b09c2012-11-22 12:46:12 +0100101 switch ((X86_ECX >> 8) & 0xff) {
Stefan Reinauer6651da32012-04-27 23:16:30 +0200102 case 0:
103 /* Get Mux */
Patrick Georgi199b09c2012-11-22 12:46:12 +0100104 X86_EAX &= 0xffff0000;
105 X86_EAX |= 0x005f;
106 X86_ECX &= 0xffff0000;
107 X86_ECX |= 0x0000;
Patrick Georgi503af722012-11-22 10:48:18 +0100108 res = 1;
Stefan Reinauer6651da32012-04-27 23:16:30 +0200109 break;
110 case 1:
111 /* Set Mux */
Patrick Georgi199b09c2012-11-22 12:46:12 +0100112 X86_EAX &= 0xffff0000;
113 X86_EAX |= 0x005f;
114 X86_ECX &= 0xffff0000;
115 X86_ECX |= 0x0000;
Patrick Georgi503af722012-11-22 10:48:18 +0100116 res = 1;
Stefan Reinauer6651da32012-04-27 23:16:30 +0200117 break;
118 case 2:
119 /* Get SG/Non-SG mode */
Patrick Georgi199b09c2012-11-22 12:46:12 +0100120 X86_EAX &= 0xffff0000;
121 X86_EAX |= 0x005f;
122 X86_ECX &= 0xffff0000;
123 X86_ECX |= 0x0000;
Patrick Georgi503af722012-11-22 10:48:18 +0100124 res = 1;
Stefan Reinauer6651da32012-04-27 23:16:30 +0200125 break;
126 default:
Patrick Georgi503af722012-11-22 10:48:18 +0100127 /* FIXME: Interrupt was not handled, but return success? */
Stefan Reinauer6651da32012-04-27 23:16:30 +0200128 printk(BIOS_DEBUG, "Unknown INT15 5f70 function: 0x%02x\n",
Patrick Georgi199b09c2012-11-22 12:46:12 +0100129 ((X86_ECX >> 8) & 0xff));
Patrick Georgi503af722012-11-22 10:48:18 +0100130 return 1;
Stefan Reinauer6651da32012-04-27 23:16:30 +0200131 }
132 break;
133
134 default:
135 printk(BIOS_DEBUG, "Unknown INT15 function %04x!\n",
Patrick Georgi199b09c2012-11-22 12:46:12 +0100136 X86_EAX & 0xffff);
Stefan Reinauer6651da32012-04-27 23:16:30 +0200137 break;
138 }
139 return res;
140}
141#endif
142
Stefan Reinauer6651da32012-04-27 23:16:30 +0200143/* Audio Setup */
144
145extern const u32 * cim_verb_data;
146extern u32 cim_verb_data_size;
147
148static 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
157static 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 Georgi89bbcf42012-09-23 18:41:03 +0200161 mainboard_interrupt_handlers(0x15, &int15_handler);
Stefan Reinauer6651da32012-04-27 23:16:30 +0200162#endif
163 verb_setup();
164}
165
166struct chip_operations mainboard_ops = {
Stefan Reinauer6651da32012-04-27 23:16:30 +0200167 .enable_dev = mainboard_enable,
168};
169