nislands_smc.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. /*
  2. * Copyright 2012 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 __NISLANDS_SMC_H__
  24. #define __NISLANDS_SMC_H__
  25. #pragma pack(push, 1)
  26. #define NISLANDS_MAX_SMC_PERFORMANCE_LEVELS_PER_SWSTATE 16
  27. struct PP_NIslands_Dpm2PerfLevel
  28. {
  29. uint8_t MaxPS;
  30. uint8_t TgtAct;
  31. uint8_t MaxPS_StepInc;
  32. uint8_t MaxPS_StepDec;
  33. uint8_t PSST;
  34. uint8_t NearTDPDec;
  35. uint8_t AboveSafeInc;
  36. uint8_t BelowSafeInc;
  37. uint8_t PSDeltaLimit;
  38. uint8_t PSDeltaWin;
  39. uint8_t Reserved[6];
  40. };
  41. typedef struct PP_NIslands_Dpm2PerfLevel PP_NIslands_Dpm2PerfLevel;
  42. struct PP_NIslands_DPM2Parameters
  43. {
  44. uint32_t TDPLimit;
  45. uint32_t NearTDPLimit;
  46. uint32_t SafePowerLimit;
  47. uint32_t PowerBoostLimit;
  48. };
  49. typedef struct PP_NIslands_DPM2Parameters PP_NIslands_DPM2Parameters;
  50. struct NISLANDS_SMC_SCLK_VALUE
  51. {
  52. uint32_t vCG_SPLL_FUNC_CNTL;
  53. uint32_t vCG_SPLL_FUNC_CNTL_2;
  54. uint32_t vCG_SPLL_FUNC_CNTL_3;
  55. uint32_t vCG_SPLL_FUNC_CNTL_4;
  56. uint32_t vCG_SPLL_SPREAD_SPECTRUM;
  57. uint32_t vCG_SPLL_SPREAD_SPECTRUM_2;
  58. uint32_t sclk_value;
  59. };
  60. typedef struct NISLANDS_SMC_SCLK_VALUE NISLANDS_SMC_SCLK_VALUE;
  61. struct NISLANDS_SMC_MCLK_VALUE
  62. {
  63. uint32_t vMPLL_FUNC_CNTL;
  64. uint32_t vMPLL_FUNC_CNTL_1;
  65. uint32_t vMPLL_FUNC_CNTL_2;
  66. uint32_t vMPLL_AD_FUNC_CNTL;
  67. uint32_t vMPLL_AD_FUNC_CNTL_2;
  68. uint32_t vMPLL_DQ_FUNC_CNTL;
  69. uint32_t vMPLL_DQ_FUNC_CNTL_2;
  70. uint32_t vMCLK_PWRMGT_CNTL;
  71. uint32_t vDLL_CNTL;
  72. uint32_t vMPLL_SS;
  73. uint32_t vMPLL_SS2;
  74. uint32_t mclk_value;
  75. };
  76. typedef struct NISLANDS_SMC_MCLK_VALUE NISLANDS_SMC_MCLK_VALUE;
  77. struct NISLANDS_SMC_VOLTAGE_VALUE
  78. {
  79. uint16_t value;
  80. uint8_t index;
  81. uint8_t padding;
  82. };
  83. typedef struct NISLANDS_SMC_VOLTAGE_VALUE NISLANDS_SMC_VOLTAGE_VALUE;
  84. struct NISLANDS_SMC_HW_PERFORMANCE_LEVEL
  85. {
  86. uint8_t arbValue;
  87. uint8_t ACIndex;
  88. uint8_t displayWatermark;
  89. uint8_t gen2PCIE;
  90. uint8_t reserved1;
  91. uint8_t reserved2;
  92. uint8_t strobeMode;
  93. uint8_t mcFlags;
  94. uint32_t aT;
  95. uint32_t bSP;
  96. NISLANDS_SMC_SCLK_VALUE sclk;
  97. NISLANDS_SMC_MCLK_VALUE mclk;
  98. NISLANDS_SMC_VOLTAGE_VALUE vddc;
  99. NISLANDS_SMC_VOLTAGE_VALUE mvdd;
  100. NISLANDS_SMC_VOLTAGE_VALUE vddci;
  101. NISLANDS_SMC_VOLTAGE_VALUE std_vddc;
  102. uint32_t powergate_en;
  103. uint8_t hUp;
  104. uint8_t hDown;
  105. uint8_t stateFlags;
  106. uint8_t arbRefreshState;
  107. uint32_t SQPowerThrottle;
  108. uint32_t SQPowerThrottle_2;
  109. uint32_t reserved[2];
  110. PP_NIslands_Dpm2PerfLevel dpm2;
  111. };
  112. #define NISLANDS_SMC_STROBE_RATIO 0x0F
  113. #define NISLANDS_SMC_STROBE_ENABLE 0x10
  114. #define NISLANDS_SMC_MC_EDC_RD_FLAG 0x01
  115. #define NISLANDS_SMC_MC_EDC_WR_FLAG 0x02
  116. #define NISLANDS_SMC_MC_RTT_ENABLE 0x04
  117. #define NISLANDS_SMC_MC_STUTTER_EN 0x08
  118. typedef struct NISLANDS_SMC_HW_PERFORMANCE_LEVEL NISLANDS_SMC_HW_PERFORMANCE_LEVEL;
  119. struct NISLANDS_SMC_SWSTATE
  120. {
  121. uint8_t flags;
  122. uint8_t levelCount;
  123. uint8_t padding2;
  124. uint8_t padding3;
  125. NISLANDS_SMC_HW_PERFORMANCE_LEVEL levels[1];
  126. };
  127. typedef struct NISLANDS_SMC_SWSTATE NISLANDS_SMC_SWSTATE;
  128. #define NISLANDS_SMC_VOLTAGEMASK_VDDC 0
  129. #define NISLANDS_SMC_VOLTAGEMASK_MVDD 1
  130. #define NISLANDS_SMC_VOLTAGEMASK_VDDCI 2
  131. #define NISLANDS_SMC_VOLTAGEMASK_MAX 4
  132. struct NISLANDS_SMC_VOLTAGEMASKTABLE
  133. {
  134. uint8_t highMask[NISLANDS_SMC_VOLTAGEMASK_MAX];
  135. uint32_t lowMask[NISLANDS_SMC_VOLTAGEMASK_MAX];
  136. };
  137. typedef struct NISLANDS_SMC_VOLTAGEMASKTABLE NISLANDS_SMC_VOLTAGEMASKTABLE;
  138. #define NISLANDS_MAX_NO_VREG_STEPS 32
  139. struct NISLANDS_SMC_STATETABLE
  140. {
  141. uint8_t thermalProtectType;
  142. uint8_t systemFlags;
  143. uint8_t maxVDDCIndexInPPTable;
  144. uint8_t extraFlags;
  145. uint8_t highSMIO[NISLANDS_MAX_NO_VREG_STEPS];
  146. uint32_t lowSMIO[NISLANDS_MAX_NO_VREG_STEPS];
  147. NISLANDS_SMC_VOLTAGEMASKTABLE voltageMaskTable;
  148. PP_NIslands_DPM2Parameters dpm2Params;
  149. NISLANDS_SMC_SWSTATE initialState;
  150. NISLANDS_SMC_SWSTATE ACPIState;
  151. NISLANDS_SMC_SWSTATE ULVState;
  152. NISLANDS_SMC_SWSTATE driverState;
  153. NISLANDS_SMC_HW_PERFORMANCE_LEVEL dpmLevels[NISLANDS_MAX_SMC_PERFORMANCE_LEVELS_PER_SWSTATE - 1];
  154. };
  155. typedef struct NISLANDS_SMC_STATETABLE NISLANDS_SMC_STATETABLE;
  156. #define NI_SMC_SOFT_REGISTERS_START 0x108
  157. #define NI_SMC_SOFT_REGISTER_mclk_chg_timeout 0x0
  158. #define NI_SMC_SOFT_REGISTER_delay_bbias 0xC
  159. #define NI_SMC_SOFT_REGISTER_delay_vreg 0x10
  160. #define NI_SMC_SOFT_REGISTER_delay_acpi 0x2C
  161. #define NI_SMC_SOFT_REGISTER_seq_index 0x64
  162. #define NI_SMC_SOFT_REGISTER_mvdd_chg_time 0x68
  163. #define NI_SMC_SOFT_REGISTER_mclk_switch_lim 0x78
  164. #define NI_SMC_SOFT_REGISTER_watermark_threshold 0x80
  165. #define NI_SMC_SOFT_REGISTER_mc_block_delay 0x84
  166. #define NI_SMC_SOFT_REGISTER_uvd_enabled 0x98
  167. #define SMC_NISLANDS_MC_TPP_CAC_NUM_OF_ENTRIES 16
  168. #define SMC_NISLANDS_LKGE_LUT_NUM_OF_TEMP_ENTRIES 16
  169. #define SMC_NISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES 16
  170. #define SMC_NISLANDS_BIF_LUT_NUM_OF_ENTRIES 4
  171. struct SMC_NISLANDS_MC_TPP_CAC_TABLE
  172. {
  173. uint32_t tpp[SMC_NISLANDS_MC_TPP_CAC_NUM_OF_ENTRIES];
  174. uint32_t cacValue[SMC_NISLANDS_MC_TPP_CAC_NUM_OF_ENTRIES];
  175. };
  176. typedef struct SMC_NISLANDS_MC_TPP_CAC_TABLE SMC_NISLANDS_MC_TPP_CAC_TABLE;
  177. struct PP_NIslands_CACTABLES
  178. {
  179. uint32_t cac_bif_lut[SMC_NISLANDS_BIF_LUT_NUM_OF_ENTRIES];
  180. uint32_t cac_lkge_lut[SMC_NISLANDS_LKGE_LUT_NUM_OF_TEMP_ENTRIES][SMC_NISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES];
  181. uint32_t pwr_const;
  182. uint32_t dc_cacValue;
  183. uint32_t bif_cacValue;
  184. uint32_t lkge_pwr;
  185. uint8_t cac_width;
  186. uint8_t window_size_p2;
  187. uint8_t num_drop_lsb;
  188. uint8_t padding_0;
  189. uint32_t last_power;
  190. uint8_t AllowOvrflw;
  191. uint8_t MCWrWeight;
  192. uint8_t MCRdWeight;
  193. uint8_t padding_1[9];
  194. uint8_t enableWinAvg;
  195. uint8_t numWin_TDP;
  196. uint8_t l2numWin_TDP;
  197. uint8_t WinIndex;
  198. uint32_t dynPwr_TDP[4];
  199. uint32_t lkgePwr_TDP[4];
  200. uint32_t power_TDP[4];
  201. uint32_t avg_dynPwr_TDP;
  202. uint32_t avg_lkgePwr_TDP;
  203. uint32_t avg_power_TDP;
  204. uint32_t lts_power_TDP;
  205. uint8_t lts_truncate_n;
  206. uint8_t padding_2[7];
  207. };
  208. typedef struct PP_NIslands_CACTABLES PP_NIslands_CACTABLES;
  209. #define SMC_NISLANDS_MC_REGISTER_ARRAY_SIZE 32
  210. #define SMC_NISLANDS_MC_REGISTER_ARRAY_SET_COUNT 20
  211. struct SMC_NIslands_MCRegisterAddress
  212. {
  213. uint16_t s0;
  214. uint16_t s1;
  215. };
  216. typedef struct SMC_NIslands_MCRegisterAddress SMC_NIslands_MCRegisterAddress;
  217. struct SMC_NIslands_MCRegisterSet
  218. {
  219. uint32_t value[SMC_NISLANDS_MC_REGISTER_ARRAY_SIZE];
  220. };
  221. typedef struct SMC_NIslands_MCRegisterSet SMC_NIslands_MCRegisterSet;
  222. struct SMC_NIslands_MCRegisters
  223. {
  224. uint8_t last;
  225. uint8_t reserved[3];
  226. SMC_NIslands_MCRegisterAddress address[SMC_NISLANDS_MC_REGISTER_ARRAY_SIZE];
  227. SMC_NIslands_MCRegisterSet data[SMC_NISLANDS_MC_REGISTER_ARRAY_SET_COUNT];
  228. };
  229. typedef struct SMC_NIslands_MCRegisters SMC_NIslands_MCRegisters;
  230. struct SMC_NIslands_MCArbDramTimingRegisterSet
  231. {
  232. uint32_t mc_arb_dram_timing;
  233. uint32_t mc_arb_dram_timing2;
  234. uint8_t mc_arb_rfsh_rate;
  235. uint8_t padding[3];
  236. };
  237. typedef struct SMC_NIslands_MCArbDramTimingRegisterSet SMC_NIslands_MCArbDramTimingRegisterSet;
  238. struct SMC_NIslands_MCArbDramTimingRegisters
  239. {
  240. uint8_t arb_current;
  241. uint8_t reserved[3];
  242. SMC_NIslands_MCArbDramTimingRegisterSet data[20];
  243. };
  244. typedef struct SMC_NIslands_MCArbDramTimingRegisters SMC_NIslands_MCArbDramTimingRegisters;
  245. struct SMC_NISLANDS_SPLL_DIV_TABLE
  246. {
  247. uint32_t freq[256];
  248. uint32_t ss[256];
  249. };
  250. #define SMC_NISLANDS_SPLL_DIV_TABLE_FBDIV_MASK 0x01ffffff
  251. #define SMC_NISLANDS_SPLL_DIV_TABLE_FBDIV_SHIFT 0
  252. #define SMC_NISLANDS_SPLL_DIV_TABLE_PDIV_MASK 0xfe000000
  253. #define SMC_NISLANDS_SPLL_DIV_TABLE_PDIV_SHIFT 25
  254. #define SMC_NISLANDS_SPLL_DIV_TABLE_CLKV_MASK 0x000fffff
  255. #define SMC_NISLANDS_SPLL_DIV_TABLE_CLKV_SHIFT 0
  256. #define SMC_NISLANDS_SPLL_DIV_TABLE_CLKS_MASK 0xfff00000
  257. #define SMC_NISLANDS_SPLL_DIV_TABLE_CLKS_SHIFT 20
  258. typedef struct SMC_NISLANDS_SPLL_DIV_TABLE SMC_NISLANDS_SPLL_DIV_TABLE;
  259. #define NISLANDS_SMC_FIRMWARE_HEADER_LOCATION 0x100
  260. #define NISLANDS_SMC_FIRMWARE_HEADER_version 0x0
  261. #define NISLANDS_SMC_FIRMWARE_HEADER_flags 0x4
  262. #define NISLANDS_SMC_FIRMWARE_HEADER_softRegisters 0x8
  263. #define NISLANDS_SMC_FIRMWARE_HEADER_stateTable 0xC
  264. #define NISLANDS_SMC_FIRMWARE_HEADER_fanTable 0x10
  265. #define NISLANDS_SMC_FIRMWARE_HEADER_cacTable 0x14
  266. #define NISLANDS_SMC_FIRMWARE_HEADER_mcRegisterTable 0x20
  267. #define NISLANDS_SMC_FIRMWARE_HEADER_mcArbDramAutoRefreshTable 0x2C
  268. #define NISLANDS_SMC_FIRMWARE_HEADER_spllTable 0x30
  269. #pragma pack(pop)
  270. #endif