2 * Copyright 2019 Advanced Micro Devices, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
25 #include <linux/firmware.h>
27 #include "amdgpu_smu.h"
28 #include "smu_internal.h"
29 #include "atomfirmware.h"
30 #include "amdgpu_atomfirmware.h"
31 #include "smu_v11_0.h"
32 #include "smu11_driver_if_arcturus.h"
33 #include "soc15_common.h"
35 #include "power_state.h"
36 #include "arcturus_ppt.h"
37 #include "smu_v11_0_pptable.h"
38 #include "arcturus_ppsmc.h"
39 #include "nbio/nbio_7_4_sh_mask.h"
40 #include "amdgpu_xgmi.h"
41 #include <linux/i2c.h>
42 #include <linux/pci.h>
43 #include "amdgpu_ras.h"
45 #define to_amdgpu_device(x) (container_of(x, struct amdgpu_ras, eeprom_control.eeprom_accessor))->adev
47 #define CTF_OFFSET_EDGE 5
48 #define CTF_OFFSET_HOTSPOT 5
49 #define CTF_OFFSET_HBM 5
51 #define MSG_MAP(msg, index) \
52 [SMU_MSG_##msg] = {1, (index)}
53 #define ARCTURUS_FEA_MAP(smu_feature, arcturus_feature) \
54 [smu_feature] = {1, (arcturus_feature)}
56 #define SMU_FEATURES_LOW_MASK 0x00000000FFFFFFFF
57 #define SMU_FEATURES_LOW_SHIFT 0
58 #define SMU_FEATURES_HIGH_MASK 0xFFFFFFFF00000000
59 #define SMU_FEATURES_HIGH_SHIFT 32
61 #define SMC_DPM_FEATURE ( \
62 FEATURE_DPM_PREFETCHER_MASK | \
63 FEATURE_DPM_GFXCLK_MASK | \
64 FEATURE_DPM_UCLK_MASK | \
65 FEATURE_DPM_SOCCLK_MASK | \
66 FEATURE_DPM_MP0CLK_MASK | \
67 FEATURE_DPM_FCLK_MASK | \
68 FEATURE_DPM_XGMI_MASK)
70 /* possible frequency drift (1Mhz) */
73 static struct smu_11_0_cmn2aisc_mapping arcturus_message_map[SMU_MSG_MAX_COUNT] = {
74 MSG_MAP(TestMessage, PPSMC_MSG_TestMessage),
75 MSG_MAP(GetSmuVersion, PPSMC_MSG_GetSmuVersion),
76 MSG_MAP(GetDriverIfVersion, PPSMC_MSG_GetDriverIfVersion),
77 MSG_MAP(SetAllowedFeaturesMaskLow, PPSMC_MSG_SetAllowedFeaturesMaskLow),
78 MSG_MAP(SetAllowedFeaturesMaskHigh, PPSMC_MSG_SetAllowedFeaturesMaskHigh),
79 MSG_MAP(EnableAllSmuFeatures, PPSMC_MSG_EnableAllSmuFeatures),
80 MSG_MAP(DisableAllSmuFeatures, PPSMC_MSG_DisableAllSmuFeatures),
81 MSG_MAP(EnableSmuFeaturesLow, PPSMC_MSG_EnableSmuFeaturesLow),
82 MSG_MAP(EnableSmuFeaturesHigh, PPSMC_MSG_EnableSmuFeaturesHigh),
83 MSG_MAP(DisableSmuFeaturesLow, PPSMC_MSG_DisableSmuFeaturesLow),
84 MSG_MAP(DisableSmuFeaturesHigh, PPSMC_MSG_DisableSmuFeaturesHigh),
85 MSG_MAP(GetEnabledSmuFeaturesLow, PPSMC_MSG_GetEnabledSmuFeaturesLow),
86 MSG_MAP(GetEnabledSmuFeaturesHigh, PPSMC_MSG_GetEnabledSmuFeaturesHigh),
87 MSG_MAP(SetDriverDramAddrHigh, PPSMC_MSG_SetDriverDramAddrHigh),
88 MSG_MAP(SetDriverDramAddrLow, PPSMC_MSG_SetDriverDramAddrLow),
89 MSG_MAP(SetToolsDramAddrHigh, PPSMC_MSG_SetToolsDramAddrHigh),
90 MSG_MAP(SetToolsDramAddrLow, PPSMC_MSG_SetToolsDramAddrLow),
91 MSG_MAP(TransferTableSmu2Dram, PPSMC_MSG_TransferTableSmu2Dram),
92 MSG_MAP(TransferTableDram2Smu, PPSMC_MSG_TransferTableDram2Smu),
93 MSG_MAP(UseDefaultPPTable, PPSMC_MSG_UseDefaultPPTable),
94 MSG_MAP(UseBackupPPTable, PPSMC_MSG_UseBackupPPTable),
95 MSG_MAP(SetSystemVirtualDramAddrHigh, PPSMC_MSG_SetSystemVirtualDramAddrHigh),
96 MSG_MAP(SetSystemVirtualDramAddrLow, PPSMC_MSG_SetSystemVirtualDramAddrLow),
97 MSG_MAP(EnterBaco, PPSMC_MSG_EnterBaco),
98 MSG_MAP(ExitBaco, PPSMC_MSG_ExitBaco),
99 MSG_MAP(ArmD3, PPSMC_MSG_ArmD3),
100 MSG_MAP(SetSoftMinByFreq, PPSMC_MSG_SetSoftMinByFreq),
101 MSG_MAP(SetSoftMaxByFreq, PPSMC_MSG_SetSoftMaxByFreq),
102 MSG_MAP(SetHardMinByFreq, PPSMC_MSG_SetHardMinByFreq),
103 MSG_MAP(SetHardMaxByFreq, PPSMC_MSG_SetHardMaxByFreq),
104 MSG_MAP(GetMinDpmFreq, PPSMC_MSG_GetMinDpmFreq),
105 MSG_MAP(GetMaxDpmFreq, PPSMC_MSG_GetMaxDpmFreq),
106 MSG_MAP(GetDpmFreqByIndex, PPSMC_MSG_GetDpmFreqByIndex),
107 MSG_MAP(SetWorkloadMask, PPSMC_MSG_SetWorkloadMask),
108 MSG_MAP(SetDfSwitchType, PPSMC_MSG_SetDfSwitchType),
109 MSG_MAP(GetVoltageByDpm, PPSMC_MSG_GetVoltageByDpm),
110 MSG_MAP(GetVoltageByDpmOverdrive, PPSMC_MSG_GetVoltageByDpmOverdrive),
111 MSG_MAP(SetPptLimit, PPSMC_MSG_SetPptLimit),
112 MSG_MAP(GetPptLimit, PPSMC_MSG_GetPptLimit),
113 MSG_MAP(PowerUpVcn0, PPSMC_MSG_PowerUpVcn0),
114 MSG_MAP(PowerDownVcn0, PPSMC_MSG_PowerDownVcn0),
115 MSG_MAP(PowerUpVcn1, PPSMC_MSG_PowerUpVcn1),
116 MSG_MAP(PowerDownVcn1, PPSMC_MSG_PowerDownVcn1),
117 MSG_MAP(PrepareMp1ForUnload, PPSMC_MSG_PrepareMp1ForUnload),
118 MSG_MAP(PrepareMp1ForReset, PPSMC_MSG_PrepareMp1ForReset),
119 MSG_MAP(PrepareMp1ForShutdown, PPSMC_MSG_PrepareMp1ForShutdown),
120 MSG_MAP(SoftReset, PPSMC_MSG_SoftReset),
121 MSG_MAP(RunAfllBtc, PPSMC_MSG_RunAfllBtc),
122 MSG_MAP(RunDcBtc, PPSMC_MSG_RunDcBtc),
123 MSG_MAP(DramLogSetDramAddrHigh, PPSMC_MSG_DramLogSetDramAddrHigh),
124 MSG_MAP(DramLogSetDramAddrLow, PPSMC_MSG_DramLogSetDramAddrLow),
125 MSG_MAP(DramLogSetDramSize, PPSMC_MSG_DramLogSetDramSize),
126 MSG_MAP(GetDebugData, PPSMC_MSG_GetDebugData),
127 MSG_MAP(WaflTest, PPSMC_MSG_WaflTest),
128 MSG_MAP(SetXgmiMode, PPSMC_MSG_SetXgmiMode),
129 MSG_MAP(SetMemoryChannelEnable, PPSMC_MSG_SetMemoryChannelEnable),
132 static struct smu_11_0_cmn2aisc_mapping arcturus_clk_map[SMU_CLK_COUNT] = {
133 CLK_MAP(GFXCLK, PPCLK_GFXCLK),
134 CLK_MAP(SCLK, PPCLK_GFXCLK),
135 CLK_MAP(SOCCLK, PPCLK_SOCCLK),
136 CLK_MAP(FCLK, PPCLK_FCLK),
137 CLK_MAP(UCLK, PPCLK_UCLK),
138 CLK_MAP(MCLK, PPCLK_UCLK),
139 CLK_MAP(DCLK, PPCLK_DCLK),
140 CLK_MAP(VCLK, PPCLK_VCLK),
143 static struct smu_11_0_cmn2aisc_mapping arcturus_feature_mask_map[SMU_FEATURE_COUNT] = {
144 FEA_MAP(DPM_PREFETCHER),
150 ARCTURUS_FEA_MAP(SMU_FEATURE_XGMI_BIT, FEATURE_DPM_XGMI_BIT),
157 ARCTURUS_FEA_MAP(SMU_FEATURE_VCN_PG_BIT, FEATURE_DPM_VCN_BIT),
158 FEA_MAP(RSMU_SMN_CG),
166 FEA_MAP(FAN_CONTROL),
168 FEA_MAP(OUT_OF_BAND_MONITOR),
169 FEA_MAP(TEMP_DEPENDENT_VMIN),
172 static struct smu_11_0_cmn2aisc_mapping arcturus_table_map[SMU_TABLE_COUNT] = {
175 TAB_MAP(AVFS_PSM_DEBUG),
176 TAB_MAP(AVFS_FUSE_OVERRIDE),
177 TAB_MAP(PMSTATUSLOG),
178 TAB_MAP(SMU_METRICS),
179 TAB_MAP(DRIVER_SMU_CONFIG),
181 TAB_MAP(I2C_COMMANDS),
184 static struct smu_11_0_cmn2aisc_mapping arcturus_pwr_src_map[SMU_POWER_SOURCE_COUNT] = {
189 static struct smu_11_0_cmn2aisc_mapping arcturus_workload_map[PP_SMC_POWER_PROFILE_COUNT] = {
190 WORKLOAD_MAP(PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT, WORKLOAD_PPLIB_DEFAULT_BIT),
191 WORKLOAD_MAP(PP_SMC_POWER_PROFILE_POWERSAVING, WORKLOAD_PPLIB_POWER_SAVING_BIT),
192 WORKLOAD_MAP(PP_SMC_POWER_PROFILE_VIDEO, WORKLOAD_PPLIB_VIDEO_BIT),
193 WORKLOAD_MAP(PP_SMC_POWER_PROFILE_COMPUTE, WORKLOAD_PPLIB_COMPUTE_BIT),
194 WORKLOAD_MAP(PP_SMC_POWER_PROFILE_CUSTOM, WORKLOAD_PPLIB_CUSTOM_BIT),
197 static int arcturus_get_smu_msg_index(struct smu_context *smc, uint32_t index)
199 struct smu_11_0_cmn2aisc_mapping mapping;
201 if (index >= SMU_MSG_MAX_COUNT)
204 mapping = arcturus_message_map[index];
205 if (!(mapping.valid_mapping))
208 return mapping.map_to;
211 static int arcturus_get_smu_clk_index(struct smu_context *smc, uint32_t index)
213 struct smu_11_0_cmn2aisc_mapping mapping;
215 if (index >= SMU_CLK_COUNT)
218 mapping = arcturus_clk_map[index];
219 if (!(mapping.valid_mapping)) {
220 pr_warn("Unsupported SMU clk: %d\n", index);
224 return mapping.map_to;
227 static int arcturus_get_smu_feature_index(struct smu_context *smc, uint32_t index)
229 struct smu_11_0_cmn2aisc_mapping mapping;
231 if (index >= SMU_FEATURE_COUNT)
234 mapping = arcturus_feature_mask_map[index];
235 if (!(mapping.valid_mapping)) {
239 return mapping.map_to;
242 static int arcturus_get_smu_table_index(struct smu_context *smc, uint32_t index)
244 struct smu_11_0_cmn2aisc_mapping mapping;
246 if (index >= SMU_TABLE_COUNT)
249 mapping = arcturus_table_map[index];
250 if (!(mapping.valid_mapping)) {
251 pr_warn("Unsupported SMU table: %d\n", index);
255 return mapping.map_to;
258 static int arcturus_get_pwr_src_index(struct smu_context *smc, uint32_t index)
260 struct smu_11_0_cmn2aisc_mapping mapping;
262 if (index >= SMU_POWER_SOURCE_COUNT)
265 mapping = arcturus_pwr_src_map[index];
266 if (!(mapping.valid_mapping)) {
267 pr_warn("Unsupported SMU power source: %d\n", index);
271 return mapping.map_to;
275 static int arcturus_get_workload_type(struct smu_context *smu, enum PP_SMC_POWER_PROFILE profile)
277 struct smu_11_0_cmn2aisc_mapping mapping;
279 if (profile > PP_SMC_POWER_PROFILE_CUSTOM)
282 mapping = arcturus_workload_map[profile];
283 if (!(mapping.valid_mapping)) {
284 pr_warn("Unsupported SMU power source: %d\n", profile);
288 return mapping.map_to;
291 static int arcturus_tables_init(struct smu_context *smu, struct smu_table *tables)
293 struct smu_table_context *smu_table = &smu->smu_table;
295 SMU_TABLE_INIT(tables, SMU_TABLE_PPTABLE, sizeof(PPTable_t),
296 PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM);
298 SMU_TABLE_INIT(tables, SMU_TABLE_PMSTATUSLOG, SMU11_TOOL_SIZE,
299 PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM);
301 SMU_TABLE_INIT(tables, SMU_TABLE_SMU_METRICS, sizeof(SmuMetrics_t),
302 PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM);
304 SMU_TABLE_INIT(tables, SMU_TABLE_I2C_COMMANDS, sizeof(SwI2cRequest_t),
305 PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM);
307 smu_table->metrics_table = kzalloc(sizeof(SmuMetrics_t), GFP_KERNEL);
308 if (!smu_table->metrics_table)
310 smu_table->metrics_time = 0;
315 static int arcturus_allocate_dpm_context(struct smu_context *smu)
317 struct smu_dpm_context *smu_dpm = &smu->smu_dpm;
319 if (smu_dpm->dpm_context)
322 smu_dpm->dpm_context = kzalloc(sizeof(struct arcturus_dpm_table),
324 if (!smu_dpm->dpm_context)
327 if (smu_dpm->golden_dpm_context)
330 smu_dpm->golden_dpm_context = kzalloc(sizeof(struct arcturus_dpm_table),
332 if (!smu_dpm->golden_dpm_context)
335 smu_dpm->dpm_context_size = sizeof(struct arcturus_dpm_table);
337 smu_dpm->dpm_current_power_state = kzalloc(sizeof(struct smu_power_state),
339 if (!smu_dpm->dpm_current_power_state)
342 smu_dpm->dpm_request_power_state = kzalloc(sizeof(struct smu_power_state),
344 if (!smu_dpm->dpm_request_power_state)
351 arcturus_get_allowed_feature_mask(struct smu_context *smu,
352 uint32_t *feature_mask, uint32_t num)
357 /* pptable will handle the features to enable */
358 memset(feature_mask, 0xFF, sizeof(uint32_t) * num);
364 arcturus_set_single_dpm_table(struct smu_context *smu,
365 struct arcturus_single_dpm_table *single_dpm_table,
369 uint32_t i, num_of_levels = 0, clk;
371 ret = smu_send_smc_msg_with_param(smu,
372 SMU_MSG_GetDpmFreqByIndex,
373 (clk_id << 16 | 0xFF));
375 pr_err("[%s] failed to get dpm levels!\n", __func__);
379 smu_read_smc_arg(smu, &num_of_levels);
380 if (!num_of_levels) {
381 pr_err("[%s] number of clk levels is invalid!\n", __func__);
385 single_dpm_table->count = num_of_levels;
386 for (i = 0; i < num_of_levels; i++) {
387 ret = smu_send_smc_msg_with_param(smu,
388 SMU_MSG_GetDpmFreqByIndex,
391 pr_err("[%s] failed to get dpm freq by index!\n", __func__);
394 smu_read_smc_arg(smu, &clk);
396 pr_err("[%s] clk value is invalid!\n", __func__);
399 single_dpm_table->dpm_levels[i].value = clk;
400 single_dpm_table->dpm_levels[i].enabled = true;
405 static void arcturus_init_single_dpm_state(struct arcturus_dpm_state *dpm_state)
407 dpm_state->soft_min_level = 0x0;
408 dpm_state->soft_max_level = 0xffff;
409 dpm_state->hard_min_level = 0x0;
410 dpm_state->hard_max_level = 0xffff;
413 static int arcturus_set_default_dpm_table(struct smu_context *smu)
417 struct smu_dpm_context *smu_dpm = &smu->smu_dpm;
418 struct arcturus_dpm_table *dpm_table = NULL;
419 struct arcturus_single_dpm_table *single_dpm_table;
421 dpm_table = smu_dpm->dpm_context;
424 single_dpm_table = &(dpm_table->soc_table);
425 if (smu_feature_is_enabled(smu, SMU_FEATURE_DPM_SOCCLK_BIT)) {
426 ret = arcturus_set_single_dpm_table(smu, single_dpm_table,
429 pr_err("[%s] failed to get socclk dpm levels!\n", __func__);
433 single_dpm_table->count = 1;
434 single_dpm_table->dpm_levels[0].value = smu->smu_table.boot_values.socclk / 100;
436 arcturus_init_single_dpm_state(&(single_dpm_table->dpm_state));
439 single_dpm_table = &(dpm_table->gfx_table);
440 if (smu_feature_is_enabled(smu, SMU_FEATURE_DPM_GFXCLK_BIT)) {
441 ret = arcturus_set_single_dpm_table(smu, single_dpm_table,
444 pr_err("[SetupDefaultDpmTable] failed to get gfxclk dpm levels!");
448 single_dpm_table->count = 1;
449 single_dpm_table->dpm_levels[0].value = smu->smu_table.boot_values.gfxclk / 100;
451 arcturus_init_single_dpm_state(&(single_dpm_table->dpm_state));
454 single_dpm_table = &(dpm_table->mem_table);
455 if (smu_feature_is_enabled(smu, SMU_FEATURE_DPM_UCLK_BIT)) {
456 ret = arcturus_set_single_dpm_table(smu, single_dpm_table,
459 pr_err("[SetupDefaultDpmTable] failed to get memclk dpm levels!");
463 single_dpm_table->count = 1;
464 single_dpm_table->dpm_levels[0].value = smu->smu_table.boot_values.uclk / 100;
466 arcturus_init_single_dpm_state(&(single_dpm_table->dpm_state));
469 single_dpm_table = &(dpm_table->fclk_table);
470 if (smu_feature_is_enabled(smu, SMU_FEATURE_DPM_FCLK_BIT)) {
471 ret = arcturus_set_single_dpm_table(smu, single_dpm_table,
474 pr_err("[SetupDefaultDpmTable] failed to get fclk dpm levels!");
478 single_dpm_table->count = 1;
479 single_dpm_table->dpm_levels[0].value = smu->smu_table.boot_values.fclk / 100;
481 arcturus_init_single_dpm_state(&(single_dpm_table->dpm_state));
483 memcpy(smu_dpm->golden_dpm_context, dpm_table,
484 sizeof(struct arcturus_dpm_table));
489 static int arcturus_check_powerplay_table(struct smu_context *smu)
494 static int arcturus_store_powerplay_table(struct smu_context *smu)
496 struct smu_11_0_powerplay_table *powerplay_table = NULL;
497 struct smu_table_context *table_context = &smu->smu_table;
500 if (!table_context->power_play_table)
503 powerplay_table = table_context->power_play_table;
505 memcpy(table_context->driver_pptable, &powerplay_table->smc_pptable,
508 table_context->thermal_controller_type = powerplay_table->thermal_controller_type;
513 static int arcturus_append_powerplay_table(struct smu_context *smu)
515 struct smu_table_context *table_context = &smu->smu_table;
516 PPTable_t *smc_pptable = table_context->driver_pptable;
517 struct atom_smc_dpm_info_v4_6 *smc_dpm_table;
520 index = get_index_into_master_table(atom_master_list_of_data_tables_v2_1,
523 ret = smu_get_atom_data_table(smu, index, NULL, NULL, NULL,
524 (uint8_t **)&smc_dpm_table);
528 pr_info("smc_dpm_info table revision(format.content): %d.%d\n",
529 smc_dpm_table->table_header.format_revision,
530 smc_dpm_table->table_header.content_revision);
532 if ((smc_dpm_table->table_header.format_revision == 4) &&
533 (smc_dpm_table->table_header.content_revision == 6))
534 memcpy(&smc_pptable->MaxVoltageStepGfx,
535 &smc_dpm_table->maxvoltagestepgfx,
536 sizeof(*smc_dpm_table) - offsetof(struct atom_smc_dpm_info_v4_6, maxvoltagestepgfx));
541 static int arcturus_run_btc(struct smu_context *smu)
545 ret = smu_send_smc_msg(smu, SMU_MSG_RunAfllBtc);
547 pr_err("RunAfllBtc failed!\n");
551 return smu_send_smc_msg(smu, SMU_MSG_RunDcBtc);
554 static int arcturus_populate_umd_state_clk(struct smu_context *smu)
556 struct smu_dpm_context *smu_dpm = &smu->smu_dpm;
557 struct arcturus_dpm_table *dpm_table = NULL;
558 struct arcturus_single_dpm_table *gfx_table = NULL;
559 struct arcturus_single_dpm_table *mem_table = NULL;
561 dpm_table = smu_dpm->dpm_context;
562 gfx_table = &(dpm_table->gfx_table);
563 mem_table = &(dpm_table->mem_table);
565 smu->pstate_sclk = gfx_table->dpm_levels[0].value;
566 smu->pstate_mclk = mem_table->dpm_levels[0].value;
568 if (gfx_table->count > ARCTURUS_UMD_PSTATE_GFXCLK_LEVEL &&
569 mem_table->count > ARCTURUS_UMD_PSTATE_MCLK_LEVEL) {
570 smu->pstate_sclk = gfx_table->dpm_levels[ARCTURUS_UMD_PSTATE_GFXCLK_LEVEL].value;
571 smu->pstate_mclk = mem_table->dpm_levels[ARCTURUS_UMD_PSTATE_MCLK_LEVEL].value;
574 smu->pstate_sclk = smu->pstate_sclk * 100;
575 smu->pstate_mclk = smu->pstate_mclk * 100;
580 static int arcturus_get_clk_table(struct smu_context *smu,
581 struct pp_clock_levels_with_latency *clocks,
582 struct arcturus_single_dpm_table *dpm_table)
586 count = (dpm_table->count > MAX_NUM_CLOCKS) ? MAX_NUM_CLOCKS : dpm_table->count;
587 clocks->num_levels = count;
589 for (i = 0; i < count; i++) {
590 clocks->data[i].clocks_in_khz =
591 dpm_table->dpm_levels[i].value * 1000;
592 clocks->data[i].latency_in_us = 0;
598 static int arcturus_freqs_in_same_level(int32_t frequency1,
601 return (abs(frequency1 - frequency2) <= EPSILON);
604 static int arcturus_print_clk_levels(struct smu_context *smu,
605 enum smu_clk_type type, char *buf)
607 int i, now, size = 0;
609 struct pp_clock_levels_with_latency clocks;
610 struct arcturus_single_dpm_table *single_dpm_table;
611 struct smu_dpm_context *smu_dpm = &smu->smu_dpm;
612 struct arcturus_dpm_table *dpm_table = NULL;
614 dpm_table = smu_dpm->dpm_context;
618 ret = smu_get_current_clk_freq(smu, SMU_GFXCLK, &now);
620 pr_err("Attempt to get current gfx clk Failed!");
624 single_dpm_table = &(dpm_table->gfx_table);
625 ret = arcturus_get_clk_table(smu, &clocks, single_dpm_table);
627 pr_err("Attempt to get gfx clk levels Failed!");
632 * For DPM disabled case, there will be only one clock level.
633 * And it's safe to assume that is always the current clock.
635 for (i = 0; i < clocks.num_levels; i++)
636 size += sprintf(buf + size, "%d: %uMhz %s\n", i,
637 clocks.data[i].clocks_in_khz / 1000,
638 (clocks.num_levels == 1) ? "*" :
639 (arcturus_freqs_in_same_level(
640 clocks.data[i].clocks_in_khz / 1000,
641 now / 100) ? "*" : ""));
645 ret = smu_get_current_clk_freq(smu, SMU_UCLK, &now);
647 pr_err("Attempt to get current mclk Failed!");
651 single_dpm_table = &(dpm_table->mem_table);
652 ret = arcturus_get_clk_table(smu, &clocks, single_dpm_table);
654 pr_err("Attempt to get memory clk levels Failed!");
658 for (i = 0; i < clocks.num_levels; i++)
659 size += sprintf(buf + size, "%d: %uMhz %s\n",
660 i, clocks.data[i].clocks_in_khz / 1000,
661 (clocks.num_levels == 1) ? "*" :
662 (arcturus_freqs_in_same_level(
663 clocks.data[i].clocks_in_khz / 1000,
664 now / 100) ? "*" : ""));
668 ret = smu_get_current_clk_freq(smu, SMU_SOCCLK, &now);
670 pr_err("Attempt to get current socclk Failed!");
674 single_dpm_table = &(dpm_table->soc_table);
675 ret = arcturus_get_clk_table(smu, &clocks, single_dpm_table);
677 pr_err("Attempt to get socclk levels Failed!");
681 for (i = 0; i < clocks.num_levels; i++)
682 size += sprintf(buf + size, "%d: %uMhz %s\n",
683 i, clocks.data[i].clocks_in_khz / 1000,
684 (clocks.num_levels == 1) ? "*" :
685 (arcturus_freqs_in_same_level(
686 clocks.data[i].clocks_in_khz / 1000,
687 now / 100) ? "*" : ""));
691 ret = smu_get_current_clk_freq(smu, SMU_FCLK, &now);
693 pr_err("Attempt to get current fclk Failed!");
697 single_dpm_table = &(dpm_table->fclk_table);
698 ret = arcturus_get_clk_table(smu, &clocks, single_dpm_table);
700 pr_err("Attempt to get fclk levels Failed!");
704 for (i = 0; i < single_dpm_table->count; i++)
705 size += sprintf(buf + size, "%d: %uMhz %s\n",
706 i, single_dpm_table->dpm_levels[i].value,
707 (clocks.num_levels == 1) ? "*" :
708 (arcturus_freqs_in_same_level(
709 clocks.data[i].clocks_in_khz / 1000,
710 now / 100) ? "*" : ""));
720 static int arcturus_upload_dpm_level(struct smu_context *smu, bool max,
721 uint32_t feature_mask)
723 struct arcturus_single_dpm_table *single_dpm_table;
724 struct arcturus_dpm_table *dpm_table =
725 smu->smu_dpm.dpm_context;
729 if (smu_feature_is_enabled(smu, SMU_FEATURE_DPM_GFXCLK_BIT) &&
730 (feature_mask & FEATURE_DPM_GFXCLK_MASK)) {
731 single_dpm_table = &(dpm_table->gfx_table);
732 freq = max ? single_dpm_table->dpm_state.soft_max_level :
733 single_dpm_table->dpm_state.soft_min_level;
734 ret = smu_send_smc_msg_with_param(smu,
735 (max ? SMU_MSG_SetSoftMaxByFreq : SMU_MSG_SetSoftMinByFreq),
736 (PPCLK_GFXCLK << 16) | (freq & 0xffff));
738 pr_err("Failed to set soft %s gfxclk !\n",
739 max ? "max" : "min");
744 if (smu_feature_is_enabled(smu, SMU_FEATURE_DPM_UCLK_BIT) &&
745 (feature_mask & FEATURE_DPM_UCLK_MASK)) {
746 single_dpm_table = &(dpm_table->mem_table);
747 freq = max ? single_dpm_table->dpm_state.soft_max_level :
748 single_dpm_table->dpm_state.soft_min_level;
749 ret = smu_send_smc_msg_with_param(smu,
750 (max ? SMU_MSG_SetSoftMaxByFreq : SMU_MSG_SetSoftMinByFreq),
751 (PPCLK_UCLK << 16) | (freq & 0xffff));
753 pr_err("Failed to set soft %s memclk !\n",
754 max ? "max" : "min");
759 if (smu_feature_is_enabled(smu, SMU_FEATURE_DPM_SOCCLK_BIT) &&
760 (feature_mask & FEATURE_DPM_SOCCLK_MASK)) {
761 single_dpm_table = &(dpm_table->soc_table);
762 freq = max ? single_dpm_table->dpm_state.soft_max_level :
763 single_dpm_table->dpm_state.soft_min_level;
764 ret = smu_send_smc_msg_with_param(smu,
765 (max ? SMU_MSG_SetSoftMaxByFreq : SMU_MSG_SetSoftMinByFreq),
766 (PPCLK_SOCCLK << 16) | (freq & 0xffff));
768 pr_err("Failed to set soft %s socclk !\n",
769 max ? "max" : "min");
777 static int arcturus_force_clk_levels(struct smu_context *smu,
778 enum smu_clk_type type, uint32_t mask)
780 struct arcturus_dpm_table *dpm_table;
781 struct arcturus_single_dpm_table *single_dpm_table;
782 uint32_t soft_min_level, soft_max_level;
785 soft_min_level = mask ? (ffs(mask) - 1) : 0;
786 soft_max_level = mask ? (fls(mask) - 1) : 0;
788 dpm_table = smu->smu_dpm.dpm_context;
792 single_dpm_table = &(dpm_table->gfx_table);
794 if (soft_max_level >= single_dpm_table->count) {
795 pr_err("Clock level specified %d is over max allowed %d\n",
796 soft_max_level, single_dpm_table->count - 1);
801 single_dpm_table->dpm_state.soft_min_level =
802 single_dpm_table->dpm_levels[soft_min_level].value;
803 single_dpm_table->dpm_state.soft_max_level =
804 single_dpm_table->dpm_levels[soft_max_level].value;
806 ret = arcturus_upload_dpm_level(smu, false, FEATURE_DPM_GFXCLK_MASK);
808 pr_err("Failed to upload boot level to lowest!\n");
812 ret = arcturus_upload_dpm_level(smu, true, FEATURE_DPM_GFXCLK_MASK);
814 pr_err("Failed to upload dpm max level to highest!\n");
822 * Should not arrive here since Arcturus does not
823 * support mclk/socclk/fclk softmin/softmax settings
835 static int arcturus_get_thermal_temperature_range(struct smu_context *smu,
836 struct smu_temperature_range *range)
838 PPTable_t *pptable = smu->smu_table.driver_pptable;
843 range->max = pptable->TedgeLimit *
844 SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;
845 range->edge_emergency_max = (pptable->TedgeLimit + CTF_OFFSET_EDGE) *
846 SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;
847 range->hotspot_crit_max = pptable->ThotspotLimit *
848 SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;
849 range->hotspot_emergency_max = (pptable->ThotspotLimit + CTF_OFFSET_HOTSPOT) *
850 SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;
851 range->mem_crit_max = pptable->TmemLimit *
852 SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;
853 range->mem_emergency_max = (pptable->TmemLimit + CTF_OFFSET_HBM)*
854 SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;
859 static int arcturus_get_metrics_table(struct smu_context *smu,
860 SmuMetrics_t *metrics_table)
862 struct smu_table_context *smu_table= &smu->smu_table;
865 mutex_lock(&smu->metrics_lock);
866 if (!smu_table->metrics_time ||
867 time_after(jiffies, smu_table->metrics_time + HZ / 1000)) {
868 ret = smu_update_table(smu, SMU_TABLE_SMU_METRICS, 0,
869 (void *)smu_table->metrics_table, false);
871 pr_info("Failed to export SMU metrics table!\n");
872 mutex_unlock(&smu->metrics_lock);
875 smu_table->metrics_time = jiffies;
878 memcpy(metrics_table, smu_table->metrics_table, sizeof(SmuMetrics_t));
879 mutex_unlock(&smu->metrics_lock);
884 static int arcturus_get_current_activity_percent(struct smu_context *smu,
885 enum amd_pp_sensors sensor,
888 SmuMetrics_t metrics;
894 ret = arcturus_get_metrics_table(smu, &metrics);
899 case AMDGPU_PP_SENSOR_GPU_LOAD:
900 *value = metrics.AverageGfxActivity;
902 case AMDGPU_PP_SENSOR_MEM_LOAD:
903 *value = metrics.AverageUclkActivity;
906 pr_err("Invalid sensor for retrieving clock activity\n");
913 static int arcturus_get_gpu_power(struct smu_context *smu, uint32_t *value)
915 SmuMetrics_t metrics;
921 ret = arcturus_get_metrics_table(smu, &metrics);
925 *value = metrics.AverageSocketPower << 8;
930 static int arcturus_thermal_get_temperature(struct smu_context *smu,
931 enum amd_pp_sensors sensor,
934 SmuMetrics_t metrics;
940 ret = arcturus_get_metrics_table(smu, &metrics);
945 case AMDGPU_PP_SENSOR_HOTSPOT_TEMP:
946 *value = metrics.TemperatureHotspot *
947 SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;
949 case AMDGPU_PP_SENSOR_EDGE_TEMP:
950 *value = metrics.TemperatureEdge *
951 SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;
953 case AMDGPU_PP_SENSOR_MEM_TEMP:
954 *value = metrics.TemperatureHBM *
955 SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;
958 pr_err("Invalid sensor for retrieving temp\n");
965 static int arcturus_read_sensor(struct smu_context *smu,
966 enum amd_pp_sensors sensor,
967 void *data, uint32_t *size)
969 struct smu_table_context *table_context = &smu->smu_table;
970 PPTable_t *pptable = table_context->driver_pptable;
976 mutex_lock(&smu->sensor_lock);
978 case AMDGPU_PP_SENSOR_MAX_FAN_RPM:
979 *(uint32_t *)data = pptable->FanMaximumRpm;
982 case AMDGPU_PP_SENSOR_MEM_LOAD:
983 case AMDGPU_PP_SENSOR_GPU_LOAD:
984 ret = arcturus_get_current_activity_percent(smu,
989 case AMDGPU_PP_SENSOR_GPU_POWER:
990 ret = arcturus_get_gpu_power(smu, (uint32_t *)data);
993 case AMDGPU_PP_SENSOR_HOTSPOT_TEMP:
994 case AMDGPU_PP_SENSOR_EDGE_TEMP:
995 case AMDGPU_PP_SENSOR_MEM_TEMP:
996 ret = arcturus_thermal_get_temperature(smu, sensor,
1001 ret = smu_v11_0_read_sensor(smu, sensor, data, size);
1003 mutex_unlock(&smu->sensor_lock);
1008 static int arcturus_get_fan_speed_rpm(struct smu_context *smu,
1011 SmuMetrics_t metrics;
1017 ret = arcturus_get_metrics_table(smu, &metrics);
1021 *speed = metrics.CurrFanSpeed;
1026 static int arcturus_get_fan_speed_percent(struct smu_context *smu,
1029 PPTable_t *pptable = smu->smu_table.driver_pptable;
1030 uint32_t percent, current_rpm;
1036 ret = arcturus_get_fan_speed_rpm(smu, ¤t_rpm);
1040 percent = current_rpm * 100 / pptable->FanMaximumRpm;
1041 *speed = percent > 100 ? 100 : percent;
1046 static int arcturus_get_current_clk_freq_by_table(struct smu_context *smu,
1047 enum smu_clk_type clk_type,
1050 static SmuMetrics_t metrics;
1051 int ret = 0, clk_id = 0;
1056 clk_id = smu_clk_get_index(smu, clk_type);
1060 ret = arcturus_get_metrics_table(smu, &metrics);
1067 * CurrClock[clk_id] can provide accurate
1068 * output only when the dpm feature is enabled.
1069 * We can use Average_* for dpm disabled case.
1070 * But this is available for gfxclk/uclk/socclk.
1072 if (smu_feature_is_enabled(smu, SMU_FEATURE_DPM_GFXCLK_BIT))
1073 *value = metrics.CurrClock[PPCLK_GFXCLK];
1075 *value = metrics.AverageGfxclkFrequency;
1078 if (smu_feature_is_enabled(smu, SMU_FEATURE_DPM_UCLK_BIT))
1079 *value = metrics.CurrClock[PPCLK_UCLK];
1081 *value = metrics.AverageUclkFrequency;
1084 if (smu_feature_is_enabled(smu, SMU_FEATURE_DPM_SOCCLK_BIT))
1085 *value = metrics.CurrClock[PPCLK_SOCCLK];
1087 *value = metrics.AverageSocclkFrequency;
1090 *value = metrics.CurrClock[clk_id];
1097 static uint32_t arcturus_find_lowest_dpm_level(struct arcturus_single_dpm_table *table)
1101 for (i = 0; i < table->count; i++) {
1102 if (table->dpm_levels[i].enabled)
1105 if (i >= table->count) {
1107 table->dpm_levels[i].enabled = true;
1113 static uint32_t arcturus_find_highest_dpm_level(struct arcturus_single_dpm_table *table)
1117 if (table->count <= 0) {
1118 pr_err("[%s] DPM Table has no entry!", __func__);
1121 if (table->count > MAX_DPM_NUMBER) {
1122 pr_err("[%s] DPM Table has too many entries!", __func__);
1123 return MAX_DPM_NUMBER - 1;
1126 for (i = table->count - 1; i >= 0; i--) {
1127 if (table->dpm_levels[i].enabled)
1132 table->dpm_levels[i].enabled = true;
1140 static int arcturus_force_dpm_limit_value(struct smu_context *smu, bool highest)
1142 struct arcturus_dpm_table *dpm_table =
1143 (struct arcturus_dpm_table *)smu->smu_dpm.dpm_context;
1144 struct amdgpu_hive_info *hive = amdgpu_get_xgmi_hive(smu->adev, 0);
1145 uint32_t soft_level;
1150 soft_level = arcturus_find_highest_dpm_level(&(dpm_table->gfx_table));
1152 soft_level = arcturus_find_lowest_dpm_level(&(dpm_table->gfx_table));
1154 dpm_table->gfx_table.dpm_state.soft_min_level =
1155 dpm_table->gfx_table.dpm_state.soft_max_level =
1156 dpm_table->gfx_table.dpm_levels[soft_level].value;
1158 ret = arcturus_upload_dpm_level(smu, false, FEATURE_DPM_GFXCLK_MASK);
1160 pr_err("Failed to upload boot level to %s!\n",
1161 highest ? "highest" : "lowest");
1165 ret = arcturus_upload_dpm_level(smu, true, FEATURE_DPM_GFXCLK_MASK);
1167 pr_err("Failed to upload dpm max level to %s!\n!",
1168 highest ? "highest" : "lowest");
1174 * Force XGMI Pstate to highest or lowest
1175 * TODO: revise this when xgmi dpm is functional
1177 ret = smu_v11_0_set_xgmi_pstate(smu, highest ? 1 : 0);
1182 static int arcturus_unforce_dpm_levels(struct smu_context *smu)
1184 struct arcturus_dpm_table *dpm_table =
1185 (struct arcturus_dpm_table *)smu->smu_dpm.dpm_context;
1186 struct amdgpu_hive_info *hive = amdgpu_get_xgmi_hive(smu->adev, 0);
1187 uint32_t soft_min_level, soft_max_level;
1191 soft_min_level = arcturus_find_lowest_dpm_level(&(dpm_table->gfx_table));
1192 soft_max_level = arcturus_find_highest_dpm_level(&(dpm_table->gfx_table));
1193 dpm_table->gfx_table.dpm_state.soft_min_level =
1194 dpm_table->gfx_table.dpm_levels[soft_min_level].value;
1195 dpm_table->gfx_table.dpm_state.soft_max_level =
1196 dpm_table->gfx_table.dpm_levels[soft_max_level].value;
1198 ret = arcturus_upload_dpm_level(smu, false, FEATURE_DPM_GFXCLK_MASK);
1200 pr_err("Failed to upload DPM Bootup Levels!");
1204 ret = arcturus_upload_dpm_level(smu, true, FEATURE_DPM_GFXCLK_MASK);
1206 pr_err("Failed to upload DPM Max Levels!");
1212 * Reset XGMI Pstate back to default
1213 * TODO: revise this when xgmi dpm is functional
1215 ret = smu_v11_0_set_xgmi_pstate(smu, 0);
1221 arcturus_get_profiling_clk_mask(struct smu_context *smu,
1222 enum amd_dpm_forced_level level,
1223 uint32_t *sclk_mask,
1224 uint32_t *mclk_mask,
1227 struct arcturus_dpm_table *dpm_table =
1228 (struct arcturus_dpm_table *)smu->smu_dpm.dpm_context;
1229 struct arcturus_single_dpm_table *gfx_dpm_table;
1230 struct arcturus_single_dpm_table *mem_dpm_table;
1231 struct arcturus_single_dpm_table *soc_dpm_table;
1233 if (!smu->smu_dpm.dpm_context)
1236 gfx_dpm_table = &dpm_table->gfx_table;
1237 mem_dpm_table = &dpm_table->mem_table;
1238 soc_dpm_table = &dpm_table->soc_table;
1244 if (gfx_dpm_table->count > ARCTURUS_UMD_PSTATE_GFXCLK_LEVEL &&
1245 mem_dpm_table->count > ARCTURUS_UMD_PSTATE_MCLK_LEVEL &&
1246 soc_dpm_table->count > ARCTURUS_UMD_PSTATE_SOCCLK_LEVEL) {
1247 *sclk_mask = ARCTURUS_UMD_PSTATE_GFXCLK_LEVEL;
1248 *mclk_mask = ARCTURUS_UMD_PSTATE_MCLK_LEVEL;
1249 *soc_mask = ARCTURUS_UMD_PSTATE_SOCCLK_LEVEL;
1252 if (level == AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK) {
1254 } else if (level == AMD_DPM_FORCED_LEVEL_PROFILE_MIN_MCLK) {
1256 } else if (level == AMD_DPM_FORCED_LEVEL_PROFILE_PEAK) {
1257 *sclk_mask = gfx_dpm_table->count - 1;
1258 *mclk_mask = mem_dpm_table->count - 1;
1259 *soc_mask = soc_dpm_table->count - 1;
1265 static int arcturus_get_power_limit(struct smu_context *smu,
1269 PPTable_t *pptable = smu->smu_table.driver_pptable;
1270 uint32_t asic_default_power_limit = 0;
1274 if (!smu->power_limit) {
1275 if (smu_feature_is_enabled(smu, SMU_FEATURE_PPT_BIT)) {
1276 power_src = smu_power_get_index(smu, SMU_POWER_SOURCE_AC);
1280 ret = smu_send_smc_msg_with_param(smu, SMU_MSG_GetPptLimit,
1283 pr_err("[%s] get PPT limit failed!", __func__);
1286 smu_read_smc_arg(smu, &asic_default_power_limit);
1288 /* the last hope to figure out the ppt limit */
1290 pr_err("Cannot get PPT limit due to pptable missing!");
1293 asic_default_power_limit =
1294 pptable->SocketPowerLimitAc[PPT_THROTTLER_PPT0];
1297 smu->power_limit = asic_default_power_limit;
1301 *limit = smu_v11_0_get_max_power_limit(smu);
1303 *limit = smu->power_limit;
1308 static int arcturus_get_power_profile_mode(struct smu_context *smu,
1311 static const char *profile_name[] = {
1319 static const char *title[] = {
1320 "PROFILE_INDEX(NAME)"};
1321 uint32_t i, size = 0;
1322 int16_t workload_type = 0;
1324 if (!smu->pm_enabled || !buf)
1327 size += sprintf(buf + size, "%16s\n",
1330 for (i = 0; i <= PP_SMC_POWER_PROFILE_CUSTOM; i++) {
1332 * Conv PP_SMC_POWER_PROFILE* to WORKLOAD_PPLIB_*_BIT
1333 * Not all profile modes are supported on arcturus.
1335 workload_type = smu_workload_get_type(smu, i);
1336 if (workload_type < 0)
1339 size += sprintf(buf + size, "%2d %14s%s\n",
1340 i, profile_name[i], (i == smu->power_profile_mode) ? "*" : " ");
1346 static int arcturus_set_power_profile_mode(struct smu_context *smu,
1350 int workload_type = 0;
1351 uint32_t profile_mode = input[size];
1354 if (!smu->pm_enabled)
1357 if (profile_mode > PP_SMC_POWER_PROFILE_CUSTOM) {
1358 pr_err("Invalid power profile mode %d\n", profile_mode);
1363 * Conv PP_SMC_POWER_PROFILE* to WORKLOAD_PPLIB_*_BIT
1364 * Not all profile modes are supported on arcturus.
1366 workload_type = smu_workload_get_type(smu, profile_mode);
1367 if (workload_type < 0) {
1368 pr_err("Unsupported power profile mode %d on arcturus\n", profile_mode);
1372 ret = smu_send_smc_msg_with_param(smu,
1373 SMU_MSG_SetWorkloadMask,
1374 1 << workload_type);
1376 pr_err("Fail to set workload type %d\n", workload_type);
1380 smu->power_profile_mode = profile_mode;
1385 static void arcturus_dump_pptable(struct smu_context *smu)
1387 struct smu_table_context *table_context = &smu->smu_table;
1388 PPTable_t *pptable = table_context->driver_pptable;
1391 pr_info("Dumped PPTable:\n");
1393 pr_info("Version = 0x%08x\n", pptable->Version);
1395 pr_info("FeaturesToRun[0] = 0x%08x\n", pptable->FeaturesToRun[0]);
1396 pr_info("FeaturesToRun[1] = 0x%08x\n", pptable->FeaturesToRun[1]);
1398 for (i = 0; i < PPT_THROTTLER_COUNT; i++) {
1399 pr_info("SocketPowerLimitAc[%d] = %d\n", i, pptable->SocketPowerLimitAc[i]);
1400 pr_info("SocketPowerLimitAcTau[%d] = %d\n", i, pptable->SocketPowerLimitAcTau[i]);
1403 pr_info("TdcLimitSoc = %d\n", pptable->TdcLimitSoc);
1404 pr_info("TdcLimitSocTau = %d\n", pptable->TdcLimitSocTau);
1405 pr_info("TdcLimitGfx = %d\n", pptable->TdcLimitGfx);
1406 pr_info("TdcLimitGfxTau = %d\n", pptable->TdcLimitGfxTau);
1408 pr_info("TedgeLimit = %d\n", pptable->TedgeLimit);
1409 pr_info("ThotspotLimit = %d\n", pptable->ThotspotLimit);
1410 pr_info("TmemLimit = %d\n", pptable->TmemLimit);
1411 pr_info("Tvr_gfxLimit = %d\n", pptable->Tvr_gfxLimit);
1412 pr_info("Tvr_memLimit = %d\n", pptable->Tvr_memLimit);
1413 pr_info("Tvr_socLimit = %d\n", pptable->Tvr_socLimit);
1414 pr_info("FitLimit = %d\n", pptable->FitLimit);
1416 pr_info("PpmPowerLimit = %d\n", pptable->PpmPowerLimit);
1417 pr_info("PpmTemperatureThreshold = %d\n", pptable->PpmTemperatureThreshold);
1419 pr_info("ThrottlerControlMask = %d\n", pptable->ThrottlerControlMask);
1421 pr_info("UlvVoltageOffsetGfx = %d\n", pptable->UlvVoltageOffsetGfx);
1422 pr_info("UlvPadding = 0x%08x\n", pptable->UlvPadding);
1424 pr_info("UlvGfxclkBypass = %d\n", pptable->UlvGfxclkBypass);
1425 pr_info("Padding234[0] = 0x%02x\n", pptable->Padding234[0]);
1426 pr_info("Padding234[1] = 0x%02x\n", pptable->Padding234[1]);
1427 pr_info("Padding234[2] = 0x%02x\n", pptable->Padding234[2]);
1429 pr_info("MinVoltageGfx = %d\n", pptable->MinVoltageGfx);
1430 pr_info("MinVoltageSoc = %d\n", pptable->MinVoltageSoc);
1431 pr_info("MaxVoltageGfx = %d\n", pptable->MaxVoltageGfx);
1432 pr_info("MaxVoltageSoc = %d\n", pptable->MaxVoltageSoc);
1434 pr_info("LoadLineResistanceGfx = %d\n", pptable->LoadLineResistanceGfx);
1435 pr_info("LoadLineResistanceSoc = %d\n", pptable->LoadLineResistanceSoc);
1437 pr_info("[PPCLK_GFXCLK]\n"
1438 " .VoltageMode = 0x%02x\n"
1439 " .SnapToDiscrete = 0x%02x\n"
1440 " .NumDiscreteLevels = 0x%02x\n"
1441 " .padding = 0x%02x\n"
1442 " .ConversionToAvfsClk{m = 0x%08x b = 0x%08x}\n"
1443 " .SsCurve {a = 0x%08x b = 0x%08x c = 0x%08x}\n"
1444 " .SsFmin = 0x%04x\n"
1445 " .Padding_16 = 0x%04x\n",
1446 pptable->DpmDescriptor[PPCLK_GFXCLK].VoltageMode,
1447 pptable->DpmDescriptor[PPCLK_GFXCLK].SnapToDiscrete,
1448 pptable->DpmDescriptor[PPCLK_GFXCLK].NumDiscreteLevels,
1449 pptable->DpmDescriptor[PPCLK_GFXCLK].padding,
1450 pptable->DpmDescriptor[PPCLK_GFXCLK].ConversionToAvfsClk.m,
1451 pptable->DpmDescriptor[PPCLK_GFXCLK].ConversionToAvfsClk.b,
1452 pptable->DpmDescriptor[PPCLK_GFXCLK].SsCurve.a,
1453 pptable->DpmDescriptor[PPCLK_GFXCLK].SsCurve.b,
1454 pptable->DpmDescriptor[PPCLK_GFXCLK].SsCurve.c,
1455 pptable->DpmDescriptor[PPCLK_GFXCLK].SsFmin,
1456 pptable->DpmDescriptor[PPCLK_GFXCLK].Padding16);
1458 pr_info("[PPCLK_VCLK]\n"
1459 " .VoltageMode = 0x%02x\n"
1460 " .SnapToDiscrete = 0x%02x\n"
1461 " .NumDiscreteLevels = 0x%02x\n"
1462 " .padding = 0x%02x\n"
1463 " .ConversionToAvfsClk{m = 0x%08x b = 0x%08x}\n"
1464 " .SsCurve {a = 0x%08x b = 0x%08x c = 0x%08x}\n"
1465 " .SsFmin = 0x%04x\n"
1466 " .Padding_16 = 0x%04x\n",
1467 pptable->DpmDescriptor[PPCLK_VCLK].VoltageMode,
1468 pptable->DpmDescriptor[PPCLK_VCLK].SnapToDiscrete,
1469 pptable->DpmDescriptor[PPCLK_VCLK].NumDiscreteLevels,
1470 pptable->DpmDescriptor[PPCLK_VCLK].padding,
1471 pptable->DpmDescriptor[PPCLK_VCLK].ConversionToAvfsClk.m,
1472 pptable->DpmDescriptor[PPCLK_VCLK].ConversionToAvfsClk.b,
1473 pptable->DpmDescriptor[PPCLK_VCLK].SsCurve.a,
1474 pptable->DpmDescriptor[PPCLK_VCLK].SsCurve.b,
1475 pptable->DpmDescriptor[PPCLK_VCLK].SsCurve.c,
1476 pptable->DpmDescriptor[PPCLK_VCLK].SsFmin,
1477 pptable->DpmDescriptor[PPCLK_VCLK].Padding16);
1479 pr_info("[PPCLK_DCLK]\n"
1480 " .VoltageMode = 0x%02x\n"
1481 " .SnapToDiscrete = 0x%02x\n"
1482 " .NumDiscreteLevels = 0x%02x\n"
1483 " .padding = 0x%02x\n"
1484 " .ConversionToAvfsClk{m = 0x%08x b = 0x%08x}\n"
1485 " .SsCurve {a = 0x%08x b = 0x%08x c = 0x%08x}\n"
1486 " .SsFmin = 0x%04x\n"
1487 " .Padding_16 = 0x%04x\n",
1488 pptable->DpmDescriptor[PPCLK_DCLK].VoltageMode,
1489 pptable->DpmDescriptor[PPCLK_DCLK].SnapToDiscrete,
1490 pptable->DpmDescriptor[PPCLK_DCLK].NumDiscreteLevels,
1491 pptable->DpmDescriptor[PPCLK_DCLK].padding,
1492 pptable->DpmDescriptor[PPCLK_DCLK].ConversionToAvfsClk.m,
1493 pptable->DpmDescriptor[PPCLK_DCLK].ConversionToAvfsClk.b,
1494 pptable->DpmDescriptor[PPCLK_DCLK].SsCurve.a,
1495 pptable->DpmDescriptor[PPCLK_DCLK].SsCurve.b,
1496 pptable->DpmDescriptor[PPCLK_DCLK].SsCurve.c,
1497 pptable->DpmDescriptor[PPCLK_DCLK].SsFmin,
1498 pptable->DpmDescriptor[PPCLK_DCLK].Padding16);
1500 pr_info("[PPCLK_SOCCLK]\n"
1501 " .VoltageMode = 0x%02x\n"
1502 " .SnapToDiscrete = 0x%02x\n"
1503 " .NumDiscreteLevels = 0x%02x\n"
1504 " .padding = 0x%02x\n"
1505 " .ConversionToAvfsClk{m = 0x%08x b = 0x%08x}\n"
1506 " .SsCurve {a = 0x%08x b = 0x%08x c = 0x%08x}\n"
1507 " .SsFmin = 0x%04x\n"
1508 " .Padding_16 = 0x%04x\n",
1509 pptable->DpmDescriptor[PPCLK_SOCCLK].VoltageMode,
1510 pptable->DpmDescriptor[PPCLK_SOCCLK].SnapToDiscrete,
1511 pptable->DpmDescriptor[PPCLK_SOCCLK].NumDiscreteLevels,
1512 pptable->DpmDescriptor[PPCLK_SOCCLK].padding,
1513 pptable->DpmDescriptor[PPCLK_SOCCLK].ConversionToAvfsClk.m,
1514 pptable->DpmDescriptor[PPCLK_SOCCLK].ConversionToAvfsClk.b,
1515 pptable->DpmDescriptor[PPCLK_SOCCLK].SsCurve.a,
1516 pptable->DpmDescriptor[PPCLK_SOCCLK].SsCurve.b,
1517 pptable->DpmDescriptor[PPCLK_SOCCLK].SsCurve.c,
1518 pptable->DpmDescriptor[PPCLK_SOCCLK].SsFmin,
1519 pptable->DpmDescriptor[PPCLK_SOCCLK].Padding16);
1521 pr_info("[PPCLK_UCLK]\n"
1522 " .VoltageMode = 0x%02x\n"
1523 " .SnapToDiscrete = 0x%02x\n"
1524 " .NumDiscreteLevels = 0x%02x\n"
1525 " .padding = 0x%02x\n"
1526 " .ConversionToAvfsClk{m = 0x%08x b = 0x%08x}\n"
1527 " .SsCurve {a = 0x%08x b = 0x%08x c = 0x%08x}\n"
1528 " .SsFmin = 0x%04x\n"
1529 " .Padding_16 = 0x%04x\n",
1530 pptable->DpmDescriptor[PPCLK_UCLK].VoltageMode,
1531 pptable->DpmDescriptor[PPCLK_UCLK].SnapToDiscrete,
1532 pptable->DpmDescriptor[PPCLK_UCLK].NumDiscreteLevels,
1533 pptable->DpmDescriptor[PPCLK_UCLK].padding,
1534 pptable->DpmDescriptor[PPCLK_UCLK].ConversionToAvfsClk.m,
1535 pptable->DpmDescriptor[PPCLK_UCLK].ConversionToAvfsClk.b,
1536 pptable->DpmDescriptor[PPCLK_UCLK].SsCurve.a,
1537 pptable->DpmDescriptor[PPCLK_UCLK].SsCurve.b,
1538 pptable->DpmDescriptor[PPCLK_UCLK].SsCurve.c,
1539 pptable->DpmDescriptor[PPCLK_UCLK].SsFmin,
1540 pptable->DpmDescriptor[PPCLK_UCLK].Padding16);
1542 pr_info("[PPCLK_FCLK]\n"
1543 " .VoltageMode = 0x%02x\n"
1544 " .SnapToDiscrete = 0x%02x\n"
1545 " .NumDiscreteLevels = 0x%02x\n"
1546 " .padding = 0x%02x\n"
1547 " .ConversionToAvfsClk{m = 0x%08x b = 0x%08x}\n"
1548 " .SsCurve {a = 0x%08x b = 0x%08x c = 0x%08x}\n"
1549 " .SsFmin = 0x%04x\n"
1550 " .Padding_16 = 0x%04x\n",
1551 pptable->DpmDescriptor[PPCLK_FCLK].VoltageMode,
1552 pptable->DpmDescriptor[PPCLK_FCLK].SnapToDiscrete,
1553 pptable->DpmDescriptor[PPCLK_FCLK].NumDiscreteLevels,
1554 pptable->DpmDescriptor[PPCLK_FCLK].padding,
1555 pptable->DpmDescriptor[PPCLK_FCLK].ConversionToAvfsClk.m,
1556 pptable->DpmDescriptor[PPCLK_FCLK].ConversionToAvfsClk.b,
1557 pptable->DpmDescriptor[PPCLK_FCLK].SsCurve.a,
1558 pptable->DpmDescriptor[PPCLK_FCLK].SsCurve.b,
1559 pptable->DpmDescriptor[PPCLK_FCLK].SsCurve.c,
1560 pptable->DpmDescriptor[PPCLK_FCLK].SsFmin,
1561 pptable->DpmDescriptor[PPCLK_FCLK].Padding16);
1564 pr_info("FreqTableGfx\n");
1565 for (i = 0; i < NUM_GFXCLK_DPM_LEVELS; i++)
1566 pr_info(" .[%02d] = %d\n", i, pptable->FreqTableGfx[i]);
1568 pr_info("FreqTableVclk\n");
1569 for (i = 0; i < NUM_VCLK_DPM_LEVELS; i++)
1570 pr_info(" .[%02d] = %d\n", i, pptable->FreqTableVclk[i]);
1572 pr_info("FreqTableDclk\n");
1573 for (i = 0; i < NUM_DCLK_DPM_LEVELS; i++)
1574 pr_info(" .[%02d] = %d\n", i, pptable->FreqTableDclk[i]);
1576 pr_info("FreqTableSocclk\n");
1577 for (i = 0; i < NUM_SOCCLK_DPM_LEVELS; i++)
1578 pr_info(" .[%02d] = %d\n", i, pptable->FreqTableSocclk[i]);
1580 pr_info("FreqTableUclk\n");
1581 for (i = 0; i < NUM_UCLK_DPM_LEVELS; i++)
1582 pr_info(" .[%02d] = %d\n", i, pptable->FreqTableUclk[i]);
1584 pr_info("FreqTableFclk\n");
1585 for (i = 0; i < NUM_FCLK_DPM_LEVELS; i++)
1586 pr_info(" .[%02d] = %d\n", i, pptable->FreqTableFclk[i]);
1588 pr_info("Mp0clkFreq\n");
1589 for (i = 0; i < NUM_MP0CLK_DPM_LEVELS; i++)
1590 pr_info(" .[%d] = %d\n", i, pptable->Mp0clkFreq[i]);
1592 pr_info("Mp0DpmVoltage\n");
1593 for (i = 0; i < NUM_MP0CLK_DPM_LEVELS; i++)
1594 pr_info(" .[%d] = %d\n", i, pptable->Mp0DpmVoltage[i]);
1596 pr_info("GfxclkFidle = 0x%x\n", pptable->GfxclkFidle);
1597 pr_info("GfxclkSlewRate = 0x%x\n", pptable->GfxclkSlewRate);
1598 pr_info("Padding567[0] = 0x%x\n", pptable->Padding567[0]);
1599 pr_info("Padding567[1] = 0x%x\n", pptable->Padding567[1]);
1600 pr_info("Padding567[2] = 0x%x\n", pptable->Padding567[2]);
1601 pr_info("Padding567[3] = 0x%x\n", pptable->Padding567[3]);
1602 pr_info("GfxclkDsMaxFreq = %d\n", pptable->GfxclkDsMaxFreq);
1603 pr_info("GfxclkSource = 0x%x\n", pptable->GfxclkSource);
1604 pr_info("Padding456 = 0x%x\n", pptable->Padding456);
1606 pr_info("EnableTdpm = %d\n", pptable->EnableTdpm);
1607 pr_info("TdpmHighHystTemperature = %d\n", pptable->TdpmHighHystTemperature);
1608 pr_info("TdpmLowHystTemperature = %d\n", pptable->TdpmLowHystTemperature);
1609 pr_info("GfxclkFreqHighTempLimit = %d\n", pptable->GfxclkFreqHighTempLimit);
1611 pr_info("FanStopTemp = %d\n", pptable->FanStopTemp);
1612 pr_info("FanStartTemp = %d\n", pptable->FanStartTemp);
1614 pr_info("FanGainEdge = %d\n", pptable->FanGainEdge);
1615 pr_info("FanGainHotspot = %d\n", pptable->FanGainHotspot);
1616 pr_info("FanGainVrGfx = %d\n", pptable->FanGainVrGfx);
1617 pr_info("FanGainVrSoc = %d\n", pptable->FanGainVrSoc);
1618 pr_info("FanGainVrMem = %d\n", pptable->FanGainVrMem);
1619 pr_info("FanGainHbm = %d\n", pptable->FanGainHbm);
1621 pr_info("FanPwmMin = %d\n", pptable->FanPwmMin);
1622 pr_info("FanAcousticLimitRpm = %d\n", pptable->FanAcousticLimitRpm);
1623 pr_info("FanThrottlingRpm = %d\n", pptable->FanThrottlingRpm);
1624 pr_info("FanMaximumRpm = %d\n", pptable->FanMaximumRpm);
1625 pr_info("FanTargetTemperature = %d\n", pptable->FanTargetTemperature);
1626 pr_info("FanTargetGfxclk = %d\n", pptable->FanTargetGfxclk);
1627 pr_info("FanZeroRpmEnable = %d\n", pptable->FanZeroRpmEnable);
1628 pr_info("FanTachEdgePerRev = %d\n", pptable->FanTachEdgePerRev);
1629 pr_info("FanTempInputSelect = %d\n", pptable->FanTempInputSelect);
1631 pr_info("FuzzyFan_ErrorSetDelta = %d\n", pptable->FuzzyFan_ErrorSetDelta);
1632 pr_info("FuzzyFan_ErrorRateSetDelta = %d\n", pptable->FuzzyFan_ErrorRateSetDelta);
1633 pr_info("FuzzyFan_PwmSetDelta = %d\n", pptable->FuzzyFan_PwmSetDelta);
1634 pr_info("FuzzyFan_Reserved = %d\n", pptable->FuzzyFan_Reserved);
1636 pr_info("OverrideAvfsGb[AVFS_VOLTAGE_GFX] = 0x%x\n", pptable->OverrideAvfsGb[AVFS_VOLTAGE_GFX]);
1637 pr_info("OverrideAvfsGb[AVFS_VOLTAGE_SOC] = 0x%x\n", pptable->OverrideAvfsGb[AVFS_VOLTAGE_SOC]);
1638 pr_info("Padding8_Avfs[0] = %d\n", pptable->Padding8_Avfs[0]);
1639 pr_info("Padding8_Avfs[1] = %d\n", pptable->Padding8_Avfs[1]);
1641 pr_info("dBtcGbGfxPll{a = 0x%x b = 0x%x c = 0x%x}\n",
1642 pptable->dBtcGbGfxPll.a,
1643 pptable->dBtcGbGfxPll.b,
1644 pptable->dBtcGbGfxPll.c);
1645 pr_info("dBtcGbGfxAfll{a = 0x%x b = 0x%x c = 0x%x}\n",
1646 pptable->dBtcGbGfxAfll.a,
1647 pptable->dBtcGbGfxAfll.b,
1648 pptable->dBtcGbGfxAfll.c);
1649 pr_info("dBtcGbSoc{a = 0x%x b = 0x%x c = 0x%x}\n",
1650 pptable->dBtcGbSoc.a,
1651 pptable->dBtcGbSoc.b,
1652 pptable->dBtcGbSoc.c);
1654 pr_info("qAgingGb[AVFS_VOLTAGE_GFX]{m = 0x%x b = 0x%x}\n",
1655 pptable->qAgingGb[AVFS_VOLTAGE_GFX].m,
1656 pptable->qAgingGb[AVFS_VOLTAGE_GFX].b);
1657 pr_info("qAgingGb[AVFS_VOLTAGE_SOC]{m = 0x%x b = 0x%x}\n",
1658 pptable->qAgingGb[AVFS_VOLTAGE_SOC].m,
1659 pptable->qAgingGb[AVFS_VOLTAGE_SOC].b);
1661 pr_info("qStaticVoltageOffset[AVFS_VOLTAGE_GFX]{a = 0x%x b = 0x%x c = 0x%x}\n",
1662 pptable->qStaticVoltageOffset[AVFS_VOLTAGE_GFX].a,
1663 pptable->qStaticVoltageOffset[AVFS_VOLTAGE_GFX].b,
1664 pptable->qStaticVoltageOffset[AVFS_VOLTAGE_GFX].c);
1665 pr_info("qStaticVoltageOffset[AVFS_VOLTAGE_SOC]{a = 0x%x b = 0x%x c = 0x%x}\n",
1666 pptable->qStaticVoltageOffset[AVFS_VOLTAGE_SOC].a,
1667 pptable->qStaticVoltageOffset[AVFS_VOLTAGE_SOC].b,
1668 pptable->qStaticVoltageOffset[AVFS_VOLTAGE_SOC].c);
1670 pr_info("DcTol[AVFS_VOLTAGE_GFX] = 0x%x\n", pptable->DcTol[AVFS_VOLTAGE_GFX]);
1671 pr_info("DcTol[AVFS_VOLTAGE_SOC] = 0x%x\n", pptable->DcTol[AVFS_VOLTAGE_SOC]);
1673 pr_info("DcBtcEnabled[AVFS_VOLTAGE_GFX] = 0x%x\n", pptable->DcBtcEnabled[AVFS_VOLTAGE_GFX]);
1674 pr_info("DcBtcEnabled[AVFS_VOLTAGE_SOC] = 0x%x\n", pptable->DcBtcEnabled[AVFS_VOLTAGE_SOC]);
1675 pr_info("Padding8_GfxBtc[0] = 0x%x\n", pptable->Padding8_GfxBtc[0]);
1676 pr_info("Padding8_GfxBtc[1] = 0x%x\n", pptable->Padding8_GfxBtc[1]);
1678 pr_info("DcBtcMin[AVFS_VOLTAGE_GFX] = 0x%x\n", pptable->DcBtcMin[AVFS_VOLTAGE_GFX]);
1679 pr_info("DcBtcMin[AVFS_VOLTAGE_SOC] = 0x%x\n", pptable->DcBtcMin[AVFS_VOLTAGE_SOC]);
1680 pr_info("DcBtcMax[AVFS_VOLTAGE_GFX] = 0x%x\n", pptable->DcBtcMax[AVFS_VOLTAGE_GFX]);
1681 pr_info("DcBtcMax[AVFS_VOLTAGE_SOC] = 0x%x\n", pptable->DcBtcMax[AVFS_VOLTAGE_SOC]);
1683 pr_info("DcBtcGb[AVFS_VOLTAGE_GFX] = 0x%x\n", pptable->DcBtcGb[AVFS_VOLTAGE_GFX]);
1684 pr_info("DcBtcGb[AVFS_VOLTAGE_SOC] = 0x%x\n", pptable->DcBtcGb[AVFS_VOLTAGE_SOC]);
1686 pr_info("XgmiDpmPstates\n");
1687 for (i = 0; i < NUM_XGMI_LEVELS; i++)
1688 pr_info(" .[%d] = %d\n", i, pptable->XgmiDpmPstates[i]);
1689 pr_info("XgmiDpmSpare[0] = 0x%02x\n", pptable->XgmiDpmSpare[0]);
1690 pr_info("XgmiDpmSpare[1] = 0x%02x\n", pptable->XgmiDpmSpare[1]);
1692 pr_info("VDDGFX_TVmin = %d\n", pptable->VDDGFX_TVmin);
1693 pr_info("VDDSOC_TVmin = %d\n", pptable->VDDSOC_TVmin);
1694 pr_info("VDDGFX_Vmin_HiTemp = %d\n", pptable->VDDGFX_Vmin_HiTemp);
1695 pr_info("VDDGFX_Vmin_LoTemp = %d\n", pptable->VDDGFX_Vmin_LoTemp);
1696 pr_info("VDDSOC_Vmin_HiTemp = %d\n", pptable->VDDSOC_Vmin_HiTemp);
1697 pr_info("VDDSOC_Vmin_LoTemp = %d\n", pptable->VDDSOC_Vmin_LoTemp);
1698 pr_info("VDDGFX_TVminHystersis = %d\n", pptable->VDDGFX_TVminHystersis);
1699 pr_info("VDDSOC_TVminHystersis = %d\n", pptable->VDDSOC_TVminHystersis);
1701 pr_info("DebugOverrides = 0x%x\n", pptable->DebugOverrides);
1702 pr_info("ReservedEquation0{a = 0x%x b = 0x%x c = 0x%x}\n",
1703 pptable->ReservedEquation0.a,
1704 pptable->ReservedEquation0.b,
1705 pptable->ReservedEquation0.c);
1706 pr_info("ReservedEquation1{a = 0x%x b = 0x%x c = 0x%x}\n",
1707 pptable->ReservedEquation1.a,
1708 pptable->ReservedEquation1.b,
1709 pptable->ReservedEquation1.c);
1710 pr_info("ReservedEquation2{a = 0x%x b = 0x%x c = 0x%x}\n",
1711 pptable->ReservedEquation2.a,
1712 pptable->ReservedEquation2.b,
1713 pptable->ReservedEquation2.c);
1714 pr_info("ReservedEquation3{a = 0x%x b = 0x%x c = 0x%x}\n",
1715 pptable->ReservedEquation3.a,
1716 pptable->ReservedEquation3.b,
1717 pptable->ReservedEquation3.c);
1719 pr_info("MinVoltageUlvGfx = %d\n", pptable->MinVoltageUlvGfx);
1720 pr_info("PaddingUlv = %d\n", pptable->PaddingUlv);
1722 pr_info("TotalPowerConfig = %d\n", pptable->TotalPowerConfig);
1723 pr_info("TotalPowerSpare1 = %d\n", pptable->TotalPowerSpare1);
1724 pr_info("TotalPowerSpare2 = %d\n", pptable->TotalPowerSpare2);
1726 pr_info("PccThresholdLow = %d\n", pptable->PccThresholdLow);
1727 pr_info("PccThresholdHigh = %d\n", pptable->PccThresholdHigh);
1729 pr_info("Board Parameters:\n");
1730 pr_info("MaxVoltageStepGfx = 0x%x\n", pptable->MaxVoltageStepGfx);
1731 pr_info("MaxVoltageStepSoc = 0x%x\n", pptable->MaxVoltageStepSoc);
1733 pr_info("VddGfxVrMapping = 0x%x\n", pptable->VddGfxVrMapping);
1734 pr_info("VddSocVrMapping = 0x%x\n", pptable->VddSocVrMapping);
1735 pr_info("VddMemVrMapping = 0x%x\n", pptable->VddMemVrMapping);
1736 pr_info("BoardVrMapping = 0x%x\n", pptable->BoardVrMapping);
1738 pr_info("GfxUlvPhaseSheddingMask = 0x%x\n", pptable->GfxUlvPhaseSheddingMask);
1739 pr_info("ExternalSensorPresent = 0x%x\n", pptable->ExternalSensorPresent);
1741 pr_info("GfxMaxCurrent = 0x%x\n", pptable->GfxMaxCurrent);
1742 pr_info("GfxOffset = 0x%x\n", pptable->GfxOffset);
1743 pr_info("Padding_TelemetryGfx = 0x%x\n", pptable->Padding_TelemetryGfx);
1745 pr_info("SocMaxCurrent = 0x%x\n", pptable->SocMaxCurrent);
1746 pr_info("SocOffset = 0x%x\n", pptable->SocOffset);
1747 pr_info("Padding_TelemetrySoc = 0x%x\n", pptable->Padding_TelemetrySoc);
1749 pr_info("MemMaxCurrent = 0x%x\n", pptable->MemMaxCurrent);
1750 pr_info("MemOffset = 0x%x\n", pptable->MemOffset);
1751 pr_info("Padding_TelemetryMem = 0x%x\n", pptable->Padding_TelemetryMem);
1753 pr_info("BoardMaxCurrent = 0x%x\n", pptable->BoardMaxCurrent);
1754 pr_info("BoardOffset = 0x%x\n", pptable->BoardOffset);
1755 pr_info("Padding_TelemetryBoardInput = 0x%x\n", pptable->Padding_TelemetryBoardInput);
1757 pr_info("VR0HotGpio = %d\n", pptable->VR0HotGpio);
1758 pr_info("VR0HotPolarity = %d\n", pptable->VR0HotPolarity);
1759 pr_info("VR1HotGpio = %d\n", pptable->VR1HotGpio);
1760 pr_info("VR1HotPolarity = %d\n", pptable->VR1HotPolarity);
1762 pr_info("PllGfxclkSpreadEnabled = %d\n", pptable->PllGfxclkSpreadEnabled);
1763 pr_info("PllGfxclkSpreadPercent = %d\n", pptable->PllGfxclkSpreadPercent);
1764 pr_info("PllGfxclkSpreadFreq = %d\n", pptable->PllGfxclkSpreadFreq);
1766 pr_info("UclkSpreadEnabled = %d\n", pptable->UclkSpreadEnabled);
1767 pr_info("UclkSpreadPercent = %d\n", pptable->UclkSpreadPercent);
1768 pr_info("UclkSpreadFreq = %d\n", pptable->UclkSpreadFreq);
1770 pr_info("FclkSpreadEnabled = %d\n", pptable->FclkSpreadEnabled);
1771 pr_info("FclkSpreadPercent = %d\n", pptable->FclkSpreadPercent);
1772 pr_info("FclkSpreadFreq = %d\n", pptable->FclkSpreadFreq);
1774 pr_info("FllGfxclkSpreadEnabled = %d\n", pptable->FllGfxclkSpreadEnabled);
1775 pr_info("FllGfxclkSpreadPercent = %d\n", pptable->FllGfxclkSpreadPercent);
1776 pr_info("FllGfxclkSpreadFreq = %d\n", pptable->FllGfxclkSpreadFreq);
1778 for (i = 0; i < NUM_I2C_CONTROLLERS; i++) {
1779 pr_info("I2cControllers[%d]:\n", i);
1780 pr_info(" .Enabled = %d\n",
1781 pptable->I2cControllers[i].Enabled);
1782 pr_info(" .SlaveAddress = 0x%x\n",
1783 pptable->I2cControllers[i].SlaveAddress);
1784 pr_info(" .ControllerPort = %d\n",
1785 pptable->I2cControllers[i].ControllerPort);
1786 pr_info(" .ControllerName = %d\n",
1787 pptable->I2cControllers[i].ControllerName);
1788 pr_info(" .ThermalThrottler = %d\n",
1789 pptable->I2cControllers[i].ThermalThrotter);
1790 pr_info(" .I2cProtocol = %d\n",
1791 pptable->I2cControllers[i].I2cProtocol);
1792 pr_info(" .Speed = %d\n",
1793 pptable->I2cControllers[i].Speed);
1796 pr_info("MemoryChannelEnabled = %d\n", pptable->MemoryChannelEnabled);
1797 pr_info("DramBitWidth = %d\n", pptable->DramBitWidth);
1799 pr_info("TotalBoardPower = %d\n", pptable->TotalBoardPower);
1801 pr_info("XgmiLinkSpeed\n");
1802 for (i = 0; i < NUM_XGMI_PSTATE_LEVELS; i++)
1803 pr_info(" .[%d] = %d\n", i, pptable->XgmiLinkSpeed[i]);
1804 pr_info("XgmiLinkWidth\n");
1805 for (i = 0; i < NUM_XGMI_PSTATE_LEVELS; i++)
1806 pr_info(" .[%d] = %d\n", i, pptable->XgmiLinkWidth[i]);
1807 pr_info("XgmiFclkFreq\n");
1808 for (i = 0; i < NUM_XGMI_PSTATE_LEVELS; i++)
1809 pr_info(" .[%d] = %d\n", i, pptable->XgmiFclkFreq[i]);
1810 pr_info("XgmiSocVoltage\n");
1811 for (i = 0; i < NUM_XGMI_PSTATE_LEVELS; i++)
1812 pr_info(" .[%d] = %d\n", i, pptable->XgmiSocVoltage[i]);
1816 static bool arcturus_is_dpm_running(struct smu_context *smu)
1819 uint32_t feature_mask[2];
1820 unsigned long feature_enabled;
1821 ret = smu_feature_get_enabled_mask(smu, feature_mask, 2);
1822 feature_enabled = (unsigned long)((uint64_t)feature_mask[0] |
1823 ((uint64_t)feature_mask[1] << 32));
1824 return !!(feature_enabled & SMC_DPM_FEATURE);
1827 static int arcturus_dpm_set_uvd_enable(struct smu_context *smu, bool enable)
1829 struct smu_power_context *smu_power = &smu->smu_power;
1830 struct smu_power_gate *power_gate = &smu_power->power_gate;
1834 if (!smu_feature_is_enabled(smu, SMU_FEATURE_VCN_PG_BIT)) {
1835 ret = smu_feature_set_enabled(smu, SMU_FEATURE_VCN_PG_BIT, 1);
1837 pr_err("[EnableVCNDPM] failed!\n");
1841 power_gate->vcn_gated = false;
1843 if (smu_feature_is_enabled(smu, SMU_FEATURE_VCN_PG_BIT)) {
1844 ret = smu_feature_set_enabled(smu, SMU_FEATURE_VCN_PG_BIT, 0);
1846 pr_err("[DisableVCNDPM] failed!\n");
1850 power_gate->vcn_gated = true;
1857 static void arcturus_fill_eeprom_i2c_req(SwI2cRequest_t *req, bool write,
1858 uint8_t address, uint32_t numbytes,
1863 BUG_ON(numbytes > MAX_SW_I2C_COMMANDS);
1865 req->I2CcontrollerPort = 0;
1867 req->SlaveAddress = address;
1868 req->NumCmds = numbytes;
1870 for (i = 0; i < numbytes; i++) {
1871 SwI2cCmd_t *cmd = &req->SwI2cCmds[i];
1873 /* First 2 bytes are always write for lower 2b EEPROM address */
1880 /* Add RESTART for read after address filled */
1881 cmd->CmdConfig |= (i == 2 && !write) ? CMDCONFIG_RESTART_MASK : 0;
1883 /* Add STOP in the end */
1884 cmd->CmdConfig |= (i == (numbytes - 1)) ? CMDCONFIG_STOP_MASK : 0;
1886 /* Fill with data regardless if read or write to simplify code */
1887 cmd->RegisterAddr = data[i];
1891 static int arcturus_i2c_eeprom_read_data(struct i2c_adapter *control,
1896 uint32_t i, ret = 0;
1898 struct amdgpu_device *adev = to_amdgpu_device(control);
1899 struct smu_table_context *smu_table = &adev->smu.smu_table;
1900 struct smu_table *table = &smu_table->tables[SMU_TABLE_I2C_COMMANDS];
1902 memset(&req, 0, sizeof(req));
1903 arcturus_fill_eeprom_i2c_req(&req, false, address, numbytes, data);
1905 mutex_lock(&adev->smu.mutex);
1906 /* Now read data starting with that address */
1907 ret = smu_update_table(&adev->smu, SMU_TABLE_I2C_COMMANDS, 0, &req,
1909 mutex_unlock(&adev->smu.mutex);
1912 SwI2cRequest_t *res = (SwI2cRequest_t *)table->cpu_addr;
1914 /* Assume SMU fills res.SwI2cCmds[i].Data with read bytes */
1915 for (i = 0; i < numbytes; i++)
1916 data[i] = res->SwI2cCmds[i].Data;
1918 pr_debug("arcturus_i2c_eeprom_read_data, address = %x, bytes = %d, data :",
1919 (uint16_t)address, numbytes);
1921 print_hex_dump(KERN_DEBUG, "data: ", DUMP_PREFIX_NONE,
1922 8, 1, data, numbytes, false);
1924 pr_err("arcturus_i2c_eeprom_read_data - error occurred :%x", ret);
1929 static int arcturus_i2c_eeprom_write_data(struct i2c_adapter *control,
1936 struct amdgpu_device *adev = to_amdgpu_device(control);
1938 memset(&req, 0, sizeof(req));
1939 arcturus_fill_eeprom_i2c_req(&req, true, address, numbytes, data);
1941 mutex_lock(&adev->smu.mutex);
1942 ret = smu_update_table(&adev->smu, SMU_TABLE_I2C_COMMANDS, 0, &req, true);
1943 mutex_unlock(&adev->smu.mutex);
1946 pr_debug("arcturus_i2c_write(), address = %x, bytes = %d , data: ",
1947 (uint16_t)address, numbytes);
1949 print_hex_dump(KERN_DEBUG, "data: ", DUMP_PREFIX_NONE,
1950 8, 1, data, numbytes, false);
1952 * According to EEPROM spec there is a MAX of 10 ms required for
1953 * EEPROM to flush internal RX buffer after STOP was issued at the
1954 * end of write transaction. During this time the EEPROM will not be
1955 * responsive to any more commands - so wait a bit more.
1960 pr_err("arcturus_i2c_write- error occurred :%x", ret);
1965 static int arcturus_i2c_eeprom_i2c_xfer(struct i2c_adapter *i2c_adap,
1966 struct i2c_msg *msgs, int num)
1968 uint32_t i, j, ret, data_size, data_chunk_size, next_eeprom_addr = 0;
1969 uint8_t *data_ptr, data_chunk[MAX_SW_I2C_COMMANDS] = { 0 };
1971 for (i = 0; i < num; i++) {
1973 * SMU interface allows at most MAX_SW_I2C_COMMANDS bytes of data at
1974 * once and hence the data needs to be spliced into chunks and sent each
1977 data_size = msgs[i].len - 2;
1978 data_chunk_size = MAX_SW_I2C_COMMANDS - 2;
1979 next_eeprom_addr = (msgs[i].buf[0] << 8 & 0xff00) | (msgs[i].buf[1] & 0xff);
1980 data_ptr = msgs[i].buf + 2;
1982 for (j = 0; j < data_size / data_chunk_size; j++) {
1983 /* Insert the EEPROM dest addess, bits 0-15 */
1984 data_chunk[0] = ((next_eeprom_addr >> 8) & 0xff);
1985 data_chunk[1] = (next_eeprom_addr & 0xff);
1987 if (msgs[i].flags & I2C_M_RD) {
1988 ret = arcturus_i2c_eeprom_read_data(i2c_adap,
1989 (uint8_t)msgs[i].addr,
1990 data_chunk, MAX_SW_I2C_COMMANDS);
1992 memcpy(data_ptr, data_chunk + 2, data_chunk_size);
1995 memcpy(data_chunk + 2, data_ptr, data_chunk_size);
1997 ret = arcturus_i2c_eeprom_write_data(i2c_adap,
1998 (uint8_t)msgs[i].addr,
1999 data_chunk, MAX_SW_I2C_COMMANDS);
2007 next_eeprom_addr += data_chunk_size;
2008 data_ptr += data_chunk_size;
2011 if (data_size % data_chunk_size) {
2012 data_chunk[0] = ((next_eeprom_addr >> 8) & 0xff);
2013 data_chunk[1] = (next_eeprom_addr & 0xff);
2015 if (msgs[i].flags & I2C_M_RD) {
2016 ret = arcturus_i2c_eeprom_read_data(i2c_adap,
2017 (uint8_t)msgs[i].addr,
2018 data_chunk, (data_size % data_chunk_size) + 2);
2020 memcpy(data_ptr, data_chunk + 2, data_size % data_chunk_size);
2022 memcpy(data_chunk + 2, data_ptr, data_size % data_chunk_size);
2024 ret = arcturus_i2c_eeprom_write_data(i2c_adap,
2025 (uint8_t)msgs[i].addr,
2026 data_chunk, (data_size % data_chunk_size) + 2);
2040 static u32 arcturus_i2c_eeprom_i2c_func(struct i2c_adapter *adap)
2042 return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
2046 static const struct i2c_algorithm arcturus_i2c_eeprom_i2c_algo = {
2047 .master_xfer = arcturus_i2c_eeprom_i2c_xfer,
2048 .functionality = arcturus_i2c_eeprom_i2c_func,
2051 static int arcturus_i2c_eeprom_control_init(struct i2c_adapter *control)
2053 struct amdgpu_device *adev = to_amdgpu_device(control);
2056 control->owner = THIS_MODULE;
2057 control->class = I2C_CLASS_SPD;
2058 control->dev.parent = &adev->pdev->dev;
2059 control->algo = &arcturus_i2c_eeprom_i2c_algo;
2060 snprintf(control->name, sizeof(control->name), "RAS EEPROM");
2062 res = i2c_add_adapter(control);
2064 DRM_ERROR("Failed to register hw i2c, err: %d\n", res);
2069 static void arcturus_i2c_eeprom_control_fini(struct i2c_adapter *control)
2071 i2c_del_adapter(control);
2074 static uint32_t arcturus_get_pptable_power_limit(struct smu_context *smu)
2076 PPTable_t *pptable = smu->smu_table.driver_pptable;
2078 return pptable->SocketPowerLimitAc[PPT_THROTTLER_PPT0];
2081 static const struct pptable_funcs arcturus_ppt_funcs = {
2082 /* translate smu index into arcturus specific index */
2083 .get_smu_msg_index = arcturus_get_smu_msg_index,
2084 .get_smu_clk_index = arcturus_get_smu_clk_index,
2085 .get_smu_feature_index = arcturus_get_smu_feature_index,
2086 .get_smu_table_index = arcturus_get_smu_table_index,
2087 .get_smu_power_index= arcturus_get_pwr_src_index,
2088 .get_workload_type = arcturus_get_workload_type,
2089 /* internal structurs allocations */
2090 .tables_init = arcturus_tables_init,
2091 .alloc_dpm_context = arcturus_allocate_dpm_context,
2092 /* pptable related */
2093 .check_powerplay_table = arcturus_check_powerplay_table,
2094 .store_powerplay_table = arcturus_store_powerplay_table,
2095 .append_powerplay_table = arcturus_append_powerplay_table,
2097 .get_allowed_feature_mask = arcturus_get_allowed_feature_mask,
2099 .run_btc = arcturus_run_btc,
2100 /* dpm/clk tables */
2101 .set_default_dpm_table = arcturus_set_default_dpm_table,
2102 .populate_umd_state_clk = arcturus_populate_umd_state_clk,
2103 .get_thermal_temperature_range = arcturus_get_thermal_temperature_range,
2104 .get_current_clk_freq_by_table = arcturus_get_current_clk_freq_by_table,
2105 .print_clk_levels = arcturus_print_clk_levels,
2106 .force_clk_levels = arcturus_force_clk_levels,
2107 .read_sensor = arcturus_read_sensor,
2108 .get_fan_speed_percent = arcturus_get_fan_speed_percent,
2109 .get_fan_speed_rpm = arcturus_get_fan_speed_rpm,
2110 .force_dpm_limit_value = arcturus_force_dpm_limit_value,
2111 .unforce_dpm_levels = arcturus_unforce_dpm_levels,
2112 .get_profiling_clk_mask = arcturus_get_profiling_clk_mask,
2113 .get_power_profile_mode = arcturus_get_power_profile_mode,
2114 .set_power_profile_mode = arcturus_set_power_profile_mode,
2115 /* debug (internal used) */
2116 .dump_pptable = arcturus_dump_pptable,
2117 .get_power_limit = arcturus_get_power_limit,
2118 .is_dpm_running = arcturus_is_dpm_running,
2119 .dpm_set_uvd_enable = arcturus_dpm_set_uvd_enable,
2120 .i2c_eeprom_init = arcturus_i2c_eeprom_control_init,
2121 .i2c_eeprom_fini = arcturus_i2c_eeprom_control_fini,
2122 .init_microcode = smu_v11_0_init_microcode,
2123 .load_microcode = smu_v11_0_load_microcode,
2124 .init_smc_tables = smu_v11_0_init_smc_tables,
2125 .fini_smc_tables = smu_v11_0_fini_smc_tables,
2126 .init_power = smu_v11_0_init_power,
2127 .fini_power = smu_v11_0_fini_power,
2128 .check_fw_status = smu_v11_0_check_fw_status,
2129 .setup_pptable = smu_v11_0_setup_pptable,
2130 .get_vbios_bootup_values = smu_v11_0_get_vbios_bootup_values,
2131 .get_clk_info_from_vbios = smu_v11_0_get_clk_info_from_vbios,
2132 .check_pptable = smu_v11_0_check_pptable,
2133 .parse_pptable = smu_v11_0_parse_pptable,
2134 .populate_smc_tables = smu_v11_0_populate_smc_pptable,
2135 .check_fw_version = smu_v11_0_check_fw_version,
2136 .write_pptable = smu_v11_0_write_pptable,
2137 .set_min_dcef_deep_sleep = smu_v11_0_set_min_dcef_deep_sleep,
2138 .set_tool_table_location = smu_v11_0_set_tool_table_location,
2139 .notify_memory_pool_location = smu_v11_0_notify_memory_pool_location,
2140 .system_features_control = smu_v11_0_system_features_control,
2141 .send_smc_msg_with_param = smu_v11_0_send_msg_with_param,
2142 .read_smc_arg = smu_v11_0_read_arg,
2143 .init_display_count = smu_v11_0_init_display_count,
2144 .set_allowed_mask = smu_v11_0_set_allowed_mask,
2145 .get_enabled_mask = smu_v11_0_get_enabled_mask,
2146 .notify_display_change = smu_v11_0_notify_display_change,
2147 .set_power_limit = smu_v11_0_set_power_limit,
2148 .get_current_clk_freq = smu_v11_0_get_current_clk_freq,
2149 .init_max_sustainable_clocks = smu_v11_0_init_max_sustainable_clocks,
2150 .start_thermal_control = smu_v11_0_start_thermal_control,
2151 .stop_thermal_control = smu_v11_0_stop_thermal_control,
2152 .set_deep_sleep_dcefclk = smu_v11_0_set_deep_sleep_dcefclk,
2153 .display_clock_voltage_request = smu_v11_0_display_clock_voltage_request,
2154 .get_fan_control_mode = smu_v11_0_get_fan_control_mode,
2155 .set_fan_control_mode = smu_v11_0_set_fan_control_mode,
2156 .set_fan_speed_percent = smu_v11_0_set_fan_speed_percent,
2157 .set_fan_speed_rpm = smu_v11_0_set_fan_speed_rpm,
2158 .set_xgmi_pstate = smu_v11_0_set_xgmi_pstate,
2159 .gfx_off_control = smu_v11_0_gfx_off_control,
2160 .register_irq_handler = smu_v11_0_register_irq_handler,
2161 .set_azalia_d3_pme = smu_v11_0_set_azalia_d3_pme,
2162 .get_max_sustainable_clocks_by_dc = smu_v11_0_get_max_sustainable_clocks_by_dc,
2163 .baco_is_support= smu_v11_0_baco_is_support,
2164 .baco_get_state = smu_v11_0_baco_get_state,
2165 .baco_set_state = smu_v11_0_baco_set_state,
2166 .baco_reset = smu_v11_0_baco_reset,
2167 .get_dpm_ultimate_freq = smu_v11_0_get_dpm_ultimate_freq,
2168 .set_soft_freq_limited_range = smu_v11_0_set_soft_freq_limited_range,
2169 .override_pcie_parameters = smu_v11_0_override_pcie_parameters,
2170 .get_pptable_power_limit = arcturus_get_pptable_power_limit,
2173 void arcturus_set_ppt_funcs(struct smu_context *smu)
2175 smu->ppt_funcs = &arcturus_ppt_funcs;