Lines Matching refs:adev

50 static bool check_atom_bios(struct amdgpu_device *adev, size_t size)  in check_atom_bios()  argument
53 uint8_t *bios = adev->bios; in check_atom_bios()
56 dev_dbg(adev->dev, "VBIOS mem is null or mem size is wrong\n"); in check_atom_bios()
61 dev_dbg(adev->dev, "VBIOS signature incorrect %x %x\n", bios[0], in check_atom_bios()
68 dev_dbg(adev->dev, "Can't locate VBIOS header\n"); in check_atom_bios()
74 dev_dbg(adev->dev, "VBIOS header is broken\n"); in check_atom_bios()
80 dev_dbg(adev->dev, "ATOMBIOS detected\n"); in check_atom_bios()
87 void amdgpu_bios_release(struct amdgpu_device *adev) in amdgpu_bios_release() argument
89 kfree(adev->bios); in amdgpu_bios_release()
90 adev->bios = NULL; in amdgpu_bios_release()
91 adev->bios_size = 0; in amdgpu_bios_release()
101 static bool amdgpu_read_bios_from_vram(struct amdgpu_device *adev) in amdgpu_read_bios_from_vram() argument
107 if (!(adev->flags & AMD_IS_APU)) in amdgpu_read_bios_from_vram()
108 if (amdgpu_device_need_post(adev)) in amdgpu_read_bios_from_vram()
112 if (pci_resource_len(adev->pdev, 0) == 0) in amdgpu_read_bios_from_vram()
115 adev->bios = NULL; in amdgpu_read_bios_from_vram()
116 vram_base = pci_resource_start(adev->pdev, 0); in amdgpu_read_bios_from_vram()
121 adev->bios = kmalloc(size, GFP_KERNEL); in amdgpu_read_bios_from_vram()
122 if (!adev->bios) { in amdgpu_read_bios_from_vram()
126 adev->bios_size = size; in amdgpu_read_bios_from_vram()
127 memcpy_fromio(adev->bios, bios, size); in amdgpu_read_bios_from_vram()
130 if (!check_atom_bios(adev, size)) { in amdgpu_read_bios_from_vram()
131 amdgpu_bios_release(adev); in amdgpu_read_bios_from_vram()
138 bool amdgpu_read_bios(struct amdgpu_device *adev) in amdgpu_read_bios() argument
143 adev->bios = NULL; in amdgpu_read_bios()
145 bios = pci_map_rom(adev->pdev, &size); in amdgpu_read_bios()
149 adev->bios = kzalloc(size, GFP_KERNEL); in amdgpu_read_bios()
150 if (adev->bios == NULL) { in amdgpu_read_bios()
151 pci_unmap_rom(adev->pdev, bios); in amdgpu_read_bios()
154 adev->bios_size = size; in amdgpu_read_bios()
155 memcpy_fromio(adev->bios, bios, size); in amdgpu_read_bios()
156 pci_unmap_rom(adev->pdev, bios); in amdgpu_read_bios()
158 if (!check_atom_bios(adev, size)) { in amdgpu_read_bios()
159 amdgpu_bios_release(adev); in amdgpu_read_bios()
166 static bool amdgpu_read_bios_from_rom(struct amdgpu_device *adev) in amdgpu_read_bios_from_rom() argument
171 if (!adev->asic_funcs || !adev->asic_funcs->read_bios_from_rom) in amdgpu_read_bios_from_rom()
175 if (amdgpu_asic_read_bios_from_rom(adev, &header[0], sizeof(header)) == false) in amdgpu_read_bios_from_rom()
188 adev->bios = kmalloc(len, GFP_KERNEL); in amdgpu_read_bios_from_rom()
189 if (!adev->bios) { in amdgpu_read_bios_from_rom()
193 adev->bios_size = len; in amdgpu_read_bios_from_rom()
196 amdgpu_asic_read_bios_from_rom(adev, adev->bios, len); in amdgpu_read_bios_from_rom()
198 if (!check_atom_bios(adev, len)) { in amdgpu_read_bios_from_rom()
199 amdgpu_bios_release(adev); in amdgpu_read_bios_from_rom()
206 static bool amdgpu_read_platform_bios(struct amdgpu_device *adev) in amdgpu_read_platform_bios() argument
208 phys_addr_t rom = adev->pdev->rom; in amdgpu_read_platform_bios()
209 size_t romlen = adev->pdev->romlen; in amdgpu_read_platform_bios()
212 adev->bios = NULL; in amdgpu_read_platform_bios()
217 adev->bios = kzalloc(romlen, GFP_KERNEL); in amdgpu_read_platform_bios()
218 if (!adev->bios) in amdgpu_read_platform_bios()
225 memcpy_fromio(adev->bios, bios, romlen); in amdgpu_read_platform_bios()
228 if (!check_atom_bios(adev, romlen)) in amdgpu_read_platform_bios()
231 adev->bios_size = romlen; in amdgpu_read_platform_bios()
235 amdgpu_bios_release(adev); in amdgpu_read_platform_bios()
288 static bool amdgpu_atrm_get_bios(struct amdgpu_device *adev) in amdgpu_atrm_get_bios() argument
299 if (dev_is_removable(&adev->pdev->dev)) in amdgpu_atrm_get_bios()
322 adev->bios = kmalloc(size, GFP_KERNEL); in amdgpu_atrm_get_bios()
323 if (!adev->bios) { in amdgpu_atrm_get_bios()
324 dev_err(adev->dev, "Unable to allocate bios\n"); in amdgpu_atrm_get_bios()
330 adev->bios, in amdgpu_atrm_get_bios()
337 if (!check_atom_bios(adev, size)) { in amdgpu_atrm_get_bios()
338 amdgpu_bios_release(adev); in amdgpu_atrm_get_bios()
341 adev->bios_size = size; in amdgpu_atrm_get_bios()
345 static inline bool amdgpu_atrm_get_bios(struct amdgpu_device *adev) in amdgpu_atrm_get_bios() argument
351 static bool amdgpu_read_disabled_bios(struct amdgpu_device *adev) in amdgpu_read_disabled_bios() argument
353 return (!adev->asic_funcs || !adev->asic_funcs->read_disabled_bios) ? in amdgpu_read_disabled_bios()
354 false : amdgpu_asic_read_disabled_bios(adev); in amdgpu_read_disabled_bios()
358 static bool amdgpu_acpi_vfct_bios(struct amdgpu_device *adev) in amdgpu_acpi_vfct_bios() argument
369 dev_info(adev->dev, "ACPI VFCT table present but broken (too short #1),skipping\n"); in amdgpu_acpi_vfct_bios()
382 dev_info(adev->dev, "ACPI VFCT image header truncated,skipping\n"); in amdgpu_acpi_vfct_bios()
388 dev_info(adev->dev, "ACPI VFCT image truncated,skipping\n"); in amdgpu_acpi_vfct_bios()
393 vhdr->PCIBus == adev->pdev->bus->number && in amdgpu_acpi_vfct_bios()
394 vhdr->PCIDevice == PCI_SLOT(adev->pdev->devfn) && in amdgpu_acpi_vfct_bios()
395 vhdr->PCIFunction == PCI_FUNC(adev->pdev->devfn) && in amdgpu_acpi_vfct_bios()
396 vhdr->VendorID == adev->pdev->vendor && in amdgpu_acpi_vfct_bios()
397 vhdr->DeviceID == adev->pdev->device) { in amdgpu_acpi_vfct_bios()
398 adev->bios = kmemdup(&vbios->VbiosContent, in amdgpu_acpi_vfct_bios()
402 if (!check_atom_bios(adev, vhdr->ImageLength)) { in amdgpu_acpi_vfct_bios()
403 amdgpu_bios_release(adev); in amdgpu_acpi_vfct_bios()
406 adev->bios_size = vhdr->ImageLength; in amdgpu_acpi_vfct_bios()
411 dev_info(adev->dev, "ACPI VFCT table present but broken (too short #2),skipping\n"); in amdgpu_acpi_vfct_bios()
415 static inline bool amdgpu_acpi_vfct_bios(struct amdgpu_device *adev) in amdgpu_acpi_vfct_bios() argument
421 static bool amdgpu_get_bios_apu(struct amdgpu_device *adev) in amdgpu_get_bios_apu() argument
423 if (amdgpu_acpi_vfct_bios(adev)) { in amdgpu_get_bios_apu()
424 dev_info(adev->dev, "Fetched VBIOS from VFCT\n"); in amdgpu_get_bios_apu()
428 if (amdgpu_read_bios_from_vram(adev)) { in amdgpu_get_bios_apu()
429 dev_info(adev->dev, "Fetched VBIOS from VRAM BAR\n"); in amdgpu_get_bios_apu()
433 if (amdgpu_read_bios(adev)) { in amdgpu_get_bios_apu()
434 dev_info(adev->dev, "Fetched VBIOS from ROM BAR\n"); in amdgpu_get_bios_apu()
438 if (amdgpu_read_platform_bios(adev)) { in amdgpu_get_bios_apu()
439 dev_info(adev->dev, "Fetched VBIOS from platform\n"); in amdgpu_get_bios_apu()
443 dev_err(adev->dev, "Unable to locate a BIOS ROM\n"); in amdgpu_get_bios_apu()
450 static bool amdgpu_prefer_rom_resource(struct amdgpu_device *adev) in amdgpu_prefer_rom_resource() argument
452 struct resource *res = &adev->pdev->resource[PCI_ROM_RESOURCE]; in amdgpu_prefer_rom_resource()
457 static bool amdgpu_get_bios_dgpu(struct amdgpu_device *adev) in amdgpu_get_bios_dgpu() argument
459 if (amdgpu_atrm_get_bios(adev)) { in amdgpu_get_bios_dgpu()
460 dev_info(adev->dev, "Fetched VBIOS from ATRM\n"); in amdgpu_get_bios_dgpu()
464 if (amdgpu_acpi_vfct_bios(adev)) { in amdgpu_get_bios_dgpu()
465 dev_info(adev->dev, "Fetched VBIOS from VFCT\n"); in amdgpu_get_bios_dgpu()
470 if (amdgpu_read_bios_from_vram(adev)) { in amdgpu_get_bios_dgpu()
471 dev_info(adev->dev, "Fetched VBIOS from VRAM BAR\n"); in amdgpu_get_bios_dgpu()
475 if (amdgpu_prefer_rom_resource(adev)) { in amdgpu_get_bios_dgpu()
476 if (amdgpu_read_bios(adev)) { in amdgpu_get_bios_dgpu()
477 dev_info(adev->dev, "Fetched VBIOS from ROM BAR\n"); in amdgpu_get_bios_dgpu()
481 if (amdgpu_read_platform_bios(adev)) { in amdgpu_get_bios_dgpu()
482 dev_info(adev->dev, "Fetched VBIOS from platform\n"); in amdgpu_get_bios_dgpu()
487 if (amdgpu_read_platform_bios(adev)) { in amdgpu_get_bios_dgpu()
488 dev_info(adev->dev, "Fetched VBIOS from platform\n"); in amdgpu_get_bios_dgpu()
492 if (amdgpu_read_bios(adev)) { in amdgpu_get_bios_dgpu()
493 dev_info(adev->dev, "Fetched VBIOS from ROM BAR\n"); in amdgpu_get_bios_dgpu()
498 if (amdgpu_read_bios_from_rom(adev)) { in amdgpu_get_bios_dgpu()
499 dev_info(adev->dev, "Fetched VBIOS from ROM\n"); in amdgpu_get_bios_dgpu()
503 if (amdgpu_read_disabled_bios(adev)) { in amdgpu_get_bios_dgpu()
504 dev_info(adev->dev, "Fetched VBIOS from disabled ROM BAR\n"); in amdgpu_get_bios_dgpu()
508 dev_err(adev->dev, "Unable to locate a BIOS ROM\n"); in amdgpu_get_bios_dgpu()
515 bool amdgpu_get_bios(struct amdgpu_device *adev) in amdgpu_get_bios() argument
519 if (adev->flags & AMD_IS_APU) in amdgpu_get_bios()
520 found = amdgpu_get_bios_apu(adev); in amdgpu_get_bios()
522 found = amdgpu_get_bios_dgpu(adev); in amdgpu_get_bios()
525 adev->is_atom_fw = adev->asic_type >= CHIP_VEGA10; in amdgpu_get_bios()
531 bool amdgpu_soc15_read_bios_from_rom(struct amdgpu_device *adev, in amdgpu_soc15_read_bios_from_rom() argument
545 if (adev->flags & AMD_IS_APU) in amdgpu_soc15_read_bios_from_rom()
547 if (!adev->smuio.funcs || in amdgpu_soc15_read_bios_from_rom()
548 !adev->smuio.funcs->get_rom_index_offset || in amdgpu_soc15_read_bios_from_rom()
549 !adev->smuio.funcs->get_rom_data_offset) in amdgpu_soc15_read_bios_from_rom()
556 adev->smuio.funcs->get_rom_index_offset(adev); in amdgpu_soc15_read_bios_from_rom()
558 adev->smuio.funcs->get_rom_data_offset(adev); in amdgpu_soc15_read_bios_from_rom()
560 if (adev->nbio.funcs && in amdgpu_soc15_read_bios_from_rom()
561 adev->nbio.funcs->get_rom_offset) { in amdgpu_soc15_read_bios_from_rom()
562 rom_offset = adev->nbio.funcs->get_rom_offset(adev); in amdgpu_soc15_read_bios_from_rom()