rv770_smc.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. /*
  2. * Copyright 2011 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 __RV770_SMC_H__
  24. #define __RV770_SMC_H__
  25. #include "ppsmc.h"
  26. #pragma pack(push, 1)
  27. #define RV770_SMC_TABLE_ADDRESS 0xB000
  28. #define RV770_SMC_PERFORMANCE_LEVELS_PER_SWSTATE 3
  29. struct RV770_SMC_SCLK_VALUE
  30. {
  31. uint32_t vCG_SPLL_FUNC_CNTL;
  32. uint32_t vCG_SPLL_FUNC_CNTL_2;
  33. uint32_t vCG_SPLL_FUNC_CNTL_3;
  34. uint32_t vCG_SPLL_SPREAD_SPECTRUM;
  35. uint32_t vCG_SPLL_SPREAD_SPECTRUM_2;
  36. uint32_t sclk_value;
  37. };
  38. typedef struct RV770_SMC_SCLK_VALUE RV770_SMC_SCLK_VALUE;
  39. struct RV770_SMC_MCLK_VALUE
  40. {
  41. uint32_t vMPLL_AD_FUNC_CNTL;
  42. uint32_t vMPLL_AD_FUNC_CNTL_2;
  43. uint32_t vMPLL_DQ_FUNC_CNTL;
  44. uint32_t vMPLL_DQ_FUNC_CNTL_2;
  45. uint32_t vMCLK_PWRMGT_CNTL;
  46. uint32_t vDLL_CNTL;
  47. uint32_t vMPLL_SS;
  48. uint32_t vMPLL_SS2;
  49. uint32_t mclk_value;
  50. };
  51. typedef struct RV770_SMC_MCLK_VALUE RV770_SMC_MCLK_VALUE;
  52. struct RV730_SMC_MCLK_VALUE
  53. {
  54. uint32_t vMCLK_PWRMGT_CNTL;
  55. uint32_t vDLL_CNTL;
  56. uint32_t vMPLL_FUNC_CNTL;
  57. uint32_t vMPLL_FUNC_CNTL2;
  58. uint32_t vMPLL_FUNC_CNTL3;
  59. uint32_t vMPLL_SS;
  60. uint32_t vMPLL_SS2;
  61. uint32_t mclk_value;
  62. };
  63. typedef struct RV730_SMC_MCLK_VALUE RV730_SMC_MCLK_VALUE;
  64. struct RV770_SMC_VOLTAGE_VALUE
  65. {
  66. uint16_t value;
  67. uint8_t index;
  68. uint8_t padding;
  69. };
  70. typedef struct RV770_SMC_VOLTAGE_VALUE RV770_SMC_VOLTAGE_VALUE;
  71. union RV7XX_SMC_MCLK_VALUE
  72. {
  73. RV770_SMC_MCLK_VALUE mclk770;
  74. RV730_SMC_MCLK_VALUE mclk730;
  75. };
  76. typedef union RV7XX_SMC_MCLK_VALUE RV7XX_SMC_MCLK_VALUE, *LPRV7XX_SMC_MCLK_VALUE;
  77. struct RV770_SMC_HW_PERFORMANCE_LEVEL
  78. {
  79. uint8_t arbValue;
  80. union{
  81. uint8_t seqValue;
  82. uint8_t ACIndex;
  83. };
  84. uint8_t displayWatermark;
  85. uint8_t gen2PCIE;
  86. uint8_t gen2XSP;
  87. uint8_t backbias;
  88. uint8_t strobeMode;
  89. uint8_t mcFlags;
  90. uint32_t aT;
  91. uint32_t bSP;
  92. RV770_SMC_SCLK_VALUE sclk;
  93. RV7XX_SMC_MCLK_VALUE mclk;
  94. RV770_SMC_VOLTAGE_VALUE vddc;
  95. RV770_SMC_VOLTAGE_VALUE mvdd;
  96. RV770_SMC_VOLTAGE_VALUE vddci;
  97. uint8_t reserved1;
  98. uint8_t reserved2;
  99. uint8_t stateFlags;
  100. uint8_t padding;
  101. };
  102. #define SMC_STROBE_RATIO 0x0F
  103. #define SMC_STROBE_ENABLE 0x10
  104. #define SMC_MC_EDC_RD_FLAG 0x01
  105. #define SMC_MC_EDC_WR_FLAG 0x02
  106. #define SMC_MC_RTT_ENABLE 0x04
  107. #define SMC_MC_STUTTER_EN 0x08
  108. typedef struct RV770_SMC_HW_PERFORMANCE_LEVEL RV770_SMC_HW_PERFORMANCE_LEVEL;
  109. struct RV770_SMC_SWSTATE
  110. {
  111. uint8_t flags;
  112. uint8_t padding1;
  113. uint8_t padding2;
  114. uint8_t padding3;
  115. RV770_SMC_HW_PERFORMANCE_LEVEL levels[RV770_SMC_PERFORMANCE_LEVELS_PER_SWSTATE];
  116. };
  117. typedef struct RV770_SMC_SWSTATE RV770_SMC_SWSTATE;
  118. #define RV770_SMC_VOLTAGEMASK_VDDC 0
  119. #define RV770_SMC_VOLTAGEMASK_MVDD 1
  120. #define RV770_SMC_VOLTAGEMASK_VDDCI 2
  121. #define RV770_SMC_VOLTAGEMASK_MAX 4
  122. struct RV770_SMC_VOLTAGEMASKTABLE
  123. {
  124. uint8_t highMask[RV770_SMC_VOLTAGEMASK_MAX];
  125. uint32_t lowMask[RV770_SMC_VOLTAGEMASK_MAX];
  126. };
  127. typedef struct RV770_SMC_VOLTAGEMASKTABLE RV770_SMC_VOLTAGEMASKTABLE;
  128. #define MAX_NO_VREG_STEPS 32
  129. struct RV770_SMC_STATETABLE
  130. {
  131. uint8_t thermalProtectType;
  132. uint8_t systemFlags;
  133. uint8_t maxVDDCIndexInPPTable;
  134. uint8_t extraFlags;
  135. uint8_t highSMIO[MAX_NO_VREG_STEPS];
  136. uint32_t lowSMIO[MAX_NO_VREG_STEPS];
  137. RV770_SMC_VOLTAGEMASKTABLE voltageMaskTable;
  138. RV770_SMC_SWSTATE initialState;
  139. RV770_SMC_SWSTATE ACPIState;
  140. RV770_SMC_SWSTATE driverState;
  141. RV770_SMC_SWSTATE ULVState;
  142. };
  143. typedef struct RV770_SMC_STATETABLE RV770_SMC_STATETABLE;
  144. #define PPSMC_STATEFLAG_AUTO_PULSE_SKIP 0x01
  145. #pragma pack(pop)
  146. #define RV770_SMC_SOFT_REGISTERS_START 0x104
  147. #define RV770_SMC_SOFT_REGISTER_mclk_chg_timeout 0x0
  148. #define RV770_SMC_SOFT_REGISTER_baby_step_timer 0x8
  149. #define RV770_SMC_SOFT_REGISTER_delay_bbias 0xC
  150. #define RV770_SMC_SOFT_REGISTER_delay_vreg 0x10
  151. #define RV770_SMC_SOFT_REGISTER_delay_acpi 0x2C
  152. #define RV770_SMC_SOFT_REGISTER_seq_index 0x64
  153. #define RV770_SMC_SOFT_REGISTER_mvdd_chg_time 0x68
  154. #define RV770_SMC_SOFT_REGISTER_mclk_switch_lim 0x78
  155. #define RV770_SMC_SOFT_REGISTER_mc_block_delay 0x90
  156. #define RV770_SMC_SOFT_REGISTER_uvd_enabled 0x9C
  157. #define RV770_SMC_SOFT_REGISTER_is_asic_lombok 0xA0
  158. int rv770_copy_bytes_to_smc(struct radeon_device *rdev,
  159. u16 smc_start_address, const u8 *src,
  160. u16 byte_count, u16 limit);
  161. void rv770_start_smc(struct radeon_device *rdev);
  162. void rv770_reset_smc(struct radeon_device *rdev);
  163. void rv770_stop_smc_clock(struct radeon_device *rdev);
  164. void rv770_start_smc_clock(struct radeon_device *rdev);
  165. bool rv770_is_smc_running(struct radeon_device *rdev);
  166. PPSMC_Result rv770_send_msg_to_smc(struct radeon_device *rdev, PPSMC_Msg msg);
  167. PPSMC_Result rv770_wait_for_smc_inactive(struct radeon_device *rdev);
  168. int rv770_read_smc_sram_dword(struct radeon_device *rdev,
  169. u16 smc_address, u32 *value, u16 limit);
  170. int rv770_write_smc_sram_dword(struct radeon_device *rdev,
  171. u16 smc_address, u32 value, u16 limit);
  172. int rv770_load_smc_ucode(struct radeon_device *rdev,
  173. u16 limit);
  174. #endif