Commit f4503f9e authored by Hawking Zhang's avatar Hawking Zhang Committed by Alex Deucher

drm/amdgpu: switch to helper function to init asd ucode

call common helper function to initialize asd ucode
Signed-off-by: default avatarHawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: default avatarGuchun Chen <guchun.chen@amd.com>
Reviewed-by: default avatarJohn Clements <john.clements@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent dc7195f6
...@@ -50,7 +50,6 @@ static int psp_v10_0_init_microcode(struct psp_context *psp) ...@@ -50,7 +50,6 @@ static int psp_v10_0_init_microcode(struct psp_context *psp)
const char *chip_name; const char *chip_name;
char fw_name[30]; char fw_name[30];
int err = 0; int err = 0;
const struct psp_firmware_header_v1_0 *hdr;
const struct ta_firmware_header_v1_0 *ta_hdr; const struct ta_firmware_header_v1_0 *ta_hdr;
DRM_DEBUG("\n"); DRM_DEBUG("\n");
...@@ -66,22 +65,10 @@ static int psp_v10_0_init_microcode(struct psp_context *psp) ...@@ -66,22 +65,10 @@ static int psp_v10_0_init_microcode(struct psp_context *psp)
default: BUG(); default: BUG();
} }
snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_asd.bin", chip_name); err = psp_init_asd_microcode(psp, chip_name);
err = request_firmware(&adev->psp.asd_fw, fw_name, adev->dev);
if (err) if (err)
goto out; goto out;
err = amdgpu_ucode_validate(adev->psp.asd_fw);
if (err)
goto out;
hdr = (const struct psp_firmware_header_v1_0 *)adev->psp.asd_fw->data;
adev->psp.asd_fw_version = le32_to_cpu(hdr->header.ucode_version);
adev->psp.asd_feature_version = le32_to_cpu(hdr->ucode_feature_version);
adev->psp.asd_ucode_size = le32_to_cpu(hdr->header.ucode_size_bytes);
adev->psp.asd_start_addr = (uint8_t *)hdr +
le32_to_cpu(hdr->header.ucode_array_offset_bytes);
snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_ta.bin", chip_name); snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_ta.bin", chip_name);
err = request_firmware(&adev->psp.ta_fw, fw_name, adev->dev); err = request_firmware(&adev->psp.ta_fw, fw_name, adev->dev);
if (err) { if (err) {
...@@ -126,8 +113,6 @@ static int psp_v10_0_init_microcode(struct psp_context *psp) ...@@ -126,8 +113,6 @@ static int psp_v10_0_init_microcode(struct psp_context *psp)
dev_err(adev->dev, dev_err(adev->dev,
"psp v10.0: Failed to load firmware \"%s\"\n", "psp v10.0: Failed to load firmware \"%s\"\n",
fw_name); fw_name);
release_firmware(adev->psp.asd_fw);
adev->psp.asd_fw = NULL;
} }
return err; return err;
......
...@@ -78,7 +78,6 @@ static int psp_v11_0_init_microcode(struct psp_context *psp) ...@@ -78,7 +78,6 @@ static int psp_v11_0_init_microcode(struct psp_context *psp)
const struct psp_firmware_header_v1_0 *sos_hdr; const struct psp_firmware_header_v1_0 *sos_hdr;
const struct psp_firmware_header_v1_1 *sos_hdr_v1_1; const struct psp_firmware_header_v1_1 *sos_hdr_v1_1;
const struct psp_firmware_header_v1_2 *sos_hdr_v1_2; const struct psp_firmware_header_v1_2 *sos_hdr_v1_2;
const struct psp_firmware_header_v1_0 *asd_hdr;
const struct ta_firmware_header_v1_0 *ta_hdr; const struct ta_firmware_header_v1_0 *ta_hdr;
DRM_DEBUG("\n"); DRM_DEBUG("\n");
...@@ -148,21 +147,9 @@ static int psp_v11_0_init_microcode(struct psp_context *psp) ...@@ -148,21 +147,9 @@ static int psp_v11_0_init_microcode(struct psp_context *psp)
goto out; goto out;
} }
snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_asd.bin", chip_name); err = psp_init_asd_microcode(psp, chip_name);
err = request_firmware(&adev->psp.asd_fw, fw_name, adev->dev);
if (err) if (err)
goto out1; goto out;
err = amdgpu_ucode_validate(adev->psp.asd_fw);
if (err)
goto out1;
asd_hdr = (const struct psp_firmware_header_v1_0 *)adev->psp.asd_fw->data;
adev->psp.asd_fw_version = le32_to_cpu(asd_hdr->header.ucode_version);
adev->psp.asd_feature_version = le32_to_cpu(asd_hdr->ucode_feature_version);
adev->psp.asd_ucode_size = le32_to_cpu(asd_hdr->header.ucode_size_bytes);
adev->psp.asd_start_addr = (uint8_t *)asd_hdr +
le32_to_cpu(asd_hdr->header.ucode_array_offset_bytes);
switch (adev->asic_type) { switch (adev->asic_type) {
case CHIP_VEGA20: case CHIP_VEGA20:
...@@ -229,9 +216,6 @@ static int psp_v11_0_init_microcode(struct psp_context *psp) ...@@ -229,9 +216,6 @@ static int psp_v11_0_init_microcode(struct psp_context *psp)
out2: out2:
release_firmware(adev->psp.ta_fw); release_firmware(adev->psp.ta_fw);
adev->psp.ta_fw = NULL; adev->psp.ta_fw = NULL;
out1:
release_firmware(adev->psp.asd_fw);
adev->psp.asd_fw = NULL;
out: out:
dev_err(adev->dev, dev_err(adev->dev,
"psp v11.0: Failed to load firmware \"%s\"\n", fw_name); "psp v11.0: Failed to load firmware \"%s\"\n", fw_name);
......
...@@ -45,11 +45,7 @@ static int psp_v12_0_init_microcode(struct psp_context *psp) ...@@ -45,11 +45,7 @@ static int psp_v12_0_init_microcode(struct psp_context *psp)
{ {
struct amdgpu_device *adev = psp->adev; struct amdgpu_device *adev = psp->adev;
const char *chip_name; const char *chip_name;
char fw_name[30];
int err = 0; int err = 0;
const struct psp_firmware_header_v1_0 *asd_hdr;
DRM_DEBUG("\n");
switch (adev->asic_type) { switch (adev->asic_type) {
case CHIP_RENOIR: case CHIP_RENOIR:
...@@ -59,28 +55,7 @@ static int psp_v12_0_init_microcode(struct psp_context *psp) ...@@ -59,28 +55,7 @@ static int psp_v12_0_init_microcode(struct psp_context *psp)
BUG(); BUG();
} }
snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_asd.bin", chip_name); err = psp_init_asd_microcode(psp, chip_name);
err = request_firmware(&adev->psp.asd_fw, fw_name, adev->dev);
if (err)
goto out1;
err = amdgpu_ucode_validate(adev->psp.asd_fw);
if (err)
goto out1;
asd_hdr = (const struct psp_firmware_header_v1_0 *)adev->psp.asd_fw->data;
adev->psp.asd_fw_version = le32_to_cpu(asd_hdr->header.ucode_version);
adev->psp.asd_feature_version = le32_to_cpu(asd_hdr->ucode_feature_version);
adev->psp.asd_ucode_size = le32_to_cpu(asd_hdr->header.ucode_size_bytes);
adev->psp.asd_start_addr = (uint8_t *)asd_hdr +
le32_to_cpu(asd_hdr->header.ucode_array_offset_bytes);
return 0;
out1:
release_firmware(adev->psp.asd_fw);
adev->psp.asd_fw = NULL;
return err; return err;
} }
......
...@@ -95,22 +95,10 @@ static int psp_v3_1_init_microcode(struct psp_context *psp) ...@@ -95,22 +95,10 @@ static int psp_v3_1_init_microcode(struct psp_context *psp)
adev->psp.sos_start_addr = (uint8_t *)adev->psp.sys_start_addr + adev->psp.sos_start_addr = (uint8_t *)adev->psp.sys_start_addr +
le32_to_cpu(hdr->sos_offset_bytes); le32_to_cpu(hdr->sos_offset_bytes);
snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_asd.bin", chip_name); err = psp_init_asd_microcode(psp, chip_name);
err = request_firmware(&adev->psp.asd_fw, fw_name, adev->dev);
if (err) if (err)
goto out; goto out;
err = amdgpu_ucode_validate(adev->psp.asd_fw);
if (err)
goto out;
hdr = (const struct psp_firmware_header_v1_0 *)adev->psp.asd_fw->data;
adev->psp.asd_fw_version = le32_to_cpu(hdr->header.ucode_version);
adev->psp.asd_feature_version = le32_to_cpu(hdr->ucode_feature_version);
adev->psp.asd_ucode_size = le32_to_cpu(hdr->header.ucode_size_bytes);
adev->psp.asd_start_addr = (uint8_t *)hdr +
le32_to_cpu(hdr->header.ucode_array_offset_bytes);
return 0; return 0;
out: out:
if (err) { if (err) {
...@@ -119,8 +107,6 @@ static int psp_v3_1_init_microcode(struct psp_context *psp) ...@@ -119,8 +107,6 @@ static int psp_v3_1_init_microcode(struct psp_context *psp)
fw_name); fw_name);
release_firmware(adev->psp.sos_fw); release_firmware(adev->psp.sos_fw);
adev->psp.sos_fw = NULL; adev->psp.sos_fw = NULL;
release_firmware(adev->psp.asd_fw);
adev->psp.asd_fw = NULL;
} }
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment