1 1.2 riastrad /* $NetBSD: ni_dpm.h,v 1.3 2021/12/18 23:45:42 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 __NI_DPM_H__ 26 1.1 riastrad #define __NI_DPM_H__ 27 1.1 riastrad 28 1.1 riastrad #include "cypress_dpm.h" 29 1.1 riastrad #include "btc_dpm.h" 30 1.1 riastrad #include "nislands_smc.h" 31 1.1 riastrad 32 1.1 riastrad struct ni_clock_registers { 33 1.1 riastrad u32 cg_spll_func_cntl; 34 1.1 riastrad u32 cg_spll_func_cntl_2; 35 1.1 riastrad u32 cg_spll_func_cntl_3; 36 1.1 riastrad u32 cg_spll_func_cntl_4; 37 1.1 riastrad u32 cg_spll_spread_spectrum; 38 1.1 riastrad u32 cg_spll_spread_spectrum_2; 39 1.1 riastrad u32 mclk_pwrmgt_cntl; 40 1.1 riastrad u32 dll_cntl; 41 1.1 riastrad u32 mpll_ad_func_cntl; 42 1.1 riastrad u32 mpll_ad_func_cntl_2; 43 1.1 riastrad u32 mpll_dq_func_cntl; 44 1.1 riastrad u32 mpll_dq_func_cntl_2; 45 1.1 riastrad u32 mpll_ss1; 46 1.1 riastrad u32 mpll_ss2; 47 1.1 riastrad }; 48 1.1 riastrad 49 1.1 riastrad struct ni_mc_reg_entry { 50 1.1 riastrad u32 mclk_max; 51 1.1 riastrad u32 mc_data[SMC_NISLANDS_MC_REGISTER_ARRAY_SIZE]; 52 1.1 riastrad }; 53 1.1 riastrad 54 1.1 riastrad struct ni_mc_reg_table { 55 1.1 riastrad u8 last; 56 1.1 riastrad u8 num_entries; 57 1.1 riastrad u16 valid_flag; 58 1.1 riastrad struct ni_mc_reg_entry mc_reg_table_entry[MAX_AC_TIMING_ENTRIES]; 59 1.1 riastrad SMC_NIslands_MCRegisterAddress mc_reg_address[SMC_NISLANDS_MC_REGISTER_ARRAY_SIZE]; 60 1.1 riastrad }; 61 1.1 riastrad 62 1.1 riastrad #define NISLANDS_MCREGISTERTABLE_FIRST_DRIVERSTATE_SLOT 2 63 1.1 riastrad 64 1.1 riastrad enum ni_dc_cac_level 65 1.1 riastrad { 66 1.1 riastrad NISLANDS_DCCAC_LEVEL_0 = 0, 67 1.1 riastrad NISLANDS_DCCAC_LEVEL_1, 68 1.1 riastrad NISLANDS_DCCAC_LEVEL_2, 69 1.1 riastrad NISLANDS_DCCAC_LEVEL_3, 70 1.1 riastrad NISLANDS_DCCAC_LEVEL_4, 71 1.1 riastrad NISLANDS_DCCAC_LEVEL_5, 72 1.1 riastrad NISLANDS_DCCAC_LEVEL_6, 73 1.1 riastrad NISLANDS_DCCAC_LEVEL_7, 74 1.1 riastrad NISLANDS_DCCAC_MAX_LEVELS 75 1.1 riastrad }; 76 1.1 riastrad 77 1.1 riastrad struct ni_leakage_coeffients 78 1.1 riastrad { 79 1.1 riastrad u32 at; 80 1.1 riastrad u32 bt; 81 1.1 riastrad u32 av; 82 1.1 riastrad u32 bv; 83 1.1 riastrad s32 t_slope; 84 1.1 riastrad s32 t_intercept; 85 1.1 riastrad u32 t_ref; 86 1.1 riastrad }; 87 1.1 riastrad 88 1.1 riastrad struct ni_cac_data 89 1.1 riastrad { 90 1.1 riastrad struct ni_leakage_coeffients leakage_coefficients; 91 1.1 riastrad u32 i_leakage; 92 1.1 riastrad s32 leakage_minimum_temperature; 93 1.1 riastrad u32 pwr_const; 94 1.1 riastrad u32 dc_cac_value; 95 1.1 riastrad u32 bif_cac_value; 96 1.1 riastrad u32 lkge_pwr; 97 1.1 riastrad u8 mc_wr_weight; 98 1.1 riastrad u8 mc_rd_weight; 99 1.1 riastrad u8 allow_ovrflw; 100 1.1 riastrad u8 num_win_tdp; 101 1.1 riastrad u8 l2num_win_tdp; 102 1.1 riastrad u8 lts_truncate_n; 103 1.1 riastrad }; 104 1.1 riastrad 105 1.1 riastrad struct ni_cac_weights 106 1.1 riastrad { 107 1.1 riastrad u32 weight_tcp_sig0; 108 1.1 riastrad u32 weight_tcp_sig1; 109 1.1 riastrad u32 weight_ta_sig; 110 1.1 riastrad u32 weight_tcc_en0; 111 1.1 riastrad u32 weight_tcc_en1; 112 1.1 riastrad u32 weight_tcc_en2; 113 1.1 riastrad u32 weight_cb_en0; 114 1.1 riastrad u32 weight_cb_en1; 115 1.1 riastrad u32 weight_cb_en2; 116 1.1 riastrad u32 weight_cb_en3; 117 1.1 riastrad u32 weight_db_sig0; 118 1.1 riastrad u32 weight_db_sig1; 119 1.1 riastrad u32 weight_db_sig2; 120 1.1 riastrad u32 weight_db_sig3; 121 1.1 riastrad u32 weight_sxm_sig0; 122 1.1 riastrad u32 weight_sxm_sig1; 123 1.1 riastrad u32 weight_sxm_sig2; 124 1.1 riastrad u32 weight_sxs_sig0; 125 1.1 riastrad u32 weight_sxs_sig1; 126 1.1 riastrad u32 weight_xbr_0; 127 1.1 riastrad u32 weight_xbr_1; 128 1.1 riastrad u32 weight_xbr_2; 129 1.1 riastrad u32 weight_spi_sig0; 130 1.1 riastrad u32 weight_spi_sig1; 131 1.1 riastrad u32 weight_spi_sig2; 132 1.1 riastrad u32 weight_spi_sig3; 133 1.1 riastrad u32 weight_spi_sig4; 134 1.1 riastrad u32 weight_spi_sig5; 135 1.1 riastrad u32 weight_lds_sig0; 136 1.1 riastrad u32 weight_lds_sig1; 137 1.1 riastrad u32 weight_sc; 138 1.1 riastrad u32 weight_bif; 139 1.1 riastrad u32 weight_cp; 140 1.1 riastrad u32 weight_pa_sig0; 141 1.1 riastrad u32 weight_pa_sig1; 142 1.1 riastrad u32 weight_vgt_sig0; 143 1.1 riastrad u32 weight_vgt_sig1; 144 1.1 riastrad u32 weight_vgt_sig2; 145 1.1 riastrad u32 weight_dc_sig0; 146 1.1 riastrad u32 weight_dc_sig1; 147 1.1 riastrad u32 weight_dc_sig2; 148 1.1 riastrad u32 weight_dc_sig3; 149 1.1 riastrad u32 weight_uvd_sig0; 150 1.1 riastrad u32 weight_uvd_sig1; 151 1.1 riastrad u32 weight_spare0; 152 1.1 riastrad u32 weight_spare1; 153 1.1 riastrad u32 weight_sq_vsp; 154 1.1 riastrad u32 weight_sq_vsp0; 155 1.1 riastrad u32 weight_sq_gpr; 156 1.1 riastrad u32 ovr_mode_spare_0; 157 1.1 riastrad u32 ovr_val_spare_0; 158 1.1 riastrad u32 ovr_mode_spare_1; 159 1.1 riastrad u32 ovr_val_spare_1; 160 1.1 riastrad u32 vsp; 161 1.1 riastrad u32 vsp0; 162 1.1 riastrad u32 gpr; 163 1.1 riastrad u8 mc_read_weight; 164 1.1 riastrad u8 mc_write_weight; 165 1.1 riastrad u32 tid_cnt; 166 1.1 riastrad u32 tid_unit; 167 1.1 riastrad u32 l2_lta_window_size; 168 1.1 riastrad u32 lts_truncate; 169 1.1 riastrad u32 dc_cac[NISLANDS_DCCAC_MAX_LEVELS]; 170 1.1 riastrad u32 pcie_cac[SMC_NISLANDS_BIF_LUT_NUM_OF_ENTRIES]; 171 1.1 riastrad bool enable_power_containment_by_default; 172 1.1 riastrad }; 173 1.1 riastrad 174 1.1 riastrad struct ni_ps { 175 1.1 riastrad u16 performance_level_count; 176 1.1 riastrad bool dc_compatible; 177 1.1 riastrad struct rv7xx_pl performance_levels[NISLANDS_MAX_SMC_PERFORMANCE_LEVELS_PER_SWSTATE]; 178 1.1 riastrad }; 179 1.1 riastrad 180 1.1 riastrad struct ni_power_info { 181 1.1 riastrad /* must be first! */ 182 1.1 riastrad struct evergreen_power_info eg; 183 1.1 riastrad struct ni_clock_registers clock_registers; 184 1.1 riastrad struct ni_mc_reg_table mc_reg_table; 185 1.1 riastrad u32 mclk_rtt_mode_threshold; 186 1.1 riastrad /* flags */ 187 1.1 riastrad bool use_power_boost_limit; 188 1.1 riastrad bool support_cac_long_term_average; 189 1.1 riastrad bool cac_enabled; 190 1.1 riastrad bool cac_configuration_required; 191 1.1 riastrad bool driver_calculate_cac_leakage; 192 1.1 riastrad bool pc_enabled; 193 1.1 riastrad bool enable_power_containment; 194 1.1 riastrad bool enable_cac; 195 1.1 riastrad bool enable_sq_ramping; 196 1.1 riastrad /* smc offsets */ 197 1.1 riastrad u16 arb_table_start; 198 1.1 riastrad u16 fan_table_start; 199 1.1 riastrad u16 cac_table_start; 200 1.1 riastrad u16 spll_table_start; 201 1.1 riastrad /* CAC stuff */ 202 1.1 riastrad struct ni_cac_data cac_data; 203 1.1 riastrad u32 dc_cac_table[NISLANDS_DCCAC_MAX_LEVELS]; 204 1.1 riastrad const struct ni_cac_weights *cac_weights; 205 1.1 riastrad u8 lta_window_size; 206 1.1 riastrad u8 lts_truncate; 207 1.1 riastrad struct ni_ps current_ps; 208 1.1 riastrad struct ni_ps requested_ps; 209 1.1 riastrad /* scratch structs */ 210 1.1 riastrad SMC_NIslands_MCRegisters smc_mc_reg_table; 211 1.1 riastrad NISLANDS_SMC_STATETABLE smc_statetable; 212 1.1 riastrad }; 213 1.1 riastrad 214 1.1 riastrad #define NISLANDS_INITIAL_STATE_ARB_INDEX 0 215 1.1 riastrad #define NISLANDS_ACPI_STATE_ARB_INDEX 1 216 1.1 riastrad #define NISLANDS_ULV_STATE_ARB_INDEX 2 217 1.1 riastrad #define NISLANDS_DRIVER_STATE_ARB_INDEX 3 218 1.1 riastrad 219 1.1 riastrad #define NISLANDS_DPM2_MAX_PULSE_SKIP 256 220 1.1 riastrad 221 1.1 riastrad #define NISLANDS_DPM2_NEAR_TDP_DEC 10 222 1.1 riastrad #define NISLANDS_DPM2_ABOVE_SAFE_INC 5 223 1.1 riastrad #define NISLANDS_DPM2_BELOW_SAFE_INC 20 224 1.1 riastrad 225 1.1 riastrad #define NISLANDS_DPM2_TDP_SAFE_LIMIT_PERCENT 80 226 1.1 riastrad 227 1.1 riastrad #define NISLANDS_DPM2_MAXPS_PERCENT_H 90 228 1.1 riastrad #define NISLANDS_DPM2_MAXPS_PERCENT_M 0 229 1.1 riastrad 230 1.1 riastrad #define NISLANDS_DPM2_SQ_RAMP_MAX_POWER 0x3FFF 231 1.1 riastrad #define NISLANDS_DPM2_SQ_RAMP_MIN_POWER 0x12 232 1.1 riastrad #define NISLANDS_DPM2_SQ_RAMP_MAX_POWER_DELTA 0x15 233 1.1 riastrad #define NISLANDS_DPM2_SQ_RAMP_STI_SIZE 0x1E 234 1.1 riastrad #define NISLANDS_DPM2_SQ_RAMP_LTI_RATIO 0xF 235 1.1 riastrad 236 1.1 riastrad int ni_copy_and_switch_arb_sets(struct radeon_device *rdev, 237 1.1 riastrad u32 arb_freq_src, u32 arb_freq_dest); 238 1.1 riastrad void ni_update_current_ps(struct radeon_device *rdev, 239 1.1 riastrad struct radeon_ps *rps); 240 1.1 riastrad void ni_update_requested_ps(struct radeon_device *rdev, 241 1.1 riastrad struct radeon_ps *rps); 242 1.1 riastrad 243 1.1 riastrad void ni_set_uvd_clock_before_set_eng_clock(struct radeon_device *rdev, 244 1.1 riastrad struct radeon_ps *new_ps, 245 1.1 riastrad struct radeon_ps *old_ps); 246 1.1 riastrad void ni_set_uvd_clock_after_set_eng_clock(struct radeon_device *rdev, 247 1.1 riastrad struct radeon_ps *new_ps, 248 1.1 riastrad struct radeon_ps *old_ps); 249 1.1 riastrad 250 1.1 riastrad bool ni_dpm_vblank_too_short(struct radeon_device *rdev); 251 1.1 riastrad 252 1.1 riastrad #endif 253