2 * Copyright 2012 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.
26 #include "cypress_dpm.h"
28 #include "nislands_smc.h"
30 struct ni_clock_registers {
31 u32 cg_spll_func_cntl;
32 u32 cg_spll_func_cntl_2;
33 u32 cg_spll_func_cntl_3;
34 u32 cg_spll_func_cntl_4;
35 u32 cg_spll_spread_spectrum;
36 u32 cg_spll_spread_spectrum_2;
39 u32 mpll_ad_func_cntl;
40 u32 mpll_ad_func_cntl_2;
41 u32 mpll_dq_func_cntl;
42 u32 mpll_dq_func_cntl_2;
47 struct ni_mc_reg_entry {
49 u32 mc_data[SMC_NISLANDS_MC_REGISTER_ARRAY_SIZE];
52 struct ni_mc_reg_table {
56 struct ni_mc_reg_entry mc_reg_table_entry[MAX_AC_TIMING_ENTRIES];
57 SMC_NIslands_MCRegisterAddress mc_reg_address[SMC_NISLANDS_MC_REGISTER_ARRAY_SIZE];
60 #define NISLANDS_MCREGISTERTABLE_FIRST_DRIVERSTATE_SLOT 2
64 NISLANDS_DCCAC_LEVEL_0 = 0,
65 NISLANDS_DCCAC_LEVEL_1,
66 NISLANDS_DCCAC_LEVEL_2,
67 NISLANDS_DCCAC_LEVEL_3,
68 NISLANDS_DCCAC_LEVEL_4,
69 NISLANDS_DCCAC_LEVEL_5,
70 NISLANDS_DCCAC_LEVEL_6,
71 NISLANDS_DCCAC_LEVEL_7,
72 NISLANDS_DCCAC_MAX_LEVELS
75 struct ni_leakage_coeffients
88 struct ni_leakage_coeffients leakage_coefficients;
90 s32 leakage_minimum_temperature;
103 struct ni_cac_weights
154 u32 ovr_mode_spare_0;
156 u32 ovr_mode_spare_1;
165 u32 l2_lta_window_size;
167 u32 dc_cac[NISLANDS_DCCAC_MAX_LEVELS];
168 u32 pcie_cac[SMC_NISLANDS_BIF_LUT_NUM_OF_ENTRIES];
169 bool enable_power_containment_by_default;
173 u16 performance_level_count;
175 struct rv7xx_pl performance_levels[NISLANDS_MAX_SMC_PERFORMANCE_LEVELS_PER_SWSTATE];
178 struct ni_power_info {
180 struct evergreen_power_info eg;
181 struct ni_clock_registers clock_registers;
182 struct ni_mc_reg_table mc_reg_table;
183 u32 mclk_rtt_mode_threshold;
185 bool use_power_boost_limit;
186 bool support_cac_long_term_average;
188 bool cac_configuration_required;
189 bool driver_calculate_cac_leakage;
191 bool enable_power_containment;
193 bool enable_sq_ramping;
198 u16 spll_table_start;
200 struct ni_cac_data cac_data;
201 u32 dc_cac_table[NISLANDS_DCCAC_MAX_LEVELS];
202 const struct ni_cac_weights *cac_weights;
205 struct ni_ps current_ps;
206 struct ni_ps requested_ps;
207 /* scratch structs */
208 SMC_NIslands_MCRegisters smc_mc_reg_table;
209 NISLANDS_SMC_STATETABLE smc_statetable;
212 #define NISLANDS_INITIAL_STATE_ARB_INDEX 0
213 #define NISLANDS_ACPI_STATE_ARB_INDEX 1
214 #define NISLANDS_ULV_STATE_ARB_INDEX 2
215 #define NISLANDS_DRIVER_STATE_ARB_INDEX 3
217 #define NISLANDS_DPM2_MAX_PULSE_SKIP 256
219 #define NISLANDS_DPM2_NEAR_TDP_DEC 10
220 #define NISLANDS_DPM2_ABOVE_SAFE_INC 5
221 #define NISLANDS_DPM2_BELOW_SAFE_INC 20
223 #define NISLANDS_DPM2_TDP_SAFE_LIMIT_PERCENT 80
225 #define NISLANDS_DPM2_MAXPS_PERCENT_H 90
226 #define NISLANDS_DPM2_MAXPS_PERCENT_M 0
228 #define NISLANDS_DPM2_SQ_RAMP_MAX_POWER 0x3FFF
229 #define NISLANDS_DPM2_SQ_RAMP_MIN_POWER 0x12
230 #define NISLANDS_DPM2_SQ_RAMP_MAX_POWER_DELTA 0x15
231 #define NISLANDS_DPM2_SQ_RAMP_STI_SIZE 0x1E
232 #define NISLANDS_DPM2_SQ_RAMP_LTI_RATIO 0xF
234 int ni_copy_and_switch_arb_sets(struct radeon_device *rdev,
235 u32 arb_freq_src, u32 arb_freq_dest);
236 void ni_update_current_ps(struct radeon_device *rdev,
237 struct radeon_ps *rps);
238 void ni_update_requested_ps(struct radeon_device *rdev,
239 struct radeon_ps *rps);
241 void ni_set_uvd_clock_before_set_eng_clock(struct radeon_device *rdev,
242 struct radeon_ps *new_ps,
243 struct radeon_ps *old_ps);
244 void ni_set_uvd_clock_after_set_eng_clock(struct radeon_device *rdev,
245 struct radeon_ps *new_ps,
246 struct radeon_ps *old_ps);
248 bool ni_dpm_vblank_too_short(struct radeon_device *rdev);