Patrick Georgi | ac95903 | 2020-05-05 22:49:26 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Patrick Rudolph | fa47042 | 2017-06-20 17:49:53 +0200 | [diff] [blame] | 2 | |
Furquan Shaikh | 76cedd2 | 2020-05-02 10:24:23 -0700 | [diff] [blame] | 3 | #include <acpi/acpi.h> |
Matt DeVillier | ebe08e0 | 2017-07-14 13:28:42 -0500 | [diff] [blame] | 4 | #include <types.h> |
| 5 | #include <string.h> |
Matt DeVillier | 53e4195 | 2017-06-27 13:07:43 -0500 | [diff] [blame] | 6 | #include <cbfs.h> |
Patrick Rudolph | fa47042 | 2017-06-20 17:49:53 +0200 | [diff] [blame] | 7 | #include <device/device.h> |
| 8 | #include <device/pci.h> |
| 9 | #include <device/pci_ids.h> |
| 10 | #include <device/pci_ops.h> |
Patrick Rudolph | bac2303 | 2017-06-30 15:18:23 +0200 | [diff] [blame] | 11 | #include <console/console.h> |
| 12 | #include <cbmem.h> |
Matt DeVillier | ebe08e0 | 2017-07-14 13:28:42 -0500 | [diff] [blame] | 13 | #include "intel_bios.h" |
Patrick Rudolph | fa47042 | 2017-06-20 17:49:53 +0200 | [diff] [blame] | 14 | #include "opregion.h" |
| 15 | |
Patrick Georgi | 4a3956d | 2018-05-03 19:15:13 +0200 | [diff] [blame] | 16 | __weak |
| 17 | const char *mainboard_vbt_filename(void) |
| 18 | { |
| 19 | return "vbt.bin"; |
| 20 | } |
| 21 | |
Srinidhi N Kaushik | 6719c82 | 2020-11-02 16:47:29 -0800 | [diff] [blame] | 22 | static char vbt_data[CONFIG_VBT_DATA_SIZE_KB * KiB]; |
Aaron Durbin | 44f8065 | 2018-05-11 11:43:52 -0600 | [diff] [blame] | 23 | static size_t vbt_data_sz; |
Patrick Georgi | 4a3956d | 2018-05-03 19:15:13 +0200 | [diff] [blame] | 24 | |
| 25 | void *locate_vbt(size_t *vbt_size) |
| 26 | { |
| 27 | uint32_t vbtsig = 0; |
| 28 | |
Aaron Durbin | 44f8065 | 2018-05-11 11:43:52 -0600 | [diff] [blame] | 29 | if (vbt_data_sz != 0) { |
| 30 | if (vbt_size) |
| 31 | *vbt_size = vbt_data_sz; |
Patrick Georgi | 4a3956d | 2018-05-03 19:15:13 +0200 | [diff] [blame] | 32 | return (void *)vbt_data; |
Aaron Durbin | 44f8065 | 2018-05-11 11:43:52 -0600 | [diff] [blame] | 33 | } |
Patrick Georgi | 4a3956d | 2018-05-03 19:15:13 +0200 | [diff] [blame] | 34 | |
| 35 | const char *filename = mainboard_vbt_filename(); |
| 36 | |
Julius Werner | 834b3ec | 2020-03-04 16:52:08 -0800 | [diff] [blame] | 37 | size_t file_size = cbfs_load(filename, vbt_data, sizeof(vbt_data)); |
Patrick Georgi | 4a3956d | 2018-05-03 19:15:13 +0200 | [diff] [blame] | 38 | |
| 39 | if (file_size == 0) |
| 40 | return NULL; |
| 41 | |
| 42 | if (vbt_size) |
| 43 | *vbt_size = file_size; |
| 44 | |
| 45 | memcpy(&vbtsig, vbt_data, sizeof(vbtsig)); |
| 46 | if (vbtsig != VBT_SIGNATURE) { |
| 47 | printk(BIOS_ERR, "Missing/invalid signature in VBT data file!\n"); |
| 48 | return NULL; |
| 49 | } |
| 50 | |
| 51 | printk(BIOS_INFO, "Found a VBT of %zu bytes after decompression\n", |
| 52 | file_size); |
Aaron Durbin | 44f8065 | 2018-05-11 11:43:52 -0600 | [diff] [blame] | 53 | vbt_data_sz = file_size; |
Patrick Georgi | 4a3956d | 2018-05-03 19:15:13 +0200 | [diff] [blame] | 54 | |
| 55 | return (void *)vbt_data; |
| 56 | } |
| 57 | |
Patrick Rudolph | fa47042 | 2017-06-20 17:49:53 +0200 | [diff] [blame] | 58 | /* Write ASLS PCI register and prepare SWSCI register. */ |
Nico Huber | f2a0be2 | 2020-04-26 17:01:25 +0200 | [diff] [blame] | 59 | static void intel_gma_opregion_register(uintptr_t opregion) |
Patrick Rudolph | fa47042 | 2017-06-20 17:49:53 +0200 | [diff] [blame] | 60 | { |
Elyes HAOUAS | 263076c | 2018-05-02 21:54:59 +0200 | [diff] [blame] | 61 | struct device *igd; |
Patrick Rudolph | fa47042 | 2017-06-20 17:49:53 +0200 | [diff] [blame] | 62 | u16 reg16; |
Matt DeVillier | 681ef51 | 2018-02-11 01:17:01 -0600 | [diff] [blame] | 63 | u16 sci_reg; |
Patrick Rudolph | fa47042 | 2017-06-20 17:49:53 +0200 | [diff] [blame] | 64 | |
Kyösti Mälkki | c70eed1 | 2018-05-22 02:18:00 +0300 | [diff] [blame] | 65 | igd = pcidev_on_root(0x2, 0); |
Patrick Rudolph | fa47042 | 2017-06-20 17:49:53 +0200 | [diff] [blame] | 66 | if (!igd || !igd->enabled) |
| 67 | return; |
| 68 | |
| 69 | /* |
| 70 | * Intel BIOS Specification |
| 71 | * Chapter 5.3.7 "Initialize Hardware State" |
| 72 | */ |
| 73 | pci_write_config32(igd, ASLS, opregion); |
| 74 | |
| 75 | /* |
Matt DeVillier | 681ef51 | 2018-02-11 01:17:01 -0600 | [diff] [blame] | 76 | * Atom-based platforms use a combined SMI/SCI register, |
| 77 | * whereas non-Atom platforms use a separate SCI register. |
| 78 | */ |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 79 | if (CONFIG(INTEL_GMA_SWSMISCI)) |
Matt DeVillier | 681ef51 | 2018-02-11 01:17:01 -0600 | [diff] [blame] | 80 | sci_reg = SWSMISCI; |
| 81 | else |
| 82 | sci_reg = SWSCI; |
| 83 | |
| 84 | /* |
Patrick Rudolph | fa47042 | 2017-06-20 17:49:53 +0200 | [diff] [blame] | 85 | * Intel's Windows driver relies on this: |
| 86 | * Intel BIOS Specification |
| 87 | * Chapter 5.4 "ASL Software SCI Handler" |
| 88 | */ |
Matt DeVillier | 681ef51 | 2018-02-11 01:17:01 -0600 | [diff] [blame] | 89 | reg16 = pci_read_config16(igd, sci_reg); |
Patrick Rudolph | fa47042 | 2017-06-20 17:49:53 +0200 | [diff] [blame] | 90 | reg16 &= ~GSSCIE; |
| 91 | reg16 |= SMISCISEL; |
Matt DeVillier | 681ef51 | 2018-02-11 01:17:01 -0600 | [diff] [blame] | 92 | pci_write_config16(igd, sci_reg, reg16); |
Patrick Rudolph | fa47042 | 2017-06-20 17:49:53 +0200 | [diff] [blame] | 93 | } |
Patrick Rudolph | bac2303 | 2017-06-30 15:18:23 +0200 | [diff] [blame] | 94 | |
| 95 | /* Restore ASLS register on S3 resume and prepare SWSCI. */ |
Nico Huber | f2a0be2 | 2020-04-26 17:01:25 +0200 | [diff] [blame] | 96 | static enum cb_err intel_gma_restore_opregion(void) |
Patrick Rudolph | bac2303 | 2017-06-30 15:18:23 +0200 | [diff] [blame] | 97 | { |
Nico Huber | f2a0be2 | 2020-04-26 17:01:25 +0200 | [diff] [blame] | 98 | const igd_opregion_t *const opregion = cbmem_find(CBMEM_ID_IGD_OPREGION); |
| 99 | if (!opregion) { |
| 100 | printk(BIOS_ERR, "GMA: Failed to find IGD OpRegion.\n"); |
| 101 | return CB_ERR; |
Patrick Rudolph | bac2303 | 2017-06-30 15:18:23 +0200 | [diff] [blame] | 102 | } |
Nico Huber | f2a0be2 | 2020-04-26 17:01:25 +0200 | [diff] [blame] | 103 | /* Write ASLS PCI register and prepare SWSCI register. */ |
| 104 | intel_gma_opregion_register((uintptr_t)opregion); |
| 105 | return CB_SUCCESS; |
Patrick Rudolph | bac2303 | 2017-06-30 15:18:23 +0200 | [diff] [blame] | 106 | } |
Matt DeVillier | ebe08e0 | 2017-07-14 13:28:42 -0500 | [diff] [blame] | 107 | |
Matt DeVillier | 53e4195 | 2017-06-27 13:07:43 -0500 | [diff] [blame] | 108 | static enum cb_err vbt_validate(struct region_device *rdev) |
Matt DeVillier | ebe08e0 | 2017-07-14 13:28:42 -0500 | [diff] [blame] | 109 | { |
Matt DeVillier | 53e4195 | 2017-06-27 13:07:43 -0500 | [diff] [blame] | 110 | uint32_t sig; |
Matt DeVillier | ebe08e0 | 2017-07-14 13:28:42 -0500 | [diff] [blame] | 111 | |
Matt DeVillier | 53e4195 | 2017-06-27 13:07:43 -0500 | [diff] [blame] | 112 | if (rdev_readat(rdev, &sig, 0, sizeof(sig)) != sizeof(sig)) |
Matt DeVillier | ebe08e0 | 2017-07-14 13:28:42 -0500 | [diff] [blame] | 113 | return CB_ERR; |
Matt DeVillier | ebe08e0 | 2017-07-14 13:28:42 -0500 | [diff] [blame] | 114 | |
Matt DeVillier | 53e4195 | 2017-06-27 13:07:43 -0500 | [diff] [blame] | 115 | if (sig != VBT_SIGNATURE) |
Matt DeVillier | ebe08e0 | 2017-07-14 13:28:42 -0500 | [diff] [blame] | 116 | return CB_ERR; |
Matt DeVillier | ebe08e0 | 2017-07-14 13:28:42 -0500 | [diff] [blame] | 117 | |
| 118 | return CB_SUCCESS; |
| 119 | } |
| 120 | |
Matt DeVillier | 53e4195 | 2017-06-27 13:07:43 -0500 | [diff] [blame] | 121 | static enum cb_err locate_vbt_vbios(const u8 *vbios, struct region_device *rdev) |
Matt DeVillier | ebe08e0 | 2017-07-14 13:28:42 -0500 | [diff] [blame] | 122 | { |
Matt DeVillier | 53e4195 | 2017-06-27 13:07:43 -0500 | [diff] [blame] | 123 | const optionrom_header_t *oprom; |
| 124 | const optionrom_pcir_t *pcir; |
| 125 | struct region_device rd; |
Matt DeVillier | ebe08e0 | 2017-07-14 13:28:42 -0500 | [diff] [blame] | 126 | enum cb_err ret; |
Matt DeVillier | 53e4195 | 2017-06-27 13:07:43 -0500 | [diff] [blame] | 127 | u8 opromsize; |
| 128 | size_t offset; |
Matt DeVillier | ebe08e0 | 2017-07-14 13:28:42 -0500 | [diff] [blame] | 129 | |
Matt DeVillier | 53e4195 | 2017-06-27 13:07:43 -0500 | [diff] [blame] | 130 | // FIXME: caller should supply a region_device instead of vbios pointer |
| 131 | if (rdev_chain(&rd, &addrspace_32bit.rdev, (uintptr_t)vbios, |
| 132 | sizeof(*oprom))) |
| 133 | return CB_ERR; |
Matt DeVillier | ebe08e0 | 2017-07-14 13:28:42 -0500 | [diff] [blame] | 134 | |
Matt DeVillier | 53e4195 | 2017-06-27 13:07:43 -0500 | [diff] [blame] | 135 | if (rdev_readat(&rd, &opromsize, offsetof(optionrom_header_t, size), |
| 136 | sizeof(opromsize)) != sizeof(opromsize) || !opromsize) |
| 137 | return CB_ERR; |
| 138 | |
| 139 | if (rdev_chain(&rd, &addrspace_32bit.rdev, (uintptr_t)vbios, |
| 140 | opromsize * 512)) |
| 141 | return CB_ERR; |
| 142 | |
| 143 | oprom = rdev_mmap(&rd, 0, sizeof(*oprom)); |
| 144 | if (!oprom) |
| 145 | return CB_ERR; |
| 146 | |
| 147 | if (!oprom->pcir_offset || !oprom->vbt_offset) { |
| 148 | rdev_munmap(&rd, (void *)oprom); |
| 149 | return CB_ERR; |
| 150 | } |
| 151 | |
| 152 | pcir = rdev_mmap(&rd, oprom->pcir_offset, sizeof(*pcir)); |
| 153 | if (pcir == NULL) { |
| 154 | rdev_munmap(&rd, (void *)oprom); |
| 155 | return CB_ERR; |
| 156 | } |
| 157 | |
Elyes HAOUAS | 75d19d7 | 2021-01-16 17:30:26 +0100 | [diff] [blame] | 158 | printk(BIOS_DEBUG, "GMA: %s: %x %x %x %x %x\n", __func__, |
Matt DeVillier | 53e4195 | 2017-06-27 13:07:43 -0500 | [diff] [blame] | 159 | oprom->signature, pcir->vendor, pcir->classcode[0], |
| 160 | pcir->classcode[1], pcir->classcode[2]); |
| 161 | |
| 162 | /* Make sure we got an Intel VGA option rom */ |
| 163 | if ((oprom->signature != OPROM_SIGNATURE) || |
| 164 | (pcir->vendor != PCI_VENDOR_ID_INTEL) || |
| 165 | (pcir->signature != 0x52494350) || |
| 166 | (pcir->classcode[0] != 0x00) || |
| 167 | (pcir->classcode[1] != 0x00) || |
| 168 | (pcir->classcode[2] != 0x03)) { |
| 169 | rdev_munmap(&rd, (void *)oprom); |
| 170 | rdev_munmap(&rd, (void *)pcir); |
| 171 | return CB_ERR; |
| 172 | } |
| 173 | |
| 174 | rdev_munmap(&rd, (void *)pcir); |
| 175 | |
| 176 | /* Search for $VBT as some VBIOS are broken... */ |
| 177 | offset = oprom->vbt_offset; |
| 178 | do { |
| 179 | ret = rdev_chain(rdev, &rd, offset, |
| 180 | (opromsize * 512) - offset); |
| 181 | offset++; |
| 182 | } while (ret == CB_SUCCESS && vbt_validate(rdev) != CB_SUCCESS); |
| 183 | |
| 184 | offset--; |
| 185 | |
| 186 | if (ret == CB_SUCCESS && offset != oprom->vbt_offset) |
| 187 | printk(BIOS_WARNING, "GMA: Buggy VBIOS found\n"); |
| 188 | else if (ret != CB_SUCCESS) |
| 189 | printk(BIOS_ERR, "GMA: Broken VBIOS found\n"); |
| 190 | |
| 191 | rdev_munmap(&rd, (void *)oprom); |
| 192 | return ret; |
| 193 | } |
| 194 | |
| 195 | static enum cb_err locate_vbt_cbfs(struct region_device *rdev) |
| 196 | { |
Patrick Georgi | 4a3956d | 2018-05-03 19:15:13 +0200 | [diff] [blame] | 197 | size_t vbt_data_size; |
| 198 | void *vbt = locate_vbt(&vbt_data_size); |
Matt DeVillier | 53e4195 | 2017-06-27 13:07:43 -0500 | [diff] [blame] | 199 | |
Patrick Georgi | 4a3956d | 2018-05-03 19:15:13 +0200 | [diff] [blame] | 200 | if (vbt == NULL) |
| 201 | return CB_ERR; |
Matt DeVillier | 53e4195 | 2017-06-27 13:07:43 -0500 | [diff] [blame] | 202 | |
Patrick Georgi | 4a3956d | 2018-05-03 19:15:13 +0200 | [diff] [blame] | 203 | if (rdev_chain(rdev, &addrspace_32bit.rdev, (uintptr_t)vbt, |
| 204 | vbt_data_size)) |
| 205 | return CB_ERR; |
| 206 | |
| 207 | printk(BIOS_INFO, "GMA: Found VBT in CBFS\n"); |
| 208 | |
| 209 | return CB_SUCCESS; |
Matt DeVillier | 53e4195 | 2017-06-27 13:07:43 -0500 | [diff] [blame] | 210 | } |
| 211 | |
| 212 | static enum cb_err locate_vbt_vbios_cbfs(struct region_device *rdev) |
| 213 | { |
| 214 | const u8 *oprom = |
Kyösti Mälkki | c70eed1 | 2018-05-22 02:18:00 +0300 | [diff] [blame] | 215 | (const u8 *)pci_rom_probe(pcidev_on_root(0x2, 0)); |
Matt DeVillier | 53e4195 | 2017-06-27 13:07:43 -0500 | [diff] [blame] | 216 | if (oprom == NULL) |
| 217 | return CB_ERR; |
| 218 | |
| 219 | printk(BIOS_INFO, "GMA: Found VBIOS in CBFS\n"); |
| 220 | |
| 221 | return locate_vbt_vbios(oprom, rdev); |
| 222 | } |
| 223 | |
| 224 | /* Initialize IGD OpRegion, called from ACPI code and OS drivers */ |
Nico Huber | f2a0be2 | 2020-04-26 17:01:25 +0200 | [diff] [blame] | 225 | enum cb_err intel_gma_init_igd_opregion(void) |
Matt DeVillier | 53e4195 | 2017-06-27 13:07:43 -0500 | [diff] [blame] | 226 | { |
Nico Huber | f2a0be2 | 2020-04-26 17:01:25 +0200 | [diff] [blame] | 227 | igd_opregion_t *opregion; |
Matt DeVillier | 53e4195 | 2017-06-27 13:07:43 -0500 | [diff] [blame] | 228 | struct region_device rdev; |
| 229 | optionrom_vbt_t *vbt = NULL; |
| 230 | optionrom_vbt_t *ext_vbt; |
| 231 | bool found = false; |
| 232 | |
Nico Huber | f2a0be2 | 2020-04-26 17:01:25 +0200 | [diff] [blame] | 233 | if (acpi_is_wakeup_s3()) |
| 234 | return intel_gma_restore_opregion(); |
| 235 | |
Matt DeVillier | 53e4195 | 2017-06-27 13:07:43 -0500 | [diff] [blame] | 236 | /* Search for vbt.bin in CBFS. */ |
| 237 | if (locate_vbt_cbfs(&rdev) == CB_SUCCESS && |
| 238 | vbt_validate(&rdev) == CB_SUCCESS) { |
| 239 | found = true; |
| 240 | printk(BIOS_INFO, "GMA: Found valid VBT in CBFS\n"); |
| 241 | } |
| 242 | /* Search for pci8086,XXXX.rom in CBFS. */ |
| 243 | else if (locate_vbt_vbios_cbfs(&rdev) == CB_SUCCESS && |
| 244 | vbt_validate(&rdev) == CB_SUCCESS) { |
| 245 | found = true; |
| 246 | printk(BIOS_INFO, "GMA: Found valid VBT in VBIOS\n"); |
| 247 | } |
| 248 | /* |
| 249 | * Try to locate Intel VBIOS at 0xc0000. It might have been placed by |
| 250 | * Native Graphics Init as fake Option ROM or when coreboot did run the |
| 251 | * VBIOS on legacy platforms. |
| 252 | * TODO: Place generated fake VBT in CBMEM and get rid of this. |
| 253 | */ |
| 254 | else if (locate_vbt_vbios((u8 *)0xc0000, &rdev) == CB_SUCCESS && |
| 255 | vbt_validate(&rdev) == CB_SUCCESS) { |
| 256 | found = true; |
| 257 | printk(BIOS_INFO, "GMA: Found valid VBT in legacy area\n"); |
| 258 | } |
| 259 | |
| 260 | if (!found) { |
| 261 | printk(BIOS_ERR, "GMA: VBT couldn't be found\n"); |
| 262 | return CB_ERR; |
| 263 | } |
| 264 | |
| 265 | vbt = rdev_mmap_full(&rdev); |
| 266 | if (!vbt) { |
| 267 | printk(BIOS_ERR, "GMA: Error mapping VBT\n"); |
| 268 | return CB_ERR; |
| 269 | } |
| 270 | |
| 271 | if (vbt->hdr_vbt_size > region_device_sz(&rdev)) { |
| 272 | printk(BIOS_ERR, "GMA: Error mapped only a partial VBT\n"); |
| 273 | rdev_munmap(&rdev, vbt); |
| 274 | return CB_ERR; |
| 275 | } |
| 276 | |
Nico Huber | f2a0be2 | 2020-04-26 17:01:25 +0200 | [diff] [blame] | 277 | opregion = cbmem_add(CBMEM_ID_IGD_OPREGION, sizeof(*opregion)); |
| 278 | if (!opregion) { |
| 279 | printk(BIOS_ERR, "GMA: Failed to add IGD OpRegion to CBMEM.\n"); |
| 280 | return CB_ERR; |
| 281 | } |
| 282 | |
Matt DeVillier | 53e4195 | 2017-06-27 13:07:43 -0500 | [diff] [blame] | 283 | memset(opregion, 0, sizeof(igd_opregion_t)); |
Matt DeVillier | ebe08e0 | 2017-07-14 13:28:42 -0500 | [diff] [blame] | 284 | |
| 285 | memcpy(&opregion->header.signature, IGD_OPREGION_SIGNATURE, |
| 286 | sizeof(opregion->header.signature)); |
Matt DeVillier | 53e4195 | 2017-06-27 13:07:43 -0500 | [diff] [blame] | 287 | memcpy(opregion->header.vbios_version, vbt->coreblock_biosbuild, |
| 288 | ARRAY_SIZE(vbt->coreblock_biosbuild)); |
| 289 | /* Extended VBT support */ |
| 290 | if (vbt->hdr_vbt_size > sizeof(opregion->vbt.gvd1)) { |
| 291 | ext_vbt = cbmem_add(CBMEM_ID_EXT_VBT, vbt->hdr_vbt_size); |
| 292 | |
| 293 | if (ext_vbt == NULL) { |
| 294 | printk(BIOS_ERR, |
| 295 | "GMA: Unable to add Ext VBT to cbmem!\n"); |
| 296 | rdev_munmap(&rdev, vbt); |
| 297 | return CB_ERR; |
| 298 | } |
| 299 | |
| 300 | memcpy(ext_vbt, vbt, vbt->hdr_vbt_size); |
| 301 | opregion->mailbox3.rvda = (uintptr_t)ext_vbt; |
| 302 | opregion->mailbox3.rvds = vbt->hdr_vbt_size; |
| 303 | } else { |
| 304 | /* Raw VBT size which can fit in gvd1 */ |
| 305 | memcpy(opregion->vbt.gvd1, vbt, vbt->hdr_vbt_size); |
| 306 | } |
| 307 | |
| 308 | rdev_munmap(&rdev, vbt); |
Matt DeVillier | ebe08e0 | 2017-07-14 13:28:42 -0500 | [diff] [blame] | 309 | |
| 310 | /* 8kb */ |
| 311 | opregion->header.size = sizeof(igd_opregion_t) / 1024; |
Matt DeVillier | fd0a891 | 2017-10-19 22:44:18 -0500 | [diff] [blame] | 312 | |
| 313 | /* |
Elyes HAOUAS | 1895838 | 2018-08-07 12:23:16 +0200 | [diff] [blame] | 314 | * Left-shift version field to accommodate Intel Windows driver quirk |
Matt DeVillier | fd0a891 | 2017-10-19 22:44:18 -0500 | [diff] [blame] | 315 | * when not using a VBIOS. |
| 316 | * Required for Legacy boot + NGI, UEFI + NGI, and UEFI + GOP driver. |
| 317 | * |
| 318 | * Tested on: (platform, GPU, windows driver version) |
| 319 | * samsung/stumpy (SNB, GT2, 9.17.10.4459) |
| 320 | * google/link (IVB, GT2, 15.33.4653) |
| 321 | * google/wolf (HSW, GT1, 15.40.36.4703) |
| 322 | * google/panther (HSW, GT2, 15.40.36.4703) |
| 323 | * google/rikku (BDW, GT1, 15.40.36.4703) |
| 324 | * google/lulu (BDW, GT2, 15.40.36.4703) |
| 325 | * google/chell (SKL-Y, GT2, 15.45.21.4821) |
| 326 | * google/sentry (SKL-U, GT1, 15.45.21.4821) |
| 327 | * purism/librem13v2 (SKL-U, GT2, 15.45.21.4821) |
| 328 | * |
| 329 | * No adverse effects when using VBIOS or booting Linux. |
| 330 | */ |
| 331 | opregion->header.version = IGD_OPREGION_VERSION << 24; |
Matt DeVillier | ebe08e0 | 2017-07-14 13:28:42 -0500 | [diff] [blame] | 332 | |
| 333 | // FIXME We just assume we're mobile for now |
| 334 | opregion->header.mailboxes = MAILBOXES_MOBILE; |
| 335 | |
| 336 | // TODO Initialize Mailbox 1 |
Patrick Georgi | 0f68b23 | 2018-01-25 18:23:15 +0100 | [diff] [blame] | 337 | opregion->mailbox1.clid = 1; |
Matt DeVillier | ebe08e0 | 2017-07-14 13:28:42 -0500 | [diff] [blame] | 338 | |
| 339 | // TODO Initialize Mailbox 3 |
| 340 | opregion->mailbox3.bclp = IGD_BACKLIGHT_BRIGHTNESS; |
| 341 | opregion->mailbox3.pfit = IGD_FIELD_VALID | IGD_PFIT_STRETCH; |
| 342 | opregion->mailbox3.pcft = 0; // should be (IMON << 1) & 0x3e |
| 343 | opregion->mailbox3.cblv = IGD_FIELD_VALID | IGD_INITIAL_BRIGHTNESS; |
| 344 | opregion->mailbox3.bclm[0] = IGD_WORD_FIELD_VALID + 0x0000; |
| 345 | opregion->mailbox3.bclm[1] = IGD_WORD_FIELD_VALID + 0x0a19; |
| 346 | opregion->mailbox3.bclm[2] = IGD_WORD_FIELD_VALID + 0x1433; |
| 347 | opregion->mailbox3.bclm[3] = IGD_WORD_FIELD_VALID + 0x1e4c; |
| 348 | opregion->mailbox3.bclm[4] = IGD_WORD_FIELD_VALID + 0x2866; |
| 349 | opregion->mailbox3.bclm[5] = IGD_WORD_FIELD_VALID + 0x327f; |
| 350 | opregion->mailbox3.bclm[6] = IGD_WORD_FIELD_VALID + 0x3c99; |
| 351 | opregion->mailbox3.bclm[7] = IGD_WORD_FIELD_VALID + 0x46b2; |
| 352 | opregion->mailbox3.bclm[8] = IGD_WORD_FIELD_VALID + 0x50cc; |
| 353 | opregion->mailbox3.bclm[9] = IGD_WORD_FIELD_VALID + 0x5ae5; |
| 354 | opregion->mailbox3.bclm[10] = IGD_WORD_FIELD_VALID + 0x64ff; |
| 355 | |
Matt DeVillier | ebe08e0 | 2017-07-14 13:28:42 -0500 | [diff] [blame] | 356 | /* Write ASLS PCI register and prepare SWSCI register. */ |
| 357 | intel_gma_opregion_register((uintptr_t)opregion); |
| 358 | |
| 359 | return CB_SUCCESS; |
| 360 | } |