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()
111 adev->bios = kmalloc(size, GFP_KERNEL); in igp_read_bios_from_vram()
112 if (!adev->bios) { in igp_read_bios_from_vram()
116 adev->bios_size = size; in igp_read_bios_from_vram()
117 memcpy_fromio(adev->bios, bios, size); in igp_read_bios_from_vram()
120 if (!check_atom_bios(adev->bios, size)) { in igp_read_bios_from_vram()
121 kfree(adev->bios); in igp_read_bios_from_vram()
128 bool amdgpu_read_bios(struct amdgpu_device *adev) in amdgpu_read_bios() argument
133 adev->bios = NULL; in amdgpu_read_bios()
135 bios = pci_map_rom(adev->pdev, &size); in amdgpu_read_bios()
140 adev->bios = kzalloc(size, GFP_KERNEL); in amdgpu_read_bios()
141 if (adev->bios == NULL) { in amdgpu_read_bios()
142 pci_unmap_rom(adev->pdev, bios); in amdgpu_read_bios()
145 adev->bios_size = size; in amdgpu_read_bios()
146 memcpy_fromio(adev->bios, bios, size); in amdgpu_read_bios()
147 pci_unmap_rom(adev->pdev, bios); in amdgpu_read_bios()
149 if (!check_atom_bios(adev->bios, size)) { in amdgpu_read_bios()
150 kfree(adev->bios); in amdgpu_read_bios()
157 static bool amdgpu_read_bios_from_rom(struct amdgpu_device *adev) in amdgpu_read_bios_from_rom() argument
162 if (!adev->asic_funcs || !adev->asic_funcs->read_bios_from_rom) in amdgpu_read_bios_from_rom()
166 if (amdgpu_asic_read_bios_from_rom(adev, &header[0], sizeof(header)) == false) in amdgpu_read_bios_from_rom()
179 adev->bios = kmalloc(len, GFP_KERNEL); in amdgpu_read_bios_from_rom()
180 if (!adev->bios) { in amdgpu_read_bios_from_rom()
184 adev->bios_size = len; in amdgpu_read_bios_from_rom()
187 amdgpu_asic_read_bios_from_rom(adev, adev->bios, len); in amdgpu_read_bios_from_rom()
189 if (!check_atom_bios(adev->bios, len)) { in amdgpu_read_bios_from_rom()
190 kfree(adev->bios); in amdgpu_read_bios_from_rom()
197 static bool amdgpu_read_platform_bios(struct amdgpu_device *adev) in amdgpu_read_platform_bios() argument
199 phys_addr_t rom = adev->pdev->rom; in amdgpu_read_platform_bios()
200 size_t romlen = adev->pdev->romlen; in amdgpu_read_platform_bios()
203 adev->bios = NULL; in amdgpu_read_platform_bios()
208 adev->bios = kzalloc(romlen, GFP_KERNEL); in amdgpu_read_platform_bios()
209 if (!adev->bios) in amdgpu_read_platform_bios()
216 memcpy_fromio(adev->bios, bios, romlen); in amdgpu_read_platform_bios()
219 if (!check_atom_bios(adev->bios, romlen)) in amdgpu_read_platform_bios()
222 adev->bios_size = romlen; in amdgpu_read_platform_bios()
226 kfree(adev->bios); in amdgpu_read_platform_bios()
278 static bool amdgpu_atrm_get_bios(struct amdgpu_device *adev) in amdgpu_atrm_get_bios() argument
289 if (adev->flags & AMD_IS_APU) 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->bios, size)) { in amdgpu_atrm_get_bios()
338 kfree(adev->bios); 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 if (adev->flags & AMD_IS_APU) in amdgpu_read_disabled_bios()
354 return igp_read_bios_from_vram(adev); in amdgpu_read_disabled_bios()
356 return (!adev->asic_funcs || !adev->asic_funcs->read_disabled_bios) ? in amdgpu_read_disabled_bios()
357 false : amdgpu_asic_read_disabled_bios(adev); in amdgpu_read_disabled_bios()
361 static bool amdgpu_acpi_vfct_bios(struct amdgpu_device *adev) in amdgpu_acpi_vfct_bios() argument
372 dev_info(adev->dev, "ACPI VFCT table present but broken (too short #1),skipping\n"); in amdgpu_acpi_vfct_bios()
385 dev_info(adev->dev, "ACPI VFCT image header truncated,skipping\n"); in amdgpu_acpi_vfct_bios()
391 dev_info(adev->dev, "ACPI VFCT image truncated,skipping\n"); in amdgpu_acpi_vfct_bios()
396 vhdr->PCIBus == adev->pdev->bus->number && in amdgpu_acpi_vfct_bios()
397 vhdr->PCIDevice == PCI_SLOT(adev->pdev->devfn) && in amdgpu_acpi_vfct_bios()
398 vhdr->PCIFunction == PCI_FUNC(adev->pdev->devfn) && in amdgpu_acpi_vfct_bios()
399 vhdr->VendorID == adev->pdev->vendor && in amdgpu_acpi_vfct_bios()
400 vhdr->DeviceID == adev->pdev->device) { in amdgpu_acpi_vfct_bios()
401 adev->bios = kmemdup(&vbios->VbiosContent, in amdgpu_acpi_vfct_bios()
405 if (!check_atom_bios(adev->bios, vhdr->ImageLength)) { in amdgpu_acpi_vfct_bios()
406 kfree(adev->bios); in amdgpu_acpi_vfct_bios()
409 adev->bios_size = vhdr->ImageLength; in amdgpu_acpi_vfct_bios()
414 dev_info(adev->dev, "ACPI VFCT table present but broken (too short #2),skipping\n"); in amdgpu_acpi_vfct_bios()
418 static inline bool amdgpu_acpi_vfct_bios(struct amdgpu_device *adev) in amdgpu_acpi_vfct_bios() argument
424 bool amdgpu_get_bios(struct amdgpu_device *adev) in amdgpu_get_bios() argument
426 if (amdgpu_atrm_get_bios(adev)) { in amdgpu_get_bios()
427 dev_info(adev->dev, "Fetched VBIOS from ATRM\n"); in amdgpu_get_bios()
431 if (amdgpu_acpi_vfct_bios(adev)) { in amdgpu_get_bios()
432 dev_info(adev->dev, "Fetched VBIOS from VFCT\n"); in amdgpu_get_bios()
436 if (igp_read_bios_from_vram(adev)) { in amdgpu_get_bios()
437 dev_info(adev->dev, "Fetched VBIOS from VRAM BAR\n"); in amdgpu_get_bios()
441 if (amdgpu_read_bios(adev)) { in amdgpu_get_bios()
442 dev_info(adev->dev, "Fetched VBIOS from ROM BAR\n"); in amdgpu_get_bios()
446 if (amdgpu_read_bios_from_rom(adev)) { in amdgpu_get_bios()
447 dev_info(adev->dev, "Fetched VBIOS from ROM\n"); in amdgpu_get_bios()
451 if (amdgpu_read_disabled_bios(adev)) { in amdgpu_get_bios()
452 dev_info(adev->dev, "Fetched VBIOS from disabled ROM BAR\n"); in amdgpu_get_bios()
456 if (amdgpu_read_platform_bios(adev)) { in amdgpu_get_bios()
457 dev_info(adev->dev, "Fetched VBIOS from platform\n"); in amdgpu_get_bios()
461 dev_err(adev->dev, "Unable to locate a BIOS ROM\n"); in amdgpu_get_bios()
465 adev->is_atom_fw = (adev->asic_type >= CHIP_VEGA10) ? true : false; in amdgpu_get_bios()
470 bool amdgpu_soc15_read_bios_from_rom(struct amdgpu_device *adev, in amdgpu_soc15_read_bios_from_rom() argument
484 if (adev->flags & AMD_IS_APU) in amdgpu_soc15_read_bios_from_rom()
486 if (!adev->smuio.funcs || in amdgpu_soc15_read_bios_from_rom()
487 !adev->smuio.funcs->get_rom_index_offset || in amdgpu_soc15_read_bios_from_rom()
488 !adev->smuio.funcs->get_rom_data_offset) in amdgpu_soc15_read_bios_from_rom()
495 adev->smuio.funcs->get_rom_index_offset(adev); in amdgpu_soc15_read_bios_from_rom()
497 adev->smuio.funcs->get_rom_data_offset(adev); in amdgpu_soc15_read_bios_from_rom()
499 if (adev->nbio.funcs && in amdgpu_soc15_read_bios_from_rom()
500 adev->nbio.funcs->get_rom_offset) { in amdgpu_soc15_read_bios_from_rom()
501 rom_offset = adev->nbio.funcs->get_rom_offset(adev); in amdgpu_soc15_read_bios_from_rom()