1 1.6 riastrad /* $NetBSD: amdgpu_bios.c,v 1.6 2022/02/27 14:23:24 riastradh Exp $ */ 2 1.1 riastrad 3 1.1 riastrad /* 4 1.1 riastrad * Copyright 2008 Advanced Micro Devices, Inc. 5 1.1 riastrad * Copyright 2008 Red Hat Inc. 6 1.1 riastrad * Copyright 2009 Jerome Glisse. 7 1.1 riastrad * 8 1.1 riastrad * Permission is hereby granted, free of charge, to any person obtaining a 9 1.1 riastrad * copy of this software and associated documentation files (the "Software"), 10 1.1 riastrad * to deal in the Software without restriction, including without limitation 11 1.1 riastrad * the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 1.1 riastrad * and/or sell copies of the Software, and to permit persons to whom the 13 1.1 riastrad * Software is furnished to do so, subject to the following conditions: 14 1.1 riastrad * 15 1.1 riastrad * The above copyright notice and this permission notice shall be included in 16 1.1 riastrad * all copies or substantial portions of the Software. 17 1.1 riastrad * 18 1.1 riastrad * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 1.1 riastrad * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 1.1 riastrad * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 1.1 riastrad * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 22 1.1 riastrad * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 23 1.1 riastrad * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 24 1.1 riastrad * OTHER DEALINGS IN THE SOFTWARE. 25 1.1 riastrad * 26 1.1 riastrad * Authors: Dave Airlie 27 1.1 riastrad * Alex Deucher 28 1.1 riastrad * Jerome Glisse 29 1.1 riastrad */ 30 1.4 riastrad 31 1.1 riastrad #include <sys/cdefs.h> 32 1.6 riastrad __KERNEL_RCSID(0, "$NetBSD: amdgpu_bios.c,v 1.6 2022/02/27 14:23:24 riastradh Exp $"); 33 1.1 riastrad 34 1.1 riastrad #include "amdgpu.h" 35 1.1 riastrad #include "atom.h" 36 1.1 riastrad 37 1.4 riastrad #include <linux/pci.h> 38 1.1 riastrad #include <linux/slab.h> 39 1.1 riastrad #include <linux/acpi.h> 40 1.5 riastrad 41 1.5 riastrad #include <linux/nbsd-namespace.h> 42 1.6 riastrad #include <linux/nbsd-namespace-acpi.h> 43 1.5 riastrad 44 1.1 riastrad /* 45 1.1 riastrad * BIOS. 46 1.1 riastrad */ 47 1.1 riastrad 48 1.4 riastrad #define AMD_VBIOS_SIGNATURE " 761295520" 49 1.4 riastrad #define AMD_VBIOS_SIGNATURE_OFFSET 0x30 50 1.4 riastrad #define AMD_VBIOS_SIGNATURE_SIZE sizeof(AMD_VBIOS_SIGNATURE) 51 1.4 riastrad #define AMD_VBIOS_SIGNATURE_END (AMD_VBIOS_SIGNATURE_OFFSET + AMD_VBIOS_SIGNATURE_SIZE) 52 1.4 riastrad #define AMD_IS_VALID_VBIOS(p) ((p)[0] == 0x55 && (p)[1] == 0xAA) 53 1.4 riastrad #define AMD_VBIOS_LENGTH(p) ((p)[2] << 9) 54 1.4 riastrad 55 1.4 riastrad /* Check if current bios is an ATOM BIOS. 56 1.4 riastrad * Return true if it is ATOM BIOS. Otherwise, return false. 57 1.4 riastrad */ 58 1.4 riastrad static bool check_atom_bios(uint8_t *bios, size_t size) 59 1.4 riastrad { 60 1.4 riastrad uint16_t tmp, bios_header_start; 61 1.4 riastrad 62 1.4 riastrad if (!bios || size < 0x49) { 63 1.4 riastrad DRM_INFO("vbios mem is null or mem size is wrong\n"); 64 1.4 riastrad return false; 65 1.4 riastrad } 66 1.4 riastrad 67 1.4 riastrad if (!AMD_IS_VALID_VBIOS(bios)) { 68 1.4 riastrad DRM_INFO("BIOS signature incorrect %x %x\n", bios[0], bios[1]); 69 1.4 riastrad return false; 70 1.4 riastrad } 71 1.4 riastrad 72 1.4 riastrad bios_header_start = bios[0x48] | (bios[0x49] << 8); 73 1.4 riastrad if (!bios_header_start) { 74 1.4 riastrad DRM_INFO("Can't locate bios header\n"); 75 1.4 riastrad return false; 76 1.4 riastrad } 77 1.4 riastrad 78 1.4 riastrad tmp = bios_header_start + 4; 79 1.4 riastrad if (size < tmp) { 80 1.4 riastrad DRM_INFO("BIOS header is broken\n"); 81 1.4 riastrad return false; 82 1.4 riastrad } 83 1.4 riastrad 84 1.4 riastrad if (!memcmp(bios + tmp, "ATOM", 4) || 85 1.4 riastrad !memcmp(bios + tmp, "MOTA", 4)) { 86 1.4 riastrad DRM_DEBUG("ATOMBIOS detected\n"); 87 1.4 riastrad return true; 88 1.4 riastrad } 89 1.4 riastrad 90 1.4 riastrad return false; 91 1.4 riastrad } 92 1.4 riastrad 93 1.1 riastrad /* If you boot an IGP board with a discrete card as the primary, 94 1.1 riastrad * the IGP rom is not accessible via the rom bar as the IGP rom is 95 1.1 riastrad * part of the system bios. On boot, the system bios puts a 96 1.1 riastrad * copy of the igp rom at the start of vram if a discrete card is 97 1.1 riastrad * present. 98 1.1 riastrad */ 99 1.1 riastrad static bool igp_read_bios_from_vram(struct amdgpu_device *adev) 100 1.1 riastrad { 101 1.3 riastrad #ifdef __NetBSD__ 102 1.3 riastrad bus_space_tag_t bst; 103 1.3 riastrad bus_space_handle_t bsh; 104 1.3 riastrad bus_size_t size; 105 1.3 riastrad #else 106 1.1 riastrad uint8_t __iomem *bios; 107 1.1 riastrad resource_size_t vram_base; 108 1.1 riastrad resource_size_t size = 256 * 1024; /* ??? */ 109 1.3 riastrad #endif 110 1.1 riastrad 111 1.1 riastrad if (!(adev->flags & AMD_IS_APU)) 112 1.4 riastrad if (amdgpu_device_need_post(adev)) 113 1.1 riastrad return false; 114 1.1 riastrad 115 1.1 riastrad adev->bios = NULL; 116 1.3 riastrad #ifdef __NetBSD__ 117 1.3 riastrad if (pci_mapreg_map(&adev->pdev->pd_pa, PCI_BAR(0), 118 1.3 riastrad /* XXX Dunno what type to expect here; fill me in... */ 119 1.3 riastrad pci_mapreg_type(adev->pdev->pd_pa.pa_pc, 120 1.3 riastrad adev->pdev->pd_pa.pa_tag, PCI_BAR(0)), 121 1.3 riastrad 0, &bst, &bsh, NULL, &size)) 122 1.3 riastrad return false; 123 1.3 riastrad if ((size == 0) || 124 1.3 riastrad (size < 256 * 1024) || 125 1.3 riastrad (bus_space_read_1(bst, bsh, 0) != 0x55) || 126 1.3 riastrad (bus_space_read_1(bst, bsh, 1) != 0xaa) || 127 1.3 riastrad ((adev->bios = kmalloc(size, GFP_KERNEL)) == NULL)) { 128 1.3 riastrad bus_space_unmap(bst, bsh, size); 129 1.3 riastrad return false; 130 1.3 riastrad } 131 1.3 riastrad bus_space_read_region_1(bst, bsh, 0, adev->bios, size); 132 1.3 riastrad bus_space_unmap(bst, bsh, size); 133 1.3 riastrad #else 134 1.1 riastrad vram_base = pci_resource_start(adev->pdev, 0); 135 1.4 riastrad bios = ioremap_wc(vram_base, size); 136 1.1 riastrad if (!bios) { 137 1.1 riastrad return false; 138 1.1 riastrad } 139 1.1 riastrad 140 1.1 riastrad adev->bios = kmalloc(size, GFP_KERNEL); 141 1.4 riastrad if (!adev->bios) { 142 1.1 riastrad iounmap(bios); 143 1.1 riastrad return false; 144 1.1 riastrad } 145 1.4 riastrad adev->bios_size = size; 146 1.1 riastrad memcpy_fromio(adev->bios, bios, size); 147 1.1 riastrad iounmap(bios); 148 1.3 riastrad #endif 149 1.4 riastrad 150 1.4 riastrad if (!check_atom_bios(adev->bios, size)) { 151 1.4 riastrad kfree(adev->bios); 152 1.4 riastrad return false; 153 1.4 riastrad } 154 1.4 riastrad 155 1.1 riastrad return true; 156 1.1 riastrad } 157 1.1 riastrad 158 1.3 riastrad #ifdef __NetBSD__ 159 1.3 riastrad # define __iomem __pci_rom_iomem 160 1.3 riastrad #endif 161 1.3 riastrad 162 1.1 riastrad bool amdgpu_read_bios(struct amdgpu_device *adev) 163 1.1 riastrad { 164 1.4 riastrad uint8_t __iomem *bios; 165 1.1 riastrad size_t size; 166 1.1 riastrad 167 1.1 riastrad adev->bios = NULL; 168 1.1 riastrad /* XXX: some cards may return 0 for rom size? ddx has a workaround */ 169 1.1 riastrad bios = pci_map_rom(adev->pdev, &size); 170 1.1 riastrad if (!bios) { 171 1.1 riastrad return false; 172 1.1 riastrad } 173 1.1 riastrad 174 1.1 riastrad adev->bios = kzalloc(size, GFP_KERNEL); 175 1.1 riastrad if (adev->bios == NULL) { 176 1.1 riastrad pci_unmap_rom(adev->pdev, bios); 177 1.1 riastrad return false; 178 1.1 riastrad } 179 1.4 riastrad adev->bios_size = size; 180 1.1 riastrad memcpy_fromio(adev->bios, bios, size); 181 1.1 riastrad pci_unmap_rom(adev->pdev, bios); 182 1.4 riastrad 183 1.4 riastrad if (!check_atom_bios(adev->bios, size)) { 184 1.4 riastrad kfree(adev->bios); 185 1.4 riastrad return false; 186 1.4 riastrad } 187 1.4 riastrad 188 1.4 riastrad return true; 189 1.4 riastrad } 190 1.4 riastrad 191 1.4 riastrad static bool amdgpu_read_bios_from_rom(struct amdgpu_device *adev) 192 1.4 riastrad { 193 1.4 riastrad u8 header[AMD_VBIOS_SIGNATURE_END+1] = {0}; 194 1.4 riastrad int len; 195 1.4 riastrad 196 1.4 riastrad if (!adev->asic_funcs->read_bios_from_rom) 197 1.4 riastrad return false; 198 1.4 riastrad 199 1.4 riastrad /* validate VBIOS signature */ 200 1.4 riastrad if (amdgpu_asic_read_bios_from_rom(adev, &header[0], sizeof(header)) == false) 201 1.4 riastrad return false; 202 1.4 riastrad header[AMD_VBIOS_SIGNATURE_END] = 0; 203 1.4 riastrad 204 1.4 riastrad if ((!AMD_IS_VALID_VBIOS(header)) || 205 1.4 riastrad 0 != memcmp((char *)&header[AMD_VBIOS_SIGNATURE_OFFSET], 206 1.4 riastrad AMD_VBIOS_SIGNATURE, 207 1.4 riastrad strlen(AMD_VBIOS_SIGNATURE))) 208 1.4 riastrad return false; 209 1.4 riastrad 210 1.4 riastrad /* valid vbios, go on */ 211 1.4 riastrad len = AMD_VBIOS_LENGTH(header); 212 1.4 riastrad len = ALIGN(len, 4); 213 1.4 riastrad adev->bios = kmalloc(len, GFP_KERNEL); 214 1.4 riastrad if (!adev->bios) { 215 1.4 riastrad DRM_ERROR("no memory to allocate for BIOS\n"); 216 1.4 riastrad return false; 217 1.4 riastrad } 218 1.4 riastrad adev->bios_size = len; 219 1.4 riastrad 220 1.4 riastrad /* read complete BIOS */ 221 1.4 riastrad amdgpu_asic_read_bios_from_rom(adev, adev->bios, len); 222 1.4 riastrad 223 1.4 riastrad if (!check_atom_bios(adev->bios, len)) { 224 1.4 riastrad kfree(adev->bios); 225 1.4 riastrad return false; 226 1.4 riastrad } 227 1.4 riastrad 228 1.1 riastrad return true; 229 1.1 riastrad } 230 1.1 riastrad 231 1.3 riastrad #ifdef __NetBSD__ 232 1.3 riastrad # undef __iomem 233 1.3 riastrad #endif 234 1.3 riastrad 235 1.1 riastrad static bool amdgpu_read_platform_bios(struct amdgpu_device *adev) 236 1.1 riastrad { 237 1.3 riastrad #ifdef __NetBSD__ /* XXX amdgpu platform bios */ 238 1.3 riastrad return false; 239 1.3 riastrad #else 240 1.1 riastrad uint8_t __iomem *bios; 241 1.1 riastrad size_t size; 242 1.1 riastrad 243 1.1 riastrad adev->bios = NULL; 244 1.1 riastrad 245 1.1 riastrad bios = pci_platform_rom(adev->pdev, &size); 246 1.1 riastrad if (!bios) { 247 1.1 riastrad return false; 248 1.1 riastrad } 249 1.1 riastrad 250 1.4 riastrad adev->bios = kzalloc(size, GFP_KERNEL); 251 1.4 riastrad if (adev->bios == NULL) 252 1.1 riastrad return false; 253 1.4 riastrad 254 1.4 riastrad memcpy_fromio(adev->bios, bios, size); 255 1.4 riastrad 256 1.4 riastrad if (!check_atom_bios(adev->bios, size)) { 257 1.4 riastrad kfree(adev->bios); 258 1.1 riastrad return false; 259 1.1 riastrad } 260 1.1 riastrad 261 1.4 riastrad adev->bios_size = size; 262 1.4 riastrad 263 1.1 riastrad return true; 264 1.3 riastrad #endif /* __NetBSD__ */ 265 1.1 riastrad } 266 1.1 riastrad 267 1.3 riastrad /* XXX amdgpu acpi */ 268 1.1 riastrad #ifdef CONFIG_ACPI 269 1.1 riastrad /* ATRM is used to get the BIOS on the discrete cards in 270 1.1 riastrad * dual-gpu systems. 271 1.1 riastrad */ 272 1.1 riastrad /* retrieve the ROM in 4k blocks */ 273 1.1 riastrad #define ATRM_BIOS_PAGE 4096 274 1.1 riastrad /** 275 1.1 riastrad * amdgpu_atrm_call - fetch a chunk of the vbios 276 1.1 riastrad * 277 1.1 riastrad * @atrm_handle: acpi ATRM handle 278 1.1 riastrad * @bios: vbios image pointer 279 1.1 riastrad * @offset: offset of vbios image data to fetch 280 1.1 riastrad * @len: length of vbios image data to fetch 281 1.1 riastrad * 282 1.1 riastrad * Executes ATRM to fetch a chunk of the discrete 283 1.1 riastrad * vbios image on PX systems (all asics). 284 1.1 riastrad * Returns the length of the buffer fetched. 285 1.1 riastrad */ 286 1.1 riastrad static int amdgpu_atrm_call(acpi_handle atrm_handle, uint8_t *bios, 287 1.1 riastrad int offset, int len) 288 1.1 riastrad { 289 1.1 riastrad acpi_status status; 290 1.1 riastrad union acpi_object atrm_arg_elements[2], *obj; 291 1.1 riastrad struct acpi_object_list atrm_arg; 292 1.1 riastrad struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL}; 293 1.1 riastrad 294 1.1 riastrad atrm_arg.count = 2; 295 1.1 riastrad atrm_arg.pointer = &atrm_arg_elements[0]; 296 1.1 riastrad 297 1.1 riastrad atrm_arg_elements[0].type = ACPI_TYPE_INTEGER; 298 1.1 riastrad atrm_arg_elements[0].integer.value = offset; 299 1.1 riastrad 300 1.1 riastrad atrm_arg_elements[1].type = ACPI_TYPE_INTEGER; 301 1.1 riastrad atrm_arg_elements[1].integer.value = len; 302 1.1 riastrad 303 1.1 riastrad status = acpi_evaluate_object(atrm_handle, NULL, &atrm_arg, &buffer); 304 1.1 riastrad if (ACPI_FAILURE(status)) { 305 1.1 riastrad printk("failed to evaluate ATRM got %s\n", acpi_format_exception(status)); 306 1.1 riastrad return -ENODEV; 307 1.1 riastrad } 308 1.1 riastrad 309 1.1 riastrad obj = (union acpi_object *)buffer.pointer; 310 1.1 riastrad memcpy(bios+offset, obj->buffer.pointer, obj->buffer.length); 311 1.1 riastrad len = obj->buffer.length; 312 1.1 riastrad kfree(buffer.pointer); 313 1.1 riastrad return len; 314 1.1 riastrad } 315 1.1 riastrad 316 1.1 riastrad static bool amdgpu_atrm_get_bios(struct amdgpu_device *adev) 317 1.1 riastrad { 318 1.1 riastrad int ret; 319 1.1 riastrad int size = 256 * 1024; 320 1.1 riastrad int i; 321 1.1 riastrad struct pci_dev *pdev = NULL; 322 1.1 riastrad acpi_handle dhandle, atrm_handle; 323 1.1 riastrad acpi_status status; 324 1.1 riastrad bool found = false; 325 1.1 riastrad 326 1.1 riastrad /* ATRM is for the discrete card only */ 327 1.1 riastrad if (adev->flags & AMD_IS_APU) 328 1.1 riastrad return false; 329 1.1 riastrad 330 1.1 riastrad while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, pdev)) != NULL) { 331 1.6 riastrad #ifdef __NetBSD__ 332 1.6 riastrad dhandle = (pdev->pd_ad ? pdev->pd_ad->ad_handle : NULL); 333 1.6 riastrad #else 334 1.1 riastrad dhandle = ACPI_HANDLE(&pdev->dev); 335 1.6 riastrad #endif 336 1.1 riastrad if (!dhandle) 337 1.1 riastrad continue; 338 1.1 riastrad 339 1.1 riastrad status = acpi_get_handle(dhandle, "ATRM", &atrm_handle); 340 1.1 riastrad if (!ACPI_FAILURE(status)) { 341 1.1 riastrad found = true; 342 1.1 riastrad break; 343 1.1 riastrad } 344 1.1 riastrad } 345 1.1 riastrad 346 1.1 riastrad if (!found) { 347 1.1 riastrad while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_OTHER << 8, pdev)) != NULL) { 348 1.6 riastrad #ifdef __NetBSD__ 349 1.6 riastrad dhandle = (pdev->pd_ad ? pdev->pd_ad->ad_handle 350 1.6 riastrad : NULL); 351 1.6 riastrad #else 352 1.1 riastrad dhandle = ACPI_HANDLE(&pdev->dev); 353 1.6 riastrad #endif 354 1.1 riastrad if (!dhandle) 355 1.1 riastrad continue; 356 1.1 riastrad 357 1.1 riastrad status = acpi_get_handle(dhandle, "ATRM", &atrm_handle); 358 1.1 riastrad if (!ACPI_FAILURE(status)) { 359 1.1 riastrad found = true; 360 1.1 riastrad break; 361 1.1 riastrad } 362 1.1 riastrad } 363 1.1 riastrad } 364 1.1 riastrad 365 1.1 riastrad if (!found) 366 1.1 riastrad return false; 367 1.1 riastrad 368 1.1 riastrad adev->bios = kmalloc(size, GFP_KERNEL); 369 1.1 riastrad if (!adev->bios) { 370 1.1 riastrad DRM_ERROR("Unable to allocate bios\n"); 371 1.1 riastrad return false; 372 1.1 riastrad } 373 1.1 riastrad 374 1.1 riastrad for (i = 0; i < size / ATRM_BIOS_PAGE; i++) { 375 1.1 riastrad ret = amdgpu_atrm_call(atrm_handle, 376 1.1 riastrad adev->bios, 377 1.1 riastrad (i * ATRM_BIOS_PAGE), 378 1.1 riastrad ATRM_BIOS_PAGE); 379 1.1 riastrad if (ret < ATRM_BIOS_PAGE) 380 1.1 riastrad break; 381 1.1 riastrad } 382 1.1 riastrad 383 1.4 riastrad if (!check_atom_bios(adev->bios, size)) { 384 1.1 riastrad kfree(adev->bios); 385 1.1 riastrad return false; 386 1.1 riastrad } 387 1.4 riastrad adev->bios_size = size; 388 1.1 riastrad return true; 389 1.1 riastrad } 390 1.1 riastrad #else 391 1.1 riastrad static inline bool amdgpu_atrm_get_bios(struct amdgpu_device *adev) 392 1.1 riastrad { 393 1.1 riastrad return false; 394 1.1 riastrad } 395 1.1 riastrad #endif 396 1.1 riastrad 397 1.1 riastrad static bool amdgpu_read_disabled_bios(struct amdgpu_device *adev) 398 1.1 riastrad { 399 1.1 riastrad if (adev->flags & AMD_IS_APU) 400 1.1 riastrad return igp_read_bios_from_vram(adev); 401 1.1 riastrad else 402 1.1 riastrad return amdgpu_asic_read_disabled_bios(adev); 403 1.1 riastrad } 404 1.1 riastrad 405 1.1 riastrad #ifdef CONFIG_ACPI 406 1.1 riastrad static bool amdgpu_acpi_vfct_bios(struct amdgpu_device *adev) 407 1.1 riastrad { 408 1.1 riastrad struct acpi_table_header *hdr; 409 1.1 riastrad acpi_size tbl_size; 410 1.1 riastrad UEFI_ACPI_VFCT *vfct; 411 1.4 riastrad unsigned offset; 412 1.1 riastrad 413 1.4 riastrad if (!ACPI_SUCCESS(acpi_get_table("VFCT", 1, &hdr))) 414 1.1 riastrad return false; 415 1.4 riastrad tbl_size = hdr->length; 416 1.1 riastrad if (tbl_size < sizeof(UEFI_ACPI_VFCT)) { 417 1.1 riastrad DRM_ERROR("ACPI VFCT table present but broken (too short #1)\n"); 418 1.4 riastrad return false; 419 1.1 riastrad } 420 1.1 riastrad 421 1.1 riastrad vfct = (UEFI_ACPI_VFCT *)hdr; 422 1.4 riastrad offset = vfct->VBIOSImageOffset; 423 1.1 riastrad 424 1.4 riastrad while (offset < tbl_size) { 425 1.4 riastrad GOP_VBIOS_CONTENT *vbios = (GOP_VBIOS_CONTENT *)((char *)hdr + offset); 426 1.4 riastrad VFCT_IMAGE_HEADER *vhdr = &vbios->VbiosHeader; 427 1.4 riastrad 428 1.4 riastrad offset += sizeof(VFCT_IMAGE_HEADER); 429 1.4 riastrad if (offset > tbl_size) { 430 1.4 riastrad DRM_ERROR("ACPI VFCT image header truncated\n"); 431 1.4 riastrad return false; 432 1.4 riastrad } 433 1.1 riastrad 434 1.4 riastrad offset += vhdr->ImageLength; 435 1.4 riastrad if (offset > tbl_size) { 436 1.4 riastrad DRM_ERROR("ACPI VFCT image truncated\n"); 437 1.4 riastrad return false; 438 1.4 riastrad } 439 1.1 riastrad 440 1.4 riastrad if (vhdr->ImageLength && 441 1.4 riastrad vhdr->PCIBus == adev->pdev->bus->number && 442 1.4 riastrad vhdr->PCIDevice == PCI_SLOT(adev->pdev->devfn) && 443 1.4 riastrad vhdr->PCIFunction == PCI_FUNC(adev->pdev->devfn) && 444 1.4 riastrad vhdr->VendorID == adev->pdev->vendor && 445 1.4 riastrad vhdr->DeviceID == adev->pdev->device) { 446 1.4 riastrad adev->bios = kmemdup(&vbios->VbiosContent, 447 1.4 riastrad vhdr->ImageLength, 448 1.4 riastrad GFP_KERNEL); 449 1.4 riastrad 450 1.4 riastrad if (!check_atom_bios(adev->bios, vhdr->ImageLength)) { 451 1.4 riastrad kfree(adev->bios); 452 1.4 riastrad return false; 453 1.4 riastrad } 454 1.4 riastrad adev->bios_size = vhdr->ImageLength; 455 1.4 riastrad return true; 456 1.4 riastrad } 457 1.1 riastrad } 458 1.1 riastrad 459 1.4 riastrad DRM_ERROR("ACPI VFCT table present but broken (too short #2)\n"); 460 1.4 riastrad return false; 461 1.1 riastrad } 462 1.1 riastrad #else 463 1.1 riastrad static inline bool amdgpu_acpi_vfct_bios(struct amdgpu_device *adev) 464 1.1 riastrad { 465 1.1 riastrad return false; 466 1.1 riastrad } 467 1.1 riastrad #endif 468 1.1 riastrad 469 1.1 riastrad bool amdgpu_get_bios(struct amdgpu_device *adev) 470 1.1 riastrad { 471 1.4 riastrad if (amdgpu_atrm_get_bios(adev)) 472 1.4 riastrad goto success; 473 1.4 riastrad 474 1.4 riastrad if (amdgpu_acpi_vfct_bios(adev)) 475 1.4 riastrad goto success; 476 1.4 riastrad 477 1.4 riastrad if (igp_read_bios_from_vram(adev)) 478 1.4 riastrad goto success; 479 1.4 riastrad 480 1.4 riastrad if (amdgpu_read_bios(adev)) 481 1.4 riastrad goto success; 482 1.1 riastrad 483 1.4 riastrad if (amdgpu_read_bios_from_rom(adev)) 484 1.4 riastrad goto success; 485 1.4 riastrad 486 1.4 riastrad if (amdgpu_read_disabled_bios(adev)) 487 1.4 riastrad goto success; 488 1.1 riastrad 489 1.4 riastrad if (amdgpu_read_platform_bios(adev)) 490 1.4 riastrad goto success; 491 1.1 riastrad 492 1.4 riastrad DRM_ERROR("Unable to locate a BIOS ROM\n"); 493 1.4 riastrad return false; 494 1.1 riastrad 495 1.4 riastrad success: 496 1.4 riastrad adev->is_atom_fw = (adev->asic_type >= CHIP_VEGA10) ? true : false; 497 1.1 riastrad return true; 498 1.1 riastrad } 499