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.
27 #include "sislands_smc.h"
29 enum si_cac_config_reg_type
31 SISLANDS_CACCONFIG_MMR
= 0,
32 SISLANDS_CACCONFIG_CGIND
,
33 SISLANDS_CACCONFIG_MAX
36 struct si_cac_config_reg
42 enum si_cac_config_reg_type type
;
45 struct si_powertune_data
48 u32 l2_lta_window_size_default
;
49 u8 lts_truncate_default
;
52 struct ni_leakage_coeffients leakage_coefficients
;
54 u32 lkge_lut_v0_percent
;
55 u8 dc_cac
[NISLANDS_DCCAC_MAX_LEVELS
];
56 bool enable_powertune_by_default
;
59 struct si_dyn_powertune_data
62 s32 leakage_minimum_temperature
;
64 u32 l2_lta_window_size
;
68 bool disable_uvd_powertune
;
73 u32 tau
[SMC_SISLANDS_DTE_MAX_FILTER_STAGES
];
74 u32 r
[SMC_SISLANDS_DTE_MAX_FILTER_STAGES
];
82 u8 t_limits
[SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE
];
83 u32 tdep_tau
[SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE
];
84 u32 tdep_r
[SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE
];
86 bool enable_dte_by_default
;
89 struct si_clock_registers
{
90 u32 cg_spll_func_cntl
;
91 u32 cg_spll_func_cntl_2
;
92 u32 cg_spll_func_cntl_3
;
93 u32 cg_spll_func_cntl_4
;
94 u32 cg_spll_spread_spectrum
;
95 u32 cg_spll_spread_spectrum_2
;
98 u32 mpll_ad_func_cntl
;
99 u32 mpll_dq_func_cntl
;
101 u32 mpll_func_cntl_1
;
102 u32 mpll_func_cntl_2
;
107 struct si_mc_reg_entry
{
109 u32 mc_data
[SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE
];
112 struct si_mc_reg_table
{
116 struct si_mc_reg_entry mc_reg_table_entry
[MAX_AC_TIMING_ENTRIES
];
117 SMC_NIslands_MCRegisterAddress mc_reg_address
[SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE
];
120 #define SISLANDS_MCREGISTERTABLE_INITIAL_SLOT 0
121 #define SISLANDS_MCREGISTERTABLE_ACPI_SLOT 1
122 #define SISLANDS_MCREGISTERTABLE_ULV_SLOT 2
123 #define SISLANDS_MCREGISTERTABLE_FIRST_DRIVERSTATE_SLOT 3
125 struct si_leakage_voltage_entry
131 #define SISLANDS_LEAKAGE_INDEX0 0xff01
132 #define SISLANDS_MAX_LEAKAGE_COUNT 4
134 struct si_leakage_voltage
137 struct si_leakage_voltage_entry entries
[SISLANDS_MAX_LEAKAGE_COUNT
];
140 #define SISLANDS_MAX_HARDWARE_POWERLEVELS 5
142 struct si_ulv_param
{
145 u32 cg_ulv_parameter
;
146 u32 volt_change_delay
;
148 bool one_pcie_lane_in_ulv
;
151 struct si_power_info
{
153 struct ni_power_info ni
;
154 struct si_clock_registers clock_registers
;
155 struct si_mc_reg_table mc_reg_table
;
156 struct atom_voltage_table mvdd_voltage_table
;
157 struct atom_voltage_table vddc_phase_shed_table
;
158 struct si_leakage_voltage leakage_voltage
;
159 u16 mvdd_bootup_value
;
160 struct si_ulv_param ulv
;
163 enum radeon_pcie_gen force_pcie_gen
;
164 enum radeon_pcie_gen boot_pcie_gen
;
165 enum radeon_pcie_gen acpi_pcie_gen
;
170 bool vddc_phase_shed_control
;
171 bool pspp_notify_required
;
172 bool sclk_deep_sleep_above_low
;
173 bool voltage_control_svi2
;
174 bool vddci_control_svi2
;
177 u32 state_table_start
;
179 u32 mc_reg_table_start
;
183 u32 spll_table_start
;
184 u32 papm_cfg_table_start
;
187 const struct si_cac_config_reg
*cac_weights
;
188 const struct si_cac_config_reg
*lcac_config
;
189 const struct si_cac_config_reg
*cac_override
;
190 const struct si_powertune_data
*powertune_data
;
191 struct si_dyn_powertune_data dyn_powertune_data
;
193 struct si_dte_data dte_data
;
194 /* scratch structs */
195 SMC_SIslands_MCRegisters smc_mc_reg_table
;
196 SISLANDS_SMC_STATETABLE smc_statetable
;
197 PP_SIslands_PAPMParameters papm_parm
;
202 bool fan_ctrl_is_in_default_mode
;
204 u32 fan_ctrl_default_mode
;
205 bool fan_is_controlled_by_smc
;
208 #define SISLANDS_INITIAL_STATE_ARB_INDEX 0
209 #define SISLANDS_ACPI_STATE_ARB_INDEX 1
210 #define SISLANDS_ULV_STATE_ARB_INDEX 2
211 #define SISLANDS_DRIVER_STATE_ARB_INDEX 3
213 #define SISLANDS_DPM2_MAX_PULSE_SKIP 256
215 #define SISLANDS_DPM2_NEAR_TDP_DEC 10
216 #define SISLANDS_DPM2_ABOVE_SAFE_INC 5
217 #define SISLANDS_DPM2_BELOW_SAFE_INC 20
219 #define SISLANDS_DPM2_TDP_SAFE_LIMIT_PERCENT 80
221 #define SISLANDS_DPM2_MAXPS_PERCENT_H 99
222 #define SISLANDS_DPM2_MAXPS_PERCENT_M 99
224 #define SISLANDS_DPM2_SQ_RAMP_MAX_POWER 0x3FFF
225 #define SISLANDS_DPM2_SQ_RAMP_MIN_POWER 0x12
226 #define SISLANDS_DPM2_SQ_RAMP_MAX_POWER_DELTA 0x15
227 #define SISLANDS_DPM2_SQ_RAMP_STI_SIZE 0x1E
228 #define SISLANDS_DPM2_SQ_RAMP_LTI_RATIO 0xF
230 #define SISLANDS_DPM2_PWREFFICIENCYRATIO_MARGIN 10
232 #define SISLANDS_VRC_DFLT 0xC000B3
233 #define SISLANDS_ULVVOLTAGECHANGEDELAY_DFLT 1687
234 #define SISLANDS_CGULVPARAMETER_DFLT 0x00040035
235 #define SISLANDS_CGULVCONTROL_DFLT 0x1f007550
237 u8
si_get_ddr3_mclk_frequency_ratio(u32 memory_clock
);
238 u8
si_get_mclk_frequency_ratio(u32 memory_clock
, bool strobe_mode
);
239 void si_trim_voltage_table_to_fit_state_table(struct radeon_device
*rdev
,
240 u32 max_voltage_steps
,
241 struct atom_voltage_table
*voltage_table
);