18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright 2011 Advanced Micro Devices, Inc.
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
58c2ecf20Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
68c2ecf20Sopenharmony_ci * to deal in the Software without restriction, including without limitation
78c2ecf20Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
88c2ecf20Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
98c2ecf20Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
108c2ecf20Sopenharmony_ci *
118c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice shall be included in
128c2ecf20Sopenharmony_ci * all copies or substantial portions of the Software.
138c2ecf20Sopenharmony_ci *
148c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
158c2ecf20Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
168c2ecf20Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
178c2ecf20Sopenharmony_ci * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
188c2ecf20Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
198c2ecf20Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
208c2ecf20Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE.
218c2ecf20Sopenharmony_ci *
228c2ecf20Sopenharmony_ci */
238c2ecf20Sopenharmony_ci#ifndef __R600_DPM_H__
248c2ecf20Sopenharmony_ci#define __R600_DPM_H__
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci#include "radeon.h"
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci#define R600_ASI_DFLT                                10000
298c2ecf20Sopenharmony_ci#define R600_BSP_DFLT                                0x41EB
308c2ecf20Sopenharmony_ci#define R600_BSU_DFLT                                0x2
318c2ecf20Sopenharmony_ci#define R600_AH_DFLT                                 5
328c2ecf20Sopenharmony_ci#define R600_RLP_DFLT                                25
338c2ecf20Sopenharmony_ci#define R600_RMP_DFLT                                65
348c2ecf20Sopenharmony_ci#define R600_LHP_DFLT                                40
358c2ecf20Sopenharmony_ci#define R600_LMP_DFLT                                15
368c2ecf20Sopenharmony_ci#define R600_TD_DFLT                                 0
378c2ecf20Sopenharmony_ci#define R600_UTC_DFLT_00                             0x24
388c2ecf20Sopenharmony_ci#define R600_UTC_DFLT_01                             0x22
398c2ecf20Sopenharmony_ci#define R600_UTC_DFLT_02                             0x22
408c2ecf20Sopenharmony_ci#define R600_UTC_DFLT_03                             0x22
418c2ecf20Sopenharmony_ci#define R600_UTC_DFLT_04                             0x22
428c2ecf20Sopenharmony_ci#define R600_UTC_DFLT_05                             0x22
438c2ecf20Sopenharmony_ci#define R600_UTC_DFLT_06                             0x22
448c2ecf20Sopenharmony_ci#define R600_UTC_DFLT_07                             0x22
458c2ecf20Sopenharmony_ci#define R600_UTC_DFLT_08                             0x22
468c2ecf20Sopenharmony_ci#define R600_UTC_DFLT_09                             0x22
478c2ecf20Sopenharmony_ci#define R600_UTC_DFLT_10                             0x22
488c2ecf20Sopenharmony_ci#define R600_UTC_DFLT_11                             0x22
498c2ecf20Sopenharmony_ci#define R600_UTC_DFLT_12                             0x22
508c2ecf20Sopenharmony_ci#define R600_UTC_DFLT_13                             0x22
518c2ecf20Sopenharmony_ci#define R600_UTC_DFLT_14                             0x22
528c2ecf20Sopenharmony_ci#define R600_DTC_DFLT_00                             0x24
538c2ecf20Sopenharmony_ci#define R600_DTC_DFLT_01                             0x22
548c2ecf20Sopenharmony_ci#define R600_DTC_DFLT_02                             0x22
558c2ecf20Sopenharmony_ci#define R600_DTC_DFLT_03                             0x22
568c2ecf20Sopenharmony_ci#define R600_DTC_DFLT_04                             0x22
578c2ecf20Sopenharmony_ci#define R600_DTC_DFLT_05                             0x22
588c2ecf20Sopenharmony_ci#define R600_DTC_DFLT_06                             0x22
598c2ecf20Sopenharmony_ci#define R600_DTC_DFLT_07                             0x22
608c2ecf20Sopenharmony_ci#define R600_DTC_DFLT_08                             0x22
618c2ecf20Sopenharmony_ci#define R600_DTC_DFLT_09                             0x22
628c2ecf20Sopenharmony_ci#define R600_DTC_DFLT_10                             0x22
638c2ecf20Sopenharmony_ci#define R600_DTC_DFLT_11                             0x22
648c2ecf20Sopenharmony_ci#define R600_DTC_DFLT_12                             0x22
658c2ecf20Sopenharmony_ci#define R600_DTC_DFLT_13                             0x22
668c2ecf20Sopenharmony_ci#define R600_DTC_DFLT_14                             0x22
678c2ecf20Sopenharmony_ci#define R600_VRC_DFLT                                0x0000C003
688c2ecf20Sopenharmony_ci#define R600_VOLTAGERESPONSETIME_DFLT                1000
698c2ecf20Sopenharmony_ci#define R600_BACKBIASRESPONSETIME_DFLT               1000
708c2ecf20Sopenharmony_ci#define R600_VRU_DFLT                                0x3
718c2ecf20Sopenharmony_ci#define R600_SPLLSTEPTIME_DFLT                       0x1000
728c2ecf20Sopenharmony_ci#define R600_SPLLSTEPUNIT_DFLT                       0x3
738c2ecf20Sopenharmony_ci#define R600_TPU_DFLT                                0
748c2ecf20Sopenharmony_ci#define R600_TPC_DFLT                                0x200
758c2ecf20Sopenharmony_ci#define R600_SSTU_DFLT                               0
768c2ecf20Sopenharmony_ci#define R600_SST_DFLT                                0x00C8
778c2ecf20Sopenharmony_ci#define R600_GICST_DFLT                              0x200
788c2ecf20Sopenharmony_ci#define R600_FCT_DFLT                                0x0400
798c2ecf20Sopenharmony_ci#define R600_FCTU_DFLT                               0
808c2ecf20Sopenharmony_ci#define R600_CTXCGTT3DRPHC_DFLT                      0x20
818c2ecf20Sopenharmony_ci#define R600_CTXCGTT3DRSDC_DFLT                      0x40
828c2ecf20Sopenharmony_ci#define R600_VDDC3DOORPHC_DFLT                       0x100
838c2ecf20Sopenharmony_ci#define R600_VDDC3DOORSDC_DFLT                       0x7
848c2ecf20Sopenharmony_ci#define R600_VDDC3DOORSU_DFLT                        0
858c2ecf20Sopenharmony_ci#define R600_MPLLLOCKTIME_DFLT                       100
868c2ecf20Sopenharmony_ci#define R600_MPLLRESETTIME_DFLT                      150
878c2ecf20Sopenharmony_ci#define R600_VCOSTEPPCT_DFLT                          20
888c2ecf20Sopenharmony_ci#define R600_ENDINGVCOSTEPPCT_DFLT                    5
898c2ecf20Sopenharmony_ci#define R600_REFERENCEDIVIDER_DFLT                    4
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ci#define R600_PM_NUMBER_OF_TC 15
928c2ecf20Sopenharmony_ci#define R600_PM_NUMBER_OF_SCLKS 20
938c2ecf20Sopenharmony_ci#define R600_PM_NUMBER_OF_MCLKS 4
948c2ecf20Sopenharmony_ci#define R600_PM_NUMBER_OF_VOLTAGE_LEVELS 4
958c2ecf20Sopenharmony_ci#define R600_PM_NUMBER_OF_ACTIVITY_LEVELS 3
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_ci/* XXX are these ok? */
988c2ecf20Sopenharmony_ci#define R600_TEMP_RANGE_MIN (90 * 1000)
998c2ecf20Sopenharmony_ci#define R600_TEMP_RANGE_MAX (120 * 1000)
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_ci#define FDO_PWM_MODE_STATIC  1
1028c2ecf20Sopenharmony_ci#define FDO_PWM_MODE_STATIC_RPM 5
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_cienum r600_power_level {
1058c2ecf20Sopenharmony_ci	R600_POWER_LEVEL_LOW = 0,
1068c2ecf20Sopenharmony_ci	R600_POWER_LEVEL_MEDIUM = 1,
1078c2ecf20Sopenharmony_ci	R600_POWER_LEVEL_HIGH = 2,
1088c2ecf20Sopenharmony_ci	R600_POWER_LEVEL_CTXSW = 3,
1098c2ecf20Sopenharmony_ci};
1108c2ecf20Sopenharmony_ci
1118c2ecf20Sopenharmony_cienum r600_td {
1128c2ecf20Sopenharmony_ci	R600_TD_AUTO,
1138c2ecf20Sopenharmony_ci	R600_TD_UP,
1148c2ecf20Sopenharmony_ci	R600_TD_DOWN,
1158c2ecf20Sopenharmony_ci};
1168c2ecf20Sopenharmony_ci
1178c2ecf20Sopenharmony_cienum r600_display_watermark {
1188c2ecf20Sopenharmony_ci	R600_DISPLAY_WATERMARK_LOW = 0,
1198c2ecf20Sopenharmony_ci	R600_DISPLAY_WATERMARK_HIGH = 1,
1208c2ecf20Sopenharmony_ci};
1218c2ecf20Sopenharmony_ci
1228c2ecf20Sopenharmony_cienum r600_display_gap
1238c2ecf20Sopenharmony_ci{
1248c2ecf20Sopenharmony_ci    R600_PM_DISPLAY_GAP_VBLANK_OR_WM = 0,
1258c2ecf20Sopenharmony_ci    R600_PM_DISPLAY_GAP_VBLANK       = 1,
1268c2ecf20Sopenharmony_ci    R600_PM_DISPLAY_GAP_WATERMARK    = 2,
1278c2ecf20Sopenharmony_ci    R600_PM_DISPLAY_GAP_IGNORE       = 3,
1288c2ecf20Sopenharmony_ci};
1298c2ecf20Sopenharmony_ci
1308c2ecf20Sopenharmony_ciextern const u32 r600_utc[R600_PM_NUMBER_OF_TC];
1318c2ecf20Sopenharmony_ciextern const u32 r600_dtc[R600_PM_NUMBER_OF_TC];
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_civoid r600_dpm_print_class_info(u32 class, u32 class2);
1348c2ecf20Sopenharmony_civoid r600_dpm_print_cap_info(u32 caps);
1358c2ecf20Sopenharmony_civoid r600_dpm_print_ps_status(struct radeon_device *rdev,
1368c2ecf20Sopenharmony_ci			      struct radeon_ps *rps);
1378c2ecf20Sopenharmony_ciu32 r600_dpm_get_vblank_time(struct radeon_device *rdev);
1388c2ecf20Sopenharmony_ciu32 r600_dpm_get_vrefresh(struct radeon_device *rdev);
1398c2ecf20Sopenharmony_cibool r600_is_uvd_state(u32 class, u32 class2);
1408c2ecf20Sopenharmony_civoid r600_calculate_u_and_p(u32 i, u32 r_c, u32 p_b,
1418c2ecf20Sopenharmony_ci			    u32 *p, u32 *u);
1428c2ecf20Sopenharmony_ciint r600_calculate_at(u32 t, u32 h, u32 fh, u32 fl, u32 *tl, u32 *th);
1438c2ecf20Sopenharmony_civoid r600_gfx_clockgating_enable(struct radeon_device *rdev, bool enable);
1448c2ecf20Sopenharmony_civoid r600_dynamicpm_enable(struct radeon_device *rdev, bool enable);
1458c2ecf20Sopenharmony_civoid r600_enable_thermal_protection(struct radeon_device *rdev, bool enable);
1468c2ecf20Sopenharmony_civoid r600_enable_acpi_pm(struct radeon_device *rdev);
1478c2ecf20Sopenharmony_civoid r600_enable_dynamic_pcie_gen2(struct radeon_device *rdev, bool enable);
1488c2ecf20Sopenharmony_cibool r600_dynamicpm_enabled(struct radeon_device *rdev);
1498c2ecf20Sopenharmony_civoid r600_enable_sclk_control(struct radeon_device *rdev, bool enable);
1508c2ecf20Sopenharmony_civoid r600_enable_mclk_control(struct radeon_device *rdev, bool enable);
1518c2ecf20Sopenharmony_civoid r600_enable_spll_bypass(struct radeon_device *rdev, bool enable);
1528c2ecf20Sopenharmony_civoid r600_wait_for_spll_change(struct radeon_device *rdev);
1538c2ecf20Sopenharmony_civoid r600_set_bsp(struct radeon_device *rdev, u32 u, u32 p);
1548c2ecf20Sopenharmony_civoid r600_set_at(struct radeon_device *rdev,
1558c2ecf20Sopenharmony_ci		 u32 l_to_m, u32 m_to_h,
1568c2ecf20Sopenharmony_ci		 u32 h_to_m, u32 m_to_l);
1578c2ecf20Sopenharmony_civoid r600_set_tc(struct radeon_device *rdev, u32 index, u32 u_t, u32 d_t);
1588c2ecf20Sopenharmony_civoid r600_select_td(struct radeon_device *rdev, enum r600_td td);
1598c2ecf20Sopenharmony_civoid r600_set_vrc(struct radeon_device *rdev, u32 vrv);
1608c2ecf20Sopenharmony_civoid r600_set_tpu(struct radeon_device *rdev, u32 u);
1618c2ecf20Sopenharmony_civoid r600_set_tpc(struct radeon_device *rdev, u32 c);
1628c2ecf20Sopenharmony_civoid r600_set_sstu(struct radeon_device *rdev, u32 u);
1638c2ecf20Sopenharmony_civoid r600_set_sst(struct radeon_device *rdev, u32 t);
1648c2ecf20Sopenharmony_civoid r600_set_git(struct radeon_device *rdev, u32 t);
1658c2ecf20Sopenharmony_civoid r600_set_fctu(struct radeon_device *rdev, u32 u);
1668c2ecf20Sopenharmony_civoid r600_set_fct(struct radeon_device *rdev, u32 t);
1678c2ecf20Sopenharmony_civoid r600_set_ctxcgtt3d_rphc(struct radeon_device *rdev, u32 p);
1688c2ecf20Sopenharmony_civoid r600_set_ctxcgtt3d_rsdc(struct radeon_device *rdev, u32 s);
1698c2ecf20Sopenharmony_civoid r600_set_vddc3d_oorsu(struct radeon_device *rdev, u32 u);
1708c2ecf20Sopenharmony_civoid r600_set_vddc3d_oorphc(struct radeon_device *rdev, u32 p);
1718c2ecf20Sopenharmony_civoid r600_set_vddc3d_oorsdc(struct radeon_device *rdev, u32 s);
1728c2ecf20Sopenharmony_civoid r600_set_mpll_lock_time(struct radeon_device *rdev, u32 lock_time);
1738c2ecf20Sopenharmony_civoid r600_set_mpll_reset_time(struct radeon_device *rdev, u32 reset_time);
1748c2ecf20Sopenharmony_civoid r600_engine_clock_entry_enable(struct radeon_device *rdev,
1758c2ecf20Sopenharmony_ci				    u32 index, bool enable);
1768c2ecf20Sopenharmony_civoid r600_engine_clock_entry_enable_pulse_skipping(struct radeon_device *rdev,
1778c2ecf20Sopenharmony_ci						   u32 index, bool enable);
1788c2ecf20Sopenharmony_civoid r600_engine_clock_entry_enable_post_divider(struct radeon_device *rdev,
1798c2ecf20Sopenharmony_ci						 u32 index, bool enable);
1808c2ecf20Sopenharmony_civoid r600_engine_clock_entry_set_post_divider(struct radeon_device *rdev,
1818c2ecf20Sopenharmony_ci					      u32 index, u32 divider);
1828c2ecf20Sopenharmony_civoid r600_engine_clock_entry_set_reference_divider(struct radeon_device *rdev,
1838c2ecf20Sopenharmony_ci						   u32 index, u32 divider);
1848c2ecf20Sopenharmony_civoid r600_engine_clock_entry_set_feedback_divider(struct radeon_device *rdev,
1858c2ecf20Sopenharmony_ci						  u32 index, u32 divider);
1868c2ecf20Sopenharmony_civoid r600_engine_clock_entry_set_step_time(struct radeon_device *rdev,
1878c2ecf20Sopenharmony_ci					   u32 index, u32 step_time);
1888c2ecf20Sopenharmony_civoid r600_vid_rt_set_ssu(struct radeon_device *rdev, u32 u);
1898c2ecf20Sopenharmony_civoid r600_vid_rt_set_vru(struct radeon_device *rdev, u32 u);
1908c2ecf20Sopenharmony_civoid r600_vid_rt_set_vrt(struct radeon_device *rdev, u32 rt);
1918c2ecf20Sopenharmony_civoid r600_voltage_control_enable_pins(struct radeon_device *rdev,
1928c2ecf20Sopenharmony_ci				      u64 mask);
1938c2ecf20Sopenharmony_civoid r600_voltage_control_program_voltages(struct radeon_device *rdev,
1948c2ecf20Sopenharmony_ci					   enum r600_power_level index, u64 pins);
1958c2ecf20Sopenharmony_civoid r600_voltage_control_deactivate_static_control(struct radeon_device *rdev,
1968c2ecf20Sopenharmony_ci						    u64 mask);
1978c2ecf20Sopenharmony_civoid r600_power_level_enable(struct radeon_device *rdev,
1988c2ecf20Sopenharmony_ci			     enum r600_power_level index, bool enable);
1998c2ecf20Sopenharmony_civoid r600_power_level_set_voltage_index(struct radeon_device *rdev,
2008c2ecf20Sopenharmony_ci					enum r600_power_level index, u32 voltage_index);
2018c2ecf20Sopenharmony_civoid r600_power_level_set_mem_clock_index(struct radeon_device *rdev,
2028c2ecf20Sopenharmony_ci					  enum r600_power_level index, u32 mem_clock_index);
2038c2ecf20Sopenharmony_civoid r600_power_level_set_eng_clock_index(struct radeon_device *rdev,
2048c2ecf20Sopenharmony_ci					  enum r600_power_level index, u32 eng_clock_index);
2058c2ecf20Sopenharmony_civoid r600_power_level_set_watermark_id(struct radeon_device *rdev,
2068c2ecf20Sopenharmony_ci				       enum r600_power_level index,
2078c2ecf20Sopenharmony_ci				       enum r600_display_watermark watermark_id);
2088c2ecf20Sopenharmony_civoid r600_power_level_set_pcie_gen2(struct radeon_device *rdev,
2098c2ecf20Sopenharmony_ci				    enum r600_power_level index, bool compatible);
2108c2ecf20Sopenharmony_cienum r600_power_level r600_power_level_get_current_index(struct radeon_device *rdev);
2118c2ecf20Sopenharmony_cienum r600_power_level r600_power_level_get_target_index(struct radeon_device *rdev);
2128c2ecf20Sopenharmony_civoid r600_power_level_set_enter_index(struct radeon_device *rdev,
2138c2ecf20Sopenharmony_ci				      enum r600_power_level index);
2148c2ecf20Sopenharmony_civoid r600_wait_for_power_level_unequal(struct radeon_device *rdev,
2158c2ecf20Sopenharmony_ci				       enum r600_power_level index);
2168c2ecf20Sopenharmony_civoid r600_wait_for_power_level(struct radeon_device *rdev,
2178c2ecf20Sopenharmony_ci			       enum r600_power_level index);
2188c2ecf20Sopenharmony_civoid r600_start_dpm(struct radeon_device *rdev);
2198c2ecf20Sopenharmony_civoid r600_stop_dpm(struct radeon_device *rdev);
2208c2ecf20Sopenharmony_ci
2218c2ecf20Sopenharmony_cibool r600_is_internal_thermal_sensor(enum radeon_int_thermal_type sensor);
2228c2ecf20Sopenharmony_ci
2238c2ecf20Sopenharmony_ciint r600_get_platform_caps(struct radeon_device *rdev);
2248c2ecf20Sopenharmony_ci
2258c2ecf20Sopenharmony_ciint r600_parse_extended_power_table(struct radeon_device *rdev);
2268c2ecf20Sopenharmony_civoid r600_free_extended_power_table(struct radeon_device *rdev);
2278c2ecf20Sopenharmony_ci
2288c2ecf20Sopenharmony_cienum radeon_pcie_gen r600_get_pcie_gen_support(struct radeon_device *rdev,
2298c2ecf20Sopenharmony_ci					       u32 sys_mask,
2308c2ecf20Sopenharmony_ci					       enum radeon_pcie_gen asic_gen,
2318c2ecf20Sopenharmony_ci					       enum radeon_pcie_gen default_gen);
2328c2ecf20Sopenharmony_ci
2338c2ecf20Sopenharmony_ciu16 r600_get_pcie_lane_support(struct radeon_device *rdev,
2348c2ecf20Sopenharmony_ci			       u16 asic_lanes,
2358c2ecf20Sopenharmony_ci			       u16 default_lanes);
2368c2ecf20Sopenharmony_ciu8 r600_encode_pci_lane_width(u32 lanes);
2378c2ecf20Sopenharmony_ci
2388c2ecf20Sopenharmony_ci#endif
239