162306a36Sopenharmony_ci/* 262306a36Sopenharmony_ci * Copyright 2012 Advanced Micro Devices, Inc. 362306a36Sopenharmony_ci * 462306a36Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 562306a36Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 662306a36Sopenharmony_ci * to deal in the Software without restriction, including without limitation 762306a36Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 862306a36Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 962306a36Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 1062306a36Sopenharmony_ci * 1162306a36Sopenharmony_ci * The above copyright notice and this permission notice shall be included in 1262306a36Sopenharmony_ci * all copies or substantial portions of the Software. 1362306a36Sopenharmony_ci * 1462306a36Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1562306a36Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1662306a36Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 1762306a36Sopenharmony_ci * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 1862306a36Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 1962306a36Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 2062306a36Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE. 2162306a36Sopenharmony_ci * 2262306a36Sopenharmony_ci */ 2362306a36Sopenharmony_ci#ifndef __SI_DPM_H__ 2462306a36Sopenharmony_ci#define __SI_DPM_H__ 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_ci#include "ni_dpm.h" 2762306a36Sopenharmony_ci#include "sislands_smc.h" 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_cienum si_cac_config_reg_type 3062306a36Sopenharmony_ci{ 3162306a36Sopenharmony_ci SISLANDS_CACCONFIG_MMR = 0, 3262306a36Sopenharmony_ci SISLANDS_CACCONFIG_CGIND, 3362306a36Sopenharmony_ci SISLANDS_CACCONFIG_MAX 3462306a36Sopenharmony_ci}; 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_cistruct si_cac_config_reg 3762306a36Sopenharmony_ci{ 3862306a36Sopenharmony_ci u32 offset; 3962306a36Sopenharmony_ci u32 mask; 4062306a36Sopenharmony_ci u32 shift; 4162306a36Sopenharmony_ci u32 value; 4262306a36Sopenharmony_ci enum si_cac_config_reg_type type; 4362306a36Sopenharmony_ci}; 4462306a36Sopenharmony_ci 4562306a36Sopenharmony_cistruct si_powertune_data 4662306a36Sopenharmony_ci{ 4762306a36Sopenharmony_ci u32 cac_window; 4862306a36Sopenharmony_ci u32 l2_lta_window_size_default; 4962306a36Sopenharmony_ci u8 lts_truncate_default; 5062306a36Sopenharmony_ci u8 shift_n_default; 5162306a36Sopenharmony_ci u8 operating_temp; 5262306a36Sopenharmony_ci struct ni_leakage_coeffients leakage_coefficients; 5362306a36Sopenharmony_ci u32 fixed_kt; 5462306a36Sopenharmony_ci u32 lkge_lut_v0_percent; 5562306a36Sopenharmony_ci u8 dc_cac[NISLANDS_DCCAC_MAX_LEVELS]; 5662306a36Sopenharmony_ci bool enable_powertune_by_default; 5762306a36Sopenharmony_ci}; 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_cistruct si_dyn_powertune_data 6062306a36Sopenharmony_ci{ 6162306a36Sopenharmony_ci u32 cac_leakage; 6262306a36Sopenharmony_ci s32 leakage_minimum_temperature; 6362306a36Sopenharmony_ci u32 wintime; 6462306a36Sopenharmony_ci u32 l2_lta_window_size; 6562306a36Sopenharmony_ci u8 lts_truncate; 6662306a36Sopenharmony_ci u8 shift_n; 6762306a36Sopenharmony_ci u8 dc_pwr_value; 6862306a36Sopenharmony_ci bool disable_uvd_powertune; 6962306a36Sopenharmony_ci}; 7062306a36Sopenharmony_ci 7162306a36Sopenharmony_cistruct si_dte_data 7262306a36Sopenharmony_ci{ 7362306a36Sopenharmony_ci u32 tau[SMC_SISLANDS_DTE_MAX_FILTER_STAGES]; 7462306a36Sopenharmony_ci u32 r[SMC_SISLANDS_DTE_MAX_FILTER_STAGES]; 7562306a36Sopenharmony_ci u32 k; 7662306a36Sopenharmony_ci u32 t0; 7762306a36Sopenharmony_ci u32 max_t; 7862306a36Sopenharmony_ci u8 window_size; 7962306a36Sopenharmony_ci u8 temp_select; 8062306a36Sopenharmony_ci u8 dte_mode; 8162306a36Sopenharmony_ci u8 tdep_count; 8262306a36Sopenharmony_ci u8 t_limits[SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE]; 8362306a36Sopenharmony_ci u32 tdep_tau[SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE]; 8462306a36Sopenharmony_ci u32 tdep_r[SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE]; 8562306a36Sopenharmony_ci u32 t_threshold; 8662306a36Sopenharmony_ci bool enable_dte_by_default; 8762306a36Sopenharmony_ci}; 8862306a36Sopenharmony_ci 8962306a36Sopenharmony_cistruct si_clock_registers { 9062306a36Sopenharmony_ci u32 cg_spll_func_cntl; 9162306a36Sopenharmony_ci u32 cg_spll_func_cntl_2; 9262306a36Sopenharmony_ci u32 cg_spll_func_cntl_3; 9362306a36Sopenharmony_ci u32 cg_spll_func_cntl_4; 9462306a36Sopenharmony_ci u32 cg_spll_spread_spectrum; 9562306a36Sopenharmony_ci u32 cg_spll_spread_spectrum_2; 9662306a36Sopenharmony_ci u32 dll_cntl; 9762306a36Sopenharmony_ci u32 mclk_pwrmgt_cntl; 9862306a36Sopenharmony_ci u32 mpll_ad_func_cntl; 9962306a36Sopenharmony_ci u32 mpll_dq_func_cntl; 10062306a36Sopenharmony_ci u32 mpll_func_cntl; 10162306a36Sopenharmony_ci u32 mpll_func_cntl_1; 10262306a36Sopenharmony_ci u32 mpll_func_cntl_2; 10362306a36Sopenharmony_ci u32 mpll_ss1; 10462306a36Sopenharmony_ci u32 mpll_ss2; 10562306a36Sopenharmony_ci}; 10662306a36Sopenharmony_ci 10762306a36Sopenharmony_cistruct si_mc_reg_entry { 10862306a36Sopenharmony_ci u32 mclk_max; 10962306a36Sopenharmony_ci u32 mc_data[SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE]; 11062306a36Sopenharmony_ci}; 11162306a36Sopenharmony_ci 11262306a36Sopenharmony_cistruct si_mc_reg_table { 11362306a36Sopenharmony_ci u8 last; 11462306a36Sopenharmony_ci u8 num_entries; 11562306a36Sopenharmony_ci u16 valid_flag; 11662306a36Sopenharmony_ci struct si_mc_reg_entry mc_reg_table_entry[MAX_AC_TIMING_ENTRIES]; 11762306a36Sopenharmony_ci SMC_NIslands_MCRegisterAddress mc_reg_address[SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE]; 11862306a36Sopenharmony_ci}; 11962306a36Sopenharmony_ci 12062306a36Sopenharmony_ci#define SISLANDS_MCREGISTERTABLE_INITIAL_SLOT 0 12162306a36Sopenharmony_ci#define SISLANDS_MCREGISTERTABLE_ACPI_SLOT 1 12262306a36Sopenharmony_ci#define SISLANDS_MCREGISTERTABLE_ULV_SLOT 2 12362306a36Sopenharmony_ci#define SISLANDS_MCREGISTERTABLE_FIRST_DRIVERSTATE_SLOT 3 12462306a36Sopenharmony_ci 12562306a36Sopenharmony_cistruct si_leakage_voltage_entry 12662306a36Sopenharmony_ci{ 12762306a36Sopenharmony_ci u16 voltage; 12862306a36Sopenharmony_ci u16 leakage_index; 12962306a36Sopenharmony_ci}; 13062306a36Sopenharmony_ci 13162306a36Sopenharmony_ci#define SISLANDS_LEAKAGE_INDEX0 0xff01 13262306a36Sopenharmony_ci#define SISLANDS_MAX_LEAKAGE_COUNT 4 13362306a36Sopenharmony_ci 13462306a36Sopenharmony_cistruct si_leakage_voltage 13562306a36Sopenharmony_ci{ 13662306a36Sopenharmony_ci u16 count; 13762306a36Sopenharmony_ci struct si_leakage_voltage_entry entries[SISLANDS_MAX_LEAKAGE_COUNT]; 13862306a36Sopenharmony_ci}; 13962306a36Sopenharmony_ci 14062306a36Sopenharmony_ci#define SISLANDS_MAX_HARDWARE_POWERLEVELS 5 14162306a36Sopenharmony_ci 14262306a36Sopenharmony_cistruct si_ulv_param { 14362306a36Sopenharmony_ci bool supported; 14462306a36Sopenharmony_ci u32 cg_ulv_control; 14562306a36Sopenharmony_ci u32 cg_ulv_parameter; 14662306a36Sopenharmony_ci u32 volt_change_delay; 14762306a36Sopenharmony_ci struct rv7xx_pl pl; 14862306a36Sopenharmony_ci bool one_pcie_lane_in_ulv; 14962306a36Sopenharmony_ci}; 15062306a36Sopenharmony_ci 15162306a36Sopenharmony_cistruct si_power_info { 15262306a36Sopenharmony_ci /* must be first! */ 15362306a36Sopenharmony_ci struct ni_power_info ni; 15462306a36Sopenharmony_ci struct si_clock_registers clock_registers; 15562306a36Sopenharmony_ci struct si_mc_reg_table mc_reg_table; 15662306a36Sopenharmony_ci struct atom_voltage_table mvdd_voltage_table; 15762306a36Sopenharmony_ci struct atom_voltage_table vddc_phase_shed_table; 15862306a36Sopenharmony_ci struct si_leakage_voltage leakage_voltage; 15962306a36Sopenharmony_ci u16 mvdd_bootup_value; 16062306a36Sopenharmony_ci struct si_ulv_param ulv; 16162306a36Sopenharmony_ci u32 max_cu; 16262306a36Sopenharmony_ci /* pcie gen */ 16362306a36Sopenharmony_ci enum radeon_pcie_gen force_pcie_gen; 16462306a36Sopenharmony_ci enum radeon_pcie_gen boot_pcie_gen; 16562306a36Sopenharmony_ci enum radeon_pcie_gen acpi_pcie_gen; 16662306a36Sopenharmony_ci u32 sys_pcie_mask; 16762306a36Sopenharmony_ci /* flags */ 16862306a36Sopenharmony_ci bool enable_dte; 16962306a36Sopenharmony_ci bool enable_ppm; 17062306a36Sopenharmony_ci bool vddc_phase_shed_control; 17162306a36Sopenharmony_ci bool pspp_notify_required; 17262306a36Sopenharmony_ci bool sclk_deep_sleep_above_low; 17362306a36Sopenharmony_ci bool voltage_control_svi2; 17462306a36Sopenharmony_ci bool vddci_control_svi2; 17562306a36Sopenharmony_ci /* smc offsets */ 17662306a36Sopenharmony_ci u32 sram_end; 17762306a36Sopenharmony_ci u32 state_table_start; 17862306a36Sopenharmony_ci u32 soft_regs_start; 17962306a36Sopenharmony_ci u32 mc_reg_table_start; 18062306a36Sopenharmony_ci u32 arb_table_start; 18162306a36Sopenharmony_ci u32 cac_table_start; 18262306a36Sopenharmony_ci u32 dte_table_start; 18362306a36Sopenharmony_ci u32 spll_table_start; 18462306a36Sopenharmony_ci u32 papm_cfg_table_start; 18562306a36Sopenharmony_ci u32 fan_table_start; 18662306a36Sopenharmony_ci /* CAC stuff */ 18762306a36Sopenharmony_ci const struct si_cac_config_reg *cac_weights; 18862306a36Sopenharmony_ci const struct si_cac_config_reg *lcac_config; 18962306a36Sopenharmony_ci const struct si_cac_config_reg *cac_override; 19062306a36Sopenharmony_ci const struct si_powertune_data *powertune_data; 19162306a36Sopenharmony_ci struct si_dyn_powertune_data dyn_powertune_data; 19262306a36Sopenharmony_ci /* DTE stuff */ 19362306a36Sopenharmony_ci struct si_dte_data dte_data; 19462306a36Sopenharmony_ci /* scratch structs */ 19562306a36Sopenharmony_ci SMC_SIslands_MCRegisters smc_mc_reg_table; 19662306a36Sopenharmony_ci SISLANDS_SMC_STATETABLE smc_statetable; 19762306a36Sopenharmony_ci PP_SIslands_PAPMParameters papm_parm; 19862306a36Sopenharmony_ci /* SVI2 */ 19962306a36Sopenharmony_ci u8 svd_gpio_id; 20062306a36Sopenharmony_ci u8 svc_gpio_id; 20162306a36Sopenharmony_ci /* fan control */ 20262306a36Sopenharmony_ci bool fan_ctrl_is_in_default_mode; 20362306a36Sopenharmony_ci u32 t_min; 20462306a36Sopenharmony_ci u32 fan_ctrl_default_mode; 20562306a36Sopenharmony_ci bool fan_is_controlled_by_smc; 20662306a36Sopenharmony_ci}; 20762306a36Sopenharmony_ci 20862306a36Sopenharmony_ci#define SISLANDS_INITIAL_STATE_ARB_INDEX 0 20962306a36Sopenharmony_ci#define SISLANDS_ACPI_STATE_ARB_INDEX 1 21062306a36Sopenharmony_ci#define SISLANDS_ULV_STATE_ARB_INDEX 2 21162306a36Sopenharmony_ci#define SISLANDS_DRIVER_STATE_ARB_INDEX 3 21262306a36Sopenharmony_ci 21362306a36Sopenharmony_ci#define SISLANDS_DPM2_MAX_PULSE_SKIP 256 21462306a36Sopenharmony_ci 21562306a36Sopenharmony_ci#define SISLANDS_DPM2_NEAR_TDP_DEC 10 21662306a36Sopenharmony_ci#define SISLANDS_DPM2_ABOVE_SAFE_INC 5 21762306a36Sopenharmony_ci#define SISLANDS_DPM2_BELOW_SAFE_INC 20 21862306a36Sopenharmony_ci 21962306a36Sopenharmony_ci#define SISLANDS_DPM2_TDP_SAFE_LIMIT_PERCENT 80 22062306a36Sopenharmony_ci 22162306a36Sopenharmony_ci#define SISLANDS_DPM2_MAXPS_PERCENT_H 99 22262306a36Sopenharmony_ci#define SISLANDS_DPM2_MAXPS_PERCENT_M 99 22362306a36Sopenharmony_ci 22462306a36Sopenharmony_ci#define SISLANDS_DPM2_SQ_RAMP_MAX_POWER 0x3FFF 22562306a36Sopenharmony_ci#define SISLANDS_DPM2_SQ_RAMP_MIN_POWER 0x12 22662306a36Sopenharmony_ci#define SISLANDS_DPM2_SQ_RAMP_MAX_POWER_DELTA 0x15 22762306a36Sopenharmony_ci#define SISLANDS_DPM2_SQ_RAMP_STI_SIZE 0x1E 22862306a36Sopenharmony_ci#define SISLANDS_DPM2_SQ_RAMP_LTI_RATIO 0xF 22962306a36Sopenharmony_ci 23062306a36Sopenharmony_ci#define SISLANDS_DPM2_PWREFFICIENCYRATIO_MARGIN 10 23162306a36Sopenharmony_ci 23262306a36Sopenharmony_ci#define SISLANDS_VRC_DFLT 0xC000B3 23362306a36Sopenharmony_ci#define SISLANDS_ULVVOLTAGECHANGEDELAY_DFLT 1687 23462306a36Sopenharmony_ci#define SISLANDS_CGULVPARAMETER_DFLT 0x00040035 23562306a36Sopenharmony_ci#define SISLANDS_CGULVCONTROL_DFLT 0x1f007550 23662306a36Sopenharmony_ci 23762306a36Sopenharmony_ciu8 si_get_ddr3_mclk_frequency_ratio(u32 memory_clock); 23862306a36Sopenharmony_ciu8 si_get_mclk_frequency_ratio(u32 memory_clock, bool strobe_mode); 23962306a36Sopenharmony_civoid si_trim_voltage_table_to_fit_state_table(struct radeon_device *rdev, 24062306a36Sopenharmony_ci u32 max_voltage_steps, 24162306a36Sopenharmony_ci struct atom_voltage_table *voltage_table); 24262306a36Sopenharmony_ci 24362306a36Sopenharmony_ci#endif 244