si_dpm.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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 __SI_DPM_H__
  24. #define __SI_DPM_H__
  25. #include "ni_dpm.h"
  26. #include "sislands_smc.h"
  27. enum si_cac_config_reg_type
  28. {
  29. SISLANDS_CACCONFIG_MMR = 0,
  30. SISLANDS_CACCONFIG_CGIND,
  31. SISLANDS_CACCONFIG_MAX
  32. };
  33. struct si_cac_config_reg
  34. {
  35. u32 offset;
  36. u32 mask;
  37. u32 shift;
  38. u32 value;
  39. enum si_cac_config_reg_type type;
  40. };
  41. struct si_powertune_data
  42. {
  43. u32 cac_window;
  44. u32 l2_lta_window_size_default;
  45. u8 lts_truncate_default;
  46. u8 shift_n_default;
  47. u8 operating_temp;
  48. struct ni_leakage_coeffients leakage_coefficients;
  49. u32 fixed_kt;
  50. u32 lkge_lut_v0_percent;
  51. u8 dc_cac[NISLANDS_DCCAC_MAX_LEVELS];
  52. bool enable_powertune_by_default;
  53. };
  54. struct si_dyn_powertune_data
  55. {
  56. u32 cac_leakage;
  57. s32 leakage_minimum_temperature;
  58. u32 wintime;
  59. u32 l2_lta_window_size;
  60. u8 lts_truncate;
  61. u8 shift_n;
  62. u8 dc_pwr_value;
  63. bool disable_uvd_powertune;
  64. };
  65. struct si_dte_data
  66. {
  67. u32 tau[SMC_SISLANDS_DTE_MAX_FILTER_STAGES];
  68. u32 r[SMC_SISLANDS_DTE_MAX_FILTER_STAGES];
  69. u32 k;
  70. u32 t0;
  71. u32 max_t;
  72. u8 window_size;
  73. u8 temp_select;
  74. u8 dte_mode;
  75. u8 tdep_count;
  76. u8 t_limits[SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE];
  77. u32 tdep_tau[SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE];
  78. u32 tdep_r[SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE];
  79. u32 t_threshold;
  80. bool enable_dte_by_default;
  81. };
  82. struct si_clock_registers {
  83. u32 cg_spll_func_cntl;
  84. u32 cg_spll_func_cntl_2;
  85. u32 cg_spll_func_cntl_3;
  86. u32 cg_spll_func_cntl_4;
  87. u32 cg_spll_spread_spectrum;
  88. u32 cg_spll_spread_spectrum_2;
  89. u32 dll_cntl;
  90. u32 mclk_pwrmgt_cntl;
  91. u32 mpll_ad_func_cntl;
  92. u32 mpll_dq_func_cntl;
  93. u32 mpll_func_cntl;
  94. u32 mpll_func_cntl_1;
  95. u32 mpll_func_cntl_2;
  96. u32 mpll_ss1;
  97. u32 mpll_ss2;
  98. };
  99. struct si_mc_reg_entry {
  100. u32 mclk_max;
  101. u32 mc_data[SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE];
  102. };
  103. struct si_mc_reg_table {
  104. u8 last;
  105. u8 num_entries;
  106. u16 valid_flag;
  107. struct si_mc_reg_entry mc_reg_table_entry[MAX_AC_TIMING_ENTRIES];
  108. SMC_NIslands_MCRegisterAddress mc_reg_address[SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE];
  109. };
  110. #define SISLANDS_MCREGISTERTABLE_INITIAL_SLOT 0
  111. #define SISLANDS_MCREGISTERTABLE_ACPI_SLOT 1
  112. #define SISLANDS_MCREGISTERTABLE_ULV_SLOT 2
  113. #define SISLANDS_MCREGISTERTABLE_FIRST_DRIVERSTATE_SLOT 3
  114. struct si_leakage_voltage_entry
  115. {
  116. u16 voltage;
  117. u16 leakage_index;
  118. };
  119. #define SISLANDS_LEAKAGE_INDEX0 0xff01
  120. #define SISLANDS_MAX_LEAKAGE_COUNT 4
  121. struct si_leakage_voltage
  122. {
  123. u16 count;
  124. struct si_leakage_voltage_entry entries[SISLANDS_MAX_LEAKAGE_COUNT];
  125. };
  126. #define SISLANDS_MAX_HARDWARE_POWERLEVELS 5
  127. struct si_ulv_param {
  128. bool supported;
  129. u32 cg_ulv_control;
  130. u32 cg_ulv_parameter;
  131. u32 volt_change_delay;
  132. struct rv7xx_pl pl;
  133. bool one_pcie_lane_in_ulv;
  134. };
  135. struct si_power_info {
  136. /* must be first! */
  137. struct ni_power_info ni;
  138. struct si_clock_registers clock_registers;
  139. struct si_mc_reg_table mc_reg_table;
  140. struct atom_voltage_table mvdd_voltage_table;
  141. struct atom_voltage_table vddc_phase_shed_table;
  142. struct si_leakage_voltage leakage_voltage;
  143. u16 mvdd_bootup_value;
  144. struct si_ulv_param ulv;
  145. u32 max_cu;
  146. /* pcie gen */
  147. enum radeon_pcie_gen force_pcie_gen;
  148. enum radeon_pcie_gen boot_pcie_gen;
  149. enum radeon_pcie_gen acpi_pcie_gen;
  150. u32 sys_pcie_mask;
  151. /* flags */
  152. bool enable_dte;
  153. bool enable_ppm;
  154. bool vddc_phase_shed_control;
  155. bool pspp_notify_required;
  156. bool sclk_deep_sleep_above_low;
  157. bool voltage_control_svi2;
  158. bool vddci_control_svi2;
  159. /* smc offsets */
  160. u32 sram_end;
  161. u32 state_table_start;
  162. u32 soft_regs_start;
  163. u32 mc_reg_table_start;
  164. u32 arb_table_start;
  165. u32 cac_table_start;
  166. u32 dte_table_start;
  167. u32 spll_table_start;
  168. u32 papm_cfg_table_start;
  169. u32 fan_table_start;
  170. /* CAC stuff */
  171. const struct si_cac_config_reg *cac_weights;
  172. const struct si_cac_config_reg *lcac_config;
  173. const struct si_cac_config_reg *cac_override;
  174. const struct si_powertune_data *powertune_data;
  175. struct si_dyn_powertune_data dyn_powertune_data;
  176. /* DTE stuff */
  177. struct si_dte_data dte_data;
  178. /* scratch structs */
  179. SMC_SIslands_MCRegisters smc_mc_reg_table;
  180. SISLANDS_SMC_STATETABLE smc_statetable;
  181. PP_SIslands_PAPMParameters papm_parm;
  182. /* SVI2 */
  183. u8 svd_gpio_id;
  184. u8 svc_gpio_id;
  185. /* fan control */
  186. bool fan_ctrl_is_in_default_mode;
  187. u32 t_min;
  188. u32 fan_ctrl_default_mode;
  189. bool fan_is_controlled_by_smc;
  190. };
  191. #define SISLANDS_INITIAL_STATE_ARB_INDEX 0
  192. #define SISLANDS_ACPI_STATE_ARB_INDEX 1
  193. #define SISLANDS_ULV_STATE_ARB_INDEX 2
  194. #define SISLANDS_DRIVER_STATE_ARB_INDEX 3
  195. #define SISLANDS_DPM2_MAX_PULSE_SKIP 256
  196. #define SISLANDS_DPM2_NEAR_TDP_DEC 10
  197. #define SISLANDS_DPM2_ABOVE_SAFE_INC 5
  198. #define SISLANDS_DPM2_BELOW_SAFE_INC 20
  199. #define SISLANDS_DPM2_TDP_SAFE_LIMIT_PERCENT 80
  200. #define SISLANDS_DPM2_MAXPS_PERCENT_H 99
  201. #define SISLANDS_DPM2_MAXPS_PERCENT_M 99
  202. #define SISLANDS_DPM2_SQ_RAMP_MAX_POWER 0x3FFF
  203. #define SISLANDS_DPM2_SQ_RAMP_MIN_POWER 0x12
  204. #define SISLANDS_DPM2_SQ_RAMP_MAX_POWER_DELTA 0x15
  205. #define SISLANDS_DPM2_SQ_RAMP_STI_SIZE 0x1E
  206. #define SISLANDS_DPM2_SQ_RAMP_LTI_RATIO 0xF
  207. #define SISLANDS_DPM2_PWREFFICIENCYRATIO_MARGIN 10
  208. #define SISLANDS_VRC_DFLT 0xC000B3
  209. #define SISLANDS_ULVVOLTAGECHANGEDELAY_DFLT 1687
  210. #define SISLANDS_CGULVPARAMETER_DFLT 0x00040035
  211. #define SISLANDS_CGULVCONTROL_DFLT 0x1f007550
  212. #endif