Aaron Durbin | c625d09 | 2013-10-04 16:00:07 -0500 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2007-2009 coresystems GmbH |
| 5 | * Copyright (C) 2011 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. |
| 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> |
| 28 | #if CONFIG_VGA_ROM_RUN |
| 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 <boot/coreboot_tables.h> |
Shawn Nematbakhsh | 9547f8d | 2013-11-08 17:23:26 -0800 | [diff] [blame] | 36 | #include <smbios.h> |
Aaron Durbin | 063c873 | 2013-10-28 11:24:53 -0500 | [diff] [blame] | 37 | #include "ec.h" |
Shawn Nematbakhsh | 9547f8d | 2013-11-08 17:23:26 -0800 | [diff] [blame] | 38 | #include "onboard.h" |
Kein Yuan | 704c006 | 2014-05-01 20:20:06 -0700 | [diff] [blame] | 39 | #include <baytrail/gpio.h> |
| 40 | #include <bootstate.h> |
Aaron Durbin | c625d09 | 2013-10-04 16:00:07 -0500 | [diff] [blame] | 41 | |
| 42 | void mainboard_suspend_resume(void) |
| 43 | { |
Aaron Durbin | c625d09 | 2013-10-04 16:00:07 -0500 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | #if CONFIG_VGA_ROM_RUN |
| 47 | static int int15_handler(void) |
| 48 | { |
| 49 | int res = 1; |
| 50 | |
| 51 | printk(BIOS_DEBUG, "%s: AX=%04x BX=%04x CX=%04x DX=%04x\n", |
| 52 | __func__, X86_AX, X86_BX, X86_CX, X86_DX); |
| 53 | |
| 54 | switch (X86_AX) { |
| 55 | case 0x5f34: |
| 56 | /* |
| 57 | * Set Panel Fitting Hook: |
| 58 | * bit 2 = Graphics Stretching |
| 59 | * bit 1 = Text Stretching |
| 60 | * bit 0 = Centering (do not set with bit1 or bit2) |
| 61 | * 0 = video bios default |
| 62 | */ |
| 63 | X86_AX = 0x005f; |
| 64 | X86_CX = 0x0001; |
| 65 | res = 1; |
| 66 | break; |
| 67 | case 0x5f35: |
| 68 | /* |
| 69 | * Boot Display Device Hook: |
| 70 | * bit 0 = CRT |
Kein Yuan | 1d07bf2 | 2014-04-01 10:13:38 -0700 | [diff] [blame] | 71 | * bit 1 = TV |
| 72 | * bit 2 = EFP (HDMI) |
| 73 | * bit 3 = LFP (eDP)* |
Aaron Durbin | c625d09 | 2013-10-04 16:00:07 -0500 | [diff] [blame] | 74 | * bit 4 = CRT2 |
Kein Yuan | 1d07bf2 | 2014-04-01 10:13:38 -0700 | [diff] [blame] | 75 | * bit 5 = TV2 |
Kein Yuan | 3511023 | 2014-02-22 12:26:55 -0800 | [diff] [blame] | 76 | * bit 6 = EFP2 |
Aaron Durbin | c625d09 | 2013-10-04 16:00:07 -0500 | [diff] [blame] | 77 | * bit 7 = LFP2 |
| 78 | */ |
| 79 | X86_AX = 0x005f; |
Kein Yuan | 1d07bf2 | 2014-04-01 10:13:38 -0700 | [diff] [blame] | 80 | X86_CX = 0x0008; |
Aaron Durbin | c625d09 | 2013-10-04 16:00:07 -0500 | [diff] [blame] | 81 | res = 1; |
| 82 | break; |
| 83 | case 0x5f51: |
| 84 | /* |
| 85 | * Hook to select active LFP configuration: |
| 86 | * 00h = No LVDS, VBIOS does not enable LVDS |
| 87 | * 01h = Int-LVDS, LFP driven by integrated LVDS decoder |
| 88 | * 02h = SVDO-LVDS, LFP driven by SVDO decoder |
| 89 | * 03h = eDP, LFP Driven by Int-DisplayPort encoder |
| 90 | */ |
| 91 | X86_AX = 0x005f; |
| 92 | X86_CX = 0x0003; |
| 93 | res = 1; |
| 94 | break; |
| 95 | case 0x5f70: |
| 96 | switch ((X86_CX >> 8) & 0xff) { |
| 97 | case 0: |
| 98 | /* Get Mux */ |
| 99 | X86_AX = 0x005f; |
| 100 | X86_CX = 0x0000; |
| 101 | res = 1; |
| 102 | break; |
| 103 | case 1: |
| 104 | /* Set Mux */ |
| 105 | X86_AX = 0x005f; |
| 106 | X86_CX = 0x0000; |
| 107 | res = 1; |
| 108 | break; |
| 109 | case 2: |
| 110 | /* Get SG/Non-SG mode */ |
| 111 | X86_AX = 0x005f; |
| 112 | X86_CX = 0x0000; |
| 113 | res = 1; |
| 114 | break; |
| 115 | default: |
| 116 | /* Interrupt was not handled */ |
| 117 | printk(BIOS_DEBUG, |
| 118 | "Unknown INT15 5f70 function: 0x%02x\n", |
| 119 | ((X86_CX >> 8) & 0xff)); |
| 120 | break; |
| 121 | } |
| 122 | break; |
| 123 | |
Shawn Nematbakhsh | 9547f8d | 2013-11-08 17:23:26 -0800 | [diff] [blame] | 124 | default: |
Aaron Durbin | c625d09 | 2013-10-04 16:00:07 -0500 | [diff] [blame] | 125 | printk(BIOS_DEBUG, "Unknown INT15 function %04x!\n", X86_AX); |
| 126 | break; |
| 127 | } |
| 128 | return res; |
| 129 | } |
| 130 | #endif |
| 131 | |
Aaron Durbin | 063c873 | 2013-10-28 11:24:53 -0500 | [diff] [blame] | 132 | static void mainboard_init(device_t dev) |
| 133 | { |
| 134 | mainboard_ec_init(); |
| 135 | } |
| 136 | |
Shawn Nematbakhsh | 9547f8d | 2013-11-08 17:23:26 -0800 | [diff] [blame] | 137 | static int mainboard_smbios_data(device_t dev, int *handle, |
| 138 | unsigned long *current) |
| 139 | { |
| 140 | int len = 0; |
| 141 | |
| 142 | len += smbios_write_type41( |
| 143 | current, handle, |
| 144 | BOARD_TRACKPAD_NAME, /* name */ |
| 145 | BOARD_TRACKPAD_IRQ, /* instance */ |
| 146 | BOARD_TRACKPAD_I2C_BUS, /* segment */ |
| 147 | BOARD_TRACKPAD_I2C_ADDR, /* bus */ |
| 148 | 0, /* device */ |
| 149 | 0); /* function */ |
| 150 | |
| 151 | len += smbios_write_type41( |
| 152 | current, handle, |
| 153 | BOARD_TOUCHSCREEN_NAME, /* name */ |
| 154 | BOARD_TOUCHSCREEN_IRQ, /* instance */ |
| 155 | BOARD_TOUCHSCREEN_I2C_BUS, /* segment */ |
| 156 | BOARD_TOUCHSCREEN_I2C_ADDR, /* bus */ |
| 157 | 0, /* device */ |
| 158 | 0); /* function */ |
| 159 | |
| 160 | return len; |
| 161 | } |
| 162 | |
Aaron Durbin | c625d09 | 2013-10-04 16:00:07 -0500 | [diff] [blame] | 163 | // mainboard_enable is executed as first thing after |
| 164 | // enumerate_buses(). |
| 165 | |
| 166 | static void mainboard_enable(device_t dev) |
| 167 | { |
Aaron Durbin | 063c873 | 2013-10-28 11:24:53 -0500 | [diff] [blame] | 168 | dev->ops->init = mainboard_init; |
Shawn Nematbakhsh | 9547f8d | 2013-11-08 17:23:26 -0800 | [diff] [blame] | 169 | dev->ops->get_smbios_data = mainboard_smbios_data; |
Aaron Durbin | c625d09 | 2013-10-04 16:00:07 -0500 | [diff] [blame] | 170 | #if CONFIG_VGA_ROM_RUN |
| 171 | /* Install custom int15 handler for VGA OPROM */ |
| 172 | mainboard_interrupt_handlers(0x15, &int15_handler); |
| 173 | #endif |
| 174 | } |
| 175 | |
| 176 | struct chip_operations mainboard_ops = { |
| 177 | .enable_dev = mainboard_enable, |
| 178 | }; |
Kein Yuan | 704c006 | 2014-05-01 20:20:06 -0700 | [diff] [blame] | 179 | |
| 180 | static void edp_vdden_cb(void *unused) |
| 181 | { |
| 182 | ncore_select_func(SOC_DDI1_VDDEN_PAD, PAD_FUNC2); |
| 183 | } |
| 184 | |
Aaron Durbin | 9ef9d85 | 2015-03-16 17:30:09 -0500 | [diff] [blame^] | 185 | BOOT_STATE_INIT_ENTRY(BS_DEV_INIT, BS_ON_EXIT, edp_vdden_cb, NULL); |