smu9_driver_if.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  1. /*
  2. * Copyright 2016 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 SMU9_DRIVER_IF_H
  24. #define SMU9_DRIVER_IF_H
  25. #include "smu9.h"
  26. /**** IMPORTANT ***
  27. * SMU TEAM: Always increment the interface version if
  28. * any structure is changed in this file
  29. */
  30. #define SMU9_DRIVER_IF_VERSION 0xE
  31. #define PPTABLE_V10_SMU_VERSION 1
  32. #define NUM_GFXCLK_DPM_LEVELS 8
  33. #define NUM_UVD_DPM_LEVELS 8
  34. #define NUM_VCE_DPM_LEVELS 8
  35. #define NUM_MP0CLK_DPM_LEVELS 8
  36. #define NUM_UCLK_DPM_LEVELS 4
  37. #define NUM_SOCCLK_DPM_LEVELS 8
  38. #define NUM_DCEFCLK_DPM_LEVELS 8
  39. #define NUM_LINK_LEVELS 2
  40. #define MAX_GFXCLK_DPM_LEVEL (NUM_GFXCLK_DPM_LEVELS - 1)
  41. #define MAX_UVD_DPM_LEVEL (NUM_UVD_DPM_LEVELS - 1)
  42. #define MAX_VCE_DPM_LEVEL (NUM_VCE_DPM_LEVELS - 1)
  43. #define MAX_MP0CLK_DPM_LEVEL (NUM_MP0CLK_DPM_LEVELS - 1)
  44. #define MAX_UCLK_DPM_LEVEL (NUM_UCLK_DPM_LEVELS - 1)
  45. #define MAX_SOCCLK_DPM_LEVEL (NUM_SOCCLK_DPM_LEVELS - 1)
  46. #define MAX_DCEFCLK_DPM_LEVEL (NUM_DCEFCLK_DPM_LEVELS - 1)
  47. #define MAX_LINK_DPM_LEVEL (NUM_LINK_LEVELS - 1)
  48. #define MIN_GFXCLK_DPM_LEVEL 0
  49. #define MIN_UVD_DPM_LEVEL 0
  50. #define MIN_VCE_DPM_LEVEL 0
  51. #define MIN_MP0CLK_DPM_LEVEL 0
  52. #define MIN_UCLK_DPM_LEVEL 0
  53. #define MIN_SOCCLK_DPM_LEVEL 0
  54. #define MIN_DCEFCLK_DPM_LEVEL 0
  55. #define MIN_LINK_DPM_LEVEL 0
  56. #define NUM_EVV_VOLTAGE_LEVELS 8
  57. #define MAX_EVV_VOLTAGE_LEVEL (NUM_EVV_VOLTAGE_LEVELS - 1)
  58. #define MIN_EVV_VOLTAGE_LEVEL 0
  59. #define NUM_PSP_LEVEL_MAP 4
  60. /* Gemini Modes */
  61. #define PPSMC_GeminiModeNone 0 /* Single GPU board */
  62. #define PPSMC_GeminiModeMaster 1 /* Master GPU on a Gemini board */
  63. #define PPSMC_GeminiModeSlave 2 /* Slave GPU on a Gemini board */
  64. /* Voltage Modes for DPMs */
  65. #define VOLTAGE_MODE_AVFS_INTERPOLATE 0
  66. #define VOLTAGE_MODE_AVFS_WORST_CASE 1
  67. #define VOLTAGE_MODE_STATIC 2
  68. typedef struct {
  69. uint32_t FbMult; /* Feedback Multiplier, bit 8:0 int, bit 15:12 post_div, bit 31:16 frac */
  70. uint32_t SsFbMult; /* Spread FB Mult: bit 8:0 int, bit 31:16 frac */
  71. uint16_t SsSlewFrac;
  72. uint8_t SsOn;
  73. uint8_t Did; /* DID */
  74. } PllSetting_t;
  75. typedef struct {
  76. int32_t a0;
  77. int32_t a1;
  78. int32_t a2;
  79. uint8_t a0_shift;
  80. uint8_t a1_shift;
  81. uint8_t a2_shift;
  82. uint8_t padding;
  83. } GbVdroopTable_t;
  84. typedef struct {
  85. int32_t m1;
  86. int32_t m2;
  87. int32_t b;
  88. uint8_t m1_shift;
  89. uint8_t m2_shift;
  90. uint8_t b_shift;
  91. uint8_t padding;
  92. } QuadraticInt_t;
  93. #define NUM_DSPCLK_LEVELS 8
  94. typedef enum {
  95. DSPCLK_DCEFCLK = 0,
  96. DSPCLK_DISPCLK,
  97. DSPCLK_PIXCLK,
  98. DSPCLK_PHYCLK,
  99. DSPCLK_COUNT,
  100. } DSPCLK_e;
  101. typedef struct {
  102. uint16_t Freq; /* in MHz */
  103. uint16_t Vid; /* min voltage in SVI2 VID */
  104. } DisplayClockTable_t;
  105. typedef struct {
  106. /* PowerTune */
  107. uint16_t SocketPowerLimit; /* Watts */
  108. uint16_t TdcLimit; /* Amps */
  109. uint16_t EdcLimit; /* Amps */
  110. uint16_t TedgeLimit; /* Celcius */
  111. uint16_t ThotspotLimit; /* Celcius */
  112. uint16_t ThbmLimit; /* Celcius */
  113. uint16_t Tvr_socLimit; /* Celcius */
  114. uint16_t Tvr_memLimit; /* Celcius */
  115. uint16_t Tliquid1Limit; /* Celcius */
  116. uint16_t Tliquid2Limit; /* Celcius */
  117. uint16_t TplxLimit; /* Celcius */
  118. uint16_t LoadLineResistance; /* in mOhms */
  119. uint32_t FitLimit; /* Failures in time (failures per million parts over the defined lifetime) */
  120. /* External Component Communication Settings */
  121. uint8_t Liquid1_I2C_address;
  122. uint8_t Liquid2_I2C_address;
  123. uint8_t Vr_I2C_address;
  124. uint8_t Plx_I2C_address;
  125. uint8_t GeminiMode;
  126. uint8_t spare17[3];
  127. uint32_t GeminiApertureHigh;
  128. uint32_t GeminiApertureLow;
  129. uint8_t Liquid_I2C_LineSCL;
  130. uint8_t Liquid_I2C_LineSDA;
  131. uint8_t Vr_I2C_LineSCL;
  132. uint8_t Vr_I2C_LineSDA;
  133. uint8_t Plx_I2C_LineSCL;
  134. uint8_t Plx_I2C_LineSDA;
  135. uint8_t paddingx[2];
  136. /* ULV Settings */
  137. uint8_t UlvOffsetVid; /* SVI2 VID */
  138. uint8_t UlvSmnclkDid; /* DID for ULV mode. 0 means CLK will not be modified in ULV. */
  139. uint8_t UlvMp1clkDid; /* DID for ULV mode. 0 means CLK will not be modified in ULV. */
  140. uint8_t UlvGfxclkBypass; /* 1 to turn off/bypass Gfxclk during ULV, 0 to leave Gfxclk on during ULV */
  141. /* VDDCR_SOC Voltages */
  142. uint8_t SocVid[NUM_EVV_VOLTAGE_LEVELS];
  143. /* This is the minimum voltage needed to run the SOC. */
  144. uint8_t MinVoltageVid; /* Minimum Voltage ("Vmin") of ASIC */
  145. uint8_t MaxVoltageVid; /* Maximum Voltage allowable */
  146. uint8_t MaxVidStep; /* Max VID step that SMU will request. Multiple steps are taken if voltage change exceeds this value. */
  147. uint8_t padding8;
  148. uint8_t UlvPhaseSheddingPsi0; /* set this to 1 to set PSI0/1 to 1 in ULV mode */
  149. uint8_t UlvPhaseSheddingPsi1; /* set this to 1 to set PSI0/1 to 1 in ULV mode */
  150. uint8_t padding8_2[2];
  151. /* SOC Frequencies */
  152. PllSetting_t GfxclkLevel [NUM_GFXCLK_DPM_LEVELS];
  153. uint8_t SocclkDid [NUM_SOCCLK_DPM_LEVELS]; /* DID */
  154. uint8_t SocDpmVoltageIndex [NUM_SOCCLK_DPM_LEVELS];
  155. uint8_t VclkDid [NUM_UVD_DPM_LEVELS]; /* DID */
  156. uint8_t DclkDid [NUM_UVD_DPM_LEVELS]; /* DID */
  157. uint8_t UvdDpmVoltageIndex [NUM_UVD_DPM_LEVELS];
  158. uint8_t EclkDid [NUM_VCE_DPM_LEVELS]; /* DID */
  159. uint8_t VceDpmVoltageIndex [NUM_VCE_DPM_LEVELS];
  160. uint8_t Mp0clkDid [NUM_MP0CLK_DPM_LEVELS]; /* DID */
  161. uint8_t Mp0DpmVoltageIndex [NUM_MP0CLK_DPM_LEVELS];
  162. DisplayClockTable_t DisplayClockTable[DSPCLK_COUNT][NUM_DSPCLK_LEVELS];
  163. QuadraticInt_t DisplayClock2Gfxclk[DSPCLK_COUNT];
  164. uint8_t GfxDpmVoltageMode;
  165. uint8_t SocDpmVoltageMode;
  166. uint8_t UclkDpmVoltageMode;
  167. uint8_t UvdDpmVoltageMode;
  168. uint8_t VceDpmVoltageMode;
  169. uint8_t Mp0DpmVoltageMode;
  170. uint8_t DisplayDpmVoltageMode;
  171. uint8_t padding8_3;
  172. uint16_t GfxclkSlewRate;
  173. uint16_t padding;
  174. uint32_t LowGfxclkInterruptThreshold; /* in units of 10KHz */
  175. /* Alpha parameters for clock averages. ("255"=1) */
  176. uint8_t GfxclkAverageAlpha;
  177. uint8_t SocclkAverageAlpha;
  178. uint8_t UclkAverageAlpha;
  179. uint8_t GfxActivityAverageAlpha;
  180. /* UCLK States */
  181. uint8_t MemVid[NUM_UCLK_DPM_LEVELS]; /* VID */
  182. PllSetting_t UclkLevel[NUM_UCLK_DPM_LEVELS]; /* Full PLL settings */
  183. uint8_t MemSocVoltageIndex[NUM_UCLK_DPM_LEVELS];
  184. uint8_t LowestUclkReservedForUlv; /* Set this to 1 if UCLK DPM0 is reserved for ULV-mode only */
  185. uint8_t paddingUclk[3];
  186. uint16_t NumMemoryChannels; /* Used for memory bandwidth calculations */
  187. uint16_t MemoryChannelWidth; /* Used for memory bandwidth calculations */
  188. /* CKS Settings */
  189. uint8_t CksEnable[NUM_GFXCLK_DPM_LEVELS];
  190. uint8_t CksVidOffset[NUM_GFXCLK_DPM_LEVELS];
  191. /* MP0 Mapping Table */
  192. uint8_t PspLevelMap[NUM_PSP_LEVEL_MAP];
  193. /* Link DPM Settings */
  194. uint8_t PcieGenSpeed[NUM_LINK_LEVELS]; /* 0:PciE-gen1 1:PciE-gen2 2:PciE-gen3 */
  195. uint8_t PcieLaneCount[NUM_LINK_LEVELS]; /* 1=x1, 2=x2, 3=x4, 4=x8, 5=x12, 6=x16 */
  196. uint8_t LclkDid[NUM_LINK_LEVELS]; /* Leave at 0 to use hardcoded values in FW */
  197. uint8_t paddingLinkDpm[2];
  198. /* Fan Control */
  199. uint16_t FanStopTemp; /* Celcius */
  200. uint16_t FanStartTemp; /* Celcius */
  201. uint16_t FanGainEdge;
  202. uint16_t FanGainHotspot;
  203. uint16_t FanGainLiquid;
  204. uint16_t FanGainVrVddc;
  205. uint16_t FanGainVrMvdd;
  206. uint16_t FanGainPlx;
  207. uint16_t FanGainHbm;
  208. uint16_t FanPwmMin;
  209. uint16_t FanAcousticLimitRpm;
  210. uint16_t FanThrottlingRpm;
  211. uint16_t FanMaximumRpm;
  212. uint16_t FanTargetTemperature;
  213. uint16_t FanTargetGfxclk;
  214. uint8_t FanZeroRpmEnable;
  215. uint8_t FanSpare;
  216. /* The following are AFC override parameters. Leave at 0 to use FW defaults. */
  217. int16_t FuzzyFan_ErrorSetDelta;
  218. int16_t FuzzyFan_ErrorRateSetDelta;
  219. int16_t FuzzyFan_PwmSetDelta;
  220. uint16_t FuzzyFan_Reserved;
  221. /* GPIO Settings */
  222. uint8_t AcDcGpio; /* GPIO pin configured for AC/DC switching */
  223. uint8_t AcDcPolarity; /* GPIO polarity for AC/DC switching */
  224. uint8_t VR0HotGpio; /* GPIO pin configured for VR0 HOT event */
  225. uint8_t VR0HotPolarity; /* GPIO polarity for VR0 HOT event */
  226. uint8_t VR1HotGpio; /* GPIO pin configured for VR1 HOT event */
  227. uint8_t VR1HotPolarity; /* GPIO polarity for VR1 HOT event */
  228. uint8_t Padding1; /* replace GPIO pin configured for CTF */
  229. uint8_t Padding2; /* replace GPIO polarity for CTF */
  230. /* LED Display Settings */
  231. uint8_t LedPin0; /* GPIO number for LedPin[0] */
  232. uint8_t LedPin1; /* GPIO number for LedPin[1] */
  233. uint8_t LedPin2; /* GPIO number for LedPin[2] */
  234. uint8_t padding8_4;
  235. /* AVFS */
  236. uint8_t OverrideBtcGbCksOn;
  237. uint8_t OverrideAvfsGbCksOn;
  238. uint8_t PaddingAvfs8[2];
  239. GbVdroopTable_t BtcGbVdroopTableCksOn;
  240. GbVdroopTable_t BtcGbVdroopTableCksOff;
  241. QuadraticInt_t AvfsGbCksOn; /* Replacement equation */
  242. QuadraticInt_t AvfsGbCksOff; /* Replacement equation */
  243. uint8_t StaticVoltageOffsetVid[NUM_GFXCLK_DPM_LEVELS]; /* This values are added on to the final voltage calculation */
  244. /* Ageing Guardband Parameters */
  245. uint32_t AConstant[3];
  246. uint16_t DC_tol_sigma;
  247. uint16_t Platform_mean;
  248. uint16_t Platform_sigma;
  249. uint16_t PSM_Age_CompFactor;
  250. uint32_t DpmLevelPowerDelta;
  251. uint8_t EnableBoostState;
  252. uint8_t AConstant_Shift;
  253. uint8_t DC_tol_sigma_Shift;
  254. uint8_t PSM_Age_CompFactor_Shift;
  255. uint16_t BoostStartTemperature;
  256. uint16_t BoostStopTemperature;
  257. PllSetting_t GfxBoostState;
  258. uint8_t AcgEnable[NUM_GFXCLK_DPM_LEVELS];
  259. GbVdroopTable_t AcgBtcGbVdroopTable;
  260. QuadraticInt_t AcgAvfsGb;
  261. /* ACG Frequency Table, in Mhz */
  262. uint32_t AcgFreqTable[NUM_GFXCLK_DPM_LEVELS];
  263. /* Padding - ignore */
  264. uint32_t MmHubPadding[3]; /* SMU internal use */
  265. } PPTable_t;
  266. typedef struct {
  267. uint16_t MinClock; // This is either DCEFCLK or SOCCLK (in MHz)
  268. uint16_t MaxClock; // This is either DCEFCLK or SOCCLK (in MHz)
  269. uint16_t MinUclk;
  270. uint16_t MaxUclk;
  271. uint8_t WmSetting;
  272. uint8_t Padding[3];
  273. } WatermarkRowGeneric_t;
  274. #define NUM_WM_RANGES 4
  275. typedef enum {
  276. WM_SOCCLK = 0,
  277. WM_DCEFCLK,
  278. WM_COUNT,
  279. } WM_CLOCK_e;
  280. typedef struct {
  281. /* Watermarks */
  282. WatermarkRowGeneric_t WatermarkRow[WM_COUNT][NUM_WM_RANGES];
  283. uint32_t MmHubPadding[7]; /* SMU internal use */
  284. } Watermarks_t;
  285. #ifdef PPTABLE_V10_SMU_VERSION
  286. typedef struct {
  287. float AvfsGbCksOn[NUM_GFXCLK_DPM_LEVELS];
  288. float AcBtcGbCksOn[NUM_GFXCLK_DPM_LEVELS];
  289. float AvfsGbCksOff[NUM_GFXCLK_DPM_LEVELS];
  290. float AcBtcGbCksOff[NUM_GFXCLK_DPM_LEVELS];
  291. float DcBtcGb;
  292. uint32_t MmHubPadding[7]; /* SMU internal use */
  293. } AvfsTable_t;
  294. #else
  295. typedef struct {
  296. uint32_t AvfsGbCksOn[NUM_GFXCLK_DPM_LEVELS];
  297. uint32_t AcBtcGbCksOn[NUM_GFXCLK_DPM_LEVELS];
  298. uint32_t AvfsGbCksOff[NUM_GFXCLK_DPM_LEVELS];
  299. uint32_t AcBtcGbCksOff[NUM_GFXCLK_DPM_LEVELS];
  300. uint32_t DcBtcGb;
  301. uint32_t MmHubPadding[7]; /* SMU internal use */
  302. } AvfsTable_t;
  303. #endif
  304. typedef struct {
  305. uint16_t avgPsmCount[30];
  306. uint16_t minPsmCount[30];
  307. float avgPsmVoltage[30];
  308. float minPsmVoltage[30];
  309. uint32_t MmHubPadding[7]; /* SMU internal use */
  310. } AvfsDebugTable_t;
  311. typedef struct {
  312. uint8_t AvfsEn;
  313. uint8_t AvfsVersion;
  314. uint8_t Padding[2];
  315. int32_t VFT0_m1; /* Q8.24 */
  316. int32_t VFT0_m2; /* Q12.12 */
  317. int32_t VFT0_b; /* Q32 */
  318. int32_t VFT1_m1; /* Q8.16 */
  319. int32_t VFT1_m2; /* Q12.12 */
  320. int32_t VFT1_b; /* Q32 */
  321. int32_t VFT2_m1; /* Q8.16 */
  322. int32_t VFT2_m2; /* Q12.12 */
  323. int32_t VFT2_b; /* Q32 */
  324. int32_t AvfsGb0_m1; /* Q8.16 */
  325. int32_t AvfsGb0_m2; /* Q12.12 */
  326. int32_t AvfsGb0_b; /* Q32 */
  327. int32_t AcBtcGb_m1; /* Q8.24 */
  328. int32_t AcBtcGb_m2; /* Q12.12 */
  329. int32_t AcBtcGb_b; /* Q32 */
  330. uint32_t AvfsTempCold;
  331. uint32_t AvfsTempMid;
  332. uint32_t AvfsTempHot;
  333. uint32_t InversionVoltage; /* in mV with 2 fractional bits */
  334. int32_t P2V_m1; /* Q8.24 */
  335. int32_t P2V_m2; /* Q12.12 */
  336. int32_t P2V_b; /* Q32 */
  337. uint32_t P2VCharzFreq; /* in 10KHz units */
  338. uint32_t EnabledAvfsModules;
  339. uint32_t MmHubPadding[7]; /* SMU internal use */
  340. } AvfsFuseOverride_t;
  341. /* These defines are used with the following messages:
  342. * SMC_MSG_TransferTableDram2Smu
  343. * SMC_MSG_TransferTableSmu2Dram
  344. */
  345. #define TABLE_PPTABLE 0
  346. #define TABLE_WATERMARKS 1
  347. #define TABLE_AVFS 2
  348. #define TABLE_AVFS_PSM_DEBUG 3
  349. #define TABLE_AVFS_FUSE_OVERRIDE 4
  350. #define TABLE_PMSTATUSLOG 5
  351. #define TABLE_COUNT 6
  352. /* These defines are used with the SMC_MSG_SetUclkFastSwitch message. */
  353. #define UCLK_SWITCH_SLOW 0
  354. #define UCLK_SWITCH_FAST 1
  355. /* GFX DIDT Configuration */
  356. #define SQ_Enable_MASK 0x1
  357. #define SQ_IR_MASK 0x2
  358. #define SQ_PCC_MASK 0x4
  359. #define SQ_EDC_MASK 0x8
  360. #define TCP_Enable_MASK 0x100
  361. #define TCP_IR_MASK 0x200
  362. #define TCP_PCC_MASK 0x400
  363. #define TCP_EDC_MASK 0x800
  364. #define TD_Enable_MASK 0x10000
  365. #define TD_IR_MASK 0x20000
  366. #define TD_PCC_MASK 0x40000
  367. #define TD_EDC_MASK 0x80000
  368. #define DB_Enable_MASK 0x1000000
  369. #define DB_IR_MASK 0x2000000
  370. #define DB_PCC_MASK 0x4000000
  371. #define DB_EDC_MASK 0x8000000
  372. #define SQ_Enable_SHIFT 0
  373. #define SQ_IR_SHIFT 1
  374. #define SQ_PCC_SHIFT 2
  375. #define SQ_EDC_SHIFT 3
  376. #define TCP_Enable_SHIFT 8
  377. #define TCP_IR_SHIFT 9
  378. #define TCP_PCC_SHIFT 10
  379. #define TCP_EDC_SHIFT 11
  380. #define TD_Enable_SHIFT 16
  381. #define TD_IR_SHIFT 17
  382. #define TD_PCC_SHIFT 18
  383. #define TD_EDC_SHIFT 19
  384. #define DB_Enable_SHIFT 24
  385. #define DB_IR_SHIFT 25
  386. #define DB_PCC_SHIFT 26
  387. #define DB_EDC_SHIFT 27
  388. #define REMOVE_FMAX_MARGIN_BIT 0x0
  389. #define REMOVE_DCTOL_MARGIN_BIT 0x1
  390. #define REMOVE_PLATFORM_MARGIN_BIT 0x2
  391. #endif