Angel Pons | a21dff6 | 2020-04-03 01:22:24 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Nico Huber | efe1fed | 2013-04-29 18:00:57 +0200 | [diff] [blame] | 2 | |
| 3 | #include <types.h> |
Nico Huber | efe1fed | 2013-04-29 18:00:57 +0200 | [diff] [blame] | 4 | #include <device/device.h> |
| 5 | #include <device/pci_def.h> |
Nico Huber | efe1fed | 2013-04-29 18:00:57 +0200 | [diff] [blame] | 6 | #include <console/console.h> |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 7 | #if CONFIG(VGA_ROM_RUN) |
Nico Huber | efe1fed | 2013-04-29 18:00:57 +0200 | [diff] [blame] | 8 | #include <x86emu/x86emu.h> |
| 9 | #endif |
Kyösti Mälkki | cbf9571 | 2020-01-05 08:05:45 +0200 | [diff] [blame] | 10 | #include <option.h> |
Nico Huber | efe1fed | 2013-04-29 18:00:57 +0200 | [diff] [blame] | 11 | #include <arch/interrupt.h> |
Nico Huber | efe1fed | 2013-04-29 18:00:57 +0200 | [diff] [blame] | 12 | #include <southbridge/intel/bd82x6x/pch.h> |
| 13 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 14 | #if CONFIG(VGA_ROM_RUN) |
Nico Huber | efe1fed | 2013-04-29 18:00:57 +0200 | [diff] [blame] | 15 | static int int15_handler(void) |
| 16 | { |
| 17 | int res = 0; |
| 18 | |
| 19 | printk(BIOS_DEBUG, "%s: AX=%04x BX=%04x CX=%04x DX=%04x\n", |
| 20 | __func__, X86_AX, X86_BX, X86_CX, X86_DX); |
| 21 | |
Elyes HAOUAS | 0ce41f1 | 2018-11-13 10:03:31 +0100 | [diff] [blame] | 22 | switch (X86_EAX & 0xffff) { |
Nico Huber | efe1fed | 2013-04-29 18:00:57 +0200 | [diff] [blame] | 23 | case 0x5f34: |
| 24 | /* |
| 25 | * Set Panel Fitting Hook: |
| 26 | * bit 2 = Graphics Stretching |
| 27 | * bit 1 = Text Stretching |
| 28 | * bit 0 = Centering (do not set with bit1 or bit2) |
Elyes HAOUAS | 6dc9d03 | 2020-02-16 16:22:52 +0100 | [diff] [blame] | 29 | * 0 = video BIOS default |
Nico Huber | efe1fed | 2013-04-29 18:00:57 +0200 | [diff] [blame] | 30 | */ |
| 31 | X86_EAX &= 0xffff0000; |
| 32 | X86_EAX |= 0x005f; |
| 33 | X86_ECX &= 0xffffff00; |
Elyes HAOUAS | 6dc9d03 | 2020-02-16 16:22:52 +0100 | [diff] [blame] | 34 | X86_ECX |= 0x00; /* Use video BIOS default */ |
Nico Huber | efe1fed | 2013-04-29 18:00:57 +0200 | [diff] [blame] | 35 | res = 1; |
| 36 | break; |
| 37 | case 0x5f35: |
| 38 | /* |
| 39 | * Boot Display Device Hook: |
| 40 | * bit 0 = CRT |
| 41 | * bit 1 = TV (eDP) |
| 42 | * bit 2 = EFP |
| 43 | * bit 3 = LFP |
| 44 | * bit 4 = CRT2 |
| 45 | * bit 5 = TV2 (eDP) |
| 46 | * bit 6 = EFP2 |
| 47 | * bit 7 = LFP2 |
| 48 | */ |
| 49 | X86_EAX &= 0xffff0000; |
| 50 | X86_EAX |= 0x005f; |
| 51 | X86_ECX &= 0xffff0000; |
Elyes HAOUAS | 6dc9d03 | 2020-02-16 16:22:52 +0100 | [diff] [blame] | 52 | X86_ECX |= 0x0000; /* Use video BIOS default */ |
Nico Huber | efe1fed | 2013-04-29 18:00:57 +0200 | [diff] [blame] | 53 | res = 1; |
| 54 | break; |
| 55 | case 0x5f51: |
| 56 | /* |
| 57 | * Hook to select active LFP configuration: |
| 58 | * 00h = No LVDS, VBIOS does not enable LVDS |
| 59 | * 01h = Int-LVDS, LFP driven by integrated LVDS decoder |
| 60 | * 02h = SDVO-LVDS, LFP driven by SDVO decoder |
| 61 | * 03h = eDP, LFP Driven by Int-DisplayPort encoder |
| 62 | */ |
| 63 | X86_EAX &= 0xffff0000; |
| 64 | X86_EAX |= 0x005f; |
| 65 | X86_ECX &= 0xffff0000; |
| 66 | X86_ECX |= 0x0000; /* TODO: Make this configurable in NVRAM? */ |
| 67 | res = 1; |
| 68 | break; |
Patrick Georgi | 7fc2da9 | 2014-06-27 12:17:17 +0200 | [diff] [blame] | 69 | case 0x5f40: |
| 70 | /* |
| 71 | * Boot Panel Type Hook: |
| 72 | * BL(in): 00h = LFP, 01h = LFP2 |
| 73 | * CL(out): panel type id in table: 1..16 |
| 74 | */ |
| 75 | if (0 == (X86_EBX & 0xff)) { |
Nico Huber | efe1fed | 2013-04-29 18:00:57 +0200 | [diff] [blame] | 76 | X86_EAX &= 0xffff0000; |
Patrick Georgi | 7fc2da9 | 2014-06-27 12:17:17 +0200 | [diff] [blame] | 77 | X86_EAX |= 0x015f; |
Nico Huber | efe1fed | 2013-04-29 18:00:57 +0200 | [diff] [blame] | 78 | res = 1; |
Patrick Georgi | 7fc2da9 | 2014-06-27 12:17:17 +0200 | [diff] [blame] | 79 | } else if (1 == (X86_EBX & 0xff)) { |
Nico Huber | efe1fed | 2013-04-29 18:00:57 +0200 | [diff] [blame] | 80 | X86_EAX &= 0xffff0000; |
Patrick Georgi | 7fc2da9 | 2014-06-27 12:17:17 +0200 | [diff] [blame] | 81 | X86_EAX |= 0x015f; |
Nico Huber | efe1fed | 2013-04-29 18:00:57 +0200 | [diff] [blame] | 82 | res = 1; |
Patrick Georgi | 7fc2da9 | 2014-06-27 12:17:17 +0200 | [diff] [blame] | 83 | } else { |
| 84 | printk(BIOS_DEBUG, |
| 85 | "Unknown panel index %u " |
| 86 | "in INT15 function %04x!\n", |
| 87 | X86_EBX & 0xff, X86_EAX & 0xffff); |
Nico Huber | efe1fed | 2013-04-29 18:00:57 +0200 | [diff] [blame] | 88 | } |
| 89 | break; |
Patrick Georgi | 7fc2da9 | 2014-06-27 12:17:17 +0200 | [diff] [blame] | 90 | case 0x5f52: |
| 91 | /* |
| 92 | * Panel Color Depth: |
| 93 | * 00h = 18 bit |
| 94 | * 01h = 24 bit |
| 95 | */ |
| 96 | X86_EAX &= 0xffff0000; |
| 97 | X86_EAX |= 0x005f; |
| 98 | X86_ECX &= 0xffff0000; |
| 99 | X86_ECX |= 0x0001; |
| 100 | res = 1; |
| 101 | break; |
| 102 | case 0x5f14: |
| 103 | if ((X86_EBX & 0xffff) == 0x78f) { |
| 104 | /* |
| 105 | * Get Miscellaneous Status Hook: |
| 106 | * bit 2: AC power active? |
| 107 | * bit 1: lid closed? |
| 108 | * bit 0: docked? |
| 109 | */ |
| 110 | X86_EAX &= 0xffff0000; |
| 111 | X86_EAX |= 0x015f; |
| 112 | res = 1; |
| 113 | } else { |
| 114 | printk(BIOS_DEBUG, |
| 115 | "Unknown BX 0x%04x in INT15 function %04x!\n", |
| 116 | X86_EBX & 0xffff, X86_EAX & 0xffff); |
| 117 | } |
| 118 | break; |
| 119 | case 0x5f49: |
| 120 | /* |
| 121 | * Get Inverter Type and Polarity: |
| 122 | * EBX: backlight control brightness: 0..255 |
| 123 | * ECX: |
| 124 | * 0 = Enable PWM inverted, 2 = Enable PWM |
| 125 | * 1 = Enable I2C inverted, 3 = Enable I2C |
| 126 | */ |
| 127 | X86_EAX &= 0xffff0000; |
| 128 | X86_EAX |= 0x015f; |
| 129 | res = 1; |
| 130 | break; |
Elyes HAOUAS | bbcb8bc | 2016-09-29 21:00:13 +0200 | [diff] [blame] | 131 | default: |
Nico Huber | efe1fed | 2013-04-29 18:00:57 +0200 | [diff] [blame] | 132 | printk(BIOS_DEBUG, "Unknown INT15 function %04x!\n", |
| 133 | X86_EAX & 0xffff); |
| 134 | break; |
| 135 | } |
| 136 | return res; |
| 137 | } |
| 138 | #endif |
| 139 | |
Nico Huber | efe1fed | 2013-04-29 18:00:57 +0200 | [diff] [blame] | 140 | |
Nico Huber | efe1fed | 2013-04-29 18:00:57 +0200 | [diff] [blame] | 141 | |
Elyes HAOUAS | f10b5ff | 2016-10-06 19:49:55 +0200 | [diff] [blame] | 142 | /* mainboard_enable is executed as first thing after */ |
| 143 | /* enumerate_buses(). */ |
Nico Huber | efe1fed | 2013-04-29 18:00:57 +0200 | [diff] [blame] | 144 | |
Elyes HAOUAS | f65f297e | 2018-05-04 22:09:07 +0200 | [diff] [blame] | 145 | static void mainboard_enable(struct device *dev) |
Nico Huber | efe1fed | 2013-04-29 18:00:57 +0200 | [diff] [blame] | 146 | { |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 147 | #if CONFIG(PCI_OPTION_ROM_RUN_YABEL) || \ |
| 148 | CONFIG(PCI_OPTION_ROM_RUN_REALMODE) |
Nico Huber | efe1fed | 2013-04-29 18:00:57 +0200 | [diff] [blame] | 149 | /* Install custom int15 handler for VGA OPROM */ |
| 150 | mainboard_interrupt_handlers(0x15, &int15_handler); |
| 151 | #endif |
Angel Pons | 88dcb31 | 2021-04-26 17:10:28 +0200 | [diff] [blame] | 152 | unsigned int disable = get_uint_option("ethernet1", 0); |
Angel Pons | f8a5eb2 | 2020-11-02 22:49:51 +0100 | [diff] [blame] | 153 | if (disable) { |
Kyösti Mälkki | c70eed1 | 2018-05-22 02:18:00 +0300 | [diff] [blame] | 154 | struct device *nic = pcidev_on_root(0x1c, 2); |
Patrick Georgi | f7381f8 | 2013-08-15 14:57:09 +0200 | [diff] [blame] | 155 | if (nic) { |
| 156 | printk(BIOS_DEBUG, "DISABLE FIRST NIC!\n"); |
| 157 | nic->enabled = 0; |
| 158 | } |
| 159 | } |
Angel Pons | 88dcb31 | 2021-04-26 17:10:28 +0200 | [diff] [blame] | 160 | disable = get_uint_option("ethernet2", 0); |
Angel Pons | f8a5eb2 | 2020-11-02 22:49:51 +0100 | [diff] [blame] | 161 | if (disable) { |
Kyösti Mälkki | c70eed1 | 2018-05-22 02:18:00 +0300 | [diff] [blame] | 162 | struct device *nic = pcidev_on_root(0x1c, 3); |
Patrick Georgi | f7381f8 | 2013-08-15 14:57:09 +0200 | [diff] [blame] | 163 | if (nic) { |
| 164 | printk(BIOS_DEBUG, "DISABLE SECOND NIC!\n"); |
| 165 | nic->enabled = 0; |
| 166 | } |
| 167 | } |
Nico Huber | efe1fed | 2013-04-29 18:00:57 +0200 | [diff] [blame] | 168 | } |
| 169 | |
| 170 | struct chip_operations mainboard_ops = { |
| 171 | .enable_dev = mainboard_enable, |
| 172 | }; |