2 * Copyright 2014 Advanced Micro Devices, Inc.
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:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
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.
23 #ifndef __AMDGPU_DPM_H__
24 #define __AMDGPU_DPM_H__
26 enum amdgpu_int_thermal_type
{
28 THERMAL_TYPE_EXTERNAL
,
29 THERMAL_TYPE_EXTERNAL_GPIO
,
32 THERMAL_TYPE_ADT7473_WITH_INTERNAL
,
33 THERMAL_TYPE_EVERGREEN
,
37 THERMAL_TYPE_EMC2103_WITH_INTERNAL
,
42 enum amdgpu_dpm_auto_throttle_src
{
43 AMDGPU_DPM_AUTO_THROTTLE_SRC_THERMAL
,
44 AMDGPU_DPM_AUTO_THROTTLE_SRC_EXTERNAL
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
56 u32 caps
; /* vbios flags */
57 u32
class; /* vbios flags */
58 u32 class2
; /* vbios flags */
66 enum amd_vce_level vce_level
;
71 struct amdgpu_dpm_thermal
{
72 /* thermal interrupt work */
73 struct work_struct work
;
74 /* low temperature threshold */
76 /* high temperature threshold */
78 /* edge max emergency(shutdown) temp */
79 int max_edge_emergency_temp
;
80 /* hotspot low temperature threshold */
82 /* hotspot high temperature critical threshold */
83 int max_hotspot_crit_temp
;
84 /* hotspot max emergency(shutdown) temp */
85 int max_hotspot_emergency_temp
;
86 /* memory low temperature threshold */
88 /* memory high temperature critical threshold */
89 int max_mem_crit_temp
;
90 /* memory max emergency(shutdown) temp */
91 int max_mem_emergency_temp
;
92 /* was last interrupt low to high or high to low */
94 /* interrupt source */
95 struct amdgpu_irq_src irq
;
98 enum amdgpu_clk_action
104 struct amdgpu_blacklist_clocks
108 enum amdgpu_clk_action action
;
111 struct amdgpu_clock_and_voltage_limits
{
118 struct amdgpu_clock_array
{
123 struct amdgpu_clock_voltage_dependency_entry
{
128 struct amdgpu_clock_voltage_dependency_table
{
130 struct amdgpu_clock_voltage_dependency_entry
*entries
;
133 union amdgpu_cac_leakage_entry
{
145 struct amdgpu_cac_leakage_table
{
147 union amdgpu_cac_leakage_entry
*entries
;
150 struct amdgpu_phase_shedding_limits_entry
{
156 struct amdgpu_phase_shedding_limits_table
{
158 struct amdgpu_phase_shedding_limits_entry
*entries
;
161 struct amdgpu_uvd_clock_voltage_dependency_entry
{
167 struct amdgpu_uvd_clock_voltage_dependency_table
{
169 struct amdgpu_uvd_clock_voltage_dependency_entry
*entries
;
172 struct amdgpu_vce_clock_voltage_dependency_entry
{
178 struct amdgpu_vce_clock_voltage_dependency_table
{
180 struct amdgpu_vce_clock_voltage_dependency_entry
*entries
;
183 struct amdgpu_ppm_table
{
187 u32 small_ac_platform_tdp
;
189 u32 small_ac_platform_tdc
;
196 struct amdgpu_cac_tdp_table
{
198 u16 configurable_tdp
;
200 u16 battery_power_limit
;
201 u16 small_power_limit
;
203 u16 high_cac_leakage
;
204 u16 maximum_power_delivery_limit
;
207 struct amdgpu_dpm_dynamic_state
{
208 struct amdgpu_clock_voltage_dependency_table vddc_dependency_on_sclk
;
209 struct amdgpu_clock_voltage_dependency_table vddci_dependency_on_mclk
;
210 struct amdgpu_clock_voltage_dependency_table vddc_dependency_on_mclk
;
211 struct amdgpu_clock_voltage_dependency_table mvdd_dependency_on_mclk
;
212 struct amdgpu_clock_voltage_dependency_table vddc_dependency_on_dispclk
;
213 struct amdgpu_uvd_clock_voltage_dependency_table uvd_clock_voltage_dependency_table
;
214 struct amdgpu_vce_clock_voltage_dependency_table vce_clock_voltage_dependency_table
;
215 struct amdgpu_clock_voltage_dependency_table samu_clock_voltage_dependency_table
;
216 struct amdgpu_clock_voltage_dependency_table acp_clock_voltage_dependency_table
;
217 struct amdgpu_clock_voltage_dependency_table vddgfx_dependency_on_sclk
;
218 struct amdgpu_clock_array valid_sclk_values
;
219 struct amdgpu_clock_array valid_mclk_values
;
220 struct amdgpu_clock_and_voltage_limits max_clock_voltage_on_dc
;
221 struct amdgpu_clock_and_voltage_limits max_clock_voltage_on_ac
;
224 u16 vddc_vddci_delta
;
225 u16 min_vddc_for_pcie_gen2
;
226 struct amdgpu_cac_leakage_table cac_leakage_table
;
227 struct amdgpu_phase_shedding_limits_table phase_shedding_limits_table
;
228 struct amdgpu_ppm_table
*ppm_table
;
229 struct amdgpu_cac_tdp_table
*cac_tdp_table
;
232 struct amdgpu_dpm_fan
{
243 u16 default_max_fan_pwm
;
244 u16 default_fan_output_sensitivity
;
245 u16 fan_output_sensitivity
;
246 bool ucode_fan_control
;
249 enum amdgpu_pcie_gen
{
250 AMDGPU_PCIE_GEN1
= 0,
251 AMDGPU_PCIE_GEN2
= 1,
252 AMDGPU_PCIE_GEN3
= 2,
253 AMDGPU_PCIE_GEN_INVALID
= 0xffff
256 #define amdgpu_dpm_pre_set_power_state(adev) \
257 ((adev)->powerplay.pp_funcs->pre_set_power_state((adev)->powerplay.pp_handle))
259 #define amdgpu_dpm_set_power_state(adev) \
260 ((adev)->powerplay.pp_funcs->set_power_state((adev)->powerplay.pp_handle))
262 #define amdgpu_dpm_post_set_power_state(adev) \
263 ((adev)->powerplay.pp_funcs->post_set_power_state((adev)->powerplay.pp_handle))
265 #define amdgpu_dpm_display_configuration_changed(adev) \
266 ((adev)->powerplay.pp_funcs->display_configuration_changed((adev)->powerplay.pp_handle))
268 #define amdgpu_dpm_print_power_state(adev, ps) \
269 ((adev)->powerplay.pp_funcs->print_power_state((adev)->powerplay.pp_handle, (ps)))
271 #define amdgpu_dpm_vblank_too_short(adev) \
272 ((adev)->powerplay.pp_funcs->vblank_too_short((adev)->powerplay.pp_handle))
274 #define amdgpu_dpm_enable_bapm(adev, e) \
275 ((adev)->powerplay.pp_funcs->enable_bapm((adev)->powerplay.pp_handle, (e)))
277 #define amdgpu_dpm_set_fan_control_mode(adev, m) \
278 ((adev)->powerplay.pp_funcs->set_fan_control_mode((adev)->powerplay.pp_handle, (m)))
280 #define amdgpu_dpm_get_fan_control_mode(adev) \
281 ((adev)->powerplay.pp_funcs->get_fan_control_mode((adev)->powerplay.pp_handle))
283 #define amdgpu_dpm_set_fan_speed_percent(adev, s) \
284 ((adev)->powerplay.pp_funcs->set_fan_speed_percent((adev)->powerplay.pp_handle, (s)))
286 #define amdgpu_dpm_get_fan_speed_percent(adev, s) \
287 ((adev)->powerplay.pp_funcs->get_fan_speed_percent((adev)->powerplay.pp_handle, (s)))
289 #define amdgpu_dpm_get_fan_speed_rpm(adev, s) \
290 ((adev)->powerplay.pp_funcs->get_fan_speed_rpm)((adev)->powerplay.pp_handle, (s))
292 #define amdgpu_dpm_set_fan_speed_rpm(adev, s) \
293 ((adev)->powerplay.pp_funcs->set_fan_speed_rpm)((adev)->powerplay.pp_handle, (s))
295 #define amdgpu_dpm_force_performance_level(adev, l) \
296 ((adev)->powerplay.pp_funcs->force_performance_level((adev)->powerplay.pp_handle, (l)))
298 #define amdgpu_dpm_get_current_power_state(adev) \
299 ((adev)->powerplay.pp_funcs->get_current_power_state((adev)->powerplay.pp_handle))
301 #define amdgpu_dpm_get_pp_num_states(adev, data) \
302 ((adev)->powerplay.pp_funcs->get_pp_num_states((adev)->powerplay.pp_handle, data))
304 #define amdgpu_dpm_get_pp_table(adev, table) \
305 ((adev)->powerplay.pp_funcs->get_pp_table((adev)->powerplay.pp_handle, table))
307 #define amdgpu_dpm_set_pp_table(adev, buf, size) \
308 ((adev)->powerplay.pp_funcs->set_pp_table((adev)->powerplay.pp_handle, buf, size))
310 #define amdgpu_dpm_print_clock_levels(adev, type, buf) \
311 ((adev)->powerplay.pp_funcs->print_clock_levels((adev)->powerplay.pp_handle, type, buf))
313 #define amdgpu_dpm_force_clock_level(adev, type, level) \
314 ((adev)->powerplay.pp_funcs->force_clock_level((adev)->powerplay.pp_handle, type, level))
316 #define amdgpu_dpm_get_sclk_od(adev) \
317 ((adev)->powerplay.pp_funcs->get_sclk_od((adev)->powerplay.pp_handle))
319 #define amdgpu_dpm_set_sclk_od(adev, value) \
320 ((adev)->powerplay.pp_funcs->set_sclk_od((adev)->powerplay.pp_handle, value))
322 #define amdgpu_dpm_get_mclk_od(adev) \
323 ((adev)->powerplay.pp_funcs->get_mclk_od((adev)->powerplay.pp_handle))
325 #define amdgpu_dpm_set_mclk_od(adev, value) \
326 ((adev)->powerplay.pp_funcs->set_mclk_od((adev)->powerplay.pp_handle, value))
328 #define amdgpu_dpm_dispatch_task(adev, task_id, user_state) \
329 ((adev)->powerplay.pp_funcs->dispatch_tasks)((adev)->powerplay.pp_handle, (task_id), (user_state))
331 #define amdgpu_dpm_check_state_equal(adev, cps, rps, equal) \
332 ((adev)->powerplay.pp_funcs->check_state_equal((adev)->powerplay.pp_handle, (cps), (rps), (equal)))
334 #define amdgpu_dpm_get_vce_clock_state(adev, i) \
335 ((adev)->powerplay.pp_funcs->get_vce_clock_state((adev)->powerplay.pp_handle, (i)))
337 #define amdgpu_dpm_get_performance_level(adev) \
338 ((adev)->powerplay.pp_funcs->get_performance_level((adev)->powerplay.pp_handle))
340 #define amdgpu_dpm_reset_power_profile_state(adev, request) \
341 ((adev)->powerplay.pp_funcs->reset_power_profile_state(\
342 (adev)->powerplay.pp_handle, request))
344 #define amdgpu_dpm_set_clockgating_by_smu(adev, msg_id) \
345 ((adev)->powerplay.pp_funcs->set_clockgating_by_smu(\
346 (adev)->powerplay.pp_handle, msg_id))
348 #define amdgpu_dpm_get_power_profile_mode(adev, buf) \
349 ((adev)->powerplay.pp_funcs->get_power_profile_mode(\
350 (adev)->powerplay.pp_handle, buf))
352 #define amdgpu_dpm_set_power_profile_mode(adev, parameter, size) \
353 ((adev)->powerplay.pp_funcs->set_power_profile_mode(\
354 (adev)->powerplay.pp_handle, parameter, size))
356 #define amdgpu_dpm_odn_edit_dpm_table(adev, type, parameter, size) \
357 ((adev)->powerplay.pp_funcs->odn_edit_dpm_table(\
358 (adev)->powerplay.pp_handle, type, parameter, size))
360 #define amdgpu_dpm_enable_mgpu_fan_boost(adev) \
361 ((adev)->powerplay.pp_funcs->enable_mgpu_fan_boost(\
362 (adev)->powerplay.pp_handle))
364 #define amdgpu_dpm_get_ppfeature_status(adev, buf) \
365 ((adev)->powerplay.pp_funcs->get_ppfeature_status(\
366 (adev)->powerplay.pp_handle, (buf)))
368 #define amdgpu_dpm_set_ppfeature_status(adev, ppfeatures) \
369 ((adev)->powerplay.pp_funcs->set_ppfeature_status(\
370 (adev)->powerplay.pp_handle, (ppfeatures)))
373 struct amdgpu_ps
*ps
;
374 /* number of valid power states */
376 /* current power state that is active */
377 struct amdgpu_ps
*current_ps
;
378 /* requested power state */
379 struct amdgpu_ps
*requested_ps
;
380 /* boot up power state */
381 struct amdgpu_ps
*boot_ps
;
382 /* default uvd power state */
383 struct amdgpu_ps
*uvd_ps
;
384 /* vce requirements */
385 u32 num_of_vce_states
;
386 struct amd_vce_state vce_states
[AMD_MAX_VCE_LEVELS
];
387 enum amd_vce_level vce_level
;
388 enum amd_pm_state_type state
;
389 enum amd_pm_state_type user_state
;
390 enum amd_pm_state_type last_state
;
391 enum amd_pm_state_type last_user_state
;
393 u32 voltage_response_time
;
394 u32 backbias_response_time
;
396 u32 new_active_crtcs
;
397 int new_active_crtc_count
;
398 u32 current_active_crtcs
;
399 int current_active_crtc_count
;
400 struct amdgpu_dpm_dynamic_state dyn_state
;
401 struct amdgpu_dpm_fan fan
;
404 u32 near_tdp_limit_adjusted
;
405 u32 sq_ramping_threshold
;
411 /* special states active */
415 /* thermal handling */
416 struct amdgpu_dpm_thermal thermal
;
418 enum amd_dpm_forced_level forced_level
;
427 struct amdgpu_i2c_chan
*i2c_bus
;
428 /* internal thermal controller on rv6xx+ */
429 enum amdgpu_int_thermal_type int_thermal_type
;
430 struct device
*int_hwmon_dev
;
431 /* fan control parameters */
433 u8 fan_pulses_per_revolution
;
438 bool sysfs_initialized
;
439 struct amdgpu_dpm dpm
;
440 const struct firmware
*fw
; /* SMC firmware */
442 uint32_t pcie_gen_mask
;
443 uint32_t pcie_mlw_mask
;
444 struct amd_pp_display_configuration pm_display_cfg
;/* set by dc */
445 uint32_t smu_prv_buffer_size
;
446 struct amdgpu_bo
*smu_prv_buffer
;
448 /* powerplay feature */
453 #define R600_SSTU_DFLT 0
454 #define R600_SST_DFLT 0x00C8
456 /* XXX are these ok? */
457 #define R600_TEMP_RANGE_MIN (90 * 1000)
458 #define R600_TEMP_RANGE_MAX (120 * 1000)
460 #define FDO_PWM_MODE_STATIC 1
461 #define FDO_PWM_MODE_STATIC_RPM 5
469 enum amdgpu_display_watermark
{
470 AMDGPU_DISPLAY_WATERMARK_LOW
= 0,
471 AMDGPU_DISPLAY_WATERMARK_HIGH
= 1,
474 enum amdgpu_display_gap
476 AMDGPU_PM_DISPLAY_GAP_VBLANK_OR_WM
= 0,
477 AMDGPU_PM_DISPLAY_GAP_VBLANK
= 1,
478 AMDGPU_PM_DISPLAY_GAP_WATERMARK
= 2,
479 AMDGPU_PM_DISPLAY_GAP_IGNORE
= 3,
482 void amdgpu_dpm_print_class_info(u32
class, u32 class2
);
483 void amdgpu_dpm_print_cap_info(u32 caps
);
484 void amdgpu_dpm_print_ps_status(struct amdgpu_device
*adev
,
485 struct amdgpu_ps
*rps
);
486 u32
amdgpu_dpm_get_vblank_time(struct amdgpu_device
*adev
);
487 u32
amdgpu_dpm_get_vrefresh(struct amdgpu_device
*adev
);
488 void amdgpu_dpm_get_active_displays(struct amdgpu_device
*adev
);
489 int amdgpu_dpm_read_sensor(struct amdgpu_device
*adev
, enum amd_pp_sensors sensor
,
490 void *data
, uint32_t *size
);
492 bool amdgpu_is_internal_thermal_sensor(enum amdgpu_int_thermal_type sensor
);
494 int amdgpu_get_platform_caps(struct amdgpu_device
*adev
);
496 int amdgpu_parse_extended_power_table(struct amdgpu_device
*adev
);
497 void amdgpu_free_extended_power_table(struct amdgpu_device
*adev
);
499 void amdgpu_add_thermal_controller(struct amdgpu_device
*adev
);
501 enum amdgpu_pcie_gen
amdgpu_get_pcie_gen_support(struct amdgpu_device
*adev
,
503 enum amdgpu_pcie_gen asic_gen
,
504 enum amdgpu_pcie_gen default_gen
);
506 struct amd_vce_state
*
507 amdgpu_get_vce_clock_state(void *handle
, u32 idx
);
509 int amdgpu_dpm_set_powergating_by_smu(struct amdgpu_device
*adev
,
510 uint32_t block_type
, bool gate
);
512 extern int amdgpu_dpm_get_sclk(struct amdgpu_device
*adev
, bool low
);
514 extern int amdgpu_dpm_get_mclk(struct amdgpu_device
*adev
, bool low
);
516 int amdgpu_dpm_set_xgmi_pstate(struct amdgpu_device
*adev
,
519 int amdgpu_dpm_switch_power_profile(struct amdgpu_device
*adev
,
520 enum PP_SMC_POWER_PROFILE type
,
523 int amdgpu_dpm_baco_reset(struct amdgpu_device
*adev
);
525 int amdgpu_dpm_mode2_reset(struct amdgpu_device
*adev
);
527 bool amdgpu_dpm_is_baco_supported(struct amdgpu_device
*adev
);
529 int amdgpu_dpm_set_mp1_state(struct amdgpu_device
*adev
,
530 enum pp_mp1_state mp1_state
);
532 int amdgpu_dpm_baco_exit(struct amdgpu_device
*adev
);
534 int amdgpu_dpm_baco_enter(struct amdgpu_device
*adev
);