18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright 2012 Advanced Micro Devices, Inc. 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 58c2ecf20Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 68c2ecf20Sopenharmony_ci * to deal in the Software without restriction, including without limitation 78c2ecf20Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 88c2ecf20Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 98c2ecf20Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 108c2ecf20Sopenharmony_ci * 118c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice shall be included in 128c2ecf20Sopenharmony_ci * all copies or substantial portions of the Software. 138c2ecf20Sopenharmony_ci * 148c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 158c2ecf20Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 168c2ecf20Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 178c2ecf20Sopenharmony_ci * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 188c2ecf20Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 198c2ecf20Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 208c2ecf20Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE. 218c2ecf20Sopenharmony_ci * 228c2ecf20Sopenharmony_ci */ 238c2ecf20Sopenharmony_ci#ifndef __SI_DPM_H__ 248c2ecf20Sopenharmony_ci#define __SI_DPM_H__ 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci#include "ni_dpm.h" 278c2ecf20Sopenharmony_ci#include "sislands_smc.h" 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_cienum si_cac_config_reg_type 308c2ecf20Sopenharmony_ci{ 318c2ecf20Sopenharmony_ci SISLANDS_CACCONFIG_MMR = 0, 328c2ecf20Sopenharmony_ci SISLANDS_CACCONFIG_CGIND, 338c2ecf20Sopenharmony_ci SISLANDS_CACCONFIG_MAX 348c2ecf20Sopenharmony_ci}; 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_cistruct si_cac_config_reg 378c2ecf20Sopenharmony_ci{ 388c2ecf20Sopenharmony_ci u32 offset; 398c2ecf20Sopenharmony_ci u32 mask; 408c2ecf20Sopenharmony_ci u32 shift; 418c2ecf20Sopenharmony_ci u32 value; 428c2ecf20Sopenharmony_ci enum si_cac_config_reg_type type; 438c2ecf20Sopenharmony_ci}; 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_cistruct si_powertune_data 468c2ecf20Sopenharmony_ci{ 478c2ecf20Sopenharmony_ci u32 cac_window; 488c2ecf20Sopenharmony_ci u32 l2_lta_window_size_default; 498c2ecf20Sopenharmony_ci u8 lts_truncate_default; 508c2ecf20Sopenharmony_ci u8 shift_n_default; 518c2ecf20Sopenharmony_ci u8 operating_temp; 528c2ecf20Sopenharmony_ci struct ni_leakage_coeffients leakage_coefficients; 538c2ecf20Sopenharmony_ci u32 fixed_kt; 548c2ecf20Sopenharmony_ci u32 lkge_lut_v0_percent; 558c2ecf20Sopenharmony_ci u8 dc_cac[NISLANDS_DCCAC_MAX_LEVELS]; 568c2ecf20Sopenharmony_ci bool enable_powertune_by_default; 578c2ecf20Sopenharmony_ci}; 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_cistruct si_dyn_powertune_data 608c2ecf20Sopenharmony_ci{ 618c2ecf20Sopenharmony_ci u32 cac_leakage; 628c2ecf20Sopenharmony_ci s32 leakage_minimum_temperature; 638c2ecf20Sopenharmony_ci u32 wintime; 648c2ecf20Sopenharmony_ci u32 l2_lta_window_size; 658c2ecf20Sopenharmony_ci u8 lts_truncate; 668c2ecf20Sopenharmony_ci u8 shift_n; 678c2ecf20Sopenharmony_ci u8 dc_pwr_value; 688c2ecf20Sopenharmony_ci bool disable_uvd_powertune; 698c2ecf20Sopenharmony_ci}; 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_cistruct si_dte_data 728c2ecf20Sopenharmony_ci{ 738c2ecf20Sopenharmony_ci u32 tau[SMC_SISLANDS_DTE_MAX_FILTER_STAGES]; 748c2ecf20Sopenharmony_ci u32 r[SMC_SISLANDS_DTE_MAX_FILTER_STAGES]; 758c2ecf20Sopenharmony_ci u32 k; 768c2ecf20Sopenharmony_ci u32 t0; 778c2ecf20Sopenharmony_ci u32 max_t; 788c2ecf20Sopenharmony_ci u8 window_size; 798c2ecf20Sopenharmony_ci u8 temp_select; 808c2ecf20Sopenharmony_ci u8 dte_mode; 818c2ecf20Sopenharmony_ci u8 tdep_count; 828c2ecf20Sopenharmony_ci u8 t_limits[SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE]; 838c2ecf20Sopenharmony_ci u32 tdep_tau[SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE]; 848c2ecf20Sopenharmony_ci u32 tdep_r[SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE]; 858c2ecf20Sopenharmony_ci u32 t_threshold; 868c2ecf20Sopenharmony_ci bool enable_dte_by_default; 878c2ecf20Sopenharmony_ci}; 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_cistruct si_clock_registers { 908c2ecf20Sopenharmony_ci u32 cg_spll_func_cntl; 918c2ecf20Sopenharmony_ci u32 cg_spll_func_cntl_2; 928c2ecf20Sopenharmony_ci u32 cg_spll_func_cntl_3; 938c2ecf20Sopenharmony_ci u32 cg_spll_func_cntl_4; 948c2ecf20Sopenharmony_ci u32 cg_spll_spread_spectrum; 958c2ecf20Sopenharmony_ci u32 cg_spll_spread_spectrum_2; 968c2ecf20Sopenharmony_ci u32 dll_cntl; 978c2ecf20Sopenharmony_ci u32 mclk_pwrmgt_cntl; 988c2ecf20Sopenharmony_ci u32 mpll_ad_func_cntl; 998c2ecf20Sopenharmony_ci u32 mpll_dq_func_cntl; 1008c2ecf20Sopenharmony_ci u32 mpll_func_cntl; 1018c2ecf20Sopenharmony_ci u32 mpll_func_cntl_1; 1028c2ecf20Sopenharmony_ci u32 mpll_func_cntl_2; 1038c2ecf20Sopenharmony_ci u32 mpll_ss1; 1048c2ecf20Sopenharmony_ci u32 mpll_ss2; 1058c2ecf20Sopenharmony_ci}; 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_cistruct si_mc_reg_entry { 1088c2ecf20Sopenharmony_ci u32 mclk_max; 1098c2ecf20Sopenharmony_ci u32 mc_data[SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE]; 1108c2ecf20Sopenharmony_ci}; 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_cistruct si_mc_reg_table { 1138c2ecf20Sopenharmony_ci u8 last; 1148c2ecf20Sopenharmony_ci u8 num_entries; 1158c2ecf20Sopenharmony_ci u16 valid_flag; 1168c2ecf20Sopenharmony_ci struct si_mc_reg_entry mc_reg_table_entry[MAX_AC_TIMING_ENTRIES]; 1178c2ecf20Sopenharmony_ci SMC_NIslands_MCRegisterAddress mc_reg_address[SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE]; 1188c2ecf20Sopenharmony_ci}; 1198c2ecf20Sopenharmony_ci 1208c2ecf20Sopenharmony_ci#define SISLANDS_MCREGISTERTABLE_INITIAL_SLOT 0 1218c2ecf20Sopenharmony_ci#define SISLANDS_MCREGISTERTABLE_ACPI_SLOT 1 1228c2ecf20Sopenharmony_ci#define SISLANDS_MCREGISTERTABLE_ULV_SLOT 2 1238c2ecf20Sopenharmony_ci#define SISLANDS_MCREGISTERTABLE_FIRST_DRIVERSTATE_SLOT 3 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_cistruct si_leakage_voltage_entry 1268c2ecf20Sopenharmony_ci{ 1278c2ecf20Sopenharmony_ci u16 voltage; 1288c2ecf20Sopenharmony_ci u16 leakage_index; 1298c2ecf20Sopenharmony_ci}; 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_ci#define SISLANDS_LEAKAGE_INDEX0 0xff01 1328c2ecf20Sopenharmony_ci#define SISLANDS_MAX_LEAKAGE_COUNT 4 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_cistruct si_leakage_voltage 1358c2ecf20Sopenharmony_ci{ 1368c2ecf20Sopenharmony_ci u16 count; 1378c2ecf20Sopenharmony_ci struct si_leakage_voltage_entry entries[SISLANDS_MAX_LEAKAGE_COUNT]; 1388c2ecf20Sopenharmony_ci}; 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_ci#define SISLANDS_MAX_HARDWARE_POWERLEVELS 5 1418c2ecf20Sopenharmony_ci 1428c2ecf20Sopenharmony_cistruct si_ulv_param { 1438c2ecf20Sopenharmony_ci bool supported; 1448c2ecf20Sopenharmony_ci u32 cg_ulv_control; 1458c2ecf20Sopenharmony_ci u32 cg_ulv_parameter; 1468c2ecf20Sopenharmony_ci u32 volt_change_delay; 1478c2ecf20Sopenharmony_ci struct rv7xx_pl pl; 1488c2ecf20Sopenharmony_ci bool one_pcie_lane_in_ulv; 1498c2ecf20Sopenharmony_ci}; 1508c2ecf20Sopenharmony_ci 1518c2ecf20Sopenharmony_cistruct si_power_info { 1528c2ecf20Sopenharmony_ci /* must be first! */ 1538c2ecf20Sopenharmony_ci struct ni_power_info ni; 1548c2ecf20Sopenharmony_ci struct si_clock_registers clock_registers; 1558c2ecf20Sopenharmony_ci struct si_mc_reg_table mc_reg_table; 1568c2ecf20Sopenharmony_ci struct atom_voltage_table mvdd_voltage_table; 1578c2ecf20Sopenharmony_ci struct atom_voltage_table vddc_phase_shed_table; 1588c2ecf20Sopenharmony_ci struct si_leakage_voltage leakage_voltage; 1598c2ecf20Sopenharmony_ci u16 mvdd_bootup_value; 1608c2ecf20Sopenharmony_ci struct si_ulv_param ulv; 1618c2ecf20Sopenharmony_ci u32 max_cu; 1628c2ecf20Sopenharmony_ci /* pcie gen */ 1638c2ecf20Sopenharmony_ci enum radeon_pcie_gen force_pcie_gen; 1648c2ecf20Sopenharmony_ci enum radeon_pcie_gen boot_pcie_gen; 1658c2ecf20Sopenharmony_ci enum radeon_pcie_gen acpi_pcie_gen; 1668c2ecf20Sopenharmony_ci u32 sys_pcie_mask; 1678c2ecf20Sopenharmony_ci /* flags */ 1688c2ecf20Sopenharmony_ci bool enable_dte; 1698c2ecf20Sopenharmony_ci bool enable_ppm; 1708c2ecf20Sopenharmony_ci bool vddc_phase_shed_control; 1718c2ecf20Sopenharmony_ci bool pspp_notify_required; 1728c2ecf20Sopenharmony_ci bool sclk_deep_sleep_above_low; 1738c2ecf20Sopenharmony_ci bool voltage_control_svi2; 1748c2ecf20Sopenharmony_ci bool vddci_control_svi2; 1758c2ecf20Sopenharmony_ci /* smc offsets */ 1768c2ecf20Sopenharmony_ci u32 sram_end; 1778c2ecf20Sopenharmony_ci u32 state_table_start; 1788c2ecf20Sopenharmony_ci u32 soft_regs_start; 1798c2ecf20Sopenharmony_ci u32 mc_reg_table_start; 1808c2ecf20Sopenharmony_ci u32 arb_table_start; 1818c2ecf20Sopenharmony_ci u32 cac_table_start; 1828c2ecf20Sopenharmony_ci u32 dte_table_start; 1838c2ecf20Sopenharmony_ci u32 spll_table_start; 1848c2ecf20Sopenharmony_ci u32 papm_cfg_table_start; 1858c2ecf20Sopenharmony_ci u32 fan_table_start; 1868c2ecf20Sopenharmony_ci /* CAC stuff */ 1878c2ecf20Sopenharmony_ci const struct si_cac_config_reg *cac_weights; 1888c2ecf20Sopenharmony_ci const struct si_cac_config_reg *lcac_config; 1898c2ecf20Sopenharmony_ci const struct si_cac_config_reg *cac_override; 1908c2ecf20Sopenharmony_ci const struct si_powertune_data *powertune_data; 1918c2ecf20Sopenharmony_ci struct si_dyn_powertune_data dyn_powertune_data; 1928c2ecf20Sopenharmony_ci /* DTE stuff */ 1938c2ecf20Sopenharmony_ci struct si_dte_data dte_data; 1948c2ecf20Sopenharmony_ci /* scratch structs */ 1958c2ecf20Sopenharmony_ci SMC_SIslands_MCRegisters smc_mc_reg_table; 1968c2ecf20Sopenharmony_ci SISLANDS_SMC_STATETABLE smc_statetable; 1978c2ecf20Sopenharmony_ci PP_SIslands_PAPMParameters papm_parm; 1988c2ecf20Sopenharmony_ci /* SVI2 */ 1998c2ecf20Sopenharmony_ci u8 svd_gpio_id; 2008c2ecf20Sopenharmony_ci u8 svc_gpio_id; 2018c2ecf20Sopenharmony_ci /* fan control */ 2028c2ecf20Sopenharmony_ci bool fan_ctrl_is_in_default_mode; 2038c2ecf20Sopenharmony_ci u32 t_min; 2048c2ecf20Sopenharmony_ci u32 fan_ctrl_default_mode; 2058c2ecf20Sopenharmony_ci bool fan_is_controlled_by_smc; 2068c2ecf20Sopenharmony_ci}; 2078c2ecf20Sopenharmony_ci 2088c2ecf20Sopenharmony_ci#define SISLANDS_INITIAL_STATE_ARB_INDEX 0 2098c2ecf20Sopenharmony_ci#define SISLANDS_ACPI_STATE_ARB_INDEX 1 2108c2ecf20Sopenharmony_ci#define SISLANDS_ULV_STATE_ARB_INDEX 2 2118c2ecf20Sopenharmony_ci#define SISLANDS_DRIVER_STATE_ARB_INDEX 3 2128c2ecf20Sopenharmony_ci 2138c2ecf20Sopenharmony_ci#define SISLANDS_DPM2_MAX_PULSE_SKIP 256 2148c2ecf20Sopenharmony_ci 2158c2ecf20Sopenharmony_ci#define SISLANDS_DPM2_NEAR_TDP_DEC 10 2168c2ecf20Sopenharmony_ci#define SISLANDS_DPM2_ABOVE_SAFE_INC 5 2178c2ecf20Sopenharmony_ci#define SISLANDS_DPM2_BELOW_SAFE_INC 20 2188c2ecf20Sopenharmony_ci 2198c2ecf20Sopenharmony_ci#define SISLANDS_DPM2_TDP_SAFE_LIMIT_PERCENT 80 2208c2ecf20Sopenharmony_ci 2218c2ecf20Sopenharmony_ci#define SISLANDS_DPM2_MAXPS_PERCENT_H 99 2228c2ecf20Sopenharmony_ci#define SISLANDS_DPM2_MAXPS_PERCENT_M 99 2238c2ecf20Sopenharmony_ci 2248c2ecf20Sopenharmony_ci#define SISLANDS_DPM2_SQ_RAMP_MAX_POWER 0x3FFF 2258c2ecf20Sopenharmony_ci#define SISLANDS_DPM2_SQ_RAMP_MIN_POWER 0x12 2268c2ecf20Sopenharmony_ci#define SISLANDS_DPM2_SQ_RAMP_MAX_POWER_DELTA 0x15 2278c2ecf20Sopenharmony_ci#define SISLANDS_DPM2_SQ_RAMP_STI_SIZE 0x1E 2288c2ecf20Sopenharmony_ci#define SISLANDS_DPM2_SQ_RAMP_LTI_RATIO 0xF 2298c2ecf20Sopenharmony_ci 2308c2ecf20Sopenharmony_ci#define SISLANDS_DPM2_PWREFFICIENCYRATIO_MARGIN 10 2318c2ecf20Sopenharmony_ci 2328c2ecf20Sopenharmony_ci#define SISLANDS_VRC_DFLT 0xC000B3 2338c2ecf20Sopenharmony_ci#define SISLANDS_ULVVOLTAGECHANGEDELAY_DFLT 1687 2348c2ecf20Sopenharmony_ci#define SISLANDS_CGULVPARAMETER_DFLT 0x00040035 2358c2ecf20Sopenharmony_ci#define SISLANDS_CGULVCONTROL_DFLT 0x1f007550 2368c2ecf20Sopenharmony_ci 2378c2ecf20Sopenharmony_ci 2388c2ecf20Sopenharmony_ci#endif 239