si_dpm.h 6.7 KB

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