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 __SUMO_DPM_H__ 248c2ecf20Sopenharmony_ci#define __SUMO_DPM_H__ 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci#include "atom.h" 278c2ecf20Sopenharmony_ci#include "radeon.h" 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci#define SUMO_MAX_HARDWARE_POWERLEVELS 5 308c2ecf20Sopenharmony_ci#define SUMO_PM_NUMBER_OF_TC 15 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_cistruct sumo_pl { 338c2ecf20Sopenharmony_ci u32 sclk; 348c2ecf20Sopenharmony_ci u32 vddc_index; 358c2ecf20Sopenharmony_ci u32 ds_divider_index; 368c2ecf20Sopenharmony_ci u32 ss_divider_index; 378c2ecf20Sopenharmony_ci u32 allow_gnb_slow; 388c2ecf20Sopenharmony_ci u32 sclk_dpm_tdp_limit; 398c2ecf20Sopenharmony_ci}; 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci/* used for the flags field */ 428c2ecf20Sopenharmony_ci#define SUMO_POWERSTATE_FLAGS_FORCE_NBPS1_STATE (1 << 0) 438c2ecf20Sopenharmony_ci#define SUMO_POWERSTATE_FLAGS_BOOST_STATE (1 << 1) 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_cistruct sumo_ps { 468c2ecf20Sopenharmony_ci struct sumo_pl levels[SUMO_MAX_HARDWARE_POWERLEVELS]; 478c2ecf20Sopenharmony_ci u32 num_levels; 488c2ecf20Sopenharmony_ci /* flags */ 498c2ecf20Sopenharmony_ci u32 flags; 508c2ecf20Sopenharmony_ci}; 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci#define NUMBER_OF_M3ARB_PARAM_SETS 10 538c2ecf20Sopenharmony_ci#define SUMO_MAX_NUMBER_VOLTAGES 4 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_cistruct sumo_disp_clock_voltage_mapping_table { 568c2ecf20Sopenharmony_ci u32 num_max_voltage_levels; 578c2ecf20Sopenharmony_ci u32 display_clock_frequency[SUMO_MAX_NUMBER_VOLTAGES]; 588c2ecf20Sopenharmony_ci}; 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_cistruct sumo_vid_mapping_entry { 618c2ecf20Sopenharmony_ci u16 vid_2bit; 628c2ecf20Sopenharmony_ci u16 vid_7bit; 638c2ecf20Sopenharmony_ci}; 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_cistruct sumo_vid_mapping_table { 668c2ecf20Sopenharmony_ci u32 num_entries; 678c2ecf20Sopenharmony_ci struct sumo_vid_mapping_entry entries[SUMO_MAX_NUMBER_VOLTAGES]; 688c2ecf20Sopenharmony_ci}; 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_cistruct sumo_sclk_voltage_mapping_entry { 718c2ecf20Sopenharmony_ci u32 sclk_frequency; 728c2ecf20Sopenharmony_ci u16 vid_2bit; 738c2ecf20Sopenharmony_ci u16 rsv; 748c2ecf20Sopenharmony_ci}; 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_cistruct sumo_sclk_voltage_mapping_table { 778c2ecf20Sopenharmony_ci u32 num_max_dpm_entries; 788c2ecf20Sopenharmony_ci struct sumo_sclk_voltage_mapping_entry entries[SUMO_MAX_HARDWARE_POWERLEVELS]; 798c2ecf20Sopenharmony_ci}; 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_cistruct sumo_sys_info { 828c2ecf20Sopenharmony_ci u32 bootup_sclk; 838c2ecf20Sopenharmony_ci u32 min_sclk; 848c2ecf20Sopenharmony_ci u32 bootup_uma_clk; 858c2ecf20Sopenharmony_ci u16 bootup_nb_voltage_index; 868c2ecf20Sopenharmony_ci u8 htc_tmp_lmt; 878c2ecf20Sopenharmony_ci u8 htc_hyst_lmt; 888c2ecf20Sopenharmony_ci struct sumo_sclk_voltage_mapping_table sclk_voltage_mapping_table; 898c2ecf20Sopenharmony_ci struct sumo_disp_clock_voltage_mapping_table disp_clk_voltage_mapping_table; 908c2ecf20Sopenharmony_ci struct sumo_vid_mapping_table vid_mapping_table; 918c2ecf20Sopenharmony_ci u32 csr_m3_arb_cntl_default[NUMBER_OF_M3ARB_PARAM_SETS]; 928c2ecf20Sopenharmony_ci u32 csr_m3_arb_cntl_uvd[NUMBER_OF_M3ARB_PARAM_SETS]; 938c2ecf20Sopenharmony_ci u32 csr_m3_arb_cntl_fs3d[NUMBER_OF_M3ARB_PARAM_SETS]; 948c2ecf20Sopenharmony_ci u32 sclk_dpm_boost_margin; 958c2ecf20Sopenharmony_ci u32 sclk_dpm_throttle_margin; 968c2ecf20Sopenharmony_ci u32 sclk_dpm_tdp_limit_pg; 978c2ecf20Sopenharmony_ci u32 gnb_tdp_limit; 988c2ecf20Sopenharmony_ci u32 sclk_dpm_tdp_limit_boost; 998c2ecf20Sopenharmony_ci u32 boost_sclk; 1008c2ecf20Sopenharmony_ci u32 boost_vid_2bit; 1018c2ecf20Sopenharmony_ci bool enable_boost; 1028c2ecf20Sopenharmony_ci}; 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_cistruct sumo_power_info { 1058c2ecf20Sopenharmony_ci u32 asi; 1068c2ecf20Sopenharmony_ci u32 pasi; 1078c2ecf20Sopenharmony_ci u32 bsp; 1088c2ecf20Sopenharmony_ci u32 bsu; 1098c2ecf20Sopenharmony_ci u32 pbsp; 1108c2ecf20Sopenharmony_ci u32 pbsu; 1118c2ecf20Sopenharmony_ci u32 dsp; 1128c2ecf20Sopenharmony_ci u32 psp; 1138c2ecf20Sopenharmony_ci u32 thermal_auto_throttling; 1148c2ecf20Sopenharmony_ci u32 uvd_m3_arbiter; 1158c2ecf20Sopenharmony_ci u32 fw_version; 1168c2ecf20Sopenharmony_ci struct sumo_sys_info sys_info; 1178c2ecf20Sopenharmony_ci struct sumo_pl acpi_pl; 1188c2ecf20Sopenharmony_ci struct sumo_pl boot_pl; 1198c2ecf20Sopenharmony_ci struct sumo_pl boost_pl; 1208c2ecf20Sopenharmony_ci bool disable_gfx_power_gating_in_uvd; 1218c2ecf20Sopenharmony_ci bool driver_nbps_policy_disable; 1228c2ecf20Sopenharmony_ci bool enable_alt_vddnb; 1238c2ecf20Sopenharmony_ci bool enable_dynamic_m3_arbiter; 1248c2ecf20Sopenharmony_ci bool enable_gfx_clock_gating; 1258c2ecf20Sopenharmony_ci bool enable_gfx_power_gating; 1268c2ecf20Sopenharmony_ci bool enable_mg_clock_gating; 1278c2ecf20Sopenharmony_ci bool enable_sclk_ds; 1288c2ecf20Sopenharmony_ci bool enable_auto_thermal_throttling; 1298c2ecf20Sopenharmony_ci bool enable_dynamic_patch_ps; 1308c2ecf20Sopenharmony_ci bool enable_dpm; 1318c2ecf20Sopenharmony_ci bool enable_boost; 1328c2ecf20Sopenharmony_ci struct radeon_ps current_rps; 1338c2ecf20Sopenharmony_ci struct sumo_ps current_ps; 1348c2ecf20Sopenharmony_ci struct radeon_ps requested_rps; 1358c2ecf20Sopenharmony_ci struct sumo_ps requested_ps; 1368c2ecf20Sopenharmony_ci}; 1378c2ecf20Sopenharmony_ci 1388c2ecf20Sopenharmony_ci#define SUMO_UTC_DFLT_00 0x48 1398c2ecf20Sopenharmony_ci#define SUMO_UTC_DFLT_01 0x44 1408c2ecf20Sopenharmony_ci#define SUMO_UTC_DFLT_02 0x44 1418c2ecf20Sopenharmony_ci#define SUMO_UTC_DFLT_03 0x44 1428c2ecf20Sopenharmony_ci#define SUMO_UTC_DFLT_04 0x44 1438c2ecf20Sopenharmony_ci#define SUMO_UTC_DFLT_05 0x44 1448c2ecf20Sopenharmony_ci#define SUMO_UTC_DFLT_06 0x44 1458c2ecf20Sopenharmony_ci#define SUMO_UTC_DFLT_07 0x44 1468c2ecf20Sopenharmony_ci#define SUMO_UTC_DFLT_08 0x44 1478c2ecf20Sopenharmony_ci#define SUMO_UTC_DFLT_09 0x44 1488c2ecf20Sopenharmony_ci#define SUMO_UTC_DFLT_10 0x44 1498c2ecf20Sopenharmony_ci#define SUMO_UTC_DFLT_11 0x44 1508c2ecf20Sopenharmony_ci#define SUMO_UTC_DFLT_12 0x44 1518c2ecf20Sopenharmony_ci#define SUMO_UTC_DFLT_13 0x44 1528c2ecf20Sopenharmony_ci#define SUMO_UTC_DFLT_14 0x44 1538c2ecf20Sopenharmony_ci 1548c2ecf20Sopenharmony_ci#define SUMO_DTC_DFLT_00 0x48 1558c2ecf20Sopenharmony_ci#define SUMO_DTC_DFLT_01 0x44 1568c2ecf20Sopenharmony_ci#define SUMO_DTC_DFLT_02 0x44 1578c2ecf20Sopenharmony_ci#define SUMO_DTC_DFLT_03 0x44 1588c2ecf20Sopenharmony_ci#define SUMO_DTC_DFLT_04 0x44 1598c2ecf20Sopenharmony_ci#define SUMO_DTC_DFLT_05 0x44 1608c2ecf20Sopenharmony_ci#define SUMO_DTC_DFLT_06 0x44 1618c2ecf20Sopenharmony_ci#define SUMO_DTC_DFLT_07 0x44 1628c2ecf20Sopenharmony_ci#define SUMO_DTC_DFLT_08 0x44 1638c2ecf20Sopenharmony_ci#define SUMO_DTC_DFLT_09 0x44 1648c2ecf20Sopenharmony_ci#define SUMO_DTC_DFLT_10 0x44 1658c2ecf20Sopenharmony_ci#define SUMO_DTC_DFLT_11 0x44 1668c2ecf20Sopenharmony_ci#define SUMO_DTC_DFLT_12 0x44 1678c2ecf20Sopenharmony_ci#define SUMO_DTC_DFLT_13 0x44 1688c2ecf20Sopenharmony_ci#define SUMO_DTC_DFLT_14 0x44 1698c2ecf20Sopenharmony_ci 1708c2ecf20Sopenharmony_ci#define SUMO_AH_DFLT 5 1718c2ecf20Sopenharmony_ci 1728c2ecf20Sopenharmony_ci#define SUMO_R_DFLT0 70 1738c2ecf20Sopenharmony_ci#define SUMO_R_DFLT1 70 1748c2ecf20Sopenharmony_ci#define SUMO_R_DFLT2 70 1758c2ecf20Sopenharmony_ci#define SUMO_R_DFLT3 70 1768c2ecf20Sopenharmony_ci#define SUMO_R_DFLT4 100 1778c2ecf20Sopenharmony_ci 1788c2ecf20Sopenharmony_ci#define SUMO_L_DFLT0 0 1798c2ecf20Sopenharmony_ci#define SUMO_L_DFLT1 20 1808c2ecf20Sopenharmony_ci#define SUMO_L_DFLT2 20 1818c2ecf20Sopenharmony_ci#define SUMO_L_DFLT3 20 1828c2ecf20Sopenharmony_ci#define SUMO_L_DFLT4 20 1838c2ecf20Sopenharmony_ci#define SUMO_VRC_DFLT 0x30033 1848c2ecf20Sopenharmony_ci#define SUMO_MGCGTTLOCAL0_DFLT 0 1858c2ecf20Sopenharmony_ci#define SUMO_MGCGTTLOCAL1_DFLT 0 1868c2ecf20Sopenharmony_ci#define SUMO_GICST_DFLT 19 1878c2ecf20Sopenharmony_ci#define SUMO_SST_DFLT 8 1888c2ecf20Sopenharmony_ci#define SUMO_VOLTAGEDROPT_DFLT 1 1898c2ecf20Sopenharmony_ci#define SUMO_GFXPOWERGATINGT_DFLT 100 1908c2ecf20Sopenharmony_ci 1918c2ecf20Sopenharmony_ci/* sumo_dpm.c */ 1928c2ecf20Sopenharmony_civoid sumo_gfx_clockgating_initialize(struct radeon_device *rdev); 1938c2ecf20Sopenharmony_civoid sumo_program_vc(struct radeon_device *rdev, u32 vrc); 1948c2ecf20Sopenharmony_civoid sumo_clear_vc(struct radeon_device *rdev); 1958c2ecf20Sopenharmony_civoid sumo_program_sstp(struct radeon_device *rdev); 1968c2ecf20Sopenharmony_civoid sumo_take_smu_control(struct radeon_device *rdev, bool enable); 1978c2ecf20Sopenharmony_civoid sumo_construct_sclk_voltage_mapping_table(struct radeon_device *rdev, 1988c2ecf20Sopenharmony_ci struct sumo_sclk_voltage_mapping_table *sclk_voltage_mapping_table, 1998c2ecf20Sopenharmony_ci ATOM_AVAILABLE_SCLK_LIST *table); 2008c2ecf20Sopenharmony_civoid sumo_construct_vid_mapping_table(struct radeon_device *rdev, 2018c2ecf20Sopenharmony_ci struct sumo_vid_mapping_table *vid_mapping_table, 2028c2ecf20Sopenharmony_ci ATOM_AVAILABLE_SCLK_LIST *table); 2038c2ecf20Sopenharmony_ciu32 sumo_convert_vid2_to_vid7(struct radeon_device *rdev, 2048c2ecf20Sopenharmony_ci struct sumo_vid_mapping_table *vid_mapping_table, 2058c2ecf20Sopenharmony_ci u32 vid_2bit); 2068c2ecf20Sopenharmony_ciu32 sumo_get_sleep_divider_from_id(u32 id); 2078c2ecf20Sopenharmony_ciu32 sumo_get_sleep_divider_id_from_clock(struct radeon_device *rdev, 2088c2ecf20Sopenharmony_ci u32 sclk, 2098c2ecf20Sopenharmony_ci u32 min_sclk_in_sr); 2108c2ecf20Sopenharmony_ci 2118c2ecf20Sopenharmony_ci/* sumo_smc.c */ 2128c2ecf20Sopenharmony_civoid sumo_initialize_m3_arb(struct radeon_device *rdev); 2138c2ecf20Sopenharmony_civoid sumo_smu_pg_init(struct radeon_device *rdev); 2148c2ecf20Sopenharmony_civoid sumo_set_tdp_limit(struct radeon_device *rdev, u32 index, u32 tdp_limit); 2158c2ecf20Sopenharmony_civoid sumo_smu_notify_alt_vddnb_change(struct radeon_device *rdev, 2168c2ecf20Sopenharmony_ci bool powersaving, bool force_nbps1); 2178c2ecf20Sopenharmony_civoid sumo_boost_state_enable(struct radeon_device *rdev, bool enable); 2188c2ecf20Sopenharmony_civoid sumo_enable_boost_timer(struct radeon_device *rdev); 2198c2ecf20Sopenharmony_ciu32 sumo_get_running_fw_version(struct radeon_device *rdev); 2208c2ecf20Sopenharmony_ci 2218c2ecf20Sopenharmony_ci#endif 222