ni_dpm.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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 __NI_DPM_H__
  24. #define __NI_DPM_H__
  25. #include "cypress_dpm.h"
  26. #include "btc_dpm.h"
  27. #include "nislands_smc.h"
  28. struct ni_clock_registers {
  29. u32 cg_spll_func_cntl;
  30. u32 cg_spll_func_cntl_2;
  31. u32 cg_spll_func_cntl_3;
  32. u32 cg_spll_func_cntl_4;
  33. u32 cg_spll_spread_spectrum;
  34. u32 cg_spll_spread_spectrum_2;
  35. u32 mclk_pwrmgt_cntl;
  36. u32 dll_cntl;
  37. u32 mpll_ad_func_cntl;
  38. u32 mpll_ad_func_cntl_2;
  39. u32 mpll_dq_func_cntl;
  40. u32 mpll_dq_func_cntl_2;
  41. u32 mpll_ss1;
  42. u32 mpll_ss2;
  43. };
  44. struct ni_mc_reg_entry {
  45. u32 mclk_max;
  46. u32 mc_data[SMC_NISLANDS_MC_REGISTER_ARRAY_SIZE];
  47. };
  48. struct ni_mc_reg_table {
  49. u8 last;
  50. u8 num_entries;
  51. u16 valid_flag;
  52. struct ni_mc_reg_entry mc_reg_table_entry[MAX_AC_TIMING_ENTRIES];
  53. SMC_NIslands_MCRegisterAddress mc_reg_address[SMC_NISLANDS_MC_REGISTER_ARRAY_SIZE];
  54. };
  55. #define NISLANDS_MCREGISTERTABLE_FIRST_DRIVERSTATE_SLOT 2
  56. enum ni_dc_cac_level
  57. {
  58. NISLANDS_DCCAC_LEVEL_0 = 0,
  59. NISLANDS_DCCAC_LEVEL_1,
  60. NISLANDS_DCCAC_LEVEL_2,
  61. NISLANDS_DCCAC_LEVEL_3,
  62. NISLANDS_DCCAC_LEVEL_4,
  63. NISLANDS_DCCAC_LEVEL_5,
  64. NISLANDS_DCCAC_LEVEL_6,
  65. NISLANDS_DCCAC_LEVEL_7,
  66. NISLANDS_DCCAC_MAX_LEVELS
  67. };
  68. struct ni_leakage_coeffients
  69. {
  70. u32 at;
  71. u32 bt;
  72. u32 av;
  73. u32 bv;
  74. s32 t_slope;
  75. s32 t_intercept;
  76. u32 t_ref;
  77. };
  78. struct ni_cac_data
  79. {
  80. struct ni_leakage_coeffients leakage_coefficients;
  81. u32 i_leakage;
  82. s32 leakage_minimum_temperature;
  83. u32 pwr_const;
  84. u32 dc_cac_value;
  85. u32 bif_cac_value;
  86. u32 lkge_pwr;
  87. u8 mc_wr_weight;
  88. u8 mc_rd_weight;
  89. u8 allow_ovrflw;
  90. u8 num_win_tdp;
  91. u8 l2num_win_tdp;
  92. u8 lts_truncate_n;
  93. };
  94. struct ni_cac_weights
  95. {
  96. u32 weight_tcp_sig0;
  97. u32 weight_tcp_sig1;
  98. u32 weight_ta_sig;
  99. u32 weight_tcc_en0;
  100. u32 weight_tcc_en1;
  101. u32 weight_tcc_en2;
  102. u32 weight_cb_en0;
  103. u32 weight_cb_en1;
  104. u32 weight_cb_en2;
  105. u32 weight_cb_en3;
  106. u32 weight_db_sig0;
  107. u32 weight_db_sig1;
  108. u32 weight_db_sig2;
  109. u32 weight_db_sig3;
  110. u32 weight_sxm_sig0;
  111. u32 weight_sxm_sig1;
  112. u32 weight_sxm_sig2;
  113. u32 weight_sxs_sig0;
  114. u32 weight_sxs_sig1;
  115. u32 weight_xbr_0;
  116. u32 weight_xbr_1;
  117. u32 weight_xbr_2;
  118. u32 weight_spi_sig0;
  119. u32 weight_spi_sig1;
  120. u32 weight_spi_sig2;
  121. u32 weight_spi_sig3;
  122. u32 weight_spi_sig4;
  123. u32 weight_spi_sig5;
  124. u32 weight_lds_sig0;
  125. u32 weight_lds_sig1;
  126. u32 weight_sc;
  127. u32 weight_bif;
  128. u32 weight_cp;
  129. u32 weight_pa_sig0;
  130. u32 weight_pa_sig1;
  131. u32 weight_vgt_sig0;
  132. u32 weight_vgt_sig1;
  133. u32 weight_vgt_sig2;
  134. u32 weight_dc_sig0;
  135. u32 weight_dc_sig1;
  136. u32 weight_dc_sig2;
  137. u32 weight_dc_sig3;
  138. u32 weight_uvd_sig0;
  139. u32 weight_uvd_sig1;
  140. u32 weight_spare0;
  141. u32 weight_spare1;
  142. u32 weight_sq_vsp;
  143. u32 weight_sq_vsp0;
  144. u32 weight_sq_gpr;
  145. u32 ovr_mode_spare_0;
  146. u32 ovr_val_spare_0;
  147. u32 ovr_mode_spare_1;
  148. u32 ovr_val_spare_1;
  149. u32 vsp;
  150. u32 vsp0;
  151. u32 gpr;
  152. u8 mc_read_weight;
  153. u8 mc_write_weight;
  154. u32 tid_cnt;
  155. u32 tid_unit;
  156. u32 l2_lta_window_size;
  157. u32 lts_truncate;
  158. u32 dc_cac[NISLANDS_DCCAC_MAX_LEVELS];
  159. u32 pcie_cac[SMC_NISLANDS_BIF_LUT_NUM_OF_ENTRIES];
  160. bool enable_power_containment_by_default;
  161. };
  162. struct ni_ps {
  163. u16 performance_level_count;
  164. bool dc_compatible;
  165. struct rv7xx_pl performance_levels[NISLANDS_MAX_SMC_PERFORMANCE_LEVELS_PER_SWSTATE];
  166. };
  167. struct ni_power_info {
  168. /* must be first! */
  169. struct evergreen_power_info eg;
  170. struct ni_clock_registers clock_registers;
  171. struct ni_mc_reg_table mc_reg_table;
  172. u32 mclk_rtt_mode_threshold;
  173. /* flags */
  174. bool use_power_boost_limit;
  175. bool support_cac_long_term_average;
  176. bool cac_enabled;
  177. bool cac_configuration_required;
  178. bool driver_calculate_cac_leakage;
  179. bool pc_enabled;
  180. bool enable_power_containment;
  181. bool enable_cac;
  182. bool enable_sq_ramping;
  183. /* smc offsets */
  184. u16 arb_table_start;
  185. u16 fan_table_start;
  186. u16 cac_table_start;
  187. u16 spll_table_start;
  188. /* CAC stuff */
  189. struct ni_cac_data cac_data;
  190. u32 dc_cac_table[NISLANDS_DCCAC_MAX_LEVELS];
  191. const struct ni_cac_weights *cac_weights;
  192. u8 lta_window_size;
  193. u8 lts_truncate;
  194. struct ni_ps current_ps;
  195. struct ni_ps requested_ps;
  196. /* scratch structs */
  197. SMC_NIslands_MCRegisters smc_mc_reg_table;
  198. NISLANDS_SMC_STATETABLE smc_statetable;
  199. };
  200. #define NISLANDS_INITIAL_STATE_ARB_INDEX 0
  201. #define NISLANDS_ACPI_STATE_ARB_INDEX 1
  202. #define NISLANDS_ULV_STATE_ARB_INDEX 2
  203. #define NISLANDS_DRIVER_STATE_ARB_INDEX 3
  204. #define NISLANDS_DPM2_MAX_PULSE_SKIP 256
  205. #define NISLANDS_DPM2_NEAR_TDP_DEC 10
  206. #define NISLANDS_DPM2_ABOVE_SAFE_INC 5
  207. #define NISLANDS_DPM2_BELOW_SAFE_INC 20
  208. #define NISLANDS_DPM2_TDP_SAFE_LIMIT_PERCENT 80
  209. #define NISLANDS_DPM2_MAXPS_PERCENT_H 90
  210. #define NISLANDS_DPM2_MAXPS_PERCENT_M 0
  211. #define NISLANDS_DPM2_SQ_RAMP_MAX_POWER 0x3FFF
  212. #define NISLANDS_DPM2_SQ_RAMP_MIN_POWER 0x12
  213. #define NISLANDS_DPM2_SQ_RAMP_MAX_POWER_DELTA 0x15
  214. #define NISLANDS_DPM2_SQ_RAMP_STI_SIZE 0x1E
  215. #define NISLANDS_DPM2_SQ_RAMP_LTI_RATIO 0xF
  216. int ni_copy_and_switch_arb_sets(struct radeon_device *rdev,
  217. u32 arb_freq_src, u32 arb_freq_dest);
  218. void ni_update_current_ps(struct radeon_device *rdev,
  219. struct radeon_ps *rps);
  220. void ni_update_requested_ps(struct radeon_device *rdev,
  221. struct radeon_ps *rps);
  222. void ni_set_uvd_clock_before_set_eng_clock(struct radeon_device *rdev,
  223. struct radeon_ps *new_ps,
  224. struct radeon_ps *old_ps);
  225. void ni_set_uvd_clock_after_set_eng_clock(struct radeon_device *rdev,
  226. struct radeon_ps *new_ps,
  227. struct radeon_ps *old_ps);
  228. bool ni_dpm_vblank_too_short(struct radeon_device *rdev);
  229. #endif