diff options
author | Alex Deucher <alexander.deucher@amd.com> | 2016-10-07 11:40:09 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2016-10-25 14:38:38 -0400 |
commit | cf0978819cf78cef8d36ca39cb242dde4731d338 (patch) | |
tree | 37aedc4543044218c7859a48e6905031daeaa936 /drivers/gpu/drm/amd/amdgpu | |
parent | 7988714237c6a548011dcd7dcce84e9f16dda427 (diff) |
drm/amdgpu: move dpm related definitions to amdgpu_dpm.h
No intended functional change.
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu.h | 449 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h | 447 |
2 files changed, 448 insertions, 448 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index fa99c0d6158c..e6f86b83652b 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h | |||
@@ -57,6 +57,7 @@ | |||
57 | #include "amdgpu_ring.h" | 57 | #include "amdgpu_ring.h" |
58 | #include "amdgpu_vm.h" | 58 | #include "amdgpu_vm.h" |
59 | #include "amd_powerplay.h" | 59 | #include "amd_powerplay.h" |
60 | #include "amdgpu_dpm.h" | ||
60 | #include "amdgpu_acp.h" | 61 | #include "amdgpu_acp.h" |
61 | 62 | ||
62 | #include "gpu_scheduler.h" | 63 | #include "gpu_scheduler.h" |
@@ -973,354 +974,6 @@ struct amdgpu_wb { | |||
973 | int amdgpu_wb_get(struct amdgpu_device *adev, u32 *wb); | 974 | int amdgpu_wb_get(struct amdgpu_device *adev, u32 *wb); |
974 | void amdgpu_wb_free(struct amdgpu_device *adev, u32 wb); | 975 | void amdgpu_wb_free(struct amdgpu_device *adev, u32 wb); |
975 | 976 | ||
976 | |||
977 | |||
978 | enum amdgpu_int_thermal_type { | ||
979 | THERMAL_TYPE_NONE, | ||
980 | THERMAL_TYPE_EXTERNAL, | ||
981 | THERMAL_TYPE_EXTERNAL_GPIO, | ||
982 | THERMAL_TYPE_RV6XX, | ||
983 | THERMAL_TYPE_RV770, | ||
984 | THERMAL_TYPE_ADT7473_WITH_INTERNAL, | ||
985 | THERMAL_TYPE_EVERGREEN, | ||
986 | THERMAL_TYPE_SUMO, | ||
987 | THERMAL_TYPE_NI, | ||
988 | THERMAL_TYPE_SI, | ||
989 | THERMAL_TYPE_EMC2103_WITH_INTERNAL, | ||
990 | THERMAL_TYPE_CI, | ||
991 | THERMAL_TYPE_KV, | ||
992 | }; | ||
993 | |||
994 | enum amdgpu_dpm_auto_throttle_src { | ||
995 | AMDGPU_DPM_AUTO_THROTTLE_SRC_THERMAL, | ||
996 | AMDGPU_DPM_AUTO_THROTTLE_SRC_EXTERNAL | ||
997 | }; | ||
998 | |||
999 | enum amdgpu_dpm_event_src { | ||
1000 | AMDGPU_DPM_EVENT_SRC_ANALOG = 0, | ||
1001 | AMDGPU_DPM_EVENT_SRC_EXTERNAL = 1, | ||
1002 | AMDGPU_DPM_EVENT_SRC_DIGITAL = 2, | ||
1003 | AMDGPU_DPM_EVENT_SRC_ANALOG_OR_EXTERNAL = 3, | ||
1004 | AMDGPU_DPM_EVENT_SRC_DIGIAL_OR_EXTERNAL = 4 | ||
1005 | }; | ||
1006 | |||
1007 | #define AMDGPU_MAX_VCE_LEVELS 6 | ||
1008 | |||
1009 | enum amdgpu_vce_level { | ||
1010 | AMDGPU_VCE_LEVEL_AC_ALL = 0, /* AC, All cases */ | ||
1011 | AMDGPU_VCE_LEVEL_DC_EE = 1, /* DC, entropy encoding */ | ||
1012 | AMDGPU_VCE_LEVEL_DC_LL_LOW = 2, /* DC, low latency queue, res <= 720 */ | ||
1013 | AMDGPU_VCE_LEVEL_DC_LL_HIGH = 3, /* DC, low latency queue, 1080 >= res > 720 */ | ||
1014 | AMDGPU_VCE_LEVEL_DC_GP_LOW = 4, /* DC, general purpose queue, res <= 720 */ | ||
1015 | AMDGPU_VCE_LEVEL_DC_GP_HIGH = 5, /* DC, general purpose queue, 1080 >= res > 720 */ | ||
1016 | }; | ||
1017 | |||
1018 | struct amdgpu_ps { | ||
1019 | u32 caps; /* vbios flags */ | ||
1020 | u32 class; /* vbios flags */ | ||
1021 | u32 class2; /* vbios flags */ | ||
1022 | /* UVD clocks */ | ||
1023 | u32 vclk; | ||
1024 | u32 dclk; | ||
1025 | /* VCE clocks */ | ||
1026 | u32 evclk; | ||
1027 | u32 ecclk; | ||
1028 | bool vce_active; | ||
1029 | enum amdgpu_vce_level vce_level; | ||
1030 | /* asic priv */ | ||
1031 | void *ps_priv; | ||
1032 | }; | ||
1033 | |||
1034 | struct amdgpu_dpm_thermal { | ||
1035 | /* thermal interrupt work */ | ||
1036 | struct work_struct work; | ||
1037 | /* low temperature threshold */ | ||
1038 | int min_temp; | ||
1039 | /* high temperature threshold */ | ||
1040 | int max_temp; | ||
1041 | /* was last interrupt low to high or high to low */ | ||
1042 | bool high_to_low; | ||
1043 | /* interrupt source */ | ||
1044 | struct amdgpu_irq_src irq; | ||
1045 | }; | ||
1046 | |||
1047 | enum amdgpu_clk_action | ||
1048 | { | ||
1049 | AMDGPU_SCLK_UP = 1, | ||
1050 | AMDGPU_SCLK_DOWN | ||
1051 | }; | ||
1052 | |||
1053 | struct amdgpu_blacklist_clocks | ||
1054 | { | ||
1055 | u32 sclk; | ||
1056 | u32 mclk; | ||
1057 | enum amdgpu_clk_action action; | ||
1058 | }; | ||
1059 | |||
1060 | struct amdgpu_clock_and_voltage_limits { | ||
1061 | u32 sclk; | ||
1062 | u32 mclk; | ||
1063 | u16 vddc; | ||
1064 | u16 vddci; | ||
1065 | }; | ||
1066 | |||
1067 | struct amdgpu_clock_array { | ||
1068 | u32 count; | ||
1069 | u32 *values; | ||
1070 | }; | ||
1071 | |||
1072 | struct amdgpu_clock_voltage_dependency_entry { | ||
1073 | u32 clk; | ||
1074 | u16 v; | ||
1075 | }; | ||
1076 | |||
1077 | struct amdgpu_clock_voltage_dependency_table { | ||
1078 | u32 count; | ||
1079 | struct amdgpu_clock_voltage_dependency_entry *entries; | ||
1080 | }; | ||
1081 | |||
1082 | union amdgpu_cac_leakage_entry { | ||
1083 | struct { | ||
1084 | u16 vddc; | ||
1085 | u32 leakage; | ||
1086 | }; | ||
1087 | struct { | ||
1088 | u16 vddc1; | ||
1089 | u16 vddc2; | ||
1090 | u16 vddc3; | ||
1091 | }; | ||
1092 | }; | ||
1093 | |||
1094 | struct amdgpu_cac_leakage_table { | ||
1095 | u32 count; | ||
1096 | union amdgpu_cac_leakage_entry *entries; | ||
1097 | }; | ||
1098 | |||
1099 | struct amdgpu_phase_shedding_limits_entry { | ||
1100 | u16 voltage; | ||
1101 | u32 sclk; | ||
1102 | u32 mclk; | ||
1103 | }; | ||
1104 | |||
1105 | struct amdgpu_phase_shedding_limits_table { | ||
1106 | u32 count; | ||
1107 | struct amdgpu_phase_shedding_limits_entry *entries; | ||
1108 | }; | ||
1109 | |||
1110 | struct amdgpu_uvd_clock_voltage_dependency_entry { | ||
1111 | u32 vclk; | ||
1112 | u32 dclk; | ||
1113 | u16 v; | ||
1114 | }; | ||
1115 | |||
1116 | struct amdgpu_uvd_clock_voltage_dependency_table { | ||
1117 | u8 count; | ||
1118 | struct amdgpu_uvd_clock_voltage_dependency_entry *entries; | ||
1119 | }; | ||
1120 | |||
1121 | struct amdgpu_vce_clock_voltage_dependency_entry { | ||
1122 | u32 ecclk; | ||
1123 | u32 evclk; | ||
1124 | u16 v; | ||
1125 | }; | ||
1126 | |||
1127 | struct amdgpu_vce_clock_voltage_dependency_table { | ||
1128 | u8 count; | ||
1129 | struct amdgpu_vce_clock_voltage_dependency_entry *entries; | ||
1130 | }; | ||
1131 | |||
1132 | struct amdgpu_ppm_table { | ||
1133 | u8 ppm_design; | ||
1134 | u16 cpu_core_number; | ||
1135 | u32 platform_tdp; | ||
1136 | u32 small_ac_platform_tdp; | ||
1137 | u32 platform_tdc; | ||
1138 | u32 small_ac_platform_tdc; | ||
1139 | u32 apu_tdp; | ||
1140 | u32 dgpu_tdp; | ||
1141 | u32 dgpu_ulv_power; | ||
1142 | u32 tj_max; | ||
1143 | }; | ||
1144 | |||
1145 | struct amdgpu_cac_tdp_table { | ||
1146 | u16 tdp; | ||
1147 | u16 configurable_tdp; | ||
1148 | u16 tdc; | ||
1149 | u16 battery_power_limit; | ||
1150 | u16 small_power_limit; | ||
1151 | u16 low_cac_leakage; | ||
1152 | u16 high_cac_leakage; | ||
1153 | u16 maximum_power_delivery_limit; | ||
1154 | }; | ||
1155 | |||
1156 | struct amdgpu_dpm_dynamic_state { | ||
1157 | struct amdgpu_clock_voltage_dependency_table vddc_dependency_on_sclk; | ||
1158 | struct amdgpu_clock_voltage_dependency_table vddci_dependency_on_mclk; | ||
1159 | struct amdgpu_clock_voltage_dependency_table vddc_dependency_on_mclk; | ||
1160 | struct amdgpu_clock_voltage_dependency_table mvdd_dependency_on_mclk; | ||
1161 | struct amdgpu_clock_voltage_dependency_table vddc_dependency_on_dispclk; | ||
1162 | struct amdgpu_uvd_clock_voltage_dependency_table uvd_clock_voltage_dependency_table; | ||
1163 | struct amdgpu_vce_clock_voltage_dependency_table vce_clock_voltage_dependency_table; | ||
1164 | struct amdgpu_clock_voltage_dependency_table samu_clock_voltage_dependency_table; | ||
1165 | struct amdgpu_clock_voltage_dependency_table acp_clock_voltage_dependency_table; | ||
1166 | struct amdgpu_clock_voltage_dependency_table vddgfx_dependency_on_sclk; | ||
1167 | struct amdgpu_clock_array valid_sclk_values; | ||
1168 | struct amdgpu_clock_array valid_mclk_values; | ||
1169 | struct amdgpu_clock_and_voltage_limits max_clock_voltage_on_dc; | ||
1170 | struct amdgpu_clock_and_voltage_limits max_clock_voltage_on_ac; | ||
1171 | u32 mclk_sclk_ratio; | ||
1172 | u32 sclk_mclk_delta; | ||
1173 | u16 vddc_vddci_delta; | ||
1174 | u16 min_vddc_for_pcie_gen2; | ||
1175 | struct amdgpu_cac_leakage_table cac_leakage_table; | ||
1176 | struct amdgpu_phase_shedding_limits_table phase_shedding_limits_table; | ||
1177 | struct amdgpu_ppm_table *ppm_table; | ||
1178 | struct amdgpu_cac_tdp_table *cac_tdp_table; | ||
1179 | }; | ||
1180 | |||
1181 | struct amdgpu_dpm_fan { | ||
1182 | u16 t_min; | ||
1183 | u16 t_med; | ||
1184 | u16 t_high; | ||
1185 | u16 pwm_min; | ||
1186 | u16 pwm_med; | ||
1187 | u16 pwm_high; | ||
1188 | u8 t_hyst; | ||
1189 | u32 cycle_delay; | ||
1190 | u16 t_max; | ||
1191 | u8 control_mode; | ||
1192 | u16 default_max_fan_pwm; | ||
1193 | u16 default_fan_output_sensitivity; | ||
1194 | u16 fan_output_sensitivity; | ||
1195 | bool ucode_fan_control; | ||
1196 | }; | ||
1197 | |||
1198 | enum amdgpu_pcie_gen { | ||
1199 | AMDGPU_PCIE_GEN1 = 0, | ||
1200 | AMDGPU_PCIE_GEN2 = 1, | ||
1201 | AMDGPU_PCIE_GEN3 = 2, | ||
1202 | AMDGPU_PCIE_GEN_INVALID = 0xffff | ||
1203 | }; | ||
1204 | |||
1205 | enum amdgpu_dpm_forced_level { | ||
1206 | AMDGPU_DPM_FORCED_LEVEL_AUTO = 0, | ||
1207 | AMDGPU_DPM_FORCED_LEVEL_LOW = 1, | ||
1208 | AMDGPU_DPM_FORCED_LEVEL_HIGH = 2, | ||
1209 | AMDGPU_DPM_FORCED_LEVEL_MANUAL = 3, | ||
1210 | }; | ||
1211 | |||
1212 | struct amdgpu_vce_state { | ||
1213 | /* vce clocks */ | ||
1214 | u32 evclk; | ||
1215 | u32 ecclk; | ||
1216 | /* gpu clocks */ | ||
1217 | u32 sclk; | ||
1218 | u32 mclk; | ||
1219 | u8 clk_idx; | ||
1220 | u8 pstate; | ||
1221 | }; | ||
1222 | |||
1223 | struct amdgpu_dpm_funcs { | ||
1224 | int (*get_temperature)(struct amdgpu_device *adev); | ||
1225 | int (*pre_set_power_state)(struct amdgpu_device *adev); | ||
1226 | int (*set_power_state)(struct amdgpu_device *adev); | ||
1227 | void (*post_set_power_state)(struct amdgpu_device *adev); | ||
1228 | void (*display_configuration_changed)(struct amdgpu_device *adev); | ||
1229 | u32 (*get_sclk)(struct amdgpu_device *adev, bool low); | ||
1230 | u32 (*get_mclk)(struct amdgpu_device *adev, bool low); | ||
1231 | void (*print_power_state)(struct amdgpu_device *adev, struct amdgpu_ps *ps); | ||
1232 | void (*debugfs_print_current_performance_level)(struct amdgpu_device *adev, struct seq_file *m); | ||
1233 | int (*force_performance_level)(struct amdgpu_device *adev, enum amdgpu_dpm_forced_level level); | ||
1234 | bool (*vblank_too_short)(struct amdgpu_device *adev); | ||
1235 | void (*powergate_uvd)(struct amdgpu_device *adev, bool gate); | ||
1236 | void (*powergate_vce)(struct amdgpu_device *adev, bool gate); | ||
1237 | void (*enable_bapm)(struct amdgpu_device *adev, bool enable); | ||
1238 | void (*set_fan_control_mode)(struct amdgpu_device *adev, u32 mode); | ||
1239 | u32 (*get_fan_control_mode)(struct amdgpu_device *adev); | ||
1240 | int (*set_fan_speed_percent)(struct amdgpu_device *adev, u32 speed); | ||
1241 | int (*get_fan_speed_percent)(struct amdgpu_device *adev, u32 *speed); | ||
1242 | int (*force_clock_level)(struct amdgpu_device *adev, enum pp_clock_type type, uint32_t mask); | ||
1243 | int (*print_clock_levels)(struct amdgpu_device *adev, enum pp_clock_type type, char *buf); | ||
1244 | int (*get_sclk_od)(struct amdgpu_device *adev); | ||
1245 | int (*set_sclk_od)(struct amdgpu_device *adev, uint32_t value); | ||
1246 | int (*get_mclk_od)(struct amdgpu_device *adev); | ||
1247 | int (*set_mclk_od)(struct amdgpu_device *adev, uint32_t value); | ||
1248 | }; | ||
1249 | |||
1250 | struct amdgpu_dpm { | ||
1251 | struct amdgpu_ps *ps; | ||
1252 | /* number of valid power states */ | ||
1253 | int num_ps; | ||
1254 | /* current power state that is active */ | ||
1255 | struct amdgpu_ps *current_ps; | ||
1256 | /* requested power state */ | ||
1257 | struct amdgpu_ps *requested_ps; | ||
1258 | /* boot up power state */ | ||
1259 | struct amdgpu_ps *boot_ps; | ||
1260 | /* default uvd power state */ | ||
1261 | struct amdgpu_ps *uvd_ps; | ||
1262 | /* vce requirements */ | ||
1263 | struct amdgpu_vce_state vce_states[AMDGPU_MAX_VCE_LEVELS]; | ||
1264 | enum amdgpu_vce_level vce_level; | ||
1265 | enum amd_pm_state_type state; | ||
1266 | enum amd_pm_state_type user_state; | ||
1267 | u32 platform_caps; | ||
1268 | u32 voltage_response_time; | ||
1269 | u32 backbias_response_time; | ||
1270 | void *priv; | ||
1271 | u32 new_active_crtcs; | ||
1272 | int new_active_crtc_count; | ||
1273 | u32 current_active_crtcs; | ||
1274 | int current_active_crtc_count; | ||
1275 | struct amdgpu_dpm_dynamic_state dyn_state; | ||
1276 | struct amdgpu_dpm_fan fan; | ||
1277 | u32 tdp_limit; | ||
1278 | u32 near_tdp_limit; | ||
1279 | u32 near_tdp_limit_adjusted; | ||
1280 | u32 sq_ramping_threshold; | ||
1281 | u32 cac_leakage; | ||
1282 | u16 tdp_od_limit; | ||
1283 | u32 tdp_adjustment; | ||
1284 | u16 load_line_slope; | ||
1285 | bool power_control; | ||
1286 | bool ac_power; | ||
1287 | /* special states active */ | ||
1288 | bool thermal_active; | ||
1289 | bool uvd_active; | ||
1290 | bool vce_active; | ||
1291 | /* thermal handling */ | ||
1292 | struct amdgpu_dpm_thermal thermal; | ||
1293 | /* forced levels */ | ||
1294 | enum amdgpu_dpm_forced_level forced_level; | ||
1295 | }; | ||
1296 | |||
1297 | struct amdgpu_pm { | ||
1298 | struct mutex mutex; | ||
1299 | u32 current_sclk; | ||
1300 | u32 current_mclk; | ||
1301 | u32 default_sclk; | ||
1302 | u32 default_mclk; | ||
1303 | struct amdgpu_i2c_chan *i2c_bus; | ||
1304 | /* internal thermal controller on rv6xx+ */ | ||
1305 | enum amdgpu_int_thermal_type int_thermal_type; | ||
1306 | struct device *int_hwmon_dev; | ||
1307 | /* fan control parameters */ | ||
1308 | bool no_fan; | ||
1309 | u8 fan_pulses_per_revolution; | ||
1310 | u8 fan_min_rpm; | ||
1311 | u8 fan_max_rpm; | ||
1312 | /* dpm */ | ||
1313 | bool dpm_enabled; | ||
1314 | bool sysfs_initialized; | ||
1315 | struct amdgpu_dpm dpm; | ||
1316 | const struct firmware *fw; /* SMC firmware */ | ||
1317 | uint32_t fw_version; | ||
1318 | const struct amdgpu_dpm_funcs *funcs; | ||
1319 | uint32_t pcie_gen_mask; | ||
1320 | uint32_t pcie_mlw_mask; | ||
1321 | struct amd_pp_display_configuration pm_display_cfg;/* set by DAL */ | ||
1322 | }; | ||
1323 | |||
1324 | void amdgpu_get_pcie_info(struct amdgpu_device *adev); | 977 | void amdgpu_get_pcie_info(struct amdgpu_device *adev); |
1325 | 978 | ||
1326 | /* | 979 | /* |
@@ -1983,108 +1636,8 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring) | |||
1983 | #define amdgpu_display_resume_mc_access(adev, s) (adev)->mode_info.funcs->resume_mc_access((adev), (s)) | 1636 | #define amdgpu_display_resume_mc_access(adev, s) (adev)->mode_info.funcs->resume_mc_access((adev), (s)) |
1984 | #define amdgpu_emit_copy_buffer(adev, ib, s, d, b) (adev)->mman.buffer_funcs->emit_copy_buffer((ib), (s), (d), (b)) | 1637 | #define amdgpu_emit_copy_buffer(adev, ib, s, d, b) (adev)->mman.buffer_funcs->emit_copy_buffer((ib), (s), (d), (b)) |
1985 | #define amdgpu_emit_fill_buffer(adev, ib, s, d, b) (adev)->mman.buffer_funcs->emit_fill_buffer((ib), (s), (d), (b)) | 1638 | #define amdgpu_emit_fill_buffer(adev, ib, s, d, b) (adev)->mman.buffer_funcs->emit_fill_buffer((ib), (s), (d), (b)) |
1986 | #define amdgpu_dpm_pre_set_power_state(adev) (adev)->pm.funcs->pre_set_power_state((adev)) | ||
1987 | #define amdgpu_dpm_set_power_state(adev) (adev)->pm.funcs->set_power_state((adev)) | ||
1988 | #define amdgpu_dpm_post_set_power_state(adev) (adev)->pm.funcs->post_set_power_state((adev)) | ||
1989 | #define amdgpu_dpm_display_configuration_changed(adev) (adev)->pm.funcs->display_configuration_changed((adev)) | ||
1990 | #define amdgpu_dpm_print_power_state(adev, ps) (adev)->pm.funcs->print_power_state((adev), (ps)) | ||
1991 | #define amdgpu_dpm_vblank_too_short(adev) (adev)->pm.funcs->vblank_too_short((adev)) | ||
1992 | #define amdgpu_dpm_enable_bapm(adev, e) (adev)->pm.funcs->enable_bapm((adev), (e)) | ||
1993 | #define amdgpu_gfx_get_gpu_clock_counter(adev) (adev)->gfx.funcs->get_gpu_clock_counter((adev)) | 1639 | #define amdgpu_gfx_get_gpu_clock_counter(adev) (adev)->gfx.funcs->get_gpu_clock_counter((adev)) |
1994 | #define amdgpu_gfx_select_se_sh(adev, se, sh, instance) (adev)->gfx.funcs->select_se_sh((adev), (se), (sh), (instance)) | 1640 | #define amdgpu_gfx_select_se_sh(adev, se, sh, instance) (adev)->gfx.funcs->select_se_sh((adev), (se), (sh), (instance)) |
1995 | |||
1996 | #define amdgpu_dpm_read_sensor(adev, idx, value) \ | ||
1997 | ((adev)->pp_enabled ? \ | ||
1998 | (adev)->powerplay.pp_funcs->read_sensor(adev->powerplay.pp_handle, (idx), (value)) : \ | ||
1999 | -EINVAL) | ||
2000 | |||
2001 | #define amdgpu_dpm_get_temperature(adev) \ | ||
2002 | ((adev)->pp_enabled ? \ | ||
2003 | (adev)->powerplay.pp_funcs->get_temperature((adev)->powerplay.pp_handle) : \ | ||
2004 | (adev)->pm.funcs->get_temperature((adev))) | ||
2005 | |||
2006 | #define amdgpu_dpm_set_fan_control_mode(adev, m) \ | ||
2007 | ((adev)->pp_enabled ? \ | ||
2008 | (adev)->powerplay.pp_funcs->set_fan_control_mode((adev)->powerplay.pp_handle, (m)) : \ | ||
2009 | (adev)->pm.funcs->set_fan_control_mode((adev), (m))) | ||
2010 | |||
2011 | #define amdgpu_dpm_get_fan_control_mode(adev) \ | ||
2012 | ((adev)->pp_enabled ? \ | ||
2013 | (adev)->powerplay.pp_funcs->get_fan_control_mode((adev)->powerplay.pp_handle) : \ | ||
2014 | (adev)->pm.funcs->get_fan_control_mode((adev))) | ||
2015 | |||
2016 | #define amdgpu_dpm_set_fan_speed_percent(adev, s) \ | ||
2017 | ((adev)->pp_enabled ? \ | ||
2018 | (adev)->powerplay.pp_funcs->set_fan_speed_percent((adev)->powerplay.pp_handle, (s)) : \ | ||
2019 | (adev)->pm.funcs->set_fan_speed_percent((adev), (s))) | ||
2020 | |||
2021 | #define amdgpu_dpm_get_fan_speed_percent(adev, s) \ | ||
2022 | ((adev)->pp_enabled ? \ | ||
2023 | (adev)->powerplay.pp_funcs->get_fan_speed_percent((adev)->powerplay.pp_handle, (s)) : \ | ||
2024 | (adev)->pm.funcs->get_fan_speed_percent((adev), (s))) | ||
2025 | |||
2026 | #define amdgpu_dpm_get_sclk(adev, l) \ | ||
2027 | ((adev)->pp_enabled ? \ | ||
2028 | (adev)->powerplay.pp_funcs->get_sclk((adev)->powerplay.pp_handle, (l)) : \ | ||
2029 | (adev)->pm.funcs->get_sclk((adev), (l))) | ||
2030 | |||
2031 | #define amdgpu_dpm_get_mclk(adev, l) \ | ||
2032 | ((adev)->pp_enabled ? \ | ||
2033 | (adev)->powerplay.pp_funcs->get_mclk((adev)->powerplay.pp_handle, (l)) : \ | ||
2034 | (adev)->pm.funcs->get_mclk((adev), (l))) | ||
2035 | |||
2036 | |||
2037 | #define amdgpu_dpm_force_performance_level(adev, l) \ | ||
2038 | ((adev)->pp_enabled ? \ | ||
2039 | (adev)->powerplay.pp_funcs->force_performance_level((adev)->powerplay.pp_handle, (l)) : \ | ||
2040 | (adev)->pm.funcs->force_performance_level((adev), (l))) | ||
2041 | |||
2042 | #define amdgpu_dpm_powergate_uvd(adev, g) \ | ||
2043 | ((adev)->pp_enabled ? \ | ||
2044 | (adev)->powerplay.pp_funcs->powergate_uvd((adev)->powerplay.pp_handle, (g)) : \ | ||
2045 | (adev)->pm.funcs->powergate_uvd((adev), (g))) | ||
2046 | |||
2047 | #define amdgpu_dpm_powergate_vce(adev, g) \ | ||
2048 | ((adev)->pp_enabled ? \ | ||
2049 | (adev)->powerplay.pp_funcs->powergate_vce((adev)->powerplay.pp_handle, (g)) : \ | ||
2050 | (adev)->pm.funcs->powergate_vce((adev), (g))) | ||
2051 | |||
2052 | #define amdgpu_dpm_get_current_power_state(adev) \ | ||
2053 | (adev)->powerplay.pp_funcs->get_current_power_state((adev)->powerplay.pp_handle) | ||
2054 | |||
2055 | #define amdgpu_dpm_get_performance_level(adev) \ | ||
2056 | (adev)->powerplay.pp_funcs->get_performance_level((adev)->powerplay.pp_handle) | ||
2057 | |||
2058 | #define amdgpu_dpm_get_pp_num_states(adev, data) \ | ||
2059 | (adev)->powerplay.pp_funcs->get_pp_num_states((adev)->powerplay.pp_handle, data) | ||
2060 | |||
2061 | #define amdgpu_dpm_get_pp_table(adev, table) \ | ||
2062 | (adev)->powerplay.pp_funcs->get_pp_table((adev)->powerplay.pp_handle, table) | ||
2063 | |||
2064 | #define amdgpu_dpm_set_pp_table(adev, buf, size) \ | ||
2065 | (adev)->powerplay.pp_funcs->set_pp_table((adev)->powerplay.pp_handle, buf, size) | ||
2066 | |||
2067 | #define amdgpu_dpm_print_clock_levels(adev, type, buf) \ | ||
2068 | (adev)->powerplay.pp_funcs->print_clock_levels((adev)->powerplay.pp_handle, type, buf) | ||
2069 | |||
2070 | #define amdgpu_dpm_force_clock_level(adev, type, level) \ | ||
2071 | (adev)->powerplay.pp_funcs->force_clock_level((adev)->powerplay.pp_handle, type, level) | ||
2072 | |||
2073 | #define amdgpu_dpm_get_sclk_od(adev) \ | ||
2074 | (adev)->powerplay.pp_funcs->get_sclk_od((adev)->powerplay.pp_handle) | ||
2075 | |||
2076 | #define amdgpu_dpm_set_sclk_od(adev, value) \ | ||
2077 | (adev)->powerplay.pp_funcs->set_sclk_od((adev)->powerplay.pp_handle, value) | ||
2078 | |||
2079 | #define amdgpu_dpm_get_mclk_od(adev) \ | ||
2080 | ((adev)->powerplay.pp_funcs->get_mclk_od((adev)->powerplay.pp_handle)) | ||
2081 | |||
2082 | #define amdgpu_dpm_set_mclk_od(adev, value) \ | ||
2083 | ((adev)->powerplay.pp_funcs->set_mclk_od((adev)->powerplay.pp_handle, value)) | ||
2084 | |||
2085 | #define amdgpu_dpm_dispatch_task(adev, event_id, input, output) \ | ||
2086 | (adev)->powerplay.pp_funcs->dispatch_tasks((adev)->powerplay.pp_handle, (event_id), (input), (output)) | ||
2087 | |||
2088 | #define amdgpu_gds_switch(adev, r, v, d, w, a) (adev)->gds.funcs->patch_gds_switch((r), (v), (d), (w), (a)) | 1641 | #define amdgpu_gds_switch(adev, r, v, d, w, a) (adev)->gds.funcs->patch_gds_switch((r), (v), (d), (w), (a)) |
2089 | 1642 | ||
2090 | /* Common functions */ | 1643 | /* Common functions */ |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h index 3738a96c2619..d06496d3e08e 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h | |||
@@ -23,6 +23,453 @@ | |||
23 | #ifndef __AMDGPU_DPM_H__ | 23 | #ifndef __AMDGPU_DPM_H__ |
24 | #define __AMDGPU_DPM_H__ | 24 | #define __AMDGPU_DPM_H__ |
25 | 25 | ||
26 | enum amdgpu_int_thermal_type { | ||
27 | THERMAL_TYPE_NONE, | ||
28 | THERMAL_TYPE_EXTERNAL, | ||
29 | THERMAL_TYPE_EXTERNAL_GPIO, | ||
30 | THERMAL_TYPE_RV6XX, | ||
31 | THERMAL_TYPE_RV770, | ||
32 | THERMAL_TYPE_ADT7473_WITH_INTERNAL, | ||
33 | THERMAL_TYPE_EVERGREEN, | ||
34 | THERMAL_TYPE_SUMO, | ||
35 | THERMAL_TYPE_NI, | ||
36 | THERMAL_TYPE_SI, | ||
37 | THERMAL_TYPE_EMC2103_WITH_INTERNAL, | ||
38 | THERMAL_TYPE_CI, | ||
39 | THERMAL_TYPE_KV, | ||
40 | }; | ||
41 | |||
42 | enum amdgpu_dpm_auto_throttle_src { | ||
43 | AMDGPU_DPM_AUTO_THROTTLE_SRC_THERMAL, | ||
44 | AMDGPU_DPM_AUTO_THROTTLE_SRC_EXTERNAL | ||
45 | }; | ||
46 | |||
47 | enum amdgpu_dpm_event_src { | ||
48 | AMDGPU_DPM_EVENT_SRC_ANALOG = 0, | ||
49 | AMDGPU_DPM_EVENT_SRC_EXTERNAL = 1, | ||
50 | AMDGPU_DPM_EVENT_SRC_DIGITAL = 2, | ||
51 | AMDGPU_DPM_EVENT_SRC_ANALOG_OR_EXTERNAL = 3, | ||
52 | AMDGPU_DPM_EVENT_SRC_DIGIAL_OR_EXTERNAL = 4 | ||
53 | }; | ||
54 | |||
55 | #define AMDGPU_MAX_VCE_LEVELS 6 | ||
56 | |||
57 | enum amdgpu_vce_level { | ||
58 | AMDGPU_VCE_LEVEL_AC_ALL = 0, /* AC, All cases */ | ||
59 | AMDGPU_VCE_LEVEL_DC_EE = 1, /* DC, entropy encoding */ | ||
60 | AMDGPU_VCE_LEVEL_DC_LL_LOW = 2, /* DC, low latency queue, res <= 720 */ | ||
61 | AMDGPU_VCE_LEVEL_DC_LL_HIGH = 3, /* DC, low latency queue, 1080 >= res > 720 */ | ||
62 | AMDGPU_VCE_LEVEL_DC_GP_LOW = 4, /* DC, general purpose queue, res <= 720 */ | ||
63 | AMDGPU_VCE_LEVEL_DC_GP_HIGH = 5, /* DC, general purpose queue, 1080 >= res > 720 */ | ||
64 | }; | ||
65 | |||
66 | struct amdgpu_ps { | ||
67 | u32 caps; /* vbios flags */ | ||
68 | u32 class; /* vbios flags */ | ||
69 | u32 class2; /* vbios flags */ | ||
70 | /* UVD clocks */ | ||
71 | u32 vclk; | ||
72 | u32 dclk; | ||
73 | /* VCE clocks */ | ||
74 | u32 evclk; | ||
75 | u32 ecclk; | ||
76 | bool vce_active; | ||
77 | enum amdgpu_vce_level vce_level; | ||
78 | /* asic priv */ | ||
79 | void *ps_priv; | ||
80 | }; | ||
81 | |||
82 | struct amdgpu_dpm_thermal { | ||
83 | /* thermal interrupt work */ | ||
84 | struct work_struct work; | ||
85 | /* low temperature threshold */ | ||
86 | int min_temp; | ||
87 | /* high temperature threshold */ | ||
88 | int max_temp; | ||
89 | /* was last interrupt low to high or high to low */ | ||
90 | bool high_to_low; | ||
91 | /* interrupt source */ | ||
92 | struct amdgpu_irq_src irq; | ||
93 | }; | ||
94 | |||
95 | enum amdgpu_clk_action | ||
96 | { | ||
97 | AMDGPU_SCLK_UP = 1, | ||
98 | AMDGPU_SCLK_DOWN | ||
99 | }; | ||
100 | |||
101 | struct amdgpu_blacklist_clocks | ||
102 | { | ||
103 | u32 sclk; | ||
104 | u32 mclk; | ||
105 | enum amdgpu_clk_action action; | ||
106 | }; | ||
107 | |||
108 | struct amdgpu_clock_and_voltage_limits { | ||
109 | u32 sclk; | ||
110 | u32 mclk; | ||
111 | u16 vddc; | ||
112 | u16 vddci; | ||
113 | }; | ||
114 | |||
115 | struct amdgpu_clock_array { | ||
116 | u32 count; | ||
117 | u32 *values; | ||
118 | }; | ||
119 | |||
120 | struct amdgpu_clock_voltage_dependency_entry { | ||
121 | u32 clk; | ||
122 | u16 v; | ||
123 | }; | ||
124 | |||
125 | struct amdgpu_clock_voltage_dependency_table { | ||
126 | u32 count; | ||
127 | struct amdgpu_clock_voltage_dependency_entry *entries; | ||
128 | }; | ||
129 | |||
130 | union amdgpu_cac_leakage_entry { | ||
131 | struct { | ||
132 | u16 vddc; | ||
133 | u32 leakage; | ||
134 | }; | ||
135 | struct { | ||
136 | u16 vddc1; | ||
137 | u16 vddc2; | ||
138 | u16 vddc3; | ||
139 | }; | ||
140 | }; | ||
141 | |||
142 | struct amdgpu_cac_leakage_table { | ||
143 | u32 count; | ||
144 | union amdgpu_cac_leakage_entry *entries; | ||
145 | }; | ||
146 | |||
147 | struct amdgpu_phase_shedding_limits_entry { | ||
148 | u16 voltage; | ||
149 | u32 sclk; | ||
150 | u32 mclk; | ||
151 | }; | ||
152 | |||
153 | struct amdgpu_phase_shedding_limits_table { | ||
154 | u32 count; | ||
155 | struct amdgpu_phase_shedding_limits_entry *entries; | ||
156 | }; | ||
157 | |||
158 | struct amdgpu_uvd_clock_voltage_dependency_entry { | ||
159 | u32 vclk; | ||
160 | u32 dclk; | ||
161 | u16 v; | ||
162 | }; | ||
163 | |||
164 | struct amdgpu_uvd_clock_voltage_dependency_table { | ||
165 | u8 count; | ||
166 | struct amdgpu_uvd_clock_voltage_dependency_entry *entries; | ||
167 | }; | ||
168 | |||
169 | struct amdgpu_vce_clock_voltage_dependency_entry { | ||
170 | u32 ecclk; | ||
171 | u32 evclk; | ||
172 | u16 v; | ||
173 | }; | ||
174 | |||
175 | struct amdgpu_vce_clock_voltage_dependency_table { | ||
176 | u8 count; | ||
177 | struct amdgpu_vce_clock_voltage_dependency_entry *entries; | ||
178 | }; | ||
179 | |||
180 | struct amdgpu_ppm_table { | ||
181 | u8 ppm_design; | ||
182 | u16 cpu_core_number; | ||
183 | u32 platform_tdp; | ||
184 | u32 small_ac_platform_tdp; | ||
185 | u32 platform_tdc; | ||
186 | u32 small_ac_platform_tdc; | ||
187 | u32 apu_tdp; | ||
188 | u32 dgpu_tdp; | ||
189 | u32 dgpu_ulv_power; | ||
190 | u32 tj_max; | ||
191 | }; | ||
192 | |||
193 | struct amdgpu_cac_tdp_table { | ||
194 | u16 tdp; | ||
195 | u16 configurable_tdp; | ||
196 | u16 tdc; | ||
197 | u16 battery_power_limit; | ||
198 | u16 small_power_limit; | ||
199 | u16 low_cac_leakage; | ||
200 | u16 high_cac_leakage; | ||
201 | u16 maximum_power_delivery_limit; | ||
202 | }; | ||
203 | |||
204 | struct amdgpu_dpm_dynamic_state { | ||
205 | struct amdgpu_clock_voltage_dependency_table vddc_dependency_on_sclk; | ||
206 | struct amdgpu_clock_voltage_dependency_table vddci_dependency_on_mclk; | ||
207 | struct amdgpu_clock_voltage_dependency_table vddc_dependency_on_mclk; | ||
208 | struct amdgpu_clock_voltage_dependency_table mvdd_dependency_on_mclk; | ||
209 | struct amdgpu_clock_voltage_dependency_table vddc_dependency_on_dispclk; | ||
210 | struct amdgpu_uvd_clock_voltage_dependency_table uvd_clock_voltage_dependency_table; | ||
211 | struct amdgpu_vce_clock_voltage_dependency_table vce_clock_voltage_dependency_table; | ||
212 | struct amdgpu_clock_voltage_dependency_table samu_clock_voltage_dependency_table; | ||
213 | struct amdgpu_clock_voltage_dependency_table acp_clock_voltage_dependency_table; | ||
214 | struct amdgpu_clock_voltage_dependency_table vddgfx_dependency_on_sclk; | ||
215 | struct amdgpu_clock_array valid_sclk_values; | ||
216 | struct amdgpu_clock_array valid_mclk_values; | ||
217 | struct amdgpu_clock_and_voltage_limits max_clock_voltage_on_dc; | ||
218 | struct amdgpu_clock_and_voltage_limits max_clock_voltage_on_ac; | ||
219 | u32 mclk_sclk_ratio; | ||
220 | u32 sclk_mclk_delta; | ||
221 | u16 vddc_vddci_delta; | ||
222 | u16 min_vddc_for_pcie_gen2; | ||
223 | struct amdgpu_cac_leakage_table cac_leakage_table; | ||
224 | struct amdgpu_phase_shedding_limits_table phase_shedding_limits_table; | ||
225 | struct amdgpu_ppm_table *ppm_table; | ||
226 | struct amdgpu_cac_tdp_table *cac_tdp_table; | ||
227 | }; | ||
228 | |||
229 | struct amdgpu_dpm_fan { | ||
230 | u16 t_min; | ||
231 | u16 t_med; | ||
232 | u16 t_high; | ||
233 | u16 pwm_min; | ||
234 | u16 pwm_med; | ||
235 | u16 pwm_high; | ||
236 | u8 t_hyst; | ||
237 | u32 cycle_delay; | ||
238 | u16 t_max; | ||
239 | u8 control_mode; | ||
240 | u16 default_max_fan_pwm; | ||
241 | u16 default_fan_output_sensitivity; | ||
242 | u16 fan_output_sensitivity; | ||
243 | bool ucode_fan_control; | ||
244 | }; | ||
245 | |||
246 | enum amdgpu_pcie_gen { | ||
247 | AMDGPU_PCIE_GEN1 = 0, | ||
248 | AMDGPU_PCIE_GEN2 = 1, | ||
249 | AMDGPU_PCIE_GEN3 = 2, | ||
250 | AMDGPU_PCIE_GEN_INVALID = 0xffff | ||
251 | }; | ||
252 | |||
253 | enum amdgpu_dpm_forced_level { | ||
254 | AMDGPU_DPM_FORCED_LEVEL_AUTO = 0, | ||
255 | AMDGPU_DPM_FORCED_LEVEL_LOW = 1, | ||
256 | AMDGPU_DPM_FORCED_LEVEL_HIGH = 2, | ||
257 | AMDGPU_DPM_FORCED_LEVEL_MANUAL = 3, | ||
258 | }; | ||
259 | |||
260 | struct amdgpu_vce_state { | ||
261 | /* vce clocks */ | ||
262 | u32 evclk; | ||
263 | u32 ecclk; | ||
264 | /* gpu clocks */ | ||
265 | u32 sclk; | ||
266 | u32 mclk; | ||
267 | u8 clk_idx; | ||
268 | u8 pstate; | ||
269 | }; | ||
270 | |||
271 | struct amdgpu_dpm_funcs { | ||
272 | int (*get_temperature)(struct amdgpu_device *adev); | ||
273 | int (*pre_set_power_state)(struct amdgpu_device *adev); | ||
274 | int (*set_power_state)(struct amdgpu_device *adev); | ||
275 | void (*post_set_power_state)(struct amdgpu_device *adev); | ||
276 | void (*display_configuration_changed)(struct amdgpu_device *adev); | ||
277 | u32 (*get_sclk)(struct amdgpu_device *adev, bool low); | ||
278 | u32 (*get_mclk)(struct amdgpu_device *adev, bool low); | ||
279 | void (*print_power_state)(struct amdgpu_device *adev, struct amdgpu_ps *ps); | ||
280 | void (*debugfs_print_current_performance_level)(struct amdgpu_device *adev, struct seq_file *m); | ||
281 | int (*force_performance_level)(struct amdgpu_device *adev, enum amdgpu_dpm_forced_level level); | ||
282 | bool (*vblank_too_short)(struct amdgpu_device *adev); | ||
283 | void (*powergate_uvd)(struct amdgpu_device *adev, bool gate); | ||
284 | void (*powergate_vce)(struct amdgpu_device *adev, bool gate); | ||
285 | void (*enable_bapm)(struct amdgpu_device *adev, bool enable); | ||
286 | void (*set_fan_control_mode)(struct amdgpu_device *adev, u32 mode); | ||
287 | u32 (*get_fan_control_mode)(struct amdgpu_device *adev); | ||
288 | int (*set_fan_speed_percent)(struct amdgpu_device *adev, u32 speed); | ||
289 | int (*get_fan_speed_percent)(struct amdgpu_device *adev, u32 *speed); | ||
290 | int (*force_clock_level)(struct amdgpu_device *adev, enum pp_clock_type type, uint32_t mask); | ||
291 | int (*print_clock_levels)(struct amdgpu_device *adev, enum pp_clock_type type, char *buf); | ||
292 | int (*get_sclk_od)(struct amdgpu_device *adev); | ||
293 | int (*set_sclk_od)(struct amdgpu_device *adev, uint32_t value); | ||
294 | int (*get_mclk_od)(struct amdgpu_device *adev); | ||
295 | int (*set_mclk_od)(struct amdgpu_device *adev, uint32_t value); | ||
296 | }; | ||
297 | |||
298 | #define amdgpu_dpm_pre_set_power_state(adev) (adev)->pm.funcs->pre_set_power_state((adev)) | ||
299 | #define amdgpu_dpm_set_power_state(adev) (adev)->pm.funcs->set_power_state((adev)) | ||
300 | #define amdgpu_dpm_post_set_power_state(adev) (adev)->pm.funcs->post_set_power_state((adev)) | ||
301 | #define amdgpu_dpm_display_configuration_changed(adev) (adev)->pm.funcs->display_configuration_changed((adev)) | ||
302 | #define amdgpu_dpm_print_power_state(adev, ps) (adev)->pm.funcs->print_power_state((adev), (ps)) | ||
303 | #define amdgpu_dpm_vblank_too_short(adev) (adev)->pm.funcs->vblank_too_short((adev)) | ||
304 | #define amdgpu_dpm_enable_bapm(adev, e) (adev)->pm.funcs->enable_bapm((adev), (e)) | ||
305 | |||
306 | #define amdgpu_dpm_read_sensor(adev, idx, value) \ | ||
307 | ((adev)->pp_enabled ? \ | ||
308 | (adev)->powerplay.pp_funcs->read_sensor(adev->powerplay.pp_handle, (idx), (value)) : \ | ||
309 | -EINVAL) | ||
310 | |||
311 | #define amdgpu_dpm_get_temperature(adev) \ | ||
312 | ((adev)->pp_enabled ? \ | ||
313 | (adev)->powerplay.pp_funcs->get_temperature((adev)->powerplay.pp_handle) : \ | ||
314 | (adev)->pm.funcs->get_temperature((adev))) | ||
315 | |||
316 | #define amdgpu_dpm_set_fan_control_mode(adev, m) \ | ||
317 | ((adev)->pp_enabled ? \ | ||
318 | (adev)->powerplay.pp_funcs->set_fan_control_mode((adev)->powerplay.pp_handle, (m)) : \ | ||
319 | (adev)->pm.funcs->set_fan_control_mode((adev), (m))) | ||
320 | |||
321 | #define amdgpu_dpm_get_fan_control_mode(adev) \ | ||
322 | ((adev)->pp_enabled ? \ | ||
323 | (adev)->powerplay.pp_funcs->get_fan_control_mode((adev)->powerplay.pp_handle) : \ | ||
324 | (adev)->pm.funcs->get_fan_control_mode((adev))) | ||
325 | |||
326 | #define amdgpu_dpm_set_fan_speed_percent(adev, s) \ | ||
327 | ((adev)->pp_enabled ? \ | ||
328 | (adev)->powerplay.pp_funcs->set_fan_speed_percent((adev)->powerplay.pp_handle, (s)) : \ | ||
329 | (adev)->pm.funcs->set_fan_speed_percent((adev), (s))) | ||
330 | |||
331 | #define amdgpu_dpm_get_fan_speed_percent(adev, s) \ | ||
332 | ((adev)->pp_enabled ? \ | ||
333 | (adev)->powerplay.pp_funcs->get_fan_speed_percent((adev)->powerplay.pp_handle, (s)) : \ | ||
334 | (adev)->pm.funcs->get_fan_speed_percent((adev), (s))) | ||
335 | |||
336 | #define amdgpu_dpm_get_sclk(adev, l) \ | ||
337 | ((adev)->pp_enabled ? \ | ||
338 | (adev)->powerplay.pp_funcs->get_sclk((adev)->powerplay.pp_handle, (l)) : \ | ||
339 | (adev)->pm.funcs->get_sclk((adev), (l))) | ||
340 | |||
341 | #define amdgpu_dpm_get_mclk(adev, l) \ | ||
342 | ((adev)->pp_enabled ? \ | ||
343 | (adev)->powerplay.pp_funcs->get_mclk((adev)->powerplay.pp_handle, (l)) : \ | ||
344 | (adev)->pm.funcs->get_mclk((adev), (l))) | ||
345 | |||
346 | |||
347 | #define amdgpu_dpm_force_performance_level(adev, l) \ | ||
348 | ((adev)->pp_enabled ? \ | ||
349 | (adev)->powerplay.pp_funcs->force_performance_level((adev)->powerplay.pp_handle, (l)) : \ | ||
350 | (adev)->pm.funcs->force_performance_level((adev), (l))) | ||
351 | |||
352 | #define amdgpu_dpm_powergate_uvd(adev, g) \ | ||
353 | ((adev)->pp_enabled ? \ | ||
354 | (adev)->powerplay.pp_funcs->powergate_uvd((adev)->powerplay.pp_handle, (g)) : \ | ||
355 | (adev)->pm.funcs->powergate_uvd((adev), (g))) | ||
356 | |||
357 | #define amdgpu_dpm_powergate_vce(adev, g) \ | ||
358 | ((adev)->pp_enabled ? \ | ||
359 | (adev)->powerplay.pp_funcs->powergate_vce((adev)->powerplay.pp_handle, (g)) : \ | ||
360 | (adev)->pm.funcs->powergate_vce((adev), (g))) | ||
361 | |||
362 | #define amdgpu_dpm_get_current_power_state(adev) \ | ||
363 | (adev)->powerplay.pp_funcs->get_current_power_state((adev)->powerplay.pp_handle) | ||
364 | |||
365 | #define amdgpu_dpm_get_performance_level(adev) \ | ||
366 | (adev)->powerplay.pp_funcs->get_performance_level((adev)->powerplay.pp_handle) | ||
367 | |||
368 | #define amdgpu_dpm_get_pp_num_states(adev, data) \ | ||
369 | (adev)->powerplay.pp_funcs->get_pp_num_states((adev)->powerplay.pp_handle, data) | ||
370 | |||
371 | #define amdgpu_dpm_get_pp_table(adev, table) \ | ||
372 | (adev)->powerplay.pp_funcs->get_pp_table((adev)->powerplay.pp_handle, table) | ||
373 | |||
374 | #define amdgpu_dpm_set_pp_table(adev, buf, size) \ | ||
375 | (adev)->powerplay.pp_funcs->set_pp_table((adev)->powerplay.pp_handle, buf, size) | ||
376 | |||
377 | #define amdgpu_dpm_print_clock_levels(adev, type, buf) \ | ||
378 | (adev)->powerplay.pp_funcs->print_clock_levels((adev)->powerplay.pp_handle, type, buf) | ||
379 | |||
380 | #define amdgpu_dpm_force_clock_level(adev, type, level) \ | ||
381 | (adev)->powerplay.pp_funcs->force_clock_level((adev)->powerplay.pp_handle, type, level) | ||
382 | |||
383 | #define amdgpu_dpm_get_sclk_od(adev) \ | ||
384 | (adev)->powerplay.pp_funcs->get_sclk_od((adev)->powerplay.pp_handle) | ||
385 | |||
386 | #define amdgpu_dpm_set_sclk_od(adev, value) \ | ||
387 | (adev)->powerplay.pp_funcs->set_sclk_od((adev)->powerplay.pp_handle, value) | ||
388 | |||
389 | #define amdgpu_dpm_get_mclk_od(adev) \ | ||
390 | ((adev)->powerplay.pp_funcs->get_mclk_od((adev)->powerplay.pp_handle)) | ||
391 | |||
392 | #define amdgpu_dpm_set_mclk_od(adev, value) \ | ||
393 | ((adev)->powerplay.pp_funcs->set_mclk_od((adev)->powerplay.pp_handle, value)) | ||
394 | |||
395 | #define amdgpu_dpm_dispatch_task(adev, event_id, input, output) \ | ||
396 | (adev)->powerplay.pp_funcs->dispatch_tasks((adev)->powerplay.pp_handle, (event_id), (input), (output)) | ||
397 | |||
398 | |||
399 | struct amdgpu_dpm { | ||
400 | struct amdgpu_ps *ps; | ||
401 | /* number of valid power states */ | ||
402 | int num_ps; | ||
403 | /* current power state that is active */ | ||
404 | struct amdgpu_ps *current_ps; | ||
405 | /* requested power state */ | ||
406 | struct amdgpu_ps *requested_ps; | ||
407 | /* boot up power state */ | ||
408 | struct amdgpu_ps *boot_ps; | ||
409 | /* default uvd power state */ | ||
410 | struct amdgpu_ps *uvd_ps; | ||
411 | /* vce requirements */ | ||
412 | struct amdgpu_vce_state vce_states[AMDGPU_MAX_VCE_LEVELS]; | ||
413 | enum amdgpu_vce_level vce_level; | ||
414 | enum amd_pm_state_type state; | ||
415 | enum amd_pm_state_type user_state; | ||
416 | u32 platform_caps; | ||
417 | u32 voltage_response_time; | ||
418 | u32 backbias_response_time; | ||
419 | void *priv; | ||
420 | u32 new_active_crtcs; | ||
421 | int new_active_crtc_count; | ||
422 | u32 current_active_crtcs; | ||
423 | int current_active_crtc_count; | ||
424 | struct amdgpu_dpm_dynamic_state dyn_state; | ||
425 | struct amdgpu_dpm_fan fan; | ||
426 | u32 tdp_limit; | ||
427 | u32 near_tdp_limit; | ||
428 | u32 near_tdp_limit_adjusted; | ||
429 | u32 sq_ramping_threshold; | ||
430 | u32 cac_leakage; | ||
431 | u16 tdp_od_limit; | ||
432 | u32 tdp_adjustment; | ||
433 | u16 load_line_slope; | ||
434 | bool power_control; | ||
435 | bool ac_power; | ||
436 | /* special states active */ | ||
437 | bool thermal_active; | ||
438 | bool uvd_active; | ||
439 | bool vce_active; | ||
440 | /* thermal handling */ | ||
441 | struct amdgpu_dpm_thermal thermal; | ||
442 | /* forced levels */ | ||
443 | enum amdgpu_dpm_forced_level forced_level; | ||
444 | }; | ||
445 | |||
446 | struct amdgpu_pm { | ||
447 | struct mutex mutex; | ||
448 | u32 current_sclk; | ||
449 | u32 current_mclk; | ||
450 | u32 default_sclk; | ||
451 | u32 default_mclk; | ||
452 | struct amdgpu_i2c_chan *i2c_bus; | ||
453 | /* internal thermal controller on rv6xx+ */ | ||
454 | enum amdgpu_int_thermal_type int_thermal_type; | ||
455 | struct device *int_hwmon_dev; | ||
456 | /* fan control parameters */ | ||
457 | bool no_fan; | ||
458 | u8 fan_pulses_per_revolution; | ||
459 | u8 fan_min_rpm; | ||
460 | u8 fan_max_rpm; | ||
461 | /* dpm */ | ||
462 | bool dpm_enabled; | ||
463 | bool sysfs_initialized; | ||
464 | struct amdgpu_dpm dpm; | ||
465 | const struct firmware *fw; /* SMC firmware */ | ||
466 | uint32_t fw_version; | ||
467 | const struct amdgpu_dpm_funcs *funcs; | ||
468 | uint32_t pcie_gen_mask; | ||
469 | uint32_t pcie_mlw_mask; | ||
470 | struct amd_pp_display_configuration pm_display_cfg;/* set by DAL */ | ||
471 | }; | ||
472 | |||
26 | #define R600_SSTU_DFLT 0 | 473 | #define R600_SSTU_DFLT 0 |
27 | #define R600_SST_DFLT 0x00C8 | 474 | #define R600_SST_DFLT 0x00C8 |
28 | 475 | ||