1 1.2 riastrad /* $NetBSD: si_dpm.h,v 1.3 2021/12/18 23:45:43 riastradh Exp $ */ 2 1.2 riastrad 3 1.1 riastrad /* 4 1.1 riastrad * Copyright 2012 Advanced Micro Devices, Inc. 5 1.1 riastrad * 6 1.1 riastrad * Permission is hereby granted, free of charge, to any person obtaining a 7 1.1 riastrad * copy of this software and associated documentation files (the "Software"), 8 1.1 riastrad * to deal in the Software without restriction, including without limitation 9 1.1 riastrad * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 1.1 riastrad * and/or sell copies of the Software, and to permit persons to whom the 11 1.1 riastrad * Software is furnished to do so, subject to the following conditions: 12 1.1 riastrad * 13 1.1 riastrad * The above copyright notice and this permission notice shall be included in 14 1.1 riastrad * all copies or substantial portions of the Software. 15 1.1 riastrad * 16 1.1 riastrad * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 1.1 riastrad * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 1.1 riastrad * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 1.1 riastrad * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 1.1 riastrad * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 1.1 riastrad * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 1.1 riastrad * OTHER DEALINGS IN THE SOFTWARE. 23 1.1 riastrad * 24 1.1 riastrad */ 25 1.1 riastrad #ifndef __SI_DPM_H__ 26 1.1 riastrad #define __SI_DPM_H__ 27 1.1 riastrad 28 1.1 riastrad #include "ni_dpm.h" 29 1.1 riastrad #include "sislands_smc.h" 30 1.1 riastrad 31 1.1 riastrad enum si_cac_config_reg_type 32 1.1 riastrad { 33 1.1 riastrad SISLANDS_CACCONFIG_MMR = 0, 34 1.1 riastrad SISLANDS_CACCONFIG_CGIND, 35 1.1 riastrad SISLANDS_CACCONFIG_MAX 36 1.1 riastrad }; 37 1.1 riastrad 38 1.1 riastrad struct si_cac_config_reg 39 1.1 riastrad { 40 1.1 riastrad u32 offset; 41 1.1 riastrad u32 mask; 42 1.1 riastrad u32 shift; 43 1.1 riastrad u32 value; 44 1.1 riastrad enum si_cac_config_reg_type type; 45 1.1 riastrad }; 46 1.1 riastrad 47 1.1 riastrad struct si_powertune_data 48 1.1 riastrad { 49 1.1 riastrad u32 cac_window; 50 1.1 riastrad u32 l2_lta_window_size_default; 51 1.1 riastrad u8 lts_truncate_default; 52 1.1 riastrad u8 shift_n_default; 53 1.1 riastrad u8 operating_temp; 54 1.1 riastrad struct ni_leakage_coeffients leakage_coefficients; 55 1.1 riastrad u32 fixed_kt; 56 1.1 riastrad u32 lkge_lut_v0_percent; 57 1.1 riastrad u8 dc_cac[NISLANDS_DCCAC_MAX_LEVELS]; 58 1.1 riastrad bool enable_powertune_by_default; 59 1.1 riastrad }; 60 1.1 riastrad 61 1.1 riastrad struct si_dyn_powertune_data 62 1.1 riastrad { 63 1.1 riastrad u32 cac_leakage; 64 1.1 riastrad s32 leakage_minimum_temperature; 65 1.1 riastrad u32 wintime; 66 1.1 riastrad u32 l2_lta_window_size; 67 1.1 riastrad u8 lts_truncate; 68 1.1 riastrad u8 shift_n; 69 1.1 riastrad u8 dc_pwr_value; 70 1.1 riastrad bool disable_uvd_powertune; 71 1.1 riastrad }; 72 1.1 riastrad 73 1.1 riastrad struct si_dte_data 74 1.1 riastrad { 75 1.1 riastrad u32 tau[SMC_SISLANDS_DTE_MAX_FILTER_STAGES]; 76 1.1 riastrad u32 r[SMC_SISLANDS_DTE_MAX_FILTER_STAGES]; 77 1.1 riastrad u32 k; 78 1.1 riastrad u32 t0; 79 1.1 riastrad u32 max_t; 80 1.1 riastrad u8 window_size; 81 1.1 riastrad u8 temp_select; 82 1.1 riastrad u8 dte_mode; 83 1.1 riastrad u8 tdep_count; 84 1.1 riastrad u8 t_limits[SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE]; 85 1.1 riastrad u32 tdep_tau[SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE]; 86 1.1 riastrad u32 tdep_r[SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE]; 87 1.1 riastrad u32 t_threshold; 88 1.1 riastrad bool enable_dte_by_default; 89 1.1 riastrad }; 90 1.1 riastrad 91 1.1 riastrad struct si_clock_registers { 92 1.1 riastrad u32 cg_spll_func_cntl; 93 1.1 riastrad u32 cg_spll_func_cntl_2; 94 1.1 riastrad u32 cg_spll_func_cntl_3; 95 1.1 riastrad u32 cg_spll_func_cntl_4; 96 1.1 riastrad u32 cg_spll_spread_spectrum; 97 1.1 riastrad u32 cg_spll_spread_spectrum_2; 98 1.1 riastrad u32 dll_cntl; 99 1.1 riastrad u32 mclk_pwrmgt_cntl; 100 1.1 riastrad u32 mpll_ad_func_cntl; 101 1.1 riastrad u32 mpll_dq_func_cntl; 102 1.1 riastrad u32 mpll_func_cntl; 103 1.1 riastrad u32 mpll_func_cntl_1; 104 1.1 riastrad u32 mpll_func_cntl_2; 105 1.1 riastrad u32 mpll_ss1; 106 1.1 riastrad u32 mpll_ss2; 107 1.1 riastrad }; 108 1.1 riastrad 109 1.1 riastrad struct si_mc_reg_entry { 110 1.1 riastrad u32 mclk_max; 111 1.1 riastrad u32 mc_data[SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE]; 112 1.1 riastrad }; 113 1.1 riastrad 114 1.1 riastrad struct si_mc_reg_table { 115 1.1 riastrad u8 last; 116 1.1 riastrad u8 num_entries; 117 1.1 riastrad u16 valid_flag; 118 1.1 riastrad struct si_mc_reg_entry mc_reg_table_entry[MAX_AC_TIMING_ENTRIES]; 119 1.1 riastrad SMC_NIslands_MCRegisterAddress mc_reg_address[SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE]; 120 1.1 riastrad }; 121 1.1 riastrad 122 1.1 riastrad #define SISLANDS_MCREGISTERTABLE_INITIAL_SLOT 0 123 1.1 riastrad #define SISLANDS_MCREGISTERTABLE_ACPI_SLOT 1 124 1.1 riastrad #define SISLANDS_MCREGISTERTABLE_ULV_SLOT 2 125 1.1 riastrad #define SISLANDS_MCREGISTERTABLE_FIRST_DRIVERSTATE_SLOT 3 126 1.1 riastrad 127 1.1 riastrad struct si_leakage_voltage_entry 128 1.1 riastrad { 129 1.1 riastrad u16 voltage; 130 1.1 riastrad u16 leakage_index; 131 1.1 riastrad }; 132 1.1 riastrad 133 1.1 riastrad #define SISLANDS_LEAKAGE_INDEX0 0xff01 134 1.1 riastrad #define SISLANDS_MAX_LEAKAGE_COUNT 4 135 1.1 riastrad 136 1.1 riastrad struct si_leakage_voltage 137 1.1 riastrad { 138 1.1 riastrad u16 count; 139 1.1 riastrad struct si_leakage_voltage_entry entries[SISLANDS_MAX_LEAKAGE_COUNT]; 140 1.1 riastrad }; 141 1.1 riastrad 142 1.1 riastrad #define SISLANDS_MAX_HARDWARE_POWERLEVELS 5 143 1.1 riastrad 144 1.1 riastrad struct si_ulv_param { 145 1.1 riastrad bool supported; 146 1.1 riastrad u32 cg_ulv_control; 147 1.1 riastrad u32 cg_ulv_parameter; 148 1.1 riastrad u32 volt_change_delay; 149 1.1 riastrad struct rv7xx_pl pl; 150 1.1 riastrad bool one_pcie_lane_in_ulv; 151 1.1 riastrad }; 152 1.1 riastrad 153 1.1 riastrad struct si_power_info { 154 1.1 riastrad /* must be first! */ 155 1.1 riastrad struct ni_power_info ni; 156 1.1 riastrad struct si_clock_registers clock_registers; 157 1.1 riastrad struct si_mc_reg_table mc_reg_table; 158 1.1 riastrad struct atom_voltage_table mvdd_voltage_table; 159 1.1 riastrad struct atom_voltage_table vddc_phase_shed_table; 160 1.1 riastrad struct si_leakage_voltage leakage_voltage; 161 1.1 riastrad u16 mvdd_bootup_value; 162 1.1 riastrad struct si_ulv_param ulv; 163 1.1 riastrad u32 max_cu; 164 1.1 riastrad /* pcie gen */ 165 1.1 riastrad enum radeon_pcie_gen force_pcie_gen; 166 1.1 riastrad enum radeon_pcie_gen boot_pcie_gen; 167 1.1 riastrad enum radeon_pcie_gen acpi_pcie_gen; 168 1.1 riastrad u32 sys_pcie_mask; 169 1.1 riastrad /* flags */ 170 1.1 riastrad bool enable_dte; 171 1.1 riastrad bool enable_ppm; 172 1.1 riastrad bool vddc_phase_shed_control; 173 1.1 riastrad bool pspp_notify_required; 174 1.1 riastrad bool sclk_deep_sleep_above_low; 175 1.2 riastrad bool voltage_control_svi2; 176 1.2 riastrad bool vddci_control_svi2; 177 1.1 riastrad /* smc offsets */ 178 1.1 riastrad u32 sram_end; 179 1.1 riastrad u32 state_table_start; 180 1.1 riastrad u32 soft_regs_start; 181 1.1 riastrad u32 mc_reg_table_start; 182 1.1 riastrad u32 arb_table_start; 183 1.1 riastrad u32 cac_table_start; 184 1.1 riastrad u32 dte_table_start; 185 1.1 riastrad u32 spll_table_start; 186 1.1 riastrad u32 papm_cfg_table_start; 187 1.2 riastrad u32 fan_table_start; 188 1.1 riastrad /* CAC stuff */ 189 1.1 riastrad const struct si_cac_config_reg *cac_weights; 190 1.1 riastrad const struct si_cac_config_reg *lcac_config; 191 1.1 riastrad const struct si_cac_config_reg *cac_override; 192 1.1 riastrad const struct si_powertune_data *powertune_data; 193 1.1 riastrad struct si_dyn_powertune_data dyn_powertune_data; 194 1.1 riastrad /* DTE stuff */ 195 1.1 riastrad struct si_dte_data dte_data; 196 1.1 riastrad /* scratch structs */ 197 1.1 riastrad SMC_SIslands_MCRegisters smc_mc_reg_table; 198 1.1 riastrad SISLANDS_SMC_STATETABLE smc_statetable; 199 1.1 riastrad PP_SIslands_PAPMParameters papm_parm; 200 1.2 riastrad /* SVI2 */ 201 1.2 riastrad u8 svd_gpio_id; 202 1.2 riastrad u8 svc_gpio_id; 203 1.2 riastrad /* fan control */ 204 1.2 riastrad bool fan_ctrl_is_in_default_mode; 205 1.2 riastrad u32 t_min; 206 1.2 riastrad u32 fan_ctrl_default_mode; 207 1.2 riastrad bool fan_is_controlled_by_smc; 208 1.1 riastrad }; 209 1.1 riastrad 210 1.1 riastrad #define SISLANDS_INITIAL_STATE_ARB_INDEX 0 211 1.1 riastrad #define SISLANDS_ACPI_STATE_ARB_INDEX 1 212 1.1 riastrad #define SISLANDS_ULV_STATE_ARB_INDEX 2 213 1.1 riastrad #define SISLANDS_DRIVER_STATE_ARB_INDEX 3 214 1.1 riastrad 215 1.1 riastrad #define SISLANDS_DPM2_MAX_PULSE_SKIP 256 216 1.1 riastrad 217 1.1 riastrad #define SISLANDS_DPM2_NEAR_TDP_DEC 10 218 1.1 riastrad #define SISLANDS_DPM2_ABOVE_SAFE_INC 5 219 1.1 riastrad #define SISLANDS_DPM2_BELOW_SAFE_INC 20 220 1.1 riastrad 221 1.1 riastrad #define SISLANDS_DPM2_TDP_SAFE_LIMIT_PERCENT 80 222 1.1 riastrad 223 1.1 riastrad #define SISLANDS_DPM2_MAXPS_PERCENT_H 99 224 1.1 riastrad #define SISLANDS_DPM2_MAXPS_PERCENT_M 99 225 1.1 riastrad 226 1.1 riastrad #define SISLANDS_DPM2_SQ_RAMP_MAX_POWER 0x3FFF 227 1.1 riastrad #define SISLANDS_DPM2_SQ_RAMP_MIN_POWER 0x12 228 1.1 riastrad #define SISLANDS_DPM2_SQ_RAMP_MAX_POWER_DELTA 0x15 229 1.1 riastrad #define SISLANDS_DPM2_SQ_RAMP_STI_SIZE 0x1E 230 1.1 riastrad #define SISLANDS_DPM2_SQ_RAMP_LTI_RATIO 0xF 231 1.1 riastrad 232 1.1 riastrad #define SISLANDS_DPM2_PWREFFICIENCYRATIO_MARGIN 10 233 1.1 riastrad 234 1.1 riastrad #define SISLANDS_VRC_DFLT 0xC000B3 235 1.1 riastrad #define SISLANDS_ULVVOLTAGECHANGEDELAY_DFLT 1687 236 1.1 riastrad #define SISLANDS_CGULVPARAMETER_DFLT 0x00040035 237 1.1 riastrad #define SISLANDS_CGULVCONTROL_DFLT 0x1f007550 238 1.1 riastrad 239 1.1 riastrad 240 1.1 riastrad #endif 241