1*b843c749SSergey Zigachev /* 2*b843c749SSergey Zigachev * Copyright 2017 Advanced Micro Devices, Inc. 3*b843c749SSergey Zigachev * 4*b843c749SSergey Zigachev * Permission is hereby granted, free of charge, to any person obtaining a 5*b843c749SSergey Zigachev * copy of this software and associated documentation files (the "Software"), 6*b843c749SSergey Zigachev * to deal in the Software without restriction, including without limitation 7*b843c749SSergey Zigachev * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8*b843c749SSergey Zigachev * and/or sell copies of the Software, and to permit persons to whom the 9*b843c749SSergey Zigachev * Software is furnished to do so, subject to the following conditions: 10*b843c749SSergey Zigachev * 11*b843c749SSergey Zigachev * The above copyright notice and this permission notice shall be included in 12*b843c749SSergey Zigachev * all copies or substantial portions of the Software. 13*b843c749SSergey Zigachev * 14*b843c749SSergey Zigachev * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15*b843c749SSergey Zigachev * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16*b843c749SSergey Zigachev * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17*b843c749SSergey Zigachev * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18*b843c749SSergey Zigachev * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19*b843c749SSergey Zigachev * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20*b843c749SSergey Zigachev * OTHER DEALINGS IN THE SOFTWARE. 21*b843c749SSergey Zigachev * 22*b843c749SSergey Zigachev */ 23*b843c749SSergey Zigachev 24*b843c749SSergey Zigachev #ifndef __KGD_PP_INTERFACE_H__ 25*b843c749SSergey Zigachev #define __KGD_PP_INTERFACE_H__ 26*b843c749SSergey Zigachev 27*b843c749SSergey Zigachev extern const struct amdgpu_ip_block_version pp_smu_ip_block; 28*b843c749SSergey Zigachev 29*b843c749SSergey Zigachev struct amd_vce_state { 30*b843c749SSergey Zigachev /* vce clocks */ 31*b843c749SSergey Zigachev u32 evclk; 32*b843c749SSergey Zigachev u32 ecclk; 33*b843c749SSergey Zigachev /* gpu clocks */ 34*b843c749SSergey Zigachev u32 sclk; 35*b843c749SSergey Zigachev u32 mclk; 36*b843c749SSergey Zigachev u8 clk_idx; 37*b843c749SSergey Zigachev u8 pstate; 38*b843c749SSergey Zigachev }; 39*b843c749SSergey Zigachev 40*b843c749SSergey Zigachev 41*b843c749SSergey Zigachev enum amd_dpm_forced_level { 42*b843c749SSergey Zigachev AMD_DPM_FORCED_LEVEL_AUTO = 0x1, 43*b843c749SSergey Zigachev AMD_DPM_FORCED_LEVEL_MANUAL = 0x2, 44*b843c749SSergey Zigachev AMD_DPM_FORCED_LEVEL_LOW = 0x4, 45*b843c749SSergey Zigachev AMD_DPM_FORCED_LEVEL_HIGH = 0x8, 46*b843c749SSergey Zigachev AMD_DPM_FORCED_LEVEL_PROFILE_STANDARD = 0x10, 47*b843c749SSergey Zigachev AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK = 0x20, 48*b843c749SSergey Zigachev AMD_DPM_FORCED_LEVEL_PROFILE_MIN_MCLK = 0x40, 49*b843c749SSergey Zigachev AMD_DPM_FORCED_LEVEL_PROFILE_PEAK = 0x80, 50*b843c749SSergey Zigachev AMD_DPM_FORCED_LEVEL_PROFILE_EXIT = 0x100, 51*b843c749SSergey Zigachev }; 52*b843c749SSergey Zigachev 53*b843c749SSergey Zigachev enum amd_pm_state_type { 54*b843c749SSergey Zigachev /* not used for dpm */ 55*b843c749SSergey Zigachev POWER_STATE_TYPE_DEFAULT, 56*b843c749SSergey Zigachev POWER_STATE_TYPE_POWERSAVE, 57*b843c749SSergey Zigachev /* user selectable states */ 58*b843c749SSergey Zigachev POWER_STATE_TYPE_BATTERY, 59*b843c749SSergey Zigachev POWER_STATE_TYPE_BALANCED, 60*b843c749SSergey Zigachev POWER_STATE_TYPE_PERFORMANCE, 61*b843c749SSergey Zigachev /* internal states */ 62*b843c749SSergey Zigachev POWER_STATE_TYPE_INTERNAL_UVD, 63*b843c749SSergey Zigachev POWER_STATE_TYPE_INTERNAL_UVD_SD, 64*b843c749SSergey Zigachev POWER_STATE_TYPE_INTERNAL_UVD_HD, 65*b843c749SSergey Zigachev POWER_STATE_TYPE_INTERNAL_UVD_HD2, 66*b843c749SSergey Zigachev POWER_STATE_TYPE_INTERNAL_UVD_MVC, 67*b843c749SSergey Zigachev POWER_STATE_TYPE_INTERNAL_BOOT, 68*b843c749SSergey Zigachev POWER_STATE_TYPE_INTERNAL_THERMAL, 69*b843c749SSergey Zigachev POWER_STATE_TYPE_INTERNAL_ACPI, 70*b843c749SSergey Zigachev POWER_STATE_TYPE_INTERNAL_ULV, 71*b843c749SSergey Zigachev POWER_STATE_TYPE_INTERNAL_3DPERF, 72*b843c749SSergey Zigachev }; 73*b843c749SSergey Zigachev 74*b843c749SSergey Zigachev #define AMD_MAX_VCE_LEVELS 6 75*b843c749SSergey Zigachev 76*b843c749SSergey Zigachev enum amd_vce_level { 77*b843c749SSergey Zigachev AMD_VCE_LEVEL_AC_ALL = 0, /* AC, All cases */ 78*b843c749SSergey Zigachev AMD_VCE_LEVEL_DC_EE = 1, /* DC, entropy encoding */ 79*b843c749SSergey Zigachev AMD_VCE_LEVEL_DC_LL_LOW = 2, /* DC, low latency queue, res <= 720 */ 80*b843c749SSergey Zigachev AMD_VCE_LEVEL_DC_LL_HIGH = 3, /* DC, low latency queue, 1080 >= res > 720 */ 81*b843c749SSergey Zigachev AMD_VCE_LEVEL_DC_GP_LOW = 4, /* DC, general purpose queue, res <= 720 */ 82*b843c749SSergey Zigachev AMD_VCE_LEVEL_DC_GP_HIGH = 5, /* DC, general purpose queue, 1080 >= res > 720 */ 83*b843c749SSergey Zigachev }; 84*b843c749SSergey Zigachev 85*b843c749SSergey Zigachev enum amd_fan_ctrl_mode { 86*b843c749SSergey Zigachev AMD_FAN_CTRL_NONE = 0, 87*b843c749SSergey Zigachev AMD_FAN_CTRL_MANUAL = 1, 88*b843c749SSergey Zigachev AMD_FAN_CTRL_AUTO = 2, 89*b843c749SSergey Zigachev }; 90*b843c749SSergey Zigachev 91*b843c749SSergey Zigachev enum pp_clock_type { 92*b843c749SSergey Zigachev PP_SCLK, 93*b843c749SSergey Zigachev PP_MCLK, 94*b843c749SSergey Zigachev PP_PCIE, 95*b843c749SSergey Zigachev OD_SCLK, 96*b843c749SSergey Zigachev OD_MCLK, 97*b843c749SSergey Zigachev OD_RANGE, 98*b843c749SSergey Zigachev }; 99*b843c749SSergey Zigachev 100*b843c749SSergey Zigachev enum amd_pp_sensors { 101*b843c749SSergey Zigachev AMDGPU_PP_SENSOR_GFX_SCLK = 0, 102*b843c749SSergey Zigachev AMDGPU_PP_SENSOR_VDDNB, 103*b843c749SSergey Zigachev AMDGPU_PP_SENSOR_VDDGFX, 104*b843c749SSergey Zigachev AMDGPU_PP_SENSOR_UVD_VCLK, 105*b843c749SSergey Zigachev AMDGPU_PP_SENSOR_UVD_DCLK, 106*b843c749SSergey Zigachev AMDGPU_PP_SENSOR_VCE_ECCLK, 107*b843c749SSergey Zigachev AMDGPU_PP_SENSOR_GPU_LOAD, 108*b843c749SSergey Zigachev AMDGPU_PP_SENSOR_GFX_MCLK, 109*b843c749SSergey Zigachev AMDGPU_PP_SENSOR_GPU_TEMP, 110*b843c749SSergey Zigachev AMDGPU_PP_SENSOR_VCE_POWER, 111*b843c749SSergey Zigachev AMDGPU_PP_SENSOR_UVD_POWER, 112*b843c749SSergey Zigachev AMDGPU_PP_SENSOR_GPU_POWER, 113*b843c749SSergey Zigachev AMDGPU_PP_SENSOR_STABLE_PSTATE_SCLK, 114*b843c749SSergey Zigachev AMDGPU_PP_SENSOR_STABLE_PSTATE_MCLK, 115*b843c749SSergey Zigachev }; 116*b843c749SSergey Zigachev 117*b843c749SSergey Zigachev enum amd_pp_task { 118*b843c749SSergey Zigachev AMD_PP_TASK_DISPLAY_CONFIG_CHANGE, 119*b843c749SSergey Zigachev AMD_PP_TASK_ENABLE_USER_STATE, 120*b843c749SSergey Zigachev AMD_PP_TASK_READJUST_POWER_STATE, 121*b843c749SSergey Zigachev AMD_PP_TASK_COMPLETE_INIT, 122*b843c749SSergey Zigachev AMD_PP_TASK_MAX 123*b843c749SSergey Zigachev }; 124*b843c749SSergey Zigachev 125*b843c749SSergey Zigachev enum PP_SMC_POWER_PROFILE { 126*b843c749SSergey Zigachev PP_SMC_POWER_PROFILE_FULLSCREEN3D = 0x0, 127*b843c749SSergey Zigachev PP_SMC_POWER_PROFILE_POWERSAVING = 0x1, 128*b843c749SSergey Zigachev PP_SMC_POWER_PROFILE_VIDEO = 0x2, 129*b843c749SSergey Zigachev PP_SMC_POWER_PROFILE_VR = 0x3, 130*b843c749SSergey Zigachev PP_SMC_POWER_PROFILE_COMPUTE = 0x4, 131*b843c749SSergey Zigachev PP_SMC_POWER_PROFILE_CUSTOM = 0x5, 132*b843c749SSergey Zigachev }; 133*b843c749SSergey Zigachev 134*b843c749SSergey Zigachev enum { 135*b843c749SSergey Zigachev PP_GROUP_UNKNOWN = 0, 136*b843c749SSergey Zigachev PP_GROUP_GFX = 1, 137*b843c749SSergey Zigachev PP_GROUP_SYS, 138*b843c749SSergey Zigachev PP_GROUP_MAX 139*b843c749SSergey Zigachev }; 140*b843c749SSergey Zigachev 141*b843c749SSergey Zigachev enum PP_OD_DPM_TABLE_COMMAND { 142*b843c749SSergey Zigachev PP_OD_EDIT_SCLK_VDDC_TABLE, 143*b843c749SSergey Zigachev PP_OD_EDIT_MCLK_VDDC_TABLE, 144*b843c749SSergey Zigachev PP_OD_RESTORE_DEFAULT_TABLE, 145*b843c749SSergey Zigachev PP_OD_COMMIT_DPM_TABLE 146*b843c749SSergey Zigachev }; 147*b843c749SSergey Zigachev 148*b843c749SSergey Zigachev struct pp_states_info { 149*b843c749SSergey Zigachev uint32_t nums; 150*b843c749SSergey Zigachev uint32_t states[16]; 151*b843c749SSergey Zigachev }; 152*b843c749SSergey Zigachev 153*b843c749SSergey Zigachev #define PP_GROUP_MASK 0xF0000000 154*b843c749SSergey Zigachev #define PP_GROUP_SHIFT 28 155*b843c749SSergey Zigachev 156*b843c749SSergey Zigachev #define PP_BLOCK_MASK 0x0FFFFF00 157*b843c749SSergey Zigachev #define PP_BLOCK_SHIFT 8 158*b843c749SSergey Zigachev 159*b843c749SSergey Zigachev #define PP_BLOCK_GFX_CG 0x01 160*b843c749SSergey Zigachev #define PP_BLOCK_GFX_MG 0x02 161*b843c749SSergey Zigachev #define PP_BLOCK_GFX_3D 0x04 162*b843c749SSergey Zigachev #define PP_BLOCK_GFX_RLC 0x08 163*b843c749SSergey Zigachev #define PP_BLOCK_GFX_CP 0x10 164*b843c749SSergey Zigachev #define PP_BLOCK_SYS_BIF 0x01 165*b843c749SSergey Zigachev #define PP_BLOCK_SYS_MC 0x02 166*b843c749SSergey Zigachev #define PP_BLOCK_SYS_ROM 0x04 167*b843c749SSergey Zigachev #define PP_BLOCK_SYS_DRM 0x08 168*b843c749SSergey Zigachev #define PP_BLOCK_SYS_HDP 0x10 169*b843c749SSergey Zigachev #define PP_BLOCK_SYS_SDMA 0x20 170*b843c749SSergey Zigachev 171*b843c749SSergey Zigachev #define PP_STATE_MASK 0x0000000F 172*b843c749SSergey Zigachev #define PP_STATE_SHIFT 0 173*b843c749SSergey Zigachev #define PP_STATE_SUPPORT_MASK 0x000000F0 174*b843c749SSergey Zigachev #define PP_STATE_SUPPORT_SHIFT 0 175*b843c749SSergey Zigachev 176*b843c749SSergey Zigachev #define PP_STATE_CG 0x01 177*b843c749SSergey Zigachev #define PP_STATE_LS 0x02 178*b843c749SSergey Zigachev #define PP_STATE_DS 0x04 179*b843c749SSergey Zigachev #define PP_STATE_SD 0x08 180*b843c749SSergey Zigachev #define PP_STATE_SUPPORT_CG 0x10 181*b843c749SSergey Zigachev #define PP_STATE_SUPPORT_LS 0x20 182*b843c749SSergey Zigachev #define PP_STATE_SUPPORT_DS 0x40 183*b843c749SSergey Zigachev #define PP_STATE_SUPPORT_SD 0x80 184*b843c749SSergey Zigachev 185*b843c749SSergey Zigachev #define PP_CG_MSG_ID(group, block, support, state) \ 186*b843c749SSergey Zigachev ((group) << PP_GROUP_SHIFT | (block) << PP_BLOCK_SHIFT | \ 187*b843c749SSergey Zigachev (support) << PP_STATE_SUPPORT_SHIFT | (state) << PP_STATE_SHIFT) 188*b843c749SSergey Zigachev 189*b843c749SSergey Zigachev struct seq_file; 190*b843c749SSergey Zigachev enum amd_pp_clock_type; 191*b843c749SSergey Zigachev struct amd_pp_simple_clock_info; 192*b843c749SSergey Zigachev struct amd_pp_display_configuration; 193*b843c749SSergey Zigachev struct amd_pp_clock_info; 194*b843c749SSergey Zigachev struct pp_display_clock_request; 195*b843c749SSergey Zigachev struct pp_clock_levels_with_voltage; 196*b843c749SSergey Zigachev struct pp_clock_levels_with_latency; 197*b843c749SSergey Zigachev struct amd_pp_clocks; 198*b843c749SSergey Zigachev 199*b843c749SSergey Zigachev struct amd_pm_funcs { 200*b843c749SSergey Zigachev /* export for dpm on ci and si */ 201*b843c749SSergey Zigachev int (*pre_set_power_state)(void *handle); 202*b843c749SSergey Zigachev int (*set_power_state)(void *handle); 203*b843c749SSergey Zigachev void (*post_set_power_state)(void *handle); 204*b843c749SSergey Zigachev void (*display_configuration_changed)(void *handle); 205*b843c749SSergey Zigachev void (*print_power_state)(void *handle, void *ps); 206*b843c749SSergey Zigachev bool (*vblank_too_short)(void *handle); 207*b843c749SSergey Zigachev void (*enable_bapm)(void *handle, bool enable); 208*b843c749SSergey Zigachev int (*check_state_equal)(void *handle, 209*b843c749SSergey Zigachev void *cps, 210*b843c749SSergey Zigachev void *rps, 211*b843c749SSergey Zigachev bool *equal); 212*b843c749SSergey Zigachev /* export for sysfs */ 213*b843c749SSergey Zigachev void (*set_fan_control_mode)(void *handle, u32 mode); 214*b843c749SSergey Zigachev u32 (*get_fan_control_mode)(void *handle); 215*b843c749SSergey Zigachev int (*set_fan_speed_percent)(void *handle, u32 speed); 216*b843c749SSergey Zigachev int (*get_fan_speed_percent)(void *handle, u32 *speed); 217*b843c749SSergey Zigachev int (*force_clock_level)(void *handle, enum pp_clock_type type, uint32_t mask); 218*b843c749SSergey Zigachev int (*print_clock_levels)(void *handle, enum pp_clock_type type, char *buf); 219*b843c749SSergey Zigachev int (*force_performance_level)(void *handle, enum amd_dpm_forced_level level); 220*b843c749SSergey Zigachev int (*get_sclk_od)(void *handle); 221*b843c749SSergey Zigachev int (*set_sclk_od)(void *handle, uint32_t value); 222*b843c749SSergey Zigachev int (*get_mclk_od)(void *handle); 223*b843c749SSergey Zigachev int (*set_mclk_od)(void *handle, uint32_t value); 224*b843c749SSergey Zigachev int (*read_sensor)(void *handle, int idx, void *value, int *size); 225*b843c749SSergey Zigachev enum amd_dpm_forced_level (*get_performance_level)(void *handle); 226*b843c749SSergey Zigachev enum amd_pm_state_type (*get_current_power_state)(void *handle); 227*b843c749SSergey Zigachev int (*get_fan_speed_rpm)(void *handle, uint32_t *rpm); 228*b843c749SSergey Zigachev int (*get_pp_num_states)(void *handle, struct pp_states_info *data); 229*b843c749SSergey Zigachev int (*get_pp_table)(void *handle, char **table); 230*b843c749SSergey Zigachev int (*set_pp_table)(void *handle, const char *buf, size_t size); 231*b843c749SSergey Zigachev void (*debugfs_print_current_performance_level)(void *handle, struct seq_file *m); 232*b843c749SSergey Zigachev int (*switch_power_profile)(void *handle, enum PP_SMC_POWER_PROFILE type, bool en); 233*b843c749SSergey Zigachev /* export to amdgpu */ 234*b843c749SSergey Zigachev struct amd_vce_state *(*get_vce_clock_state)(void *handle, u32 idx); 235*b843c749SSergey Zigachev int (*dispatch_tasks)(void *handle, enum amd_pp_task task_id, 236*b843c749SSergey Zigachev enum amd_pm_state_type *user_state); 237*b843c749SSergey Zigachev int (*load_firmware)(void *handle); 238*b843c749SSergey Zigachev int (*wait_for_fw_loading_complete)(void *handle); 239*b843c749SSergey Zigachev int (*set_powergating_by_smu)(void *handle, 240*b843c749SSergey Zigachev uint32_t block_type, bool gate); 241*b843c749SSergey Zigachev int (*set_clockgating_by_smu)(void *handle, uint32_t msg_id); 242*b843c749SSergey Zigachev int (*set_power_limit)(void *handle, uint32_t n); 243*b843c749SSergey Zigachev int (*get_power_limit)(void *handle, uint32_t *limit, bool default_limit); 244*b843c749SSergey Zigachev int (*get_power_profile_mode)(void *handle, char *buf); 245*b843c749SSergey Zigachev int (*set_power_profile_mode)(void *handle, long *input, uint32_t size); 246*b843c749SSergey Zigachev int (*odn_edit_dpm_table)(void *handle, uint32_t type, long *input, uint32_t size); 247*b843c749SSergey Zigachev /* export to DC */ 248*b843c749SSergey Zigachev u32 (*get_sclk)(void *handle, bool low); 249*b843c749SSergey Zigachev u32 (*get_mclk)(void *handle, bool low); 250*b843c749SSergey Zigachev int (*display_configuration_change)(void *handle, 251*b843c749SSergey Zigachev const struct amd_pp_display_configuration *input); 252*b843c749SSergey Zigachev int (*get_display_power_level)(void *handle, 253*b843c749SSergey Zigachev struct amd_pp_simple_clock_info *output); 254*b843c749SSergey Zigachev int (*get_current_clocks)(void *handle, 255*b843c749SSergey Zigachev struct amd_pp_clock_info *clocks); 256*b843c749SSergey Zigachev int (*get_clock_by_type)(void *handle, 257*b843c749SSergey Zigachev enum amd_pp_clock_type type, 258*b843c749SSergey Zigachev struct amd_pp_clocks *clocks); 259*b843c749SSergey Zigachev int (*get_clock_by_type_with_latency)(void *handle, 260*b843c749SSergey Zigachev enum amd_pp_clock_type type, 261*b843c749SSergey Zigachev struct pp_clock_levels_with_latency *clocks); 262*b843c749SSergey Zigachev int (*get_clock_by_type_with_voltage)(void *handle, 263*b843c749SSergey Zigachev enum amd_pp_clock_type type, 264*b843c749SSergey Zigachev struct pp_clock_levels_with_voltage *clocks); 265*b843c749SSergey Zigachev int (*set_watermarks_for_clocks_ranges)(void *handle, 266*b843c749SSergey Zigachev void *clock_ranges); 267*b843c749SSergey Zigachev int (*display_clock_voltage_request)(void *handle, 268*b843c749SSergey Zigachev struct pp_display_clock_request *clock); 269*b843c749SSergey Zigachev int (*get_display_mode_validation_clocks)(void *handle, 270*b843c749SSergey Zigachev struct amd_pp_simple_clock_info *clocks); 271*b843c749SSergey Zigachev int (*notify_smu_enable_pwe)(void *handle); 272*b843c749SSergey Zigachev }; 273*b843c749SSergey Zigachev 274*b843c749SSergey Zigachev #endif 275