/* * Copyright 2008 Advanced Micro Devices, Inc. * Copyright 2008 Red Hat Inc. * Copyright 2009 Jerome Glisse. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. * * Authors: Dave Airlie * Alex Deucher * Jerome Glisse */ #include "amdgpu.h" #include "atom.h" #include <linux/device.h> #include <linux/pci.h> #include <linux/slab.h> #include <linux/acpi.h> /* * BIOS. */ #define AMD_VBIOS_SIGNATURE … #define AMD_VBIOS_SIGNATURE_OFFSET … #define AMD_VBIOS_SIGNATURE_SIZE … #define AMD_VBIOS_SIGNATURE_END … #define AMD_IS_VALID_VBIOS(p) … #define AMD_VBIOS_LENGTH(p) … /* Check if current bios is an ATOM BIOS. * Return true if it is ATOM BIOS. Otherwise, return false. */ static bool check_atom_bios(uint8_t *bios, size_t size) { … } /* If you boot an IGP board with a discrete card as the primary, * the IGP rom is not accessible via the rom bar as the IGP rom is * part of the system bios. On boot, the system bios puts a * copy of the igp rom at the start of vram if a discrete card is * present. */ static bool igp_read_bios_from_vram(struct amdgpu_device *adev) { … } bool amdgpu_read_bios(struct amdgpu_device *adev) { … } static bool amdgpu_read_bios_from_rom(struct amdgpu_device *adev) { … } static bool amdgpu_read_platform_bios(struct amdgpu_device *adev) { … } #ifdef CONFIG_ACPI /* ATRM is used to get the BIOS on the discrete cards in * dual-gpu systems. */ /* retrieve the ROM in 4k blocks */ #define ATRM_BIOS_PAGE … /** * amdgpu_atrm_call - fetch a chunk of the vbios * * @atrm_handle: acpi ATRM handle * @bios: vbios image pointer * @offset: offset of vbios image data to fetch * @len: length of vbios image data to fetch * * Executes ATRM to fetch a chunk of the discrete * vbios image on PX systems (all asics). * Returns the length of the buffer fetched. */ static int amdgpu_atrm_call(acpi_handle atrm_handle, uint8_t *bios, int offset, int len) { … } static bool amdgpu_atrm_get_bios(struct amdgpu_device *adev) { … } #else static inline bool amdgpu_atrm_get_bios(struct amdgpu_device *adev) { return false; } #endif static bool amdgpu_read_disabled_bios(struct amdgpu_device *adev) { … } #ifdef CONFIG_ACPI static bool amdgpu_acpi_vfct_bios(struct amdgpu_device *adev) { … } #else static inline bool amdgpu_acpi_vfct_bios(struct amdgpu_device *adev) { return false; } #endif bool amdgpu_get_bios(struct amdgpu_device *adev) { … } /* helper function for soc15 and onwards to read bios from rom */ bool amdgpu_soc15_read_bios_from_rom(struct amdgpu_device *adev, u8 *bios, u32 length_bytes) { … }