2 * Copyright 2013 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.
23 #ifndef PP_SISLANDS_SMC_H
24 #define PP_SISLANDS_SMC_H
30 #define SISLANDS_MAX_SMC_PERFORMANCE_LEVELS_PER_SWSTATE 16
32 struct PP_SIslands_Dpm2PerfLevel
36 uint8_t MaxPS_StepInc;
37 uint8_t MaxPS_StepDec;
38 uint8_t PSSamplingTime;
44 uint16_t PwrEfficiencyRatio;
48 typedef struct PP_SIslands_Dpm2PerfLevel PP_SIslands_Dpm2PerfLevel;
50 struct PP_SIslands_DPM2Status
54 uint8_t CurrPSkipPowerShift;
59 uint8_t CurrSPLLIndex;
64 uint8_t SwitchDownThreshold;
65 uint32_t SwitchDownCounter;
66 uint32_t SysScalingFactor;
69 typedef struct PP_SIslands_DPM2Status PP_SIslands_DPM2Status;
71 struct PP_SIslands_DPM2Parameters
74 uint32_t NearTDPLimit;
75 uint32_t SafePowerLimit;
76 uint32_t PowerBoostLimit;
77 uint32_t MinLimitDelta;
79 typedef struct PP_SIslands_DPM2Parameters PP_SIslands_DPM2Parameters;
81 struct PP_SIslands_PAPMStatus
83 uint32_t EstimatedDGPU_T;
84 uint32_t EstimatedDGPU_P;
85 uint32_t EstimatedAPU_T;
86 uint32_t EstimatedAPU_P;
87 uint8_t dGPU_T_Limit_Exceeded;
90 typedef struct PP_SIslands_PAPMStatus PP_SIslands_PAPMStatus;
92 struct PP_SIslands_PAPMParameters
94 uint32_t NearTDPLimitTherm;
95 uint32_t NearTDPLimitPAPM;
96 uint32_t PlatformPowerLimit;
97 uint32_t dGPU_T_Limit;
98 uint32_t dGPU_T_Warning;
99 uint32_t dGPU_T_Hysteresis;
101 typedef struct PP_SIslands_PAPMParameters PP_SIslands_PAPMParameters;
103 struct SISLANDS_SMC_SCLK_VALUE
105 uint32_t vCG_SPLL_FUNC_CNTL;
106 uint32_t vCG_SPLL_FUNC_CNTL_2;
107 uint32_t vCG_SPLL_FUNC_CNTL_3;
108 uint32_t vCG_SPLL_FUNC_CNTL_4;
109 uint32_t vCG_SPLL_SPREAD_SPECTRUM;
110 uint32_t vCG_SPLL_SPREAD_SPECTRUM_2;
114 typedef struct SISLANDS_SMC_SCLK_VALUE SISLANDS_SMC_SCLK_VALUE;
116 struct SISLANDS_SMC_MCLK_VALUE
118 uint32_t vMPLL_FUNC_CNTL;
119 uint32_t vMPLL_FUNC_CNTL_1;
120 uint32_t vMPLL_FUNC_CNTL_2;
121 uint32_t vMPLL_AD_FUNC_CNTL;
122 uint32_t vMPLL_DQ_FUNC_CNTL;
123 uint32_t vMCLK_PWRMGT_CNTL;
130 typedef struct SISLANDS_SMC_MCLK_VALUE SISLANDS_SMC_MCLK_VALUE;
132 struct SISLANDS_SMC_VOLTAGE_VALUE
136 uint8_t phase_settings;
139 typedef struct SISLANDS_SMC_VOLTAGE_VALUE SISLANDS_SMC_VOLTAGE_VALUE;
141 struct SISLANDS_SMC_HW_PERFORMANCE_LEVEL
144 uint8_t displayWatermark;
146 uint8_t UVDWatermark;
147 uint8_t VCEWatermark;
153 SISLANDS_SMC_SCLK_VALUE sclk;
154 SISLANDS_SMC_MCLK_VALUE mclk;
155 SISLANDS_SMC_VOLTAGE_VALUE vddc;
156 SISLANDS_SMC_VOLTAGE_VALUE mvdd;
157 SISLANDS_SMC_VOLTAGE_VALUE vddci;
158 SISLANDS_SMC_VOLTAGE_VALUE std_vddc;
159 uint8_t hysteresisUp;
160 uint8_t hysteresisDown;
162 uint8_t arbRefreshState;
163 uint32_t SQPowerThrottle;
164 uint32_t SQPowerThrottle_2;
165 uint32_t MaxPoweredUpCU;
166 SISLANDS_SMC_VOLTAGE_VALUE high_temp_vddc;
167 SISLANDS_SMC_VOLTAGE_VALUE low_temp_vddc;
168 uint32_t reserved[2];
169 PP_SIslands_Dpm2PerfLevel dpm2;
172 #define SISLANDS_SMC_STROBE_RATIO 0x0F
173 #define SISLANDS_SMC_STROBE_ENABLE 0x10
175 #define SISLANDS_SMC_MC_EDC_RD_FLAG 0x01
176 #define SISLANDS_SMC_MC_EDC_WR_FLAG 0x02
177 #define SISLANDS_SMC_MC_RTT_ENABLE 0x04
178 #define SISLANDS_SMC_MC_STUTTER_EN 0x08
179 #define SISLANDS_SMC_MC_PG_EN 0x10
181 typedef struct SISLANDS_SMC_HW_PERFORMANCE_LEVEL SISLANDS_SMC_HW_PERFORMANCE_LEVEL;
183 struct SISLANDS_SMC_SWSTATE
189 SISLANDS_SMC_HW_PERFORMANCE_LEVEL levels[];
192 typedef struct SISLANDS_SMC_SWSTATE SISLANDS_SMC_SWSTATE;
194 struct SISLANDS_SMC_SWSTATE_SINGLE {
199 SISLANDS_SMC_HW_PERFORMANCE_LEVEL level;
202 #define SISLANDS_SMC_VOLTAGEMASK_VDDC 0
203 #define SISLANDS_SMC_VOLTAGEMASK_MVDD 1
204 #define SISLANDS_SMC_VOLTAGEMASK_VDDCI 2
205 #define SISLANDS_SMC_VOLTAGEMASK_VDDC_PHASE_SHEDDING 3
206 #define SISLANDS_SMC_VOLTAGEMASK_MAX 4
208 struct SISLANDS_SMC_VOLTAGEMASKTABLE
210 uint32_t lowMask[SISLANDS_SMC_VOLTAGEMASK_MAX];
213 typedef struct SISLANDS_SMC_VOLTAGEMASKTABLE SISLANDS_SMC_VOLTAGEMASKTABLE;
215 #define SISLANDS_MAX_NO_VREG_STEPS 32
217 struct SISLANDS_SMC_STATETABLE
219 uint8_t thermalProtectType;
221 uint8_t maxVDDCIndexInPPTable;
223 uint32_t lowSMIO[SISLANDS_MAX_NO_VREG_STEPS];
224 SISLANDS_SMC_VOLTAGEMASKTABLE voltageMaskTable;
225 SISLANDS_SMC_VOLTAGEMASKTABLE phaseMaskTable;
226 PP_SIslands_DPM2Parameters dpm2Params;
227 struct SISLANDS_SMC_SWSTATE_SINGLE initialState;
228 struct SISLANDS_SMC_SWSTATE_SINGLE ACPIState;
229 struct SISLANDS_SMC_SWSTATE_SINGLE ULVState;
230 SISLANDS_SMC_SWSTATE driverState;
231 SISLANDS_SMC_HW_PERFORMANCE_LEVEL dpmLevels[SISLANDS_MAX_SMC_PERFORMANCE_LEVELS_PER_SWSTATE];
234 typedef struct SISLANDS_SMC_STATETABLE SISLANDS_SMC_STATETABLE;
236 #define SI_SMC_SOFT_REGISTER_mclk_chg_timeout 0x0
237 #define SI_SMC_SOFT_REGISTER_delay_vreg 0xC
238 #define SI_SMC_SOFT_REGISTER_delay_acpi 0x28
239 #define SI_SMC_SOFT_REGISTER_seq_index 0x5C
240 #define SI_SMC_SOFT_REGISTER_mvdd_chg_time 0x60
241 #define SI_SMC_SOFT_REGISTER_mclk_switch_lim 0x70
242 #define SI_SMC_SOFT_REGISTER_watermark_threshold 0x78
243 #define SI_SMC_SOFT_REGISTER_phase_shedding_delay 0x88
244 #define SI_SMC_SOFT_REGISTER_ulv_volt_change_delay 0x8C
245 #define SI_SMC_SOFT_REGISTER_mc_block_delay 0x98
246 #define SI_SMC_SOFT_REGISTER_ticks_per_us 0xA8
247 #define SI_SMC_SOFT_REGISTER_crtc_index 0xC4
248 #define SI_SMC_SOFT_REGISTER_mclk_change_block_cp_min 0xC8
249 #define SI_SMC_SOFT_REGISTER_mclk_change_block_cp_max 0xCC
250 #define SI_SMC_SOFT_REGISTER_non_ulv_pcie_link_width 0xF4
251 #define SI_SMC_SOFT_REGISTER_tdr_is_about_to_happen 0xFC
252 #define SI_SMC_SOFT_REGISTER_vr_hot_gpio 0x100
253 #define SI_SMC_SOFT_REGISTER_svi_rework_plat_type 0x118
254 #define SI_SMC_SOFT_REGISTER_svi_rework_gpio_id_svd 0x11c
255 #define SI_SMC_SOFT_REGISTER_svi_rework_gpio_id_svc 0x120
257 struct PP_SIslands_FanTable
270 int16_t temp_resp_lim;
274 uint32_t refresh_period;
280 typedef struct PP_SIslands_FanTable PP_SIslands_FanTable;
282 #define SMC_SISLANDS_LKGE_LUT_NUM_OF_TEMP_ENTRIES 16
283 #define SMC_SISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES 32
285 #define SMC_SISLANDS_SCALE_I 7
286 #define SMC_SISLANDS_SCALE_R 12
288 struct PP_SIslands_CacConfig
290 uint16_t cac_lkge_lut[SMC_SISLANDS_LKGE_LUT_NUM_OF_TEMP_ENTRIES][SMC_SISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES];
291 uint32_t lkge_lut_V0;
292 uint32_t lkge_lut_Vstep;
295 uint32_t calculation_repeats;
296 uint32_t l2numWin_TDP;
298 uint8_t lts_truncate_n;
300 uint8_t log2_PG_LKG_SCALE;
302 uint32_t lkge_lut_T0;
303 uint32_t lkge_lut_Tstep;
306 typedef struct PP_SIslands_CacConfig PP_SIslands_CacConfig;
308 #define SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE 16
309 #define SMC_SISLANDS_MC_REGISTER_ARRAY_SET_COUNT 20
311 struct SMC_SIslands_MCRegisterAddress
317 typedef struct SMC_SIslands_MCRegisterAddress SMC_SIslands_MCRegisterAddress;
319 struct SMC_SIslands_MCRegisterSet
321 uint32_t value[SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE];
324 typedef struct SMC_SIslands_MCRegisterSet SMC_SIslands_MCRegisterSet;
326 struct SMC_SIslands_MCRegisters
330 SMC_SIslands_MCRegisterAddress address[SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE];
331 SMC_SIslands_MCRegisterSet data[SMC_SISLANDS_MC_REGISTER_ARRAY_SET_COUNT];
334 typedef struct SMC_SIslands_MCRegisters SMC_SIslands_MCRegisters;
336 struct SMC_SIslands_MCArbDramTimingRegisterSet
338 uint32_t mc_arb_dram_timing;
339 uint32_t mc_arb_dram_timing2;
340 uint8_t mc_arb_rfsh_rate;
341 uint8_t mc_arb_burst_time;
345 typedef struct SMC_SIslands_MCArbDramTimingRegisterSet SMC_SIslands_MCArbDramTimingRegisterSet;
347 struct SMC_SIslands_MCArbDramTimingRegisters
351 SMC_SIslands_MCArbDramTimingRegisterSet data[16];
354 typedef struct SMC_SIslands_MCArbDramTimingRegisters SMC_SIslands_MCArbDramTimingRegisters;
356 struct SMC_SISLANDS_SPLL_DIV_TABLE
362 #define SMC_SISLANDS_SPLL_DIV_TABLE_FBDIV_MASK 0x01ffffff
363 #define SMC_SISLANDS_SPLL_DIV_TABLE_FBDIV_SHIFT 0
364 #define SMC_SISLANDS_SPLL_DIV_TABLE_PDIV_MASK 0xfe000000
365 #define SMC_SISLANDS_SPLL_DIV_TABLE_PDIV_SHIFT 25
366 #define SMC_SISLANDS_SPLL_DIV_TABLE_CLKV_MASK 0x000fffff
367 #define SMC_SISLANDS_SPLL_DIV_TABLE_CLKV_SHIFT 0
368 #define SMC_SISLANDS_SPLL_DIV_TABLE_CLKS_MASK 0xfff00000
369 #define SMC_SISLANDS_SPLL_DIV_TABLE_CLKS_SHIFT 20
371 typedef struct SMC_SISLANDS_SPLL_DIV_TABLE SMC_SISLANDS_SPLL_DIV_TABLE;
373 #define SMC_SISLANDS_DTE_MAX_FILTER_STAGES 5
375 #define SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE 16
377 struct Smc_SIslands_DTE_Configuration
379 uint32_t tau[SMC_SISLANDS_DTE_MAX_FILTER_STAGES];
380 uint32_t R[SMC_SISLANDS_DTE_MAX_FILTER_STAGES];
388 uint8_t T_limits[SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE];
389 uint32_t Tdep_tau[SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE];
390 uint32_t Tdep_R[SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE];
394 typedef struct Smc_SIslands_DTE_Configuration Smc_SIslands_DTE_Configuration;
396 #define SMC_SISLANDS_DTE_STATUS_FLAG_DTE_ON 1
398 #define SISLANDS_SMC_FIRMWARE_HEADER_LOCATION 0x10000
400 #define SISLANDS_SMC_FIRMWARE_HEADER_version 0x0
401 #define SISLANDS_SMC_FIRMWARE_HEADER_flags 0x4
402 #define SISLANDS_SMC_FIRMWARE_HEADER_softRegisters 0xC
403 #define SISLANDS_SMC_FIRMWARE_HEADER_stateTable 0x10
404 #define SISLANDS_SMC_FIRMWARE_HEADER_fanTable 0x14
405 #define SISLANDS_SMC_FIRMWARE_HEADER_CacConfigTable 0x18
406 #define SISLANDS_SMC_FIRMWARE_HEADER_mcRegisterTable 0x24
407 #define SISLANDS_SMC_FIRMWARE_HEADER_mcArbDramAutoRefreshTable 0x30
408 #define SISLANDS_SMC_FIRMWARE_HEADER_spllTable 0x38
409 #define SISLANDS_SMC_FIRMWARE_HEADER_DteConfiguration 0x40
410 #define SISLANDS_SMC_FIRMWARE_HEADER_PAPMParameters 0x48
414 int amdgpu_si_copy_bytes_to_smc(struct amdgpu_device *adev,
415 u32 smc_start_address,
416 const u8 *src, u32 byte_count, u32 limit);
417 void amdgpu_si_start_smc(struct amdgpu_device *adev);
418 void amdgpu_si_reset_smc(struct amdgpu_device *adev);
419 int amdgpu_si_program_jump_on_start(struct amdgpu_device *adev);
420 void amdgpu_si_smc_clock(struct amdgpu_device *adev, bool enable);
421 bool amdgpu_si_is_smc_running(struct amdgpu_device *adev);
422 PPSMC_Result amdgpu_si_send_msg_to_smc(struct amdgpu_device *adev, PPSMC_Msg msg);
423 PPSMC_Result amdgpu_si_wait_for_smc_inactive(struct amdgpu_device *adev);
424 int amdgpu_si_load_smc_ucode(struct amdgpu_device *adev, u32 limit);
425 int amdgpu_si_read_smc_sram_dword(struct amdgpu_device *adev, u32 smc_address,
426 u32 *value, u32 limit);
427 int amdgpu_si_write_smc_sram_dword(struct amdgpu_device *adev, u32 smc_address,
428 u32 value, u32 limit);