kgd_pp_interface.h 9.5 KB

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