|
65 | 65 | #undef pr_info |
66 | 66 | #undef pr_debug |
67 | 67 |
|
| 68 | +MODULE_FIRMWARE("amdgpu/smu_13_0_6.bin"); |
| 69 | + |
68 | 70 | #define to_amdgpu_device(x) (container_of(x, struct amdgpu_device, pm.smu_i2c)) |
69 | 71 |
|
70 | 72 | #define SMU_13_0_6_FEA_MAP(smu_feature, smu_13_0_6_feature) \ |
@@ -123,6 +125,9 @@ struct mca_ras_info { |
123 | 125 | enum amdgpu_mca_error_type type, int idx, uint32_t *count); |
124 | 126 | }; |
125 | 127 |
|
| 128 | +#define P2S_TABLE_ID_A 0x50325341 |
| 129 | +#define P2S_TABLE_ID_X 0x50325358 |
| 130 | + |
126 | 131 | static const struct cmn2asic_msg_mapping smu_v13_0_6_message_map[SMU_MSG_MAX_COUNT] = { |
127 | 132 | MSG_MAP(TestMessage, PPSMC_MSG_TestMessage, 0), |
128 | 133 | MSG_MAP(GetSmuVersion, PPSMC_MSG_GetSmuVersion, 1), |
@@ -256,6 +261,70 @@ struct smu_v13_0_6_dpm_map { |
256 | 261 | uint32_t *freq_table; |
257 | 262 | }; |
258 | 263 |
|
| 264 | +static int smu_v13_0_6_init_microcode(struct smu_context *smu) |
| 265 | +{ |
| 266 | + const struct smc_firmware_header_v2_1 *v2_1; |
| 267 | + const struct common_firmware_header *hdr; |
| 268 | + struct amdgpu_firmware_info *ucode = NULL; |
| 269 | + struct smc_soft_pptable_entry *entries; |
| 270 | + struct amdgpu_device *adev = smu->adev; |
| 271 | + uint32_t p2s_table_id = P2S_TABLE_ID_A; |
| 272 | + int ret = 0, i, p2stable_count; |
| 273 | + char ucode_prefix[30]; |
| 274 | + char fw_name[30]; |
| 275 | + |
| 276 | + /* No need to load P2S tables in IOV mode */ |
| 277 | + if (amdgpu_sriov_vf(adev)) |
| 278 | + return 0; |
| 279 | + |
| 280 | + if (!(adev->flags & AMD_IS_APU)) |
| 281 | + p2s_table_id = P2S_TABLE_ID_X; |
| 282 | + |
| 283 | + amdgpu_ucode_ip_version_decode(adev, MP1_HWIP, ucode_prefix, |
| 284 | + sizeof(ucode_prefix)); |
| 285 | + |
| 286 | + snprintf(fw_name, sizeof(fw_name), "amdgpu/%s.bin", ucode_prefix); |
| 287 | + |
| 288 | + ret = amdgpu_ucode_request(adev, &adev->pm.fw, fw_name); |
| 289 | + if (ret) |
| 290 | + goto out; |
| 291 | + |
| 292 | + hdr = (const struct common_firmware_header *)adev->pm.fw->data; |
| 293 | + amdgpu_ucode_print_smc_hdr(hdr); |
| 294 | + |
| 295 | + /* SMU v13.0.6 binary file doesn't carry pptables, instead the entries |
| 296 | + * are used to carry p2s tables. |
| 297 | + */ |
| 298 | + v2_1 = (const struct smc_firmware_header_v2_1 *)adev->pm.fw->data; |
| 299 | + entries = (struct smc_soft_pptable_entry |
| 300 | + *)((uint8_t *)v2_1 + |
| 301 | + le32_to_cpu(v2_1->pptable_entry_offset)); |
| 302 | + p2stable_count = le32_to_cpu(v2_1->pptable_count); |
| 303 | + for (i = 0; i < p2stable_count; i++) { |
| 304 | + if (le32_to_cpu(entries[i].id) == p2s_table_id) { |
| 305 | + smu->pptable_firmware.data = |
| 306 | + ((uint8_t *)v2_1 + |
| 307 | + le32_to_cpu(entries[i].ppt_offset_bytes)); |
| 308 | + smu->pptable_firmware.size = |
| 309 | + le32_to_cpu(entries[i].ppt_size_bytes); |
| 310 | + break; |
| 311 | + } |
| 312 | + } |
| 313 | + |
| 314 | + if (smu->pptable_firmware.data && smu->pptable_firmware.size) { |
| 315 | + ucode = &adev->firmware.ucode[AMDGPU_UCODE_ID_P2S_TABLE]; |
| 316 | + ucode->ucode_id = AMDGPU_UCODE_ID_P2S_TABLE; |
| 317 | + ucode->fw = &smu->pptable_firmware; |
| 318 | + adev->firmware.fw_size += ALIGN(ucode->fw->size, PAGE_SIZE); |
| 319 | + } |
| 320 | + |
| 321 | + return 0; |
| 322 | +out: |
| 323 | + amdgpu_ucode_release(&adev->pm.fw); |
| 324 | + |
| 325 | + return ret; |
| 326 | +} |
| 327 | + |
259 | 328 | static int smu_v13_0_6_tables_init(struct smu_context *smu) |
260 | 329 | { |
261 | 330 | struct smu_table_context *smu_table = &smu->smu_table; |
@@ -2775,6 +2844,8 @@ static const struct pptable_funcs smu_v13_0_6_ppt_funcs = { |
2775 | 2844 | .get_power_limit = smu_v13_0_6_get_power_limit, |
2776 | 2845 | .is_dpm_running = smu_v13_0_6_is_dpm_running, |
2777 | 2846 | .get_unique_id = smu_v13_0_6_get_unique_id, |
| 2847 | + .init_microcode = smu_v13_0_6_init_microcode, |
| 2848 | + .fini_microcode = smu_v13_0_fini_microcode, |
2778 | 2849 | .init_smc_tables = smu_v13_0_6_init_smc_tables, |
2779 | 2850 | .fini_smc_tables = smu_v13_0_fini_smc_tables, |
2780 | 2851 | .init_power = smu_v13_0_init_power, |
|
0 commit comments