Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

amdgpu: detect if we are using atomfirmware or atombios for vbios (v2)

Supposedly atomfirmware rom header is 3.3 atombios is 1.1.

v2: rebased on newer kernel

Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

+24 -7
+1
drivers/gpu/drm/amd/amdgpu/amdgpu.h
··· 1308 1308 bool have_disp_power_ref; 1309 1309 1310 1310 /* BIOS */ 1311 + bool is_atom_fw; 1311 1312 uint8_t *bios; 1312 1313 uint32_t bios_size; 1313 1314 struct amdgpu_bo *stollen_vga_memory;
+23 -7
drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c
··· 86 86 return false; 87 87 } 88 88 89 + static bool is_atom_fw(uint8_t *bios) 90 + { 91 + uint16_t bios_header_start = bios[0x48] | (bios[0x49] << 8); 92 + uint8_t frev = bios[bios_header_start + 2]; 93 + uint8_t crev = bios[bios_header_start + 3]; 94 + 95 + if ((frev < 3) || 96 + ((frev == 3) && (crev < 3))) 97 + return false; 98 + 99 + return true; 100 + } 89 101 90 102 /* If you boot an IGP board with a discrete card as the primary, 91 103 * the IGP rom is not accessible via the rom bar as the IGP rom is ··· 431 419 bool amdgpu_get_bios(struct amdgpu_device *adev) 432 420 { 433 421 if (amdgpu_atrm_get_bios(adev)) 434 - return true; 422 + goto success; 435 423 436 424 if (amdgpu_acpi_vfct_bios(adev)) 437 - return true; 425 + goto success; 438 426 439 427 if (igp_read_bios_from_vram(adev)) 440 - return true; 428 + goto success; 441 429 442 430 if (amdgpu_read_bios(adev)) 443 - return true; 431 + goto success; 444 432 445 433 if (amdgpu_read_bios_from_rom(adev)) 446 - return true; 434 + goto success; 447 435 448 436 if (amdgpu_read_disabled_bios(adev)) 449 - return true; 437 + goto success; 450 438 451 439 if (amdgpu_read_platform_bios(adev)) 452 - return true; 440 + goto success; 453 441 454 442 DRM_ERROR("Unable to locate a BIOS ROM\n"); 455 443 return false; 444 + 445 + success: 446 + adev->is_atom_fw = is_atom_fw(adev->bios); 447 + return true; 456 448 }