Lines Matching refs:adev
90 static bool igp_read_bios_from_vram(struct amdgpu_device *adev) in igp_read_bios_from_vram() argument
96 if (!(adev->flags & AMD_IS_APU)) in igp_read_bios_from_vram()
97 if (amdgpu_device_need_post(adev)) in igp_read_bios_from_vram()
101 if (pci_resource_len(adev->pdev, 0) == 0) in igp_read_bios_from_vram()
104 adev->bios = NULL; in igp_read_bios_from_vram()
105 vram_base = pci_resource_start(adev->pdev, 0); in igp_read_bios_from_vram()
110 adev->bios = kmalloc(size, GFP_KERNEL); in igp_read_bios_from_vram()
111 if (!adev->bios) { in igp_read_bios_from_vram()
115 adev->bios_size = size; in igp_read_bios_from_vram()
116 memcpy_fromio(adev->bios, bios, size); in igp_read_bios_from_vram()
119 if (!check_atom_bios(adev->bios, size)) { in igp_read_bios_from_vram()
120 kfree(adev->bios); in igp_read_bios_from_vram()
127 bool amdgpu_read_bios(struct amdgpu_device *adev) in amdgpu_read_bios() argument
132 adev->bios = NULL; in amdgpu_read_bios()
134 bios = pci_map_rom(adev->pdev, &size); in amdgpu_read_bios()
138 adev->bios = kzalloc(size, GFP_KERNEL); in amdgpu_read_bios()
139 if (adev->bios == NULL) { in amdgpu_read_bios()
140 pci_unmap_rom(adev->pdev, bios); in amdgpu_read_bios()
143 adev->bios_size = size; in amdgpu_read_bios()
144 memcpy_fromio(adev->bios, bios, size); in amdgpu_read_bios()
145 pci_unmap_rom(adev->pdev, bios); in amdgpu_read_bios()
147 if (!check_atom_bios(adev->bios, size)) { in amdgpu_read_bios()
148 kfree(adev->bios); in amdgpu_read_bios()
155 static bool amdgpu_read_bios_from_rom(struct amdgpu_device *adev) in amdgpu_read_bios_from_rom() argument
160 if (!adev->asic_funcs || !adev->asic_funcs->read_bios_from_rom) in amdgpu_read_bios_from_rom()
164 if (amdgpu_asic_read_bios_from_rom(adev, &header[0], sizeof(header)) == false) in amdgpu_read_bios_from_rom()
177 adev->bios = kmalloc(len, GFP_KERNEL); in amdgpu_read_bios_from_rom()
178 if (!adev->bios) { in amdgpu_read_bios_from_rom()
182 adev->bios_size = len; in amdgpu_read_bios_from_rom()
185 amdgpu_asic_read_bios_from_rom(adev, adev->bios, len); in amdgpu_read_bios_from_rom()
187 if (!check_atom_bios(adev->bios, len)) { in amdgpu_read_bios_from_rom()
188 kfree(adev->bios); in amdgpu_read_bios_from_rom()
195 static bool amdgpu_read_platform_bios(struct amdgpu_device *adev) in amdgpu_read_platform_bios() argument
197 phys_addr_t rom = adev->pdev->rom; in amdgpu_read_platform_bios()
198 size_t romlen = adev->pdev->romlen; in amdgpu_read_platform_bios()
201 adev->bios = NULL; in amdgpu_read_platform_bios()
206 adev->bios = kzalloc(romlen, GFP_KERNEL); in amdgpu_read_platform_bios()
207 if (!adev->bios) in amdgpu_read_platform_bios()
214 memcpy_fromio(adev->bios, bios, romlen); in amdgpu_read_platform_bios()
217 if (!check_atom_bios(adev->bios, romlen)) in amdgpu_read_platform_bios()
220 adev->bios_size = romlen; in amdgpu_read_platform_bios()
224 kfree(adev->bios); in amdgpu_read_platform_bios()
276 static bool amdgpu_atrm_get_bios(struct amdgpu_device *adev) in amdgpu_atrm_get_bios() argument
287 if (adev->flags & AMD_IS_APU) in amdgpu_atrm_get_bios()
320 adev->bios = kmalloc(size, GFP_KERNEL); in amdgpu_atrm_get_bios()
321 if (!adev->bios) { in amdgpu_atrm_get_bios()
322 dev_err(adev->dev, "Unable to allocate bios\n"); in amdgpu_atrm_get_bios()
328 adev->bios, in amdgpu_atrm_get_bios()
335 if (!check_atom_bios(adev->bios, size)) { in amdgpu_atrm_get_bios()
336 kfree(adev->bios); in amdgpu_atrm_get_bios()
339 adev->bios_size = size; in amdgpu_atrm_get_bios()
343 static inline bool amdgpu_atrm_get_bios(struct amdgpu_device *adev) in amdgpu_atrm_get_bios() argument
349 static bool amdgpu_read_disabled_bios(struct amdgpu_device *adev) in amdgpu_read_disabled_bios() argument
351 if (adev->flags & AMD_IS_APU) in amdgpu_read_disabled_bios()
352 return igp_read_bios_from_vram(adev); in amdgpu_read_disabled_bios()
354 return (!adev->asic_funcs || !adev->asic_funcs->read_disabled_bios) ? in amdgpu_read_disabled_bios()
355 false : amdgpu_asic_read_disabled_bios(adev); in amdgpu_read_disabled_bios()
359 static bool amdgpu_acpi_vfct_bios(struct amdgpu_device *adev) in amdgpu_acpi_vfct_bios() argument
370 dev_info(adev->dev, "ACPI VFCT table present but broken (too short #1),skipping\n"); in amdgpu_acpi_vfct_bios()
383 dev_info(adev->dev, "ACPI VFCT image header truncated,skipping\n"); in amdgpu_acpi_vfct_bios()
389 dev_info(adev->dev, "ACPI VFCT image truncated,skipping\n"); in amdgpu_acpi_vfct_bios()
394 vhdr->PCIBus == adev->pdev->bus->number && in amdgpu_acpi_vfct_bios()
395 vhdr->PCIDevice == PCI_SLOT(adev->pdev->devfn) && in amdgpu_acpi_vfct_bios()
396 vhdr->PCIFunction == PCI_FUNC(adev->pdev->devfn) && in amdgpu_acpi_vfct_bios()
397 vhdr->VendorID == adev->pdev->vendor && in amdgpu_acpi_vfct_bios()
398 vhdr->DeviceID == adev->pdev->device) { in amdgpu_acpi_vfct_bios()
399 adev->bios = kmemdup(&vbios->VbiosContent, in amdgpu_acpi_vfct_bios()
403 if (!check_atom_bios(adev->bios, vhdr->ImageLength)) { in amdgpu_acpi_vfct_bios()
404 kfree(adev->bios); in amdgpu_acpi_vfct_bios()
407 adev->bios_size = vhdr->ImageLength; in amdgpu_acpi_vfct_bios()
412 dev_info(adev->dev, "ACPI VFCT table present but broken (too short #2),skipping\n"); in amdgpu_acpi_vfct_bios()
416 static inline bool amdgpu_acpi_vfct_bios(struct amdgpu_device *adev) in amdgpu_acpi_vfct_bios() argument
422 bool amdgpu_get_bios(struct amdgpu_device *adev) in amdgpu_get_bios() argument
424 if (amdgpu_atrm_get_bios(adev)) { in amdgpu_get_bios()
425 dev_info(adev->dev, "Fetched VBIOS from ATRM\n"); in amdgpu_get_bios()
429 if (amdgpu_acpi_vfct_bios(adev)) { in amdgpu_get_bios()
430 dev_info(adev->dev, "Fetched VBIOS from VFCT\n"); in amdgpu_get_bios()
434 if (igp_read_bios_from_vram(adev)) { in amdgpu_get_bios()
435 dev_info(adev->dev, "Fetched VBIOS from VRAM BAR\n"); in amdgpu_get_bios()
439 if (amdgpu_read_bios(adev)) { in amdgpu_get_bios()
440 dev_info(adev->dev, "Fetched VBIOS from ROM BAR\n"); in amdgpu_get_bios()
444 if (amdgpu_read_bios_from_rom(adev)) { in amdgpu_get_bios()
445 dev_info(adev->dev, "Fetched VBIOS from ROM\n"); in amdgpu_get_bios()
449 if (amdgpu_read_disabled_bios(adev)) { in amdgpu_get_bios()
450 dev_info(adev->dev, "Fetched VBIOS from disabled ROM BAR\n"); in amdgpu_get_bios()
454 if (amdgpu_read_platform_bios(adev)) { in amdgpu_get_bios()
455 dev_info(adev->dev, "Fetched VBIOS from platform\n"); in amdgpu_get_bios()
459 dev_err(adev->dev, "Unable to locate a BIOS ROM\n"); in amdgpu_get_bios()
463 adev->is_atom_fw = adev->asic_type >= CHIP_VEGA10; in amdgpu_get_bios()
468 bool amdgpu_soc15_read_bios_from_rom(struct amdgpu_device *adev, in amdgpu_soc15_read_bios_from_rom() argument
482 if (adev->flags & AMD_IS_APU) in amdgpu_soc15_read_bios_from_rom()
484 if (!adev->smuio.funcs || in amdgpu_soc15_read_bios_from_rom()
485 !adev->smuio.funcs->get_rom_index_offset || in amdgpu_soc15_read_bios_from_rom()
486 !adev->smuio.funcs->get_rom_data_offset) in amdgpu_soc15_read_bios_from_rom()
493 adev->smuio.funcs->get_rom_index_offset(adev); in amdgpu_soc15_read_bios_from_rom()
495 adev->smuio.funcs->get_rom_data_offset(adev); in amdgpu_soc15_read_bios_from_rom()
497 if (adev->nbio.funcs && in amdgpu_soc15_read_bios_from_rom()
498 adev->nbio.funcs->get_rom_offset) { in amdgpu_soc15_read_bios_from_rom()
499 rom_offset = adev->nbio.funcs->get_rom_offset(adev); in amdgpu_soc15_read_bios_from_rom()