mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-11-14 02:04:43 +00:00
Add function of init mircrocode for smu11. Signed-off-by: Likun Gao <Likun.Gao@amd.com> Reviewed-by: Huang Rui <ray.huang@amd.com> Acked-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
100 lines
3 KiB
C
100 lines
3 KiB
C
/*
|
|
* Copyright 2019 Advanced Micro Devices, Inc.
|
|
*
|
|
* 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.
|
|
*/
|
|
|
|
#include "pp_debug.h"
|
|
#include <linux/firmware.h>
|
|
#include "amdgpu.h"
|
|
#include "amdgpu_smu.h"
|
|
#include "smu_v11_0.h"
|
|
|
|
MODULE_FIRMWARE("amdgpu/vega20_smc.bin");
|
|
|
|
static int smu_v11_0_init_microcode(struct smu_context *smu)
|
|
{
|
|
struct amdgpu_device *adev = smu->adev;
|
|
const char *chip_name;
|
|
char fw_name[30];
|
|
int err = 0;
|
|
const struct smc_firmware_header_v1_0 *hdr;
|
|
const struct common_firmware_header *header;
|
|
struct amdgpu_firmware_info *ucode = NULL;
|
|
|
|
switch (adev->asic_type) {
|
|
case CHIP_VEGA20:
|
|
chip_name = "vega20";
|
|
break;
|
|
default:
|
|
BUG();
|
|
}
|
|
|
|
snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_smc.bin", chip_name);
|
|
|
|
err = request_firmware(&adev->pm.fw, fw_name, adev->dev);
|
|
if (err)
|
|
goto out;
|
|
err = amdgpu_ucode_validate(adev->pm.fw);
|
|
if (err)
|
|
goto out;
|
|
|
|
hdr = (const struct smc_firmware_header_v1_0 *) adev->pm.fw->data;
|
|
amdgpu_ucode_print_smc_hdr(&hdr->header);
|
|
adev->pm.fw_version = le32_to_cpu(hdr->header.ucode_version);
|
|
|
|
if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP) {
|
|
ucode = &adev->firmware.ucode[AMDGPU_UCODE_ID_SMC];
|
|
ucode->ucode_id = AMDGPU_UCODE_ID_SMC;
|
|
ucode->fw = adev->pm.fw;
|
|
header = (const struct common_firmware_header *)ucode->fw->data;
|
|
adev->firmware.fw_size +=
|
|
ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE);
|
|
}
|
|
|
|
out:
|
|
if (err) {
|
|
DRM_ERROR("smu_v11_0: Failed to load firmware \"%s\"\n",
|
|
fw_name);
|
|
release_firmware(adev->pm.fw);
|
|
adev->pm.fw = NULL;
|
|
}
|
|
return err;
|
|
}
|
|
|
|
static int smu_v11_0_load_microcode(struct smu_context *smu)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static int smu_v11_0_check_fw_status(struct smu_context *smu)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static const struct smu_funcs smu_v11_0_funcs = {
|
|
.init_microcode = smu_v11_0_init_microcode,
|
|
.load_microcode = smu_v11_0_load_microcode,
|
|
.check_fw_status = smu_v11_0_check_fw_status,
|
|
};
|
|
|
|
void smu_v11_0_set_smu_funcs(struct smu_context *smu)
|
|
{
|
|
smu->funcs = &smu_v11_0_funcs;
|
|
}
|