sislands_smc.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. /*
  2. * Copyright 2013 Advanced Micro Devices, Inc.
  3. *
  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:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  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.
  21. *
  22. */
  23. #ifndef PP_SISLANDS_SMC_H
  24. #define PP_SISLANDS_SMC_H
  25. #include "ppsmc.h"
  26. #pragma pack(push, 1)
  27. #define SISLANDS_MAX_SMC_PERFORMANCE_LEVELS_PER_SWSTATE 16
  28. struct PP_SIslands_Dpm2PerfLevel
  29. {
  30. uint8_t MaxPS;
  31. uint8_t TgtAct;
  32. uint8_t MaxPS_StepInc;
  33. uint8_t MaxPS_StepDec;
  34. uint8_t PSSamplingTime;
  35. uint8_t NearTDPDec;
  36. uint8_t AboveSafeInc;
  37. uint8_t BelowSafeInc;
  38. uint8_t PSDeltaLimit;
  39. uint8_t PSDeltaWin;
  40. uint16_t PwrEfficiencyRatio;
  41. uint8_t Reserved[4];
  42. };
  43. typedef struct PP_SIslands_Dpm2PerfLevel PP_SIslands_Dpm2PerfLevel;
  44. struct PP_SIslands_DPM2Status
  45. {
  46. uint32_t dpm2Flags;
  47. uint8_t CurrPSkip;
  48. uint8_t CurrPSkipPowerShift;
  49. uint8_t CurrPSkipTDP;
  50. uint8_t CurrPSkipOCP;
  51. uint8_t MaxSPLLIndex;
  52. uint8_t MinSPLLIndex;
  53. uint8_t CurrSPLLIndex;
  54. uint8_t InfSweepMode;
  55. uint8_t InfSweepDir;
  56. uint8_t TDPexceeded;
  57. uint8_t reserved;
  58. uint8_t SwitchDownThreshold;
  59. uint32_t SwitchDownCounter;
  60. uint32_t SysScalingFactor;
  61. };
  62. typedef struct PP_SIslands_DPM2Status PP_SIslands_DPM2Status;
  63. struct PP_SIslands_DPM2Parameters
  64. {
  65. uint32_t TDPLimit;
  66. uint32_t NearTDPLimit;
  67. uint32_t SafePowerLimit;
  68. uint32_t PowerBoostLimit;
  69. uint32_t MinLimitDelta;
  70. };
  71. typedef struct PP_SIslands_DPM2Parameters PP_SIslands_DPM2Parameters;
  72. struct PP_SIslands_PAPMStatus
  73. {
  74. uint32_t EstimatedDGPU_T;
  75. uint32_t EstimatedDGPU_P;
  76. uint32_t EstimatedAPU_T;
  77. uint32_t EstimatedAPU_P;
  78. uint8_t dGPU_T_Limit_Exceeded;
  79. uint8_t reserved[3];
  80. };
  81. typedef struct PP_SIslands_PAPMStatus PP_SIslands_PAPMStatus;
  82. struct PP_SIslands_PAPMParameters
  83. {
  84. uint32_t NearTDPLimitTherm;
  85. uint32_t NearTDPLimitPAPM;
  86. uint32_t PlatformPowerLimit;
  87. uint32_t dGPU_T_Limit;
  88. uint32_t dGPU_T_Warning;
  89. uint32_t dGPU_T_Hysteresis;
  90. };
  91. typedef struct PP_SIslands_PAPMParameters PP_SIslands_PAPMParameters;
  92. struct SISLANDS_SMC_SCLK_VALUE
  93. {
  94. uint32_t vCG_SPLL_FUNC_CNTL;
  95. uint32_t vCG_SPLL_FUNC_CNTL_2;
  96. uint32_t vCG_SPLL_FUNC_CNTL_3;
  97. uint32_t vCG_SPLL_FUNC_CNTL_4;
  98. uint32_t vCG_SPLL_SPREAD_SPECTRUM;
  99. uint32_t vCG_SPLL_SPREAD_SPECTRUM_2;
  100. uint32_t sclk_value;
  101. };
  102. typedef struct SISLANDS_SMC_SCLK_VALUE SISLANDS_SMC_SCLK_VALUE;
  103. struct SISLANDS_SMC_MCLK_VALUE
  104. {
  105. uint32_t vMPLL_FUNC_CNTL;
  106. uint32_t vMPLL_FUNC_CNTL_1;
  107. uint32_t vMPLL_FUNC_CNTL_2;
  108. uint32_t vMPLL_AD_FUNC_CNTL;
  109. uint32_t vMPLL_DQ_FUNC_CNTL;
  110. uint32_t vMCLK_PWRMGT_CNTL;
  111. uint32_t vDLL_CNTL;
  112. uint32_t vMPLL_SS;
  113. uint32_t vMPLL_SS2;
  114. uint32_t mclk_value;
  115. };
  116. typedef struct SISLANDS_SMC_MCLK_VALUE SISLANDS_SMC_MCLK_VALUE;
  117. struct SISLANDS_SMC_VOLTAGE_VALUE
  118. {
  119. uint16_t value;
  120. uint8_t index;
  121. uint8_t phase_settings;
  122. };
  123. typedef struct SISLANDS_SMC_VOLTAGE_VALUE SISLANDS_SMC_VOLTAGE_VALUE;
  124. struct SISLANDS_SMC_HW_PERFORMANCE_LEVEL
  125. {
  126. uint8_t ACIndex;
  127. uint8_t displayWatermark;
  128. uint8_t gen2PCIE;
  129. uint8_t UVDWatermark;
  130. uint8_t VCEWatermark;
  131. uint8_t strobeMode;
  132. uint8_t mcFlags;
  133. uint8_t padding;
  134. uint32_t aT;
  135. uint32_t bSP;
  136. SISLANDS_SMC_SCLK_VALUE sclk;
  137. SISLANDS_SMC_MCLK_VALUE mclk;
  138. SISLANDS_SMC_VOLTAGE_VALUE vddc;
  139. SISLANDS_SMC_VOLTAGE_VALUE mvdd;
  140. SISLANDS_SMC_VOLTAGE_VALUE vddci;
  141. SISLANDS_SMC_VOLTAGE_VALUE std_vddc;
  142. uint8_t hysteresisUp;
  143. uint8_t hysteresisDown;
  144. uint8_t stateFlags;
  145. uint8_t arbRefreshState;
  146. uint32_t SQPowerThrottle;
  147. uint32_t SQPowerThrottle_2;
  148. uint32_t MaxPoweredUpCU;
  149. SISLANDS_SMC_VOLTAGE_VALUE high_temp_vddc;
  150. SISLANDS_SMC_VOLTAGE_VALUE low_temp_vddc;
  151. uint32_t reserved[2];
  152. PP_SIslands_Dpm2PerfLevel dpm2;
  153. };
  154. #define SISLANDS_SMC_STROBE_RATIO 0x0F
  155. #define SISLANDS_SMC_STROBE_ENABLE 0x10
  156. #define SISLANDS_SMC_MC_EDC_RD_FLAG 0x01
  157. #define SISLANDS_SMC_MC_EDC_WR_FLAG 0x02
  158. #define SISLANDS_SMC_MC_RTT_ENABLE 0x04
  159. #define SISLANDS_SMC_MC_STUTTER_EN 0x08
  160. #define SISLANDS_SMC_MC_PG_EN 0x10
  161. typedef struct SISLANDS_SMC_HW_PERFORMANCE_LEVEL SISLANDS_SMC_HW_PERFORMANCE_LEVEL;
  162. struct SISLANDS_SMC_SWSTATE
  163. {
  164. uint8_t flags;
  165. uint8_t levelCount;
  166. uint8_t padding2;
  167. uint8_t padding3;
  168. SISLANDS_SMC_HW_PERFORMANCE_LEVEL levels[1];
  169. };
  170. typedef struct SISLANDS_SMC_SWSTATE SISLANDS_SMC_SWSTATE;
  171. #define SISLANDS_SMC_VOLTAGEMASK_VDDC 0
  172. #define SISLANDS_SMC_VOLTAGEMASK_MVDD 1
  173. #define SISLANDS_SMC_VOLTAGEMASK_VDDCI 2
  174. #define SISLANDS_SMC_VOLTAGEMASK_VDDC_PHASE_SHEDDING 3
  175. #define SISLANDS_SMC_VOLTAGEMASK_MAX 4
  176. struct SISLANDS_SMC_VOLTAGEMASKTABLE
  177. {
  178. uint32_t lowMask[SISLANDS_SMC_VOLTAGEMASK_MAX];
  179. };
  180. typedef struct SISLANDS_SMC_VOLTAGEMASKTABLE SISLANDS_SMC_VOLTAGEMASKTABLE;
  181. #define SISLANDS_MAX_NO_VREG_STEPS 32
  182. struct SISLANDS_SMC_STATETABLE
  183. {
  184. uint8_t thermalProtectType;
  185. uint8_t systemFlags;
  186. uint8_t maxVDDCIndexInPPTable;
  187. uint8_t extraFlags;
  188. uint32_t lowSMIO[SISLANDS_MAX_NO_VREG_STEPS];
  189. SISLANDS_SMC_VOLTAGEMASKTABLE voltageMaskTable;
  190. SISLANDS_SMC_VOLTAGEMASKTABLE phaseMaskTable;
  191. PP_SIslands_DPM2Parameters dpm2Params;
  192. SISLANDS_SMC_SWSTATE initialState;
  193. SISLANDS_SMC_SWSTATE ACPIState;
  194. SISLANDS_SMC_SWSTATE ULVState;
  195. SISLANDS_SMC_SWSTATE driverState;
  196. SISLANDS_SMC_HW_PERFORMANCE_LEVEL dpmLevels[SISLANDS_MAX_SMC_PERFORMANCE_LEVELS_PER_SWSTATE - 1];
  197. };
  198. typedef struct SISLANDS_SMC_STATETABLE SISLANDS_SMC_STATETABLE;
  199. #define SI_SMC_SOFT_REGISTER_mclk_chg_timeout 0x0
  200. #define SI_SMC_SOFT_REGISTER_delay_vreg 0xC
  201. #define SI_SMC_SOFT_REGISTER_delay_acpi 0x28
  202. #define SI_SMC_SOFT_REGISTER_seq_index 0x5C
  203. #define SI_SMC_SOFT_REGISTER_mvdd_chg_time 0x60
  204. #define SI_SMC_SOFT_REGISTER_mclk_switch_lim 0x70
  205. #define SI_SMC_SOFT_REGISTER_watermark_threshold 0x78
  206. #define SI_SMC_SOFT_REGISTER_phase_shedding_delay 0x88
  207. #define SI_SMC_SOFT_REGISTER_ulv_volt_change_delay 0x8C
  208. #define SI_SMC_SOFT_REGISTER_mc_block_delay 0x98
  209. #define SI_SMC_SOFT_REGISTER_ticks_per_us 0xA8
  210. #define SI_SMC_SOFT_REGISTER_crtc_index 0xC4
  211. #define SI_SMC_SOFT_REGISTER_mclk_change_block_cp_min 0xC8
  212. #define SI_SMC_SOFT_REGISTER_mclk_change_block_cp_max 0xCC
  213. #define SI_SMC_SOFT_REGISTER_non_ulv_pcie_link_width 0xF4
  214. #define SI_SMC_SOFT_REGISTER_tdr_is_about_to_happen 0xFC
  215. #define SI_SMC_SOFT_REGISTER_vr_hot_gpio 0x100
  216. #define SI_SMC_SOFT_REGISTER_svi_rework_plat_type 0x118
  217. #define SI_SMC_SOFT_REGISTER_svi_rework_gpio_id_svd 0x11c
  218. #define SI_SMC_SOFT_REGISTER_svi_rework_gpio_id_svc 0x120
  219. struct PP_SIslands_FanTable
  220. {
  221. uint8_t fdo_mode;
  222. uint8_t padding;
  223. int16_t temp_min;
  224. int16_t temp_med;
  225. int16_t temp_max;
  226. int16_t slope1;
  227. int16_t slope2;
  228. int16_t fdo_min;
  229. int16_t hys_up;
  230. int16_t hys_down;
  231. int16_t hys_slope;
  232. int16_t temp_resp_lim;
  233. int16_t temp_curr;
  234. int16_t slope_curr;
  235. int16_t pwm_curr;
  236. uint32_t refresh_period;
  237. int16_t fdo_max;
  238. uint8_t temp_src;
  239. int8_t padding2;
  240. };
  241. typedef struct PP_SIslands_FanTable PP_SIslands_FanTable;
  242. #define SMC_SISLANDS_LKGE_LUT_NUM_OF_TEMP_ENTRIES 16
  243. #define SMC_SISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES 32
  244. #define SMC_SISLANDS_SCALE_I 7
  245. #define SMC_SISLANDS_SCALE_R 12
  246. struct PP_SIslands_CacConfig
  247. {
  248. uint16_t cac_lkge_lut[SMC_SISLANDS_LKGE_LUT_NUM_OF_TEMP_ENTRIES][SMC_SISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES];
  249. uint32_t lkge_lut_V0;
  250. uint32_t lkge_lut_Vstep;
  251. uint32_t WinTime;
  252. uint32_t R_LL;
  253. uint32_t calculation_repeats;
  254. uint32_t l2numWin_TDP;
  255. uint32_t dc_cac;
  256. uint8_t lts_truncate_n;
  257. uint8_t SHIFT_N;
  258. uint8_t log2_PG_LKG_SCALE;
  259. uint8_t cac_temp;
  260. uint32_t lkge_lut_T0;
  261. uint32_t lkge_lut_Tstep;
  262. };
  263. typedef struct PP_SIslands_CacConfig PP_SIslands_CacConfig;
  264. #define SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE 16
  265. #define SMC_SISLANDS_MC_REGISTER_ARRAY_SET_COUNT 20
  266. struct SMC_SIslands_MCRegisterAddress
  267. {
  268. uint16_t s0;
  269. uint16_t s1;
  270. };
  271. typedef struct SMC_SIslands_MCRegisterAddress SMC_SIslands_MCRegisterAddress;
  272. struct SMC_SIslands_MCRegisterSet
  273. {
  274. uint32_t value[SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE];
  275. };
  276. typedef struct SMC_SIslands_MCRegisterSet SMC_SIslands_MCRegisterSet;
  277. struct SMC_SIslands_MCRegisters
  278. {
  279. uint8_t last;
  280. uint8_t reserved[3];
  281. SMC_SIslands_MCRegisterAddress address[SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE];
  282. SMC_SIslands_MCRegisterSet data[SMC_SISLANDS_MC_REGISTER_ARRAY_SET_COUNT];
  283. };
  284. typedef struct SMC_SIslands_MCRegisters SMC_SIslands_MCRegisters;
  285. struct SMC_SIslands_MCArbDramTimingRegisterSet
  286. {
  287. uint32_t mc_arb_dram_timing;
  288. uint32_t mc_arb_dram_timing2;
  289. uint8_t mc_arb_rfsh_rate;
  290. uint8_t mc_arb_burst_time;
  291. uint8_t padding[2];
  292. };
  293. typedef struct SMC_SIslands_MCArbDramTimingRegisterSet SMC_SIslands_MCArbDramTimingRegisterSet;
  294. struct SMC_SIslands_MCArbDramTimingRegisters
  295. {
  296. uint8_t arb_current;
  297. uint8_t reserved[3];
  298. SMC_SIslands_MCArbDramTimingRegisterSet data[16];
  299. };
  300. typedef struct SMC_SIslands_MCArbDramTimingRegisters SMC_SIslands_MCArbDramTimingRegisters;
  301. struct SMC_SISLANDS_SPLL_DIV_TABLE
  302. {
  303. uint32_t freq[256];
  304. uint32_t ss[256];
  305. };
  306. #define SMC_SISLANDS_SPLL_DIV_TABLE_FBDIV_MASK 0x01ffffff
  307. #define SMC_SISLANDS_SPLL_DIV_TABLE_FBDIV_SHIFT 0
  308. #define SMC_SISLANDS_SPLL_DIV_TABLE_PDIV_MASK 0xfe000000
  309. #define SMC_SISLANDS_SPLL_DIV_TABLE_PDIV_SHIFT 25
  310. #define SMC_SISLANDS_SPLL_DIV_TABLE_CLKV_MASK 0x000fffff
  311. #define SMC_SISLANDS_SPLL_DIV_TABLE_CLKV_SHIFT 0
  312. #define SMC_SISLANDS_SPLL_DIV_TABLE_CLKS_MASK 0xfff00000
  313. #define SMC_SISLANDS_SPLL_DIV_TABLE_CLKS_SHIFT 20
  314. typedef struct SMC_SISLANDS_SPLL_DIV_TABLE SMC_SISLANDS_SPLL_DIV_TABLE;
  315. #define SMC_SISLANDS_DTE_MAX_FILTER_STAGES 5
  316. #define SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE 16
  317. struct Smc_SIslands_DTE_Configuration
  318. {
  319. uint32_t tau[SMC_SISLANDS_DTE_MAX_FILTER_STAGES];
  320. uint32_t R[SMC_SISLANDS_DTE_MAX_FILTER_STAGES];
  321. uint32_t K;
  322. uint32_t T0;
  323. uint32_t MaxT;
  324. uint8_t WindowSize;
  325. uint8_t Tdep_count;
  326. uint8_t temp_select;
  327. uint8_t DTE_mode;
  328. uint8_t T_limits[SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE];
  329. uint32_t Tdep_tau[SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE];
  330. uint32_t Tdep_R[SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE];
  331. uint32_t Tthreshold;
  332. };
  333. typedef struct Smc_SIslands_DTE_Configuration Smc_SIslands_DTE_Configuration;
  334. #define SMC_SISLANDS_DTE_STATUS_FLAG_DTE_ON 1
  335. #define SISLANDS_SMC_FIRMWARE_HEADER_LOCATION 0x10000
  336. #define SISLANDS_SMC_FIRMWARE_HEADER_version 0x0
  337. #define SISLANDS_SMC_FIRMWARE_HEADER_flags 0x4
  338. #define SISLANDS_SMC_FIRMWARE_HEADER_softRegisters 0xC
  339. #define SISLANDS_SMC_FIRMWARE_HEADER_stateTable 0x10
  340. #define SISLANDS_SMC_FIRMWARE_HEADER_fanTable 0x14
  341. #define SISLANDS_SMC_FIRMWARE_HEADER_CacConfigTable 0x18
  342. #define SISLANDS_SMC_FIRMWARE_HEADER_mcRegisterTable 0x24
  343. #define SISLANDS_SMC_FIRMWARE_HEADER_mcArbDramAutoRefreshTable 0x30
  344. #define SISLANDS_SMC_FIRMWARE_HEADER_spllTable 0x38
  345. #define SISLANDS_SMC_FIRMWARE_HEADER_DteConfiguration 0x40
  346. #define SISLANDS_SMC_FIRMWARE_HEADER_PAPMParameters 0x48
  347. #pragma pack(pop)
  348. int amdgpu_si_copy_bytes_to_smc(struct amdgpu_device *adev,
  349. u32 smc_start_address,
  350. const u8 *src, u32 byte_count, u32 limit);
  351. void amdgpu_si_start_smc(struct amdgpu_device *adev);
  352. void amdgpu_si_reset_smc(struct amdgpu_device *adev);
  353. int amdgpu_si_program_jump_on_start(struct amdgpu_device *adev);
  354. void amdgpu_si_smc_clock(struct amdgpu_device *adev, bool enable);
  355. bool amdgpu_si_is_smc_running(struct amdgpu_device *adev);
  356. PPSMC_Result amdgpu_si_send_msg_to_smc(struct amdgpu_device *adev, PPSMC_Msg msg);
  357. PPSMC_Result amdgpu_si_wait_for_smc_inactive(struct amdgpu_device *adev);
  358. int amdgpu_si_load_smc_ucode(struct amdgpu_device *adev, u32 limit);
  359. int amdgpu_si_read_smc_sram_dword(struct amdgpu_device *adev, u32 smc_address,
  360. u32 *value, u32 limit);
  361. int amdgpu_si_write_smc_sram_dword(struct amdgpu_device *adev, u32 smc_address,
  362. u32 value, u32 limit);
  363. #endif