drm/amdgpu/psp: init/de-init xgmi ta microcode
authorHawking Zhang <Hawking.Zhang@amd.com>
Thu, 11 Oct 2018 13:48:00 +0000 (21:48 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 6 Nov 2018 19:02:40 +0000 (14:02 -0500)
Add ucode handling for psp xgmi ta firmware.

Signed-off-by: Hawking Zhang <Hawking.Zhang@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h
drivers/gpu/drm/amd/amdgpu/psp_v11_0.c

index a18a8c9..b00592d 100644 (file)
@@ -90,6 +90,8 @@ static int psp_sw_fini(void *handle)
        adev->psp.sos_fw = NULL;
        release_firmware(adev->psp.asd_fw);
        adev->psp.asd_fw = NULL;
+       release_firmware(adev->psp.ta_fw);
+       adev->psp.ta_fw = NULL;
        return 0;
 }
 
index aa6641b..7ac25a1 100644 (file)
@@ -57,6 +57,17 @@ struct psp_firmware_header_v1_0 {
        uint32_t sos_size_bytes;
 };
 
+/* version_major=1, version_minor=0 */
+struct ta_firmware_header_v1_0 {
+       struct common_firmware_header header;
+       uint32_t ta_xgmi_ucode_version;
+       uint32_t ta_xgmi_offset_bytes;
+       uint32_t ta_xgmi_size_bytes;
+       uint32_t ta_ras_ucode_version;
+       uint32_t ta_ras_offset_bytes;
+       uint32_t ta_ras_size_bytes;
+};
+
 /* version_major=1, version_minor=0 */
 struct gfx_firmware_header_v1_0 {
        struct common_firmware_header header;
@@ -170,6 +181,7 @@ union amdgpu_firmware_header {
        struct mc_firmware_header_v1_0 mc;
        struct smc_firmware_header_v1_0 smc;
        struct psp_firmware_header_v1_0 psp;
+       struct ta_firmware_header_v1_0 ta;
        struct gfx_firmware_header_v1_0 gfx;
        struct rlc_firmware_header_v1_0 rlc;
        struct rlc_firmware_header_v2_0 rlc_v2_0;
index 2372f42..902b0e6 100644 (file)
@@ -34,6 +34,7 @@
 #include "nbio/nbio_7_4_offset.h"
 
 MODULE_FIRMWARE("amdgpu/vega20_sos.bin");
+MODULE_FIRMWARE("amdgpu/vega20_ta.bin");
 
 /* address block */
 #define smnMP1_FIRMWARE_FLAGS          0x3010024
@@ -98,7 +99,8 @@ static int psp_v11_0_init_microcode(struct psp_context *psp)
        const char *chip_name;
        char fw_name[30];
        int err = 0;
-       const struct psp_firmware_header_v1_0 *hdr;
+       const struct psp_firmware_header_v1_0 *sos_hdr;
+       const struct ta_firmware_header_v1_0 *ta_hdr;
 
        DRM_DEBUG("\n");
 
@@ -119,16 +121,32 @@ static int psp_v11_0_init_microcode(struct psp_context *psp)
        if (err)
                goto out;
 
-       hdr = (const struct psp_firmware_header_v1_0 *)adev->psp.sos_fw->data;
-       adev->psp.sos_fw_version = le32_to_cpu(hdr->header.ucode_version);
-       adev->psp.sos_feature_version = le32_to_cpu(hdr->ucode_feature_version);
-       adev->psp.sos_bin_size = le32_to_cpu(hdr->sos_size_bytes);
-       adev->psp.sys_bin_size = le32_to_cpu(hdr->header.ucode_size_bytes) -
-                                       le32_to_cpu(hdr->sos_size_bytes);
-       adev->psp.sys_start_addr = (uint8_t *)hdr +
-                               le32_to_cpu(hdr->header.ucode_array_offset_bytes);
+       sos_hdr = (const struct psp_firmware_header_v1_0 *)adev->psp.sos_fw->data;
+       adev->psp.sos_fw_version = le32_to_cpu(sos_hdr->header.ucode_version);
+       adev->psp.sos_feature_version = le32_to_cpu(sos_hdr->ucode_feature_version);
+       adev->psp.sos_bin_size = le32_to_cpu(sos_hdr->sos_size_bytes);
+       adev->psp.sys_bin_size = le32_to_cpu(sos_hdr->header.ucode_size_bytes) -
+                                       le32_to_cpu(sos_hdr->sos_size_bytes);
+       adev->psp.sys_start_addr = (uint8_t *)sos_hdr +
+                               le32_to_cpu(sos_hdr->header.ucode_array_offset_bytes);
        adev->psp.sos_start_addr = (uint8_t *)adev->psp.sys_start_addr +
-                               le32_to_cpu(hdr->sos_offset_bytes);
+                               le32_to_cpu(sos_hdr->sos_offset_bytes);
+
+       snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_ta.bin", chip_name);
+       err = request_firmware(&adev->psp.ta_fw, fw_name, adev->dev);
+       if (err)
+               goto out;
+
+       err = amdgpu_ucode_validate(adev->psp.ta_fw);
+       if (err)
+               goto out;
+
+       ta_hdr = (const struct ta_firmware_header_v1_0 *)adev->psp.ta_fw->data;
+       adev->psp.ta_xgmi_ucode_version = le32_to_cpu(ta_hdr->ta_xgmi_ucode_version);
+       adev->psp.ta_xgmi_ucode_size = le32_to_cpu(ta_hdr->ta_xgmi_size_bytes);
+       adev->psp.ta_xgmi_start_addr = (uint8_t *)ta_hdr +
+               le32_to_cpu(ta_hdr->header.ucode_array_offset_bytes);
+
        return 0;
 out:
        if (err) {