Patrick Georgi | 04746fc | 2015-06-05 18:53:43 +0200 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2007-2009 coresystems GmbH |
| 5 | * Copyright (C) 2014 Google Inc. |
| 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. |
Patrick Georgi | 04746fc | 2015-06-05 18:53:43 +0200 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | #include <types.h> |
| 18 | #include <string.h> |
| 19 | #include <smbios.h> |
| 20 | #include <device/device.h> |
| 21 | #include <device/device.h> |
| 22 | #include <device/pci_def.h> |
| 23 | #include <device/pci_ops.h> |
| 24 | #include <console/console.h> |
| 25 | #if CONFIG_VGA_ROM_RUN |
| 26 | #include <x86emu/x86emu.h> |
| 27 | #endif |
| 28 | #include <pc80/mc146818rtc.h> |
| 29 | #include <arch/acpi.h> |
| 30 | #include <arch/io.h> |
| 31 | #include <arch/interrupt.h> |
| 32 | #include <boot/coreboot_tables.h> |
Patrick Georgi | 04746fc | 2015-06-05 18:53:43 +0200 | [diff] [blame] | 33 | #include "onboard.h" |
| 34 | |
| 35 | void mainboard_suspend_resume(void) |
| 36 | { |
| 37 | /* Call SMM finalize() handlers before resume */ |
| 38 | outb(0xcb, 0xb2); |
| 39 | } |
| 40 | |
| 41 | #if CONFIG_VGA_ROM_RUN |
| 42 | static int int15_handler(void) |
| 43 | { |
| 44 | int res = 0; |
| 45 | |
| 46 | printk(BIOS_DEBUG, "%s: AX=%04x BX=%04x CX=%04x DX=%04x\n", |
| 47 | __func__, X86_AX, X86_BX, X86_CX, X86_DX); |
| 48 | |
| 49 | switch (X86_AX) { |
| 50 | case 0x5f34: |
| 51 | /* |
| 52 | * Set Panel Fitting Hook: |
| 53 | * bit 2 = Graphics Stretching |
| 54 | * bit 1 = Text Stretching |
| 55 | * bit 0 = Centering (do not set with bit1 or bit2) |
| 56 | * 0 = video bios default |
| 57 | */ |
| 58 | X86_AX = 0x005f; |
| 59 | X86_CX = 0x0001; |
| 60 | res = 1; |
| 61 | break; |
| 62 | case 0x5f35: |
| 63 | /* |
| 64 | * Boot Display Device Hook: |
| 65 | * bit 0 = CRT |
| 66 | * bit 1 = TV (eDP) * |
| 67 | * bit 2 = EFP * |
| 68 | * bit 3 = LFP |
| 69 | * bit 4 = CRT2 |
| 70 | * bit 5 = TV2 (eDP) * |
| 71 | * bit 6 = EFP2 * |
| 72 | * bit 7 = LFP2 |
| 73 | */ |
| 74 | X86_AX = 0x005f; |
| 75 | X86_CX = 0x0000; |
| 76 | res = 1; |
| 77 | break; |
| 78 | case 0x5f51: |
| 79 | /* |
| 80 | * Hook to select active LFP configuration: |
| 81 | * 00h = No LVDS, VBIOS does not enable LVDS |
| 82 | * 01h = Int-LVDS, LFP driven by integrated LVDS decoder |
| 83 | * 02h = SVDO-LVDS, LFP driven by SVDO decoder |
| 84 | * 03h = eDP, LFP Driven by Int-DisplayPort encoder |
| 85 | */ |
| 86 | X86_AX = 0x005f; |
| 87 | X86_CX = 0x0003; |
| 88 | res = 1; |
| 89 | break; |
| 90 | case 0x5f70: |
| 91 | switch ((X86_CX >> 8) & 0xff) { |
| 92 | case 0: |
| 93 | /* Get Mux */ |
| 94 | X86_AX = 0x005f; |
| 95 | X86_CX = 0x0000; |
| 96 | res = 1; |
| 97 | break; |
| 98 | case 1: |
| 99 | /* Set Mux */ |
| 100 | X86_AX = 0x005f; |
| 101 | X86_CX = 0x0000; |
| 102 | res = 1; |
| 103 | break; |
| 104 | case 2: |
| 105 | /* Get SG/Non-SG mode */ |
| 106 | X86_AX = 0x005f; |
| 107 | X86_CX = 0x0000; |
| 108 | res = 1; |
| 109 | break; |
| 110 | default: |
| 111 | /* Interrupt was not handled */ |
| 112 | printk(BIOS_DEBUG, |
| 113 | "Unknown INT15 5f70 function: 0x%02x\n", |
| 114 | ((X86_CX >> 8) & 0xff)); |
| 115 | break; |
| 116 | } |
| 117 | break; |
| 118 | |
| 119 | default: |
| 120 | printk(BIOS_DEBUG, "Unknown INT15 function %04x!\n", X86_AX); |
| 121 | break; |
| 122 | } |
| 123 | return res; |
| 124 | } |
| 125 | #endif |
| 126 | |
Patrick Georgi | 04746fc | 2015-06-05 18:53:43 +0200 | [diff] [blame] | 127 | static void mainboard_init(device_t dev) |
| 128 | { |
| 129 | lan_init(); |
| 130 | } |
| 131 | |
| 132 | // mainboard_enable is executed as first thing after |
| 133 | // enumerate_buses(). |
| 134 | |
| 135 | static void mainboard_enable(device_t dev) |
| 136 | { |
| 137 | dev->ops->init = mainboard_init; |
| 138 | #if CONFIG_VGA_ROM_RUN |
| 139 | /* Install custom int15 handler for VGA OPROM */ |
| 140 | mainboard_interrupt_handlers(0x15, &int15_handler); |
| 141 | #endif |
Patrick Georgi | 04746fc | 2015-06-05 18:53:43 +0200 | [diff] [blame] | 142 | } |
| 143 | |
| 144 | struct chip_operations mainboard_ops = { |
| 145 | .enable_dev = mainboard_enable, |
| 146 | }; |
| 147 | |