kgd_pp_interface.h 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. /*
  2. * Copyright 2017 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 __KGD_PP_INTERFACE_H__
  24. #define __KGD_PP_INTERFACE_H__
  25. extern const struct amdgpu_ip_block_version pp_smu_ip_block;
  26. struct amd_vce_state {
  27. /* vce clocks */
  28. u32 evclk;
  29. u32 ecclk;
  30. /* gpu clocks */
  31. u32 sclk;
  32. u32 mclk;
  33. u8 clk_idx;
  34. u8 pstate;
  35. };
  36. enum amd_dpm_forced_level {
  37. AMD_DPM_FORCED_LEVEL_AUTO = 0x1,
  38. AMD_DPM_FORCED_LEVEL_MANUAL = 0x2,
  39. AMD_DPM_FORCED_LEVEL_LOW = 0x4,
  40. AMD_DPM_FORCED_LEVEL_HIGH = 0x8,
  41. AMD_DPM_FORCED_LEVEL_PROFILE_STANDARD = 0x10,
  42. AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK = 0x20,
  43. AMD_DPM_FORCED_LEVEL_PROFILE_MIN_MCLK = 0x40,
  44. AMD_DPM_FORCED_LEVEL_PROFILE_PEAK = 0x80,
  45. AMD_DPM_FORCED_LEVEL_PROFILE_EXIT = 0x100,
  46. };
  47. enum amd_pm_state_type {
  48. /* not used for dpm */
  49. POWER_STATE_TYPE_DEFAULT,
  50. POWER_STATE_TYPE_POWERSAVE,
  51. /* user selectable states */
  52. POWER_STATE_TYPE_BATTERY,
  53. POWER_STATE_TYPE_BALANCED,
  54. POWER_STATE_TYPE_PERFORMANCE,
  55. /* internal states */
  56. POWER_STATE_TYPE_INTERNAL_UVD,
  57. POWER_STATE_TYPE_INTERNAL_UVD_SD,
  58. POWER_STATE_TYPE_INTERNAL_UVD_HD,
  59. POWER_STATE_TYPE_INTERNAL_UVD_HD2,
  60. POWER_STATE_TYPE_INTERNAL_UVD_MVC,
  61. POWER_STATE_TYPE_INTERNAL_BOOT,
  62. POWER_STATE_TYPE_INTERNAL_THERMAL,
  63. POWER_STATE_TYPE_INTERNAL_ACPI,
  64. POWER_STATE_TYPE_INTERNAL_ULV,
  65. POWER_STATE_TYPE_INTERNAL_3DPERF,
  66. };
  67. #define AMD_MAX_VCE_LEVELS 6
  68. enum amd_vce_level {
  69. AMD_VCE_LEVEL_AC_ALL = 0, /* AC, All cases */
  70. AMD_VCE_LEVEL_DC_EE = 1, /* DC, entropy encoding */
  71. AMD_VCE_LEVEL_DC_LL_LOW = 2, /* DC, low latency queue, res <= 720 */
  72. AMD_VCE_LEVEL_DC_LL_HIGH = 3, /* DC, low latency queue, 1080 >= res > 720 */
  73. AMD_VCE_LEVEL_DC_GP_LOW = 4, /* DC, general purpose queue, res <= 720 */
  74. AMD_VCE_LEVEL_DC_GP_HIGH = 5, /* DC, general purpose queue, 1080 >= res > 720 */
  75. };
  76. enum amd_fan_ctrl_mode {
  77. AMD_FAN_CTRL_NONE = 0,
  78. AMD_FAN_CTRL_MANUAL = 1,
  79. AMD_FAN_CTRL_AUTO = 2,
  80. };
  81. enum pp_clock_type {
  82. PP_SCLK,
  83. PP_MCLK,
  84. PP_PCIE,
  85. OD_SCLK,
  86. OD_MCLK,
  87. };
  88. enum amd_pp_sensors {
  89. AMDGPU_PP_SENSOR_GFX_SCLK = 0,
  90. AMDGPU_PP_SENSOR_VDDNB,
  91. AMDGPU_PP_SENSOR_VDDGFX,
  92. AMDGPU_PP_SENSOR_UVD_VCLK,
  93. AMDGPU_PP_SENSOR_UVD_DCLK,
  94. AMDGPU_PP_SENSOR_VCE_ECCLK,
  95. AMDGPU_PP_SENSOR_GPU_LOAD,
  96. AMDGPU_PP_SENSOR_GFX_MCLK,
  97. AMDGPU_PP_SENSOR_GPU_TEMP,
  98. AMDGPU_PP_SENSOR_VCE_POWER,
  99. AMDGPU_PP_SENSOR_UVD_POWER,
  100. AMDGPU_PP_SENSOR_GPU_POWER,
  101. AMDGPU_PP_SENSOR_STABLE_PSTATE_SCLK,
  102. AMDGPU_PP_SENSOR_STABLE_PSTATE_MCLK,
  103. };
  104. enum amd_pp_task {
  105. AMD_PP_TASK_DISPLAY_CONFIG_CHANGE,
  106. AMD_PP_TASK_ENABLE_USER_STATE,
  107. AMD_PP_TASK_READJUST_POWER_STATE,
  108. AMD_PP_TASK_COMPLETE_INIT,
  109. AMD_PP_TASK_MAX
  110. };
  111. enum PP_SMC_POWER_PROFILE {
  112. PP_SMC_POWER_PROFILE_FULLSCREEN3D = 0x0,
  113. PP_SMC_POWER_PROFILE_POWERSAVING = 0x1,
  114. PP_SMC_POWER_PROFILE_VIDEO = 0x2,
  115. PP_SMC_POWER_PROFILE_VR = 0x3,
  116. PP_SMC_POWER_PROFILE_COMPUTE = 0x4,
  117. PP_SMC_POWER_PROFILE_CUSTOM = 0x5,
  118. };
  119. enum {
  120. PP_GROUP_UNKNOWN = 0,
  121. PP_GROUP_GFX = 1,
  122. PP_GROUP_SYS,
  123. PP_GROUP_MAX
  124. };
  125. enum PP_OD_DPM_TABLE_COMMAND {
  126. PP_OD_EDIT_SCLK_VDDC_TABLE,
  127. PP_OD_EDIT_MCLK_VDDC_TABLE,
  128. PP_OD_RESTORE_DEFAULT_TABLE,
  129. PP_OD_COMMIT_DPM_TABLE
  130. };
  131. struct pp_states_info {
  132. uint32_t nums;
  133. uint32_t states[16];
  134. };
  135. struct pp_gpu_power {
  136. uint32_t vddc_power;
  137. uint32_t vddci_power;
  138. uint32_t max_gpu_power;
  139. uint32_t average_gpu_power;
  140. };
  141. #define PP_GROUP_MASK 0xF0000000
  142. #define PP_GROUP_SHIFT 28
  143. #define PP_BLOCK_MASK 0x0FFFFF00
  144. #define PP_BLOCK_SHIFT 8
  145. #define PP_BLOCK_GFX_CG 0x01
  146. #define PP_BLOCK_GFX_MG 0x02
  147. #define PP_BLOCK_GFX_3D 0x04
  148. #define PP_BLOCK_GFX_RLC 0x08
  149. #define PP_BLOCK_GFX_CP 0x10
  150. #define PP_BLOCK_SYS_BIF 0x01
  151. #define PP_BLOCK_SYS_MC 0x02
  152. #define PP_BLOCK_SYS_ROM 0x04
  153. #define PP_BLOCK_SYS_DRM 0x08
  154. #define PP_BLOCK_SYS_HDP 0x10
  155. #define PP_BLOCK_SYS_SDMA 0x20
  156. #define PP_STATE_MASK 0x0000000F
  157. #define PP_STATE_SHIFT 0
  158. #define PP_STATE_SUPPORT_MASK 0x000000F0
  159. #define PP_STATE_SUPPORT_SHIFT 0
  160. #define PP_STATE_CG 0x01
  161. #define PP_STATE_LS 0x02
  162. #define PP_STATE_DS 0x04
  163. #define PP_STATE_SD 0x08
  164. #define PP_STATE_SUPPORT_CG 0x10
  165. #define PP_STATE_SUPPORT_LS 0x20
  166. #define PP_STATE_SUPPORT_DS 0x40
  167. #define PP_STATE_SUPPORT_SD 0x80
  168. #define PP_CG_MSG_ID(group, block, support, state) \
  169. ((group) << PP_GROUP_SHIFT | (block) << PP_BLOCK_SHIFT | \
  170. (support) << PP_STATE_SUPPORT_SHIFT | (state) << PP_STATE_SHIFT)
  171. struct seq_file;
  172. enum amd_pp_clock_type;
  173. struct amd_pp_simple_clock_info;
  174. struct amd_pp_display_configuration;
  175. struct amd_pp_clock_info;
  176. struct pp_display_clock_request;
  177. struct pp_wm_sets_with_clock_ranges_soc15;
  178. struct pp_clock_levels_with_voltage;
  179. struct pp_clock_levels_with_latency;
  180. struct amd_pp_clocks;
  181. struct amd_pm_funcs {
  182. /* export for dpm on ci and si */
  183. int (*pre_set_power_state)(void *handle);
  184. int (*set_power_state)(void *handle);
  185. void (*post_set_power_state)(void *handle);
  186. void (*display_configuration_changed)(void *handle);
  187. void (*print_power_state)(void *handle, void *ps);
  188. bool (*vblank_too_short)(void *handle);
  189. void (*enable_bapm)(void *handle, bool enable);
  190. int (*check_state_equal)(void *handle,
  191. void *cps,
  192. void *rps,
  193. bool *equal);
  194. /* export for sysfs */
  195. void (*set_fan_control_mode)(void *handle, u32 mode);
  196. u32 (*get_fan_control_mode)(void *handle);
  197. int (*set_fan_speed_percent)(void *handle, u32 speed);
  198. int (*get_fan_speed_percent)(void *handle, u32 *speed);
  199. int (*force_clock_level)(void *handle, enum pp_clock_type type, uint32_t mask);
  200. int (*print_clock_levels)(void *handle, enum pp_clock_type type, char *buf);
  201. int (*force_performance_level)(void *handle, enum amd_dpm_forced_level level);
  202. int (*get_sclk_od)(void *handle);
  203. int (*set_sclk_od)(void *handle, uint32_t value);
  204. int (*get_mclk_od)(void *handle);
  205. int (*set_mclk_od)(void *handle, uint32_t value);
  206. int (*read_sensor)(void *handle, int idx, void *value, int *size);
  207. enum amd_dpm_forced_level (*get_performance_level)(void *handle);
  208. enum amd_pm_state_type (*get_current_power_state)(void *handle);
  209. int (*get_fan_speed_rpm)(void *handle, uint32_t *rpm);
  210. int (*get_pp_num_states)(void *handle, struct pp_states_info *data);
  211. int (*get_pp_table)(void *handle, char **table);
  212. int (*set_pp_table)(void *handle, const char *buf, size_t size);
  213. void (*debugfs_print_current_performance_level)(void *handle, struct seq_file *m);
  214. int (*switch_power_profile)(void *handle, enum PP_SMC_POWER_PROFILE type, bool en);
  215. /* export to amdgpu */
  216. void (*powergate_uvd)(void *handle, bool gate);
  217. void (*powergate_vce)(void *handle, bool gate);
  218. struct amd_vce_state *(*get_vce_clock_state)(void *handle, u32 idx);
  219. int (*dispatch_tasks)(void *handle, enum amd_pp_task task_id,
  220. enum amd_pm_state_type *user_state);
  221. int (*load_firmware)(void *handle);
  222. int (*wait_for_fw_loading_complete)(void *handle);
  223. int (*set_clockgating_by_smu)(void *handle, uint32_t msg_id);
  224. int (*notify_smu_memory_info)(void *handle, uint32_t virtual_addr_low,
  225. uint32_t virtual_addr_hi,
  226. uint32_t mc_addr_low,
  227. uint32_t mc_addr_hi,
  228. uint32_t size);
  229. int (*set_power_limit)(void *handle, uint32_t n);
  230. int (*get_power_limit)(void *handle, uint32_t *limit, bool default_limit);
  231. /* export to DC */
  232. u32 (*get_sclk)(void *handle, bool low);
  233. u32 (*get_mclk)(void *handle, bool low);
  234. int (*display_configuration_change)(void *handle,
  235. const struct amd_pp_display_configuration *input);
  236. int (*get_display_power_level)(void *handle,
  237. struct amd_pp_simple_clock_info *output);
  238. int (*get_current_clocks)(void *handle,
  239. struct amd_pp_clock_info *clocks);
  240. int (*get_clock_by_type)(void *handle,
  241. enum amd_pp_clock_type type,
  242. struct amd_pp_clocks *clocks);
  243. int (*get_clock_by_type_with_latency)(void *handle,
  244. enum amd_pp_clock_type type,
  245. struct pp_clock_levels_with_latency *clocks);
  246. int (*get_clock_by_type_with_voltage)(void *handle,
  247. enum amd_pp_clock_type type,
  248. struct pp_clock_levels_with_voltage *clocks);
  249. int (*set_watermarks_for_clocks_ranges)(void *handle,
  250. struct pp_wm_sets_with_clock_ranges_soc15 *wm_with_clock_ranges);
  251. int (*display_clock_voltage_request)(void *handle,
  252. struct pp_display_clock_request *clock);
  253. int (*get_display_mode_validation_clocks)(void *handle,
  254. struct amd_pp_simple_clock_info *clocks);
  255. int (*get_power_profile_mode)(void *handle, char *buf);
  256. int (*set_power_profile_mode)(void *handle, long *input, uint32_t size);
  257. int (*odn_edit_dpm_table)(void *handle, uint32_t type, long *input, uint32_t size);
  258. int (*set_mmhub_powergating_by_smu)(void *handle);
  259. };
  260. #endif