kv_dpm.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. /*
  2. * Copyright 2013 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 __KV_DPM_H__
  24. #define __KV_DPM_H__
  25. #define SMU__NUM_SCLK_DPM_STATE 8
  26. #define SMU__NUM_MCLK_DPM_LEVELS 4
  27. #define SMU__NUM_LCLK_DPM_LEVELS 8
  28. #define SMU__NUM_PCIE_DPM_LEVELS 0 /* ??? */
  29. #include "smu7_fusion.h"
  30. #include "ppsmc.h"
  31. #define SUMO_MAX_HARDWARE_POWERLEVELS 5
  32. #define SUMO_MAX_NUMBER_VOLTAGES 4
  33. struct sumo_vid_mapping_entry {
  34. u16 vid_2bit;
  35. u16 vid_7bit;
  36. };
  37. struct sumo_vid_mapping_table {
  38. u32 num_entries;
  39. struct sumo_vid_mapping_entry entries[SUMO_MAX_NUMBER_VOLTAGES];
  40. };
  41. struct sumo_sclk_voltage_mapping_entry {
  42. u32 sclk_frequency;
  43. u16 vid_2bit;
  44. u16 rsv;
  45. };
  46. struct sumo_sclk_voltage_mapping_table {
  47. u32 num_max_dpm_entries;
  48. struct sumo_sclk_voltage_mapping_entry entries[SUMO_MAX_HARDWARE_POWERLEVELS];
  49. };
  50. #define TRINITY_AT_DFLT 30
  51. #define KV_NUM_NBPSTATES 4
  52. enum kv_pt_config_reg_type {
  53. KV_CONFIGREG_MMR = 0,
  54. KV_CONFIGREG_SMC_IND,
  55. KV_CONFIGREG_DIDT_IND,
  56. KV_CONFIGREG_CACHE,
  57. KV_CONFIGREG_MAX
  58. };
  59. struct kv_pt_config_reg {
  60. u32 offset;
  61. u32 mask;
  62. u32 shift;
  63. u32 value;
  64. enum kv_pt_config_reg_type type;
  65. };
  66. struct kv_lcac_config_values {
  67. u32 block_id;
  68. u32 signal_id;
  69. u32 t;
  70. };
  71. struct kv_lcac_config_reg {
  72. u32 cntl;
  73. u32 block_mask;
  74. u32 block_shift;
  75. u32 signal_mask;
  76. u32 signal_shift;
  77. u32 t_mask;
  78. u32 t_shift;
  79. u32 enable_mask;
  80. u32 enable_shift;
  81. };
  82. struct kv_pl {
  83. u32 sclk;
  84. u8 vddc_index;
  85. u8 ds_divider_index;
  86. u8 ss_divider_index;
  87. u8 allow_gnb_slow;
  88. u8 force_nbp_state;
  89. u8 display_wm;
  90. u8 vce_wm;
  91. };
  92. struct kv_ps {
  93. struct kv_pl levels[SUMO_MAX_HARDWARE_POWERLEVELS];
  94. u32 num_levels;
  95. bool need_dfs_bypass;
  96. u8 dpm0_pg_nb_ps_lo;
  97. u8 dpm0_pg_nb_ps_hi;
  98. u8 dpmx_nb_ps_lo;
  99. u8 dpmx_nb_ps_hi;
  100. };
  101. struct kv_sys_info {
  102. u32 bootup_uma_clk;
  103. u32 bootup_sclk;
  104. u32 dentist_vco_freq;
  105. u32 nb_dpm_enable;
  106. u32 nbp_memory_clock[KV_NUM_NBPSTATES];
  107. u32 nbp_n_clock[KV_NUM_NBPSTATES];
  108. u16 bootup_nb_voltage_index;
  109. u8 htc_tmp_lmt;
  110. u8 htc_hyst_lmt;
  111. struct sumo_sclk_voltage_mapping_table sclk_voltage_mapping_table;
  112. struct sumo_vid_mapping_table vid_mapping_table;
  113. u32 uma_channel_number;
  114. };
  115. struct kv_power_info {
  116. u32 at[SUMO_MAX_HARDWARE_POWERLEVELS];
  117. u32 voltage_drop_t;
  118. struct kv_sys_info sys_info;
  119. struct kv_pl boot_pl;
  120. bool enable_nb_ps_policy;
  121. bool disable_nb_ps3_in_battery;
  122. bool video_start;
  123. bool battery_state;
  124. u32 lowest_valid;
  125. u32 highest_valid;
  126. u16 high_voltage_t;
  127. bool cac_enabled;
  128. bool bapm_enable;
  129. /* smc offsets */
  130. u32 sram_end;
  131. u32 dpm_table_start;
  132. u32 soft_regs_start;
  133. /* dpm SMU tables */
  134. u8 graphics_dpm_level_count;
  135. u8 uvd_level_count;
  136. u8 vce_level_count;
  137. u8 acp_level_count;
  138. u8 samu_level_count;
  139. u16 fps_high_t;
  140. SMU7_Fusion_GraphicsLevel graphics_level[SMU__NUM_SCLK_DPM_STATE];
  141. SMU7_Fusion_ACPILevel acpi_level;
  142. SMU7_Fusion_UvdLevel uvd_level[SMU7_MAX_LEVELS_UVD];
  143. SMU7_Fusion_ExtClkLevel vce_level[SMU7_MAX_LEVELS_VCE];
  144. SMU7_Fusion_ExtClkLevel acp_level[SMU7_MAX_LEVELS_ACP];
  145. SMU7_Fusion_ExtClkLevel samu_level[SMU7_MAX_LEVELS_SAMU];
  146. u8 uvd_boot_level;
  147. u8 vce_boot_level;
  148. u8 acp_boot_level;
  149. u8 samu_boot_level;
  150. u8 uvd_interval;
  151. u8 vce_interval;
  152. u8 acp_interval;
  153. u8 samu_interval;
  154. u8 graphics_boot_level;
  155. u8 graphics_interval;
  156. u8 graphics_therm_throttle_enable;
  157. u8 graphics_voltage_change_enable;
  158. u8 graphics_clk_slow_enable;
  159. u8 graphics_clk_slow_divider;
  160. u8 fps_low_t;
  161. u32 low_sclk_interrupt_t;
  162. bool uvd_power_gated;
  163. bool vce_power_gated;
  164. bool acp_power_gated;
  165. bool samu_power_gated;
  166. bool nb_dpm_enabled;
  167. /* flags */
  168. bool enable_didt;
  169. bool enable_dpm;
  170. bool enable_auto_thermal_throttling;
  171. bool enable_nb_dpm;
  172. /* caps */
  173. bool caps_cac;
  174. bool caps_power_containment;
  175. bool caps_sq_ramping;
  176. bool caps_db_ramping;
  177. bool caps_td_ramping;
  178. bool caps_tcp_ramping;
  179. bool caps_sclk_throttle_low_notification;
  180. bool caps_fps;
  181. bool caps_uvd_dpm;
  182. bool caps_uvd_pg;
  183. bool caps_vce_pg;
  184. bool caps_samu_pg;
  185. bool caps_acp_pg;
  186. bool caps_stable_p_state;
  187. bool caps_enable_dfs_bypass;
  188. bool caps_sclk_ds;
  189. struct amdgpu_ps current_rps;
  190. struct kv_ps current_ps;
  191. struct amdgpu_ps requested_rps;
  192. struct kv_ps requested_ps;
  193. };
  194. /* XXX are these ok? */
  195. #define KV_TEMP_RANGE_MIN (90 * 1000)
  196. #define KV_TEMP_RANGE_MAX (120 * 1000)
  197. /* kv_smc.c */
  198. int amdgpu_kv_notify_message_to_smu(struct amdgpu_device *adev, u32 id);
  199. int amdgpu_kv_dpm_get_enable_mask(struct amdgpu_device *adev, u32 *enable_mask);
  200. int amdgpu_kv_send_msg_to_smc_with_parameter(struct amdgpu_device *adev,
  201. PPSMC_Msg msg, u32 parameter);
  202. int amdgpu_kv_read_smc_sram_dword(struct amdgpu_device *adev, u32 smc_address,
  203. u32 *value, u32 limit);
  204. int amdgpu_kv_smc_dpm_enable(struct amdgpu_device *adev, bool enable);
  205. int amdgpu_kv_smc_bapm_enable(struct amdgpu_device *adev, bool enable);
  206. int amdgpu_kv_copy_bytes_to_smc(struct amdgpu_device *adev,
  207. u32 smc_start_address,
  208. const u8 *src, u32 byte_count, u32 limit);
  209. #endif