1b843c749SSergey Zigachev /* 2b843c749SSergey Zigachev * Copyright 2014 Advanced Micro Devices, Inc. 3b843c749SSergey Zigachev * 4b843c749SSergey Zigachev * Permission is hereby granted, free of charge, to any person obtaining a 5b843c749SSergey Zigachev * copy of this software and associated documentation files (the "Software"), 6b843c749SSergey Zigachev * to deal in the Software without restriction, including without limitation 7b843c749SSergey Zigachev * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8b843c749SSergey Zigachev * and/or sell copies of the Software, and to permit persons to whom the 9b843c749SSergey Zigachev * Software is furnished to do so, subject to the following conditions: 10b843c749SSergey Zigachev * 11b843c749SSergey Zigachev * The above copyright notice and this permission notice shall be included in 12b843c749SSergey Zigachev * all copies or substantial portions of the Software. 13b843c749SSergey Zigachev * 14b843c749SSergey Zigachev * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15b843c749SSergey Zigachev * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16b843c749SSergey Zigachev * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17b843c749SSergey Zigachev * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18b843c749SSergey Zigachev * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19b843c749SSergey Zigachev * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20b843c749SSergey Zigachev * OTHER DEALINGS IN THE SOFTWARE. 21b843c749SSergey Zigachev * 22b843c749SSergey Zigachev */ 23b843c749SSergey Zigachev #ifndef __AMDGPU_DPM_H__ 24b843c749SSergey Zigachev #define __AMDGPU_DPM_H__ 25b843c749SSergey Zigachev 26b843c749SSergey Zigachev enum amdgpu_int_thermal_type { 27b843c749SSergey Zigachev THERMAL_TYPE_NONE, 28b843c749SSergey Zigachev THERMAL_TYPE_EXTERNAL, 29b843c749SSergey Zigachev THERMAL_TYPE_EXTERNAL_GPIO, 30b843c749SSergey Zigachev THERMAL_TYPE_RV6XX, 31b843c749SSergey Zigachev THERMAL_TYPE_RV770, 32b843c749SSergey Zigachev THERMAL_TYPE_ADT7473_WITH_INTERNAL, 33b843c749SSergey Zigachev THERMAL_TYPE_EVERGREEN, 34b843c749SSergey Zigachev THERMAL_TYPE_SUMO, 35b843c749SSergey Zigachev THERMAL_TYPE_NI, 36b843c749SSergey Zigachev THERMAL_TYPE_SI, 37b843c749SSergey Zigachev THERMAL_TYPE_EMC2103_WITH_INTERNAL, 38b843c749SSergey Zigachev THERMAL_TYPE_CI, 39b843c749SSergey Zigachev THERMAL_TYPE_KV, 40b843c749SSergey Zigachev }; 41b843c749SSergey Zigachev 42b843c749SSergey Zigachev enum amdgpu_dpm_auto_throttle_src { 43b843c749SSergey Zigachev AMDGPU_DPM_AUTO_THROTTLE_SRC_THERMAL, 44b843c749SSergey Zigachev AMDGPU_DPM_AUTO_THROTTLE_SRC_EXTERNAL 45b843c749SSergey Zigachev }; 46b843c749SSergey Zigachev 47b843c749SSergey Zigachev enum amdgpu_dpm_event_src { 48b843c749SSergey Zigachev AMDGPU_DPM_EVENT_SRC_ANALOG = 0, 49b843c749SSergey Zigachev AMDGPU_DPM_EVENT_SRC_EXTERNAL = 1, 50b843c749SSergey Zigachev AMDGPU_DPM_EVENT_SRC_DIGITAL = 2, 51b843c749SSergey Zigachev AMDGPU_DPM_EVENT_SRC_ANALOG_OR_EXTERNAL = 3, 52b843c749SSergey Zigachev AMDGPU_DPM_EVENT_SRC_DIGIAL_OR_EXTERNAL = 4 53b843c749SSergey Zigachev }; 54b843c749SSergey Zigachev 55b843c749SSergey Zigachev struct amdgpu_ps { 56b843c749SSergey Zigachev u32 caps; /* vbios flags */ 57b843c749SSergey Zigachev u32 class; /* vbios flags */ 58b843c749SSergey Zigachev u32 class2; /* vbios flags */ 59b843c749SSergey Zigachev /* UVD clocks */ 60b843c749SSergey Zigachev u32 vclk; 61b843c749SSergey Zigachev u32 dclk; 62b843c749SSergey Zigachev /* VCE clocks */ 63b843c749SSergey Zigachev u32 evclk; 64b843c749SSergey Zigachev u32 ecclk; 65b843c749SSergey Zigachev bool vce_active; 66b843c749SSergey Zigachev enum amd_vce_level vce_level; 67b843c749SSergey Zigachev /* asic priv */ 68b843c749SSergey Zigachev void *ps_priv; 69b843c749SSergey Zigachev }; 70b843c749SSergey Zigachev 71b843c749SSergey Zigachev struct amdgpu_dpm_thermal { 72b843c749SSergey Zigachev /* thermal interrupt work */ 73b843c749SSergey Zigachev struct work_struct work; 74b843c749SSergey Zigachev /* low temperature threshold */ 75b843c749SSergey Zigachev int min_temp; 76b843c749SSergey Zigachev /* high temperature threshold */ 77b843c749SSergey Zigachev int max_temp; 78b843c749SSergey Zigachev /* was last interrupt low to high or high to low */ 79b843c749SSergey Zigachev bool high_to_low; 80b843c749SSergey Zigachev /* interrupt source */ 81b843c749SSergey Zigachev struct amdgpu_irq_src irq; 82b843c749SSergey Zigachev }; 83b843c749SSergey Zigachev 84b843c749SSergey Zigachev enum amdgpu_clk_action 85b843c749SSergey Zigachev { 86b843c749SSergey Zigachev AMDGPU_SCLK_UP = 1, 87b843c749SSergey Zigachev AMDGPU_SCLK_DOWN 88b843c749SSergey Zigachev }; 89b843c749SSergey Zigachev 90b843c749SSergey Zigachev struct amdgpu_blacklist_clocks 91b843c749SSergey Zigachev { 92b843c749SSergey Zigachev u32 sclk; 93b843c749SSergey Zigachev u32 mclk; 94b843c749SSergey Zigachev enum amdgpu_clk_action action; 95b843c749SSergey Zigachev }; 96b843c749SSergey Zigachev 97b843c749SSergey Zigachev struct amdgpu_clock_and_voltage_limits { 98b843c749SSergey Zigachev u32 sclk; 99b843c749SSergey Zigachev u32 mclk; 100b843c749SSergey Zigachev u16 vddc; 101b843c749SSergey Zigachev u16 vddci; 102b843c749SSergey Zigachev }; 103b843c749SSergey Zigachev 104b843c749SSergey Zigachev struct amdgpu_clock_array { 105b843c749SSergey Zigachev u32 count; 106b843c749SSergey Zigachev u32 *values; 107b843c749SSergey Zigachev }; 108b843c749SSergey Zigachev 109b843c749SSergey Zigachev struct amdgpu_clock_voltage_dependency_entry { 110b843c749SSergey Zigachev u32 clk; 111b843c749SSergey Zigachev u16 v; 112b843c749SSergey Zigachev }; 113b843c749SSergey Zigachev 114b843c749SSergey Zigachev struct amdgpu_clock_voltage_dependency_table { 115b843c749SSergey Zigachev u32 count; 116b843c749SSergey Zigachev struct amdgpu_clock_voltage_dependency_entry *entries; 117b843c749SSergey Zigachev }; 118b843c749SSergey Zigachev 119b843c749SSergey Zigachev union amdgpu_cac_leakage_entry { 120b843c749SSergey Zigachev struct { 121b843c749SSergey Zigachev u16 vddc; 122b843c749SSergey Zigachev u32 leakage; 123b843c749SSergey Zigachev }; 124b843c749SSergey Zigachev struct { 125b843c749SSergey Zigachev u16 vddc1; 126b843c749SSergey Zigachev u16 vddc2; 127b843c749SSergey Zigachev u16 vddc3; 128b843c749SSergey Zigachev }; 129b843c749SSergey Zigachev }; 130b843c749SSergey Zigachev 131b843c749SSergey Zigachev struct amdgpu_cac_leakage_table { 132b843c749SSergey Zigachev u32 count; 133b843c749SSergey Zigachev union amdgpu_cac_leakage_entry *entries; 134b843c749SSergey Zigachev }; 135b843c749SSergey Zigachev 136b843c749SSergey Zigachev struct amdgpu_phase_shedding_limits_entry { 137b843c749SSergey Zigachev u16 voltage; 138b843c749SSergey Zigachev u32 sclk; 139b843c749SSergey Zigachev u32 mclk; 140b843c749SSergey Zigachev }; 141b843c749SSergey Zigachev 142b843c749SSergey Zigachev struct amdgpu_phase_shedding_limits_table { 143b843c749SSergey Zigachev u32 count; 144b843c749SSergey Zigachev struct amdgpu_phase_shedding_limits_entry *entries; 145b843c749SSergey Zigachev }; 146b843c749SSergey Zigachev 147b843c749SSergey Zigachev struct amdgpu_uvd_clock_voltage_dependency_entry { 148b843c749SSergey Zigachev u32 vclk; 149b843c749SSergey Zigachev u32 dclk; 150b843c749SSergey Zigachev u16 v; 151b843c749SSergey Zigachev }; 152b843c749SSergey Zigachev 153b843c749SSergey Zigachev struct amdgpu_uvd_clock_voltage_dependency_table { 154b843c749SSergey Zigachev u8 count; 155b843c749SSergey Zigachev struct amdgpu_uvd_clock_voltage_dependency_entry *entries; 156b843c749SSergey Zigachev }; 157b843c749SSergey Zigachev 158b843c749SSergey Zigachev struct amdgpu_vce_clock_voltage_dependency_entry { 159b843c749SSergey Zigachev u32 ecclk; 160b843c749SSergey Zigachev u32 evclk; 161b843c749SSergey Zigachev u16 v; 162b843c749SSergey Zigachev }; 163b843c749SSergey Zigachev 164b843c749SSergey Zigachev struct amdgpu_vce_clock_voltage_dependency_table { 165b843c749SSergey Zigachev u8 count; 166b843c749SSergey Zigachev struct amdgpu_vce_clock_voltage_dependency_entry *entries; 167b843c749SSergey Zigachev }; 168b843c749SSergey Zigachev 169b843c749SSergey Zigachev struct amdgpu_ppm_table { 170b843c749SSergey Zigachev u8 ppm_design; 171b843c749SSergey Zigachev u16 cpu_core_number; 172b843c749SSergey Zigachev u32 platform_tdp; 173b843c749SSergey Zigachev u32 small_ac_platform_tdp; 174b843c749SSergey Zigachev u32 platform_tdc; 175b843c749SSergey Zigachev u32 small_ac_platform_tdc; 176b843c749SSergey Zigachev u32 apu_tdp; 177b843c749SSergey Zigachev u32 dgpu_tdp; 178b843c749SSergey Zigachev u32 dgpu_ulv_power; 179b843c749SSergey Zigachev u32 tj_max; 180b843c749SSergey Zigachev }; 181b843c749SSergey Zigachev 182b843c749SSergey Zigachev struct amdgpu_cac_tdp_table { 183b843c749SSergey Zigachev u16 tdp; 184b843c749SSergey Zigachev u16 configurable_tdp; 185b843c749SSergey Zigachev u16 tdc; 186b843c749SSergey Zigachev u16 battery_power_limit; 187b843c749SSergey Zigachev u16 small_power_limit; 188b843c749SSergey Zigachev u16 low_cac_leakage; 189b843c749SSergey Zigachev u16 high_cac_leakage; 190b843c749SSergey Zigachev u16 maximum_power_delivery_limit; 191b843c749SSergey Zigachev }; 192b843c749SSergey Zigachev 193b843c749SSergey Zigachev struct amdgpu_dpm_dynamic_state { 194b843c749SSergey Zigachev struct amdgpu_clock_voltage_dependency_table vddc_dependency_on_sclk; 195b843c749SSergey Zigachev struct amdgpu_clock_voltage_dependency_table vddci_dependency_on_mclk; 196b843c749SSergey Zigachev struct amdgpu_clock_voltage_dependency_table vddc_dependency_on_mclk; 197b843c749SSergey Zigachev struct amdgpu_clock_voltage_dependency_table mvdd_dependency_on_mclk; 198b843c749SSergey Zigachev struct amdgpu_clock_voltage_dependency_table vddc_dependency_on_dispclk; 199b843c749SSergey Zigachev struct amdgpu_uvd_clock_voltage_dependency_table uvd_clock_voltage_dependency_table; 200b843c749SSergey Zigachev struct amdgpu_vce_clock_voltage_dependency_table vce_clock_voltage_dependency_table; 201b843c749SSergey Zigachev struct amdgpu_clock_voltage_dependency_table samu_clock_voltage_dependency_table; 202b843c749SSergey Zigachev struct amdgpu_clock_voltage_dependency_table acp_clock_voltage_dependency_table; 203b843c749SSergey Zigachev struct amdgpu_clock_voltage_dependency_table vddgfx_dependency_on_sclk; 204b843c749SSergey Zigachev struct amdgpu_clock_array valid_sclk_values; 205b843c749SSergey Zigachev struct amdgpu_clock_array valid_mclk_values; 206b843c749SSergey Zigachev struct amdgpu_clock_and_voltage_limits max_clock_voltage_on_dc; 207b843c749SSergey Zigachev struct amdgpu_clock_and_voltage_limits max_clock_voltage_on_ac; 208b843c749SSergey Zigachev u32 mclk_sclk_ratio; 209b843c749SSergey Zigachev u32 sclk_mclk_delta; 210b843c749SSergey Zigachev u16 vddc_vddci_delta; 211b843c749SSergey Zigachev u16 min_vddc_for_pcie_gen2; 212b843c749SSergey Zigachev struct amdgpu_cac_leakage_table cac_leakage_table; 213b843c749SSergey Zigachev struct amdgpu_phase_shedding_limits_table phase_shedding_limits_table; 214b843c749SSergey Zigachev struct amdgpu_ppm_table *ppm_table; 215b843c749SSergey Zigachev struct amdgpu_cac_tdp_table *cac_tdp_table; 216b843c749SSergey Zigachev }; 217b843c749SSergey Zigachev 218b843c749SSergey Zigachev struct amdgpu_dpm_fan { 219b843c749SSergey Zigachev u16 t_min; 220b843c749SSergey Zigachev u16 t_med; 221b843c749SSergey Zigachev u16 t_high; 222b843c749SSergey Zigachev u16 pwm_min; 223b843c749SSergey Zigachev u16 pwm_med; 224b843c749SSergey Zigachev u16 pwm_high; 225b843c749SSergey Zigachev u8 t_hyst; 226b843c749SSergey Zigachev u32 cycle_delay; 227b843c749SSergey Zigachev u16 t_max; 228b843c749SSergey Zigachev u8 control_mode; 229b843c749SSergey Zigachev u16 default_max_fan_pwm; 230b843c749SSergey Zigachev u16 default_fan_output_sensitivity; 231b843c749SSergey Zigachev u16 fan_output_sensitivity; 232b843c749SSergey Zigachev bool ucode_fan_control; 233b843c749SSergey Zigachev }; 234b843c749SSergey Zigachev 235b843c749SSergey Zigachev enum amdgpu_pcie_gen { 236b843c749SSergey Zigachev AMDGPU_PCIE_GEN1 = 0, 237b843c749SSergey Zigachev AMDGPU_PCIE_GEN2 = 1, 238b843c749SSergey Zigachev AMDGPU_PCIE_GEN3 = 2, 239b843c749SSergey Zigachev AMDGPU_PCIE_GEN_INVALID = 0xffff 240b843c749SSergey Zigachev }; 241b843c749SSergey Zigachev 242b843c749SSergey Zigachev #define amdgpu_dpm_pre_set_power_state(adev) \ 243b843c749SSergey Zigachev ((adev)->powerplay.pp_funcs->pre_set_power_state((adev)->powerplay.pp_handle)) 244b843c749SSergey Zigachev 245b843c749SSergey Zigachev #define amdgpu_dpm_set_power_state(adev) \ 246b843c749SSergey Zigachev ((adev)->powerplay.pp_funcs->set_power_state((adev)->powerplay.pp_handle)) 247b843c749SSergey Zigachev 248b843c749SSergey Zigachev #define amdgpu_dpm_post_set_power_state(adev) \ 249b843c749SSergey Zigachev ((adev)->powerplay.pp_funcs->post_set_power_state((adev)->powerplay.pp_handle)) 250b843c749SSergey Zigachev 251b843c749SSergey Zigachev #define amdgpu_dpm_display_configuration_changed(adev) \ 252b843c749SSergey Zigachev ((adev)->powerplay.pp_funcs->display_configuration_changed((adev)->powerplay.pp_handle)) 253b843c749SSergey Zigachev 254b843c749SSergey Zigachev #define amdgpu_dpm_print_power_state(adev, ps) \ 255b843c749SSergey Zigachev ((adev)->powerplay.pp_funcs->print_power_state((adev)->powerplay.pp_handle, (ps))) 256b843c749SSergey Zigachev 257b843c749SSergey Zigachev #define amdgpu_dpm_vblank_too_short(adev) \ 258b843c749SSergey Zigachev ((adev)->powerplay.pp_funcs->vblank_too_short((adev)->powerplay.pp_handle)) 259b843c749SSergey Zigachev 260b843c749SSergey Zigachev #define amdgpu_dpm_enable_bapm(adev, e) \ 261b843c749SSergey Zigachev ((adev)->powerplay.pp_funcs->enable_bapm((adev)->powerplay.pp_handle, (e))) 262b843c749SSergey Zigachev 263b843c749SSergey Zigachev #define amdgpu_dpm_read_sensor(adev, idx, value, size) \ 264b843c749SSergey Zigachev ((adev)->powerplay.pp_funcs->read_sensor((adev)->powerplay.pp_handle, (idx), (value), (size))) 265b843c749SSergey Zigachev 266b843c749SSergey Zigachev #define amdgpu_dpm_set_fan_control_mode(adev, m) \ 267b843c749SSergey Zigachev ((adev)->powerplay.pp_funcs->set_fan_control_mode((adev)->powerplay.pp_handle, (m))) 268b843c749SSergey Zigachev 269b843c749SSergey Zigachev #define amdgpu_dpm_get_fan_control_mode(adev) \ 270b843c749SSergey Zigachev ((adev)->powerplay.pp_funcs->get_fan_control_mode((adev)->powerplay.pp_handle)) 271b843c749SSergey Zigachev 272b843c749SSergey Zigachev #define amdgpu_dpm_set_fan_speed_percent(adev, s) \ 273b843c749SSergey Zigachev ((adev)->powerplay.pp_funcs->set_fan_speed_percent((adev)->powerplay.pp_handle, (s))) 274b843c749SSergey Zigachev 275b843c749SSergey Zigachev #define amdgpu_dpm_get_fan_speed_percent(adev, s) \ 276b843c749SSergey Zigachev ((adev)->powerplay.pp_funcs->get_fan_speed_percent((adev)->powerplay.pp_handle, (s))) 277b843c749SSergey Zigachev 278b843c749SSergey Zigachev #define amdgpu_dpm_get_fan_speed_rpm(adev, s) \ 279b843c749SSergey Zigachev ((adev)->powerplay.pp_funcs->get_fan_speed_rpm)((adev)->powerplay.pp_handle, (s)) 280b843c749SSergey Zigachev 281b843c749SSergey Zigachev #define amdgpu_dpm_get_sclk(adev, l) \ 282b843c749SSergey Zigachev ((adev)->powerplay.pp_funcs->get_sclk((adev)->powerplay.pp_handle, (l))) 283b843c749SSergey Zigachev 284b843c749SSergey Zigachev #define amdgpu_dpm_get_mclk(adev, l) \ 285b843c749SSergey Zigachev ((adev)->powerplay.pp_funcs->get_mclk((adev)->powerplay.pp_handle, (l))) 286b843c749SSergey Zigachev 287b843c749SSergey Zigachev #define amdgpu_dpm_force_performance_level(adev, l) \ 288b843c749SSergey Zigachev ((adev)->powerplay.pp_funcs->force_performance_level((adev)->powerplay.pp_handle, (l))) 289b843c749SSergey Zigachev 290b843c749SSergey Zigachev #define amdgpu_dpm_get_current_power_state(adev) \ 291b843c749SSergey Zigachev ((adev)->powerplay.pp_funcs->get_current_power_state((adev)->powerplay.pp_handle)) 292b843c749SSergey Zigachev 293b843c749SSergey Zigachev #define amdgpu_dpm_get_pp_num_states(adev, data) \ 294b843c749SSergey Zigachev ((adev)->powerplay.pp_funcs->get_pp_num_states((adev)->powerplay.pp_handle, data)) 295b843c749SSergey Zigachev 296b843c749SSergey Zigachev #define amdgpu_dpm_get_pp_table(adev, table) \ 297b843c749SSergey Zigachev ((adev)->powerplay.pp_funcs->get_pp_table((adev)->powerplay.pp_handle, table)) 298b843c749SSergey Zigachev 299b843c749SSergey Zigachev #define amdgpu_dpm_set_pp_table(adev, buf, size) \ 300b843c749SSergey Zigachev ((adev)->powerplay.pp_funcs->set_pp_table((adev)->powerplay.pp_handle, buf, size)) 301b843c749SSergey Zigachev 302b843c749SSergey Zigachev #define amdgpu_dpm_print_clock_levels(adev, type, buf) \ 303b843c749SSergey Zigachev ((adev)->powerplay.pp_funcs->print_clock_levels((adev)->powerplay.pp_handle, type, buf)) 304b843c749SSergey Zigachev 305b843c749SSergey Zigachev #define amdgpu_dpm_force_clock_level(adev, type, level) \ 306b843c749SSergey Zigachev ((adev)->powerplay.pp_funcs->force_clock_level((adev)->powerplay.pp_handle, type, level)) 307b843c749SSergey Zigachev 308b843c749SSergey Zigachev #define amdgpu_dpm_get_sclk_od(adev) \ 309b843c749SSergey Zigachev ((adev)->powerplay.pp_funcs->get_sclk_od((adev)->powerplay.pp_handle)) 310b843c749SSergey Zigachev 311b843c749SSergey Zigachev #define amdgpu_dpm_set_sclk_od(adev, value) \ 312b843c749SSergey Zigachev ((adev)->powerplay.pp_funcs->set_sclk_od((adev)->powerplay.pp_handle, value)) 313b843c749SSergey Zigachev 314b843c749SSergey Zigachev #define amdgpu_dpm_get_mclk_od(adev) \ 315b843c749SSergey Zigachev ((adev)->powerplay.pp_funcs->get_mclk_od((adev)->powerplay.pp_handle)) 316b843c749SSergey Zigachev 317b843c749SSergey Zigachev #define amdgpu_dpm_set_mclk_od(adev, value) \ 318b843c749SSergey Zigachev ((adev)->powerplay.pp_funcs->set_mclk_od((adev)->powerplay.pp_handle, value)) 319b843c749SSergey Zigachev 320b843c749SSergey Zigachev #define amdgpu_dpm_dispatch_task(adev, task_id, user_state) \ 321b843c749SSergey Zigachev ((adev)->powerplay.pp_funcs->dispatch_tasks)((adev)->powerplay.pp_handle, (task_id), (user_state)) 322b843c749SSergey Zigachev 323b843c749SSergey Zigachev #define amdgpu_dpm_check_state_equal(adev, cps, rps, equal) \ 324b843c749SSergey Zigachev ((adev)->powerplay.pp_funcs->check_state_equal((adev)->powerplay.pp_handle, (cps), (rps), (equal))) 325b843c749SSergey Zigachev 326b843c749SSergey Zigachev #define amdgpu_dpm_get_vce_clock_state(adev, i) \ 327b843c749SSergey Zigachev ((adev)->powerplay.pp_funcs->get_vce_clock_state((adev)->powerplay.pp_handle, (i))) 328b843c749SSergey Zigachev 329b843c749SSergey Zigachev #define amdgpu_dpm_get_performance_level(adev) \ 330b843c749SSergey Zigachev ((adev)->powerplay.pp_funcs->get_performance_level((adev)->powerplay.pp_handle)) 331b843c749SSergey Zigachev 332b843c749SSergey Zigachev #define amdgpu_dpm_reset_power_profile_state(adev, request) \ 333b843c749SSergey Zigachev ((adev)->powerplay.pp_funcs->reset_power_profile_state(\ 334b843c749SSergey Zigachev (adev)->powerplay.pp_handle, request)) 335b843c749SSergey Zigachev 336b843c749SSergey Zigachev #define amdgpu_dpm_switch_power_profile(adev, type, en) \ 337b843c749SSergey Zigachev ((adev)->powerplay.pp_funcs->switch_power_profile(\ 338b843c749SSergey Zigachev (adev)->powerplay.pp_handle, type, en)) 339b843c749SSergey Zigachev 340b843c749SSergey Zigachev #define amdgpu_dpm_set_clockgating_by_smu(adev, msg_id) \ 341b843c749SSergey Zigachev ((adev)->powerplay.pp_funcs->set_clockgating_by_smu(\ 342b843c749SSergey Zigachev (adev)->powerplay.pp_handle, msg_id)) 343b843c749SSergey Zigachev 344b843c749SSergey Zigachev #define amdgpu_dpm_set_powergating_by_smu(adev, block_type, gate) \ 345b843c749SSergey Zigachev ((adev)->powerplay.pp_funcs->set_powergating_by_smu(\ 346b843c749SSergey Zigachev (adev)->powerplay.pp_handle, block_type, gate)) 347b843c749SSergey Zigachev 348b843c749SSergey Zigachev #define amdgpu_dpm_get_power_profile_mode(adev, buf) \ 349b843c749SSergey Zigachev ((adev)->powerplay.pp_funcs->get_power_profile_mode(\ 350b843c749SSergey Zigachev (adev)->powerplay.pp_handle, buf)) 351b843c749SSergey Zigachev 352b843c749SSergey Zigachev #define amdgpu_dpm_set_power_profile_mode(adev, parameter, size) \ 353b843c749SSergey Zigachev ((adev)->powerplay.pp_funcs->set_power_profile_mode(\ 354b843c749SSergey Zigachev (adev)->powerplay.pp_handle, parameter, size)) 355b843c749SSergey Zigachev 356b843c749SSergey Zigachev #define amdgpu_dpm_odn_edit_dpm_table(adev, type, parameter, size) \ 357b843c749SSergey Zigachev ((adev)->powerplay.pp_funcs->odn_edit_dpm_table(\ 358b843c749SSergey Zigachev (adev)->powerplay.pp_handle, type, parameter, size)) 359b843c749SSergey Zigachev 360b843c749SSergey Zigachev struct amdgpu_dpm { 361b843c749SSergey Zigachev struct amdgpu_ps *ps; 362b843c749SSergey Zigachev /* number of valid power states */ 363b843c749SSergey Zigachev int num_ps; 364b843c749SSergey Zigachev /* current power state that is active */ 365b843c749SSergey Zigachev struct amdgpu_ps *current_ps; 366b843c749SSergey Zigachev /* requested power state */ 367b843c749SSergey Zigachev struct amdgpu_ps *requested_ps; 368b843c749SSergey Zigachev /* boot up power state */ 369b843c749SSergey Zigachev struct amdgpu_ps *boot_ps; 370b843c749SSergey Zigachev /* default uvd power state */ 371b843c749SSergey Zigachev struct amdgpu_ps *uvd_ps; 372b843c749SSergey Zigachev /* vce requirements */ 373b843c749SSergey Zigachev u32 num_of_vce_states; 374b843c749SSergey Zigachev struct amd_vce_state vce_states[AMD_MAX_VCE_LEVELS]; 375b843c749SSergey Zigachev enum amd_vce_level vce_level; 376b843c749SSergey Zigachev enum amd_pm_state_type state; 377b843c749SSergey Zigachev enum amd_pm_state_type user_state; 378b843c749SSergey Zigachev enum amd_pm_state_type last_state; 379b843c749SSergey Zigachev enum amd_pm_state_type last_user_state; 380b843c749SSergey Zigachev u32 platform_caps; 381b843c749SSergey Zigachev u32 voltage_response_time; 382b843c749SSergey Zigachev u32 backbias_response_time; 383b843c749SSergey Zigachev void *priv; 384b843c749SSergey Zigachev u32 new_active_crtcs; 385b843c749SSergey Zigachev int new_active_crtc_count; 386b843c749SSergey Zigachev u32 current_active_crtcs; 387b843c749SSergey Zigachev int current_active_crtc_count; 388b843c749SSergey Zigachev struct amdgpu_dpm_dynamic_state dyn_state; 389b843c749SSergey Zigachev struct amdgpu_dpm_fan fan; 390b843c749SSergey Zigachev u32 tdp_limit; 391b843c749SSergey Zigachev u32 near_tdp_limit; 392b843c749SSergey Zigachev u32 near_tdp_limit_adjusted; 393b843c749SSergey Zigachev u32 sq_ramping_threshold; 394b843c749SSergey Zigachev u32 cac_leakage; 395b843c749SSergey Zigachev u16 tdp_od_limit; 396b843c749SSergey Zigachev u32 tdp_adjustment; 397b843c749SSergey Zigachev u16 load_line_slope; 398b843c749SSergey Zigachev bool power_control; 399b843c749SSergey Zigachev /* special states active */ 400b843c749SSergey Zigachev bool thermal_active; 401b843c749SSergey Zigachev bool uvd_active; 402b843c749SSergey Zigachev bool vce_active; 403b843c749SSergey Zigachev /* thermal handling */ 404b843c749SSergey Zigachev struct amdgpu_dpm_thermal thermal; 405b843c749SSergey Zigachev /* forced levels */ 406b843c749SSergey Zigachev enum amd_dpm_forced_level forced_level; 407b843c749SSergey Zigachev }; 408b843c749SSergey Zigachev 409b843c749SSergey Zigachev struct amdgpu_pm { 410*78973132SSergey Zigachev struct lock mutex; 411b843c749SSergey Zigachev u32 current_sclk; 412b843c749SSergey Zigachev u32 current_mclk; 413b843c749SSergey Zigachev u32 default_sclk; 414b843c749SSergey Zigachev u32 default_mclk; 415b843c749SSergey Zigachev struct amdgpu_i2c_chan *i2c_bus; 416b843c749SSergey Zigachev /* internal thermal controller on rv6xx+ */ 417b843c749SSergey Zigachev enum amdgpu_int_thermal_type int_thermal_type; 418b843c749SSergey Zigachev struct device *int_hwmon_dev; 419b843c749SSergey Zigachev /* fan control parameters */ 420b843c749SSergey Zigachev bool no_fan; 421b843c749SSergey Zigachev u8 fan_pulses_per_revolution; 422b843c749SSergey Zigachev u8 fan_min_rpm; 423b843c749SSergey Zigachev u8 fan_max_rpm; 424b843c749SSergey Zigachev /* dpm */ 425b843c749SSergey Zigachev bool dpm_enabled; 426b843c749SSergey Zigachev bool sysfs_initialized; 427b843c749SSergey Zigachev struct amdgpu_dpm dpm; 428b843c749SSergey Zigachev const struct firmware *fw; /* SMC firmware */ 429b843c749SSergey Zigachev uint32_t fw_version; 430b843c749SSergey Zigachev uint32_t pcie_gen_mask; 431b843c749SSergey Zigachev uint32_t pcie_mlw_mask; 432b843c749SSergey Zigachev struct amd_pp_display_configuration pm_display_cfg;/* set by dc */ 433b843c749SSergey Zigachev uint32_t smu_prv_buffer_size; 434b843c749SSergey Zigachev struct amdgpu_bo *smu_prv_buffer; 435b843c749SSergey Zigachev bool ac_power; 436b843c749SSergey Zigachev }; 437b843c749SSergey Zigachev 438b843c749SSergey Zigachev #define R600_SSTU_DFLT 0 439b843c749SSergey Zigachev #define R600_SST_DFLT 0x00C8 440b843c749SSergey Zigachev 441b843c749SSergey Zigachev /* XXX are these ok? */ 442b843c749SSergey Zigachev #define R600_TEMP_RANGE_MIN (90 * 1000) 443b843c749SSergey Zigachev #define R600_TEMP_RANGE_MAX (120 * 1000) 444b843c749SSergey Zigachev 445b843c749SSergey Zigachev #define FDO_PWM_MODE_STATIC 1 446b843c749SSergey Zigachev #define FDO_PWM_MODE_STATIC_RPM 5 447b843c749SSergey Zigachev 448b843c749SSergey Zigachev enum amdgpu_td { 449b843c749SSergey Zigachev AMDGPU_TD_AUTO, 450b843c749SSergey Zigachev AMDGPU_TD_UP, 451b843c749SSergey Zigachev AMDGPU_TD_DOWN, 452b843c749SSergey Zigachev }; 453b843c749SSergey Zigachev 454b843c749SSergey Zigachev enum amdgpu_display_watermark { 455b843c749SSergey Zigachev AMDGPU_DISPLAY_WATERMARK_LOW = 0, 456b843c749SSergey Zigachev AMDGPU_DISPLAY_WATERMARK_HIGH = 1, 457b843c749SSergey Zigachev }; 458b843c749SSergey Zigachev 459b843c749SSergey Zigachev enum amdgpu_display_gap 460b843c749SSergey Zigachev { 461b843c749SSergey Zigachev AMDGPU_PM_DISPLAY_GAP_VBLANK_OR_WM = 0, 462b843c749SSergey Zigachev AMDGPU_PM_DISPLAY_GAP_VBLANK = 1, 463b843c749SSergey Zigachev AMDGPU_PM_DISPLAY_GAP_WATERMARK = 2, 464b843c749SSergey Zigachev AMDGPU_PM_DISPLAY_GAP_IGNORE = 3, 465b843c749SSergey Zigachev }; 466b843c749SSergey Zigachev 467b843c749SSergey Zigachev void amdgpu_dpm_print_class_info(u32 class, u32 class2); 468b843c749SSergey Zigachev void amdgpu_dpm_print_cap_info(u32 caps); 469b843c749SSergey Zigachev void amdgpu_dpm_print_ps_status(struct amdgpu_device *adev, 470b843c749SSergey Zigachev struct amdgpu_ps *rps); 471b843c749SSergey Zigachev u32 amdgpu_dpm_get_vblank_time(struct amdgpu_device *adev); 472b843c749SSergey Zigachev u32 amdgpu_dpm_get_vrefresh(struct amdgpu_device *adev); 473b843c749SSergey Zigachev void amdgpu_dpm_get_active_displays(struct amdgpu_device *adev); 474b843c749SSergey Zigachev bool amdgpu_is_uvd_state(u32 class, u32 class2); 475b843c749SSergey Zigachev void amdgpu_calculate_u_and_p(u32 i, u32 r_c, u32 p_b, 476b843c749SSergey Zigachev u32 *p, u32 *u); 477b843c749SSergey Zigachev int amdgpu_calculate_at(u32 t, u32 h, u32 fh, u32 fl, u32 *tl, u32 *th); 478b843c749SSergey Zigachev 479b843c749SSergey Zigachev bool amdgpu_is_internal_thermal_sensor(enum amdgpu_int_thermal_type sensor); 480b843c749SSergey Zigachev 481b843c749SSergey Zigachev int amdgpu_get_platform_caps(struct amdgpu_device *adev); 482b843c749SSergey Zigachev 483b843c749SSergey Zigachev int amdgpu_parse_extended_power_table(struct amdgpu_device *adev); 484b843c749SSergey Zigachev void amdgpu_free_extended_power_table(struct amdgpu_device *adev); 485b843c749SSergey Zigachev 486b843c749SSergey Zigachev void amdgpu_add_thermal_controller(struct amdgpu_device *adev); 487b843c749SSergey Zigachev 488b843c749SSergey Zigachev enum amdgpu_pcie_gen amdgpu_get_pcie_gen_support(struct amdgpu_device *adev, 489b843c749SSergey Zigachev u32 sys_mask, 490b843c749SSergey Zigachev enum amdgpu_pcie_gen asic_gen, 491b843c749SSergey Zigachev enum amdgpu_pcie_gen default_gen); 492b843c749SSergey Zigachev 493b843c749SSergey Zigachev u16 amdgpu_get_pcie_lane_support(struct amdgpu_device *adev, 494b843c749SSergey Zigachev u16 asic_lanes, 495b843c749SSergey Zigachev u16 default_lanes); 496b843c749SSergey Zigachev u8 amdgpu_encode_pci_lane_width(u32 lanes); 497b843c749SSergey Zigachev 498b843c749SSergey Zigachev struct amd_vce_state* 499b843c749SSergey Zigachev amdgpu_get_vce_clock_state(void *handle, u32 idx); 500b843c749SSergey Zigachev 501b843c749SSergey Zigachev #endif 502