18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright 2015 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 _HWMGR_H_ 248c2ecf20Sopenharmony_ci#define _HWMGR_H_ 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci#include <linux/seq_file.h> 278c2ecf20Sopenharmony_ci#include "amd_powerplay.h" 288c2ecf20Sopenharmony_ci#include "hardwaremanager.h" 298c2ecf20Sopenharmony_ci#include "hwmgr_ppt.h" 308c2ecf20Sopenharmony_ci#include "ppatomctrl.h" 318c2ecf20Sopenharmony_ci#include "power_state.h" 328c2ecf20Sopenharmony_ci#include "smu_helper.h" 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_cistruct pp_hwmgr; 358c2ecf20Sopenharmony_cistruct phm_fan_speed_info; 368c2ecf20Sopenharmony_cistruct pp_atomctrl_voltage_table; 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci#define VOLTAGE_SCALE 4 398c2ecf20Sopenharmony_ci#define VOLTAGE_VID_OFFSET_SCALE1 625 408c2ecf20Sopenharmony_ci#define VOLTAGE_VID_OFFSET_SCALE2 100 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_cienum DISPLAY_GAP { 438c2ecf20Sopenharmony_ci DISPLAY_GAP_VBLANK_OR_WM = 0, /* Wait for vblank or MCHG watermark. */ 448c2ecf20Sopenharmony_ci DISPLAY_GAP_VBLANK = 1, /* Wait for vblank. */ 458c2ecf20Sopenharmony_ci DISPLAY_GAP_WATERMARK = 2, /* Wait for MCHG watermark. (Note that HW may deassert WM in VBI depending on DC_STUTTER_CNTL.) */ 468c2ecf20Sopenharmony_ci DISPLAY_GAP_IGNORE = 3 /* Do not wait. */ 478c2ecf20Sopenharmony_ci}; 488c2ecf20Sopenharmony_citypedef enum DISPLAY_GAP DISPLAY_GAP; 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_cienum BACO_STATE { 518c2ecf20Sopenharmony_ci BACO_STATE_OUT = 0, 528c2ecf20Sopenharmony_ci BACO_STATE_IN, 538c2ecf20Sopenharmony_ci}; 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_cistruct vi_dpm_level { 568c2ecf20Sopenharmony_ci bool enabled; 578c2ecf20Sopenharmony_ci uint32_t value; 588c2ecf20Sopenharmony_ci uint32_t param1; 598c2ecf20Sopenharmony_ci}; 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_cistruct vi_dpm_table { 628c2ecf20Sopenharmony_ci uint32_t count; 638c2ecf20Sopenharmony_ci struct vi_dpm_level dpm_level[1]; 648c2ecf20Sopenharmony_ci}; 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci#define PCIE_PERF_REQ_REMOVE_REGISTRY 0 678c2ecf20Sopenharmony_ci#define PCIE_PERF_REQ_FORCE_LOWPOWER 1 688c2ecf20Sopenharmony_ci#define PCIE_PERF_REQ_GEN1 2 698c2ecf20Sopenharmony_ci#define PCIE_PERF_REQ_GEN2 3 708c2ecf20Sopenharmony_ci#define PCIE_PERF_REQ_GEN3 4 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_cienum PHM_BackEnd_Magic { 738c2ecf20Sopenharmony_ci PHM_Dummy_Magic = 0xAA5555AA, 748c2ecf20Sopenharmony_ci PHM_RV770_Magic = 0xDCBAABCD, 758c2ecf20Sopenharmony_ci PHM_Kong_Magic = 0x239478DF, 768c2ecf20Sopenharmony_ci PHM_NIslands_Magic = 0x736C494E, 778c2ecf20Sopenharmony_ci PHM_Sumo_Magic = 0x8339FA11, 788c2ecf20Sopenharmony_ci PHM_SIslands_Magic = 0x369431AC, 798c2ecf20Sopenharmony_ci PHM_Trinity_Magic = 0x96751873, 808c2ecf20Sopenharmony_ci PHM_CIslands_Magic = 0x38AC78B0, 818c2ecf20Sopenharmony_ci PHM_Kv_Magic = 0xDCBBABC0, 828c2ecf20Sopenharmony_ci PHM_VIslands_Magic = 0x20130307, 838c2ecf20Sopenharmony_ci PHM_Cz_Magic = 0x67DCBA25, 848c2ecf20Sopenharmony_ci PHM_Rv_Magic = 0x20161121 858c2ecf20Sopenharmony_ci}; 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_cistruct phm_set_power_state_input { 888c2ecf20Sopenharmony_ci const struct pp_hw_power_state *pcurrent_state; 898c2ecf20Sopenharmony_ci const struct pp_hw_power_state *pnew_state; 908c2ecf20Sopenharmony_ci}; 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_cistruct phm_clock_array { 938c2ecf20Sopenharmony_ci uint32_t count; 948c2ecf20Sopenharmony_ci uint32_t values[1]; 958c2ecf20Sopenharmony_ci}; 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_cistruct phm_clock_voltage_dependency_record { 988c2ecf20Sopenharmony_ci uint32_t clk; 998c2ecf20Sopenharmony_ci uint32_t v; 1008c2ecf20Sopenharmony_ci}; 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_cistruct phm_vceclock_voltage_dependency_record { 1038c2ecf20Sopenharmony_ci uint32_t ecclk; 1048c2ecf20Sopenharmony_ci uint32_t evclk; 1058c2ecf20Sopenharmony_ci uint32_t v; 1068c2ecf20Sopenharmony_ci}; 1078c2ecf20Sopenharmony_ci 1088c2ecf20Sopenharmony_cistruct phm_uvdclock_voltage_dependency_record { 1098c2ecf20Sopenharmony_ci uint32_t vclk; 1108c2ecf20Sopenharmony_ci uint32_t dclk; 1118c2ecf20Sopenharmony_ci uint32_t v; 1128c2ecf20Sopenharmony_ci}; 1138c2ecf20Sopenharmony_ci 1148c2ecf20Sopenharmony_cistruct phm_samuclock_voltage_dependency_record { 1158c2ecf20Sopenharmony_ci uint32_t samclk; 1168c2ecf20Sopenharmony_ci uint32_t v; 1178c2ecf20Sopenharmony_ci}; 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_cistruct phm_acpclock_voltage_dependency_record { 1208c2ecf20Sopenharmony_ci uint32_t acpclk; 1218c2ecf20Sopenharmony_ci uint32_t v; 1228c2ecf20Sopenharmony_ci}; 1238c2ecf20Sopenharmony_ci 1248c2ecf20Sopenharmony_cistruct phm_clock_voltage_dependency_table { 1258c2ecf20Sopenharmony_ci uint32_t count; /* Number of entries. */ 1268c2ecf20Sopenharmony_ci struct phm_clock_voltage_dependency_record entries[1]; /* Dynamically allocate count entries. */ 1278c2ecf20Sopenharmony_ci}; 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_cistruct phm_phase_shedding_limits_record { 1308c2ecf20Sopenharmony_ci uint32_t Voltage; 1318c2ecf20Sopenharmony_ci uint32_t Sclk; 1328c2ecf20Sopenharmony_ci uint32_t Mclk; 1338c2ecf20Sopenharmony_ci}; 1348c2ecf20Sopenharmony_ci 1358c2ecf20Sopenharmony_cistruct phm_uvd_clock_voltage_dependency_record { 1368c2ecf20Sopenharmony_ci uint32_t vclk; 1378c2ecf20Sopenharmony_ci uint32_t dclk; 1388c2ecf20Sopenharmony_ci uint32_t v; 1398c2ecf20Sopenharmony_ci}; 1408c2ecf20Sopenharmony_ci 1418c2ecf20Sopenharmony_cistruct phm_uvd_clock_voltage_dependency_table { 1428c2ecf20Sopenharmony_ci uint8_t count; 1438c2ecf20Sopenharmony_ci struct phm_uvd_clock_voltage_dependency_record entries[1]; 1448c2ecf20Sopenharmony_ci}; 1458c2ecf20Sopenharmony_ci 1468c2ecf20Sopenharmony_cistruct phm_acp_clock_voltage_dependency_record { 1478c2ecf20Sopenharmony_ci uint32_t acpclk; 1488c2ecf20Sopenharmony_ci uint32_t v; 1498c2ecf20Sopenharmony_ci}; 1508c2ecf20Sopenharmony_ci 1518c2ecf20Sopenharmony_cistruct phm_acp_clock_voltage_dependency_table { 1528c2ecf20Sopenharmony_ci uint32_t count; 1538c2ecf20Sopenharmony_ci struct phm_acp_clock_voltage_dependency_record entries[1]; 1548c2ecf20Sopenharmony_ci}; 1558c2ecf20Sopenharmony_ci 1568c2ecf20Sopenharmony_cistruct phm_vce_clock_voltage_dependency_record { 1578c2ecf20Sopenharmony_ci uint32_t ecclk; 1588c2ecf20Sopenharmony_ci uint32_t evclk; 1598c2ecf20Sopenharmony_ci uint32_t v; 1608c2ecf20Sopenharmony_ci}; 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_cistruct phm_phase_shedding_limits_table { 1638c2ecf20Sopenharmony_ci uint32_t count; 1648c2ecf20Sopenharmony_ci struct phm_phase_shedding_limits_record entries[1]; 1658c2ecf20Sopenharmony_ci}; 1668c2ecf20Sopenharmony_ci 1678c2ecf20Sopenharmony_cistruct phm_vceclock_voltage_dependency_table { 1688c2ecf20Sopenharmony_ci uint8_t count; /* Number of entries. */ 1698c2ecf20Sopenharmony_ci struct phm_vceclock_voltage_dependency_record entries[1]; /* Dynamically allocate count entries. */ 1708c2ecf20Sopenharmony_ci}; 1718c2ecf20Sopenharmony_ci 1728c2ecf20Sopenharmony_cistruct phm_uvdclock_voltage_dependency_table { 1738c2ecf20Sopenharmony_ci uint8_t count; /* Number of entries. */ 1748c2ecf20Sopenharmony_ci struct phm_uvdclock_voltage_dependency_record entries[1]; /* Dynamically allocate count entries. */ 1758c2ecf20Sopenharmony_ci}; 1768c2ecf20Sopenharmony_ci 1778c2ecf20Sopenharmony_cistruct phm_samuclock_voltage_dependency_table { 1788c2ecf20Sopenharmony_ci uint8_t count; /* Number of entries. */ 1798c2ecf20Sopenharmony_ci struct phm_samuclock_voltage_dependency_record entries[1]; /* Dynamically allocate count entries. */ 1808c2ecf20Sopenharmony_ci}; 1818c2ecf20Sopenharmony_ci 1828c2ecf20Sopenharmony_cistruct phm_acpclock_voltage_dependency_table { 1838c2ecf20Sopenharmony_ci uint32_t count; /* Number of entries. */ 1848c2ecf20Sopenharmony_ci struct phm_acpclock_voltage_dependency_record entries[1]; /* Dynamically allocate count entries. */ 1858c2ecf20Sopenharmony_ci}; 1868c2ecf20Sopenharmony_ci 1878c2ecf20Sopenharmony_cistruct phm_vce_clock_voltage_dependency_table { 1888c2ecf20Sopenharmony_ci uint8_t count; 1898c2ecf20Sopenharmony_ci struct phm_vce_clock_voltage_dependency_record entries[1]; 1908c2ecf20Sopenharmony_ci}; 1918c2ecf20Sopenharmony_ci 1928c2ecf20Sopenharmony_ci 1938c2ecf20Sopenharmony_cienum SMU_ASIC_RESET_MODE 1948c2ecf20Sopenharmony_ci{ 1958c2ecf20Sopenharmony_ci SMU_ASIC_RESET_MODE_0, 1968c2ecf20Sopenharmony_ci SMU_ASIC_RESET_MODE_1, 1978c2ecf20Sopenharmony_ci SMU_ASIC_RESET_MODE_2, 1988c2ecf20Sopenharmony_ci}; 1998c2ecf20Sopenharmony_ci 2008c2ecf20Sopenharmony_cistruct pp_smumgr_func { 2018c2ecf20Sopenharmony_ci char *name; 2028c2ecf20Sopenharmony_ci int (*smu_init)(struct pp_hwmgr *hwmgr); 2038c2ecf20Sopenharmony_ci int (*smu_fini)(struct pp_hwmgr *hwmgr); 2048c2ecf20Sopenharmony_ci int (*start_smu)(struct pp_hwmgr *hwmgr); 2058c2ecf20Sopenharmony_ci int (*check_fw_load_finish)(struct pp_hwmgr *hwmgr, 2068c2ecf20Sopenharmony_ci uint32_t firmware); 2078c2ecf20Sopenharmony_ci int (*request_smu_load_fw)(struct pp_hwmgr *hwmgr); 2088c2ecf20Sopenharmony_ci int (*request_smu_load_specific_fw)(struct pp_hwmgr *hwmgr, 2098c2ecf20Sopenharmony_ci uint32_t firmware); 2108c2ecf20Sopenharmony_ci uint32_t (*get_argument)(struct pp_hwmgr *hwmgr); 2118c2ecf20Sopenharmony_ci int (*send_msg_to_smc)(struct pp_hwmgr *hwmgr, uint16_t msg); 2128c2ecf20Sopenharmony_ci int (*send_msg_to_smc_with_parameter)(struct pp_hwmgr *hwmgr, 2138c2ecf20Sopenharmony_ci uint16_t msg, uint32_t parameter); 2148c2ecf20Sopenharmony_ci int (*download_pptable_settings)(struct pp_hwmgr *hwmgr, 2158c2ecf20Sopenharmony_ci void **table); 2168c2ecf20Sopenharmony_ci int (*upload_pptable_settings)(struct pp_hwmgr *hwmgr); 2178c2ecf20Sopenharmony_ci int (*update_smc_table)(struct pp_hwmgr *hwmgr, uint32_t type); 2188c2ecf20Sopenharmony_ci int (*process_firmware_header)(struct pp_hwmgr *hwmgr); 2198c2ecf20Sopenharmony_ci int (*update_sclk_threshold)(struct pp_hwmgr *hwmgr); 2208c2ecf20Sopenharmony_ci int (*thermal_setup_fan_table)(struct pp_hwmgr *hwmgr); 2218c2ecf20Sopenharmony_ci int (*thermal_avfs_enable)(struct pp_hwmgr *hwmgr); 2228c2ecf20Sopenharmony_ci int (*init_smc_table)(struct pp_hwmgr *hwmgr); 2238c2ecf20Sopenharmony_ci int (*populate_all_graphic_levels)(struct pp_hwmgr *hwmgr); 2248c2ecf20Sopenharmony_ci int (*populate_all_memory_levels)(struct pp_hwmgr *hwmgr); 2258c2ecf20Sopenharmony_ci int (*initialize_mc_reg_table)(struct pp_hwmgr *hwmgr); 2268c2ecf20Sopenharmony_ci uint32_t (*get_offsetof)(uint32_t type, uint32_t member); 2278c2ecf20Sopenharmony_ci uint32_t (*get_mac_definition)(uint32_t value); 2288c2ecf20Sopenharmony_ci bool (*is_dpm_running)(struct pp_hwmgr *hwmgr); 2298c2ecf20Sopenharmony_ci bool (*is_hw_avfs_present)(struct pp_hwmgr *hwmgr); 2308c2ecf20Sopenharmony_ci int (*update_dpm_settings)(struct pp_hwmgr *hwmgr, void *profile_setting); 2318c2ecf20Sopenharmony_ci int (*smc_table_manager)(struct pp_hwmgr *hwmgr, uint8_t *table, uint16_t table_id, bool rw); /*rw: true for read, false for write */ 2328c2ecf20Sopenharmony_ci int (*stop_smc)(struct pp_hwmgr *hwmgr); 2338c2ecf20Sopenharmony_ci}; 2348c2ecf20Sopenharmony_ci 2358c2ecf20Sopenharmony_cistruct pp_hwmgr_func { 2368c2ecf20Sopenharmony_ci int (*backend_init)(struct pp_hwmgr *hw_mgr); 2378c2ecf20Sopenharmony_ci int (*backend_fini)(struct pp_hwmgr *hw_mgr); 2388c2ecf20Sopenharmony_ci int (*asic_setup)(struct pp_hwmgr *hw_mgr); 2398c2ecf20Sopenharmony_ci int (*get_power_state_size)(struct pp_hwmgr *hw_mgr); 2408c2ecf20Sopenharmony_ci 2418c2ecf20Sopenharmony_ci int (*apply_state_adjust_rules)(struct pp_hwmgr *hwmgr, 2428c2ecf20Sopenharmony_ci struct pp_power_state *prequest_ps, 2438c2ecf20Sopenharmony_ci const struct pp_power_state *pcurrent_ps); 2448c2ecf20Sopenharmony_ci 2458c2ecf20Sopenharmony_ci int (*apply_clocks_adjust_rules)(struct pp_hwmgr *hwmgr); 2468c2ecf20Sopenharmony_ci 2478c2ecf20Sopenharmony_ci int (*force_dpm_level)(struct pp_hwmgr *hw_mgr, 2488c2ecf20Sopenharmony_ci enum amd_dpm_forced_level level); 2498c2ecf20Sopenharmony_ci 2508c2ecf20Sopenharmony_ci int (*dynamic_state_management_enable)( 2518c2ecf20Sopenharmony_ci struct pp_hwmgr *hw_mgr); 2528c2ecf20Sopenharmony_ci int (*dynamic_state_management_disable)( 2538c2ecf20Sopenharmony_ci struct pp_hwmgr *hw_mgr); 2548c2ecf20Sopenharmony_ci 2558c2ecf20Sopenharmony_ci int (*patch_boot_state)(struct pp_hwmgr *hwmgr, 2568c2ecf20Sopenharmony_ci struct pp_hw_power_state *hw_ps); 2578c2ecf20Sopenharmony_ci 2588c2ecf20Sopenharmony_ci int (*get_pp_table_entry)(struct pp_hwmgr *hwmgr, 2598c2ecf20Sopenharmony_ci unsigned long, struct pp_power_state *); 2608c2ecf20Sopenharmony_ci int (*get_num_of_pp_table_entries)(struct pp_hwmgr *hwmgr); 2618c2ecf20Sopenharmony_ci int (*powerdown_uvd)(struct pp_hwmgr *hwmgr); 2628c2ecf20Sopenharmony_ci void (*powergate_vce)(struct pp_hwmgr *hwmgr, bool bgate); 2638c2ecf20Sopenharmony_ci void (*powergate_uvd)(struct pp_hwmgr *hwmgr, bool bgate); 2648c2ecf20Sopenharmony_ci void (*powergate_acp)(struct pp_hwmgr *hwmgr, bool bgate); 2658c2ecf20Sopenharmony_ci uint32_t (*get_mclk)(struct pp_hwmgr *hwmgr, bool low); 2668c2ecf20Sopenharmony_ci uint32_t (*get_sclk)(struct pp_hwmgr *hwmgr, bool low); 2678c2ecf20Sopenharmony_ci int (*power_state_set)(struct pp_hwmgr *hwmgr, 2688c2ecf20Sopenharmony_ci const void *state); 2698c2ecf20Sopenharmony_ci int (*notify_smc_display_config_after_ps_adjustment)(struct pp_hwmgr *hwmgr); 2708c2ecf20Sopenharmony_ci int (*pre_display_config_changed)(struct pp_hwmgr *hwmgr); 2718c2ecf20Sopenharmony_ci int (*display_config_changed)(struct pp_hwmgr *hwmgr); 2728c2ecf20Sopenharmony_ci int (*disable_clock_power_gating)(struct pp_hwmgr *hwmgr); 2738c2ecf20Sopenharmony_ci int (*update_clock_gatings)(struct pp_hwmgr *hwmgr, 2748c2ecf20Sopenharmony_ci const uint32_t *msg_id); 2758c2ecf20Sopenharmony_ci int (*set_max_fan_rpm_output)(struct pp_hwmgr *hwmgr, uint16_t us_max_fan_pwm); 2768c2ecf20Sopenharmony_ci int (*set_max_fan_pwm_output)(struct pp_hwmgr *hwmgr, uint16_t us_max_fan_pwm); 2778c2ecf20Sopenharmony_ci int (*stop_thermal_controller)(struct pp_hwmgr *hwmgr); 2788c2ecf20Sopenharmony_ci int (*get_fan_speed_info)(struct pp_hwmgr *hwmgr, struct phm_fan_speed_info *fan_speed_info); 2798c2ecf20Sopenharmony_ci void (*set_fan_control_mode)(struct pp_hwmgr *hwmgr, uint32_t mode); 2808c2ecf20Sopenharmony_ci uint32_t (*get_fan_control_mode)(struct pp_hwmgr *hwmgr); 2818c2ecf20Sopenharmony_ci int (*set_fan_speed_percent)(struct pp_hwmgr *hwmgr, uint32_t percent); 2828c2ecf20Sopenharmony_ci int (*get_fan_speed_percent)(struct pp_hwmgr *hwmgr, uint32_t *speed); 2838c2ecf20Sopenharmony_ci int (*set_fan_speed_rpm)(struct pp_hwmgr *hwmgr, uint32_t percent); 2848c2ecf20Sopenharmony_ci int (*get_fan_speed_rpm)(struct pp_hwmgr *hwmgr, uint32_t *speed); 2858c2ecf20Sopenharmony_ci int (*reset_fan_speed_to_default)(struct pp_hwmgr *hwmgr); 2868c2ecf20Sopenharmony_ci int (*uninitialize_thermal_controller)(struct pp_hwmgr *hwmgr); 2878c2ecf20Sopenharmony_ci int (*register_irq_handlers)(struct pp_hwmgr *hwmgr); 2888c2ecf20Sopenharmony_ci bool (*check_smc_update_required_for_display_configuration)(struct pp_hwmgr *hwmgr); 2898c2ecf20Sopenharmony_ci int (*check_states_equal)(struct pp_hwmgr *hwmgr, 2908c2ecf20Sopenharmony_ci const struct pp_hw_power_state *pstate1, 2918c2ecf20Sopenharmony_ci const struct pp_hw_power_state *pstate2, 2928c2ecf20Sopenharmony_ci bool *equal); 2938c2ecf20Sopenharmony_ci int (*set_cpu_power_state)(struct pp_hwmgr *hwmgr); 2948c2ecf20Sopenharmony_ci int (*store_cc6_data)(struct pp_hwmgr *hwmgr, uint32_t separation_time, 2958c2ecf20Sopenharmony_ci bool cc6_disable, bool pstate_disable, 2968c2ecf20Sopenharmony_ci bool pstate_switch_disable); 2978c2ecf20Sopenharmony_ci int (*get_dal_power_level)(struct pp_hwmgr *hwmgr, 2988c2ecf20Sopenharmony_ci struct amd_pp_simple_clock_info *info); 2998c2ecf20Sopenharmony_ci int (*get_performance_level)(struct pp_hwmgr *, const struct pp_hw_power_state *, 3008c2ecf20Sopenharmony_ci PHM_PerformanceLevelDesignation, uint32_t, PHM_PerformanceLevel *); 3018c2ecf20Sopenharmony_ci int (*get_current_shallow_sleep_clocks)(struct pp_hwmgr *hwmgr, 3028c2ecf20Sopenharmony_ci const struct pp_hw_power_state *state, struct pp_clock_info *clock_info); 3038c2ecf20Sopenharmony_ci int (*get_clock_by_type)(struct pp_hwmgr *hwmgr, enum amd_pp_clock_type type, struct amd_pp_clocks *clocks); 3048c2ecf20Sopenharmony_ci int (*get_clock_by_type_with_latency)(struct pp_hwmgr *hwmgr, 3058c2ecf20Sopenharmony_ci enum amd_pp_clock_type type, 3068c2ecf20Sopenharmony_ci struct pp_clock_levels_with_latency *clocks); 3078c2ecf20Sopenharmony_ci int (*get_clock_by_type_with_voltage)(struct pp_hwmgr *hwmgr, 3088c2ecf20Sopenharmony_ci enum amd_pp_clock_type type, 3098c2ecf20Sopenharmony_ci struct pp_clock_levels_with_voltage *clocks); 3108c2ecf20Sopenharmony_ci int (*set_watermarks_for_clocks_ranges)(struct pp_hwmgr *hwmgr, void *clock_ranges); 3118c2ecf20Sopenharmony_ci int (*display_clock_voltage_request)(struct pp_hwmgr *hwmgr, 3128c2ecf20Sopenharmony_ci struct pp_display_clock_request *clock); 3138c2ecf20Sopenharmony_ci int (*get_max_high_clocks)(struct pp_hwmgr *hwmgr, struct amd_pp_simple_clock_info *clocks); 3148c2ecf20Sopenharmony_ci int (*power_off_asic)(struct pp_hwmgr *hwmgr); 3158c2ecf20Sopenharmony_ci int (*force_clock_level)(struct pp_hwmgr *hwmgr, enum pp_clock_type type, uint32_t mask); 3168c2ecf20Sopenharmony_ci int (*print_clock_levels)(struct pp_hwmgr *hwmgr, enum pp_clock_type type, char *buf); 3178c2ecf20Sopenharmony_ci int (*powergate_gfx)(struct pp_hwmgr *hwmgr, bool enable); 3188c2ecf20Sopenharmony_ci int (*get_sclk_od)(struct pp_hwmgr *hwmgr); 3198c2ecf20Sopenharmony_ci int (*set_sclk_od)(struct pp_hwmgr *hwmgr, uint32_t value); 3208c2ecf20Sopenharmony_ci int (*get_mclk_od)(struct pp_hwmgr *hwmgr); 3218c2ecf20Sopenharmony_ci int (*set_mclk_od)(struct pp_hwmgr *hwmgr, uint32_t value); 3228c2ecf20Sopenharmony_ci int (*read_sensor)(struct pp_hwmgr *hwmgr, int idx, void *value, int *size); 3238c2ecf20Sopenharmony_ci int (*avfs_control)(struct pp_hwmgr *hwmgr, bool enable); 3248c2ecf20Sopenharmony_ci int (*disable_smc_firmware_ctf)(struct pp_hwmgr *hwmgr); 3258c2ecf20Sopenharmony_ci int (*set_active_display_count)(struct pp_hwmgr *hwmgr, uint32_t count); 3268c2ecf20Sopenharmony_ci int (*set_min_deep_sleep_dcefclk)(struct pp_hwmgr *hwmgr, uint32_t clock); 3278c2ecf20Sopenharmony_ci int (*start_thermal_controller)(struct pp_hwmgr *hwmgr, struct PP_TemperatureRange *range); 3288c2ecf20Sopenharmony_ci int (*notify_cac_buffer_info)(struct pp_hwmgr *hwmgr, 3298c2ecf20Sopenharmony_ci uint32_t virtual_addr_low, 3308c2ecf20Sopenharmony_ci uint32_t virtual_addr_hi, 3318c2ecf20Sopenharmony_ci uint32_t mc_addr_low, 3328c2ecf20Sopenharmony_ci uint32_t mc_addr_hi, 3338c2ecf20Sopenharmony_ci uint32_t size); 3348c2ecf20Sopenharmony_ci int (*update_nbdpm_pstate)(struct pp_hwmgr *hwmgr, 3358c2ecf20Sopenharmony_ci bool enable, 3368c2ecf20Sopenharmony_ci bool lock); 3378c2ecf20Sopenharmony_ci int (*get_thermal_temperature_range)(struct pp_hwmgr *hwmgr, 3388c2ecf20Sopenharmony_ci struct PP_TemperatureRange *range); 3398c2ecf20Sopenharmony_ci int (*get_power_profile_mode)(struct pp_hwmgr *hwmgr, char *buf); 3408c2ecf20Sopenharmony_ci int (*set_power_profile_mode)(struct pp_hwmgr *hwmgr, long *input, uint32_t size); 3418c2ecf20Sopenharmony_ci int (*odn_edit_dpm_table)(struct pp_hwmgr *hwmgr, 3428c2ecf20Sopenharmony_ci enum PP_OD_DPM_TABLE_COMMAND type, 3438c2ecf20Sopenharmony_ci long *input, uint32_t size); 3448c2ecf20Sopenharmony_ci int (*set_fine_grain_clk_vol)(struct pp_hwmgr *hwmgr, 3458c2ecf20Sopenharmony_ci enum PP_OD_DPM_TABLE_COMMAND type, 3468c2ecf20Sopenharmony_ci long *input, uint32_t size); 3478c2ecf20Sopenharmony_ci int (*set_power_limit)(struct pp_hwmgr *hwmgr, uint32_t n); 3488c2ecf20Sopenharmony_ci int (*powergate_mmhub)(struct pp_hwmgr *hwmgr); 3498c2ecf20Sopenharmony_ci int (*smus_notify_pwe)(struct pp_hwmgr *hwmgr); 3508c2ecf20Sopenharmony_ci int (*powergate_sdma)(struct pp_hwmgr *hwmgr, bool bgate); 3518c2ecf20Sopenharmony_ci int (*enable_mgpu_fan_boost)(struct pp_hwmgr *hwmgr); 3528c2ecf20Sopenharmony_ci int (*set_hard_min_dcefclk_by_freq)(struct pp_hwmgr *hwmgr, uint32_t clock); 3538c2ecf20Sopenharmony_ci int (*set_hard_min_fclk_by_freq)(struct pp_hwmgr *hwmgr, uint32_t clock); 3548c2ecf20Sopenharmony_ci int (*set_hard_min_gfxclk_by_freq)(struct pp_hwmgr *hwmgr, uint32_t clock); 3558c2ecf20Sopenharmony_ci int (*set_soft_max_gfxclk_by_freq)(struct pp_hwmgr *hwmgr, uint32_t clock); 3568c2ecf20Sopenharmony_ci int (*get_asic_baco_capability)(struct pp_hwmgr *hwmgr, bool *cap); 3578c2ecf20Sopenharmony_ci int (*get_asic_baco_state)(struct pp_hwmgr *hwmgr, enum BACO_STATE *state); 3588c2ecf20Sopenharmony_ci int (*set_asic_baco_state)(struct pp_hwmgr *hwmgr, enum BACO_STATE state); 3598c2ecf20Sopenharmony_ci int (*get_ppfeature_status)(struct pp_hwmgr *hwmgr, char *buf); 3608c2ecf20Sopenharmony_ci int (*set_ppfeature_status)(struct pp_hwmgr *hwmgr, uint64_t ppfeature_masks); 3618c2ecf20Sopenharmony_ci int (*set_mp1_state)(struct pp_hwmgr *hwmgr, enum pp_mp1_state mp1_state); 3628c2ecf20Sopenharmony_ci int (*asic_reset)(struct pp_hwmgr *hwmgr, enum SMU_ASIC_RESET_MODE mode); 3638c2ecf20Sopenharmony_ci int (*smu_i2c_bus_access)(struct pp_hwmgr *hwmgr, bool aquire); 3648c2ecf20Sopenharmony_ci int (*set_df_cstate)(struct pp_hwmgr *hwmgr, enum pp_df_cstate state); 3658c2ecf20Sopenharmony_ci int (*set_xgmi_pstate)(struct pp_hwmgr *hwmgr, uint32_t pstate); 3668c2ecf20Sopenharmony_ci int (*disable_power_features_for_compute_performance)(struct pp_hwmgr *hwmgr, 3678c2ecf20Sopenharmony_ci bool disable); 3688c2ecf20Sopenharmony_ci ssize_t (*get_gpu_metrics)(struct pp_hwmgr *hwmgr, void **table); 3698c2ecf20Sopenharmony_ci}; 3708c2ecf20Sopenharmony_ci 3718c2ecf20Sopenharmony_cistruct pp_table_func { 3728c2ecf20Sopenharmony_ci int (*pptable_init)(struct pp_hwmgr *hw_mgr); 3738c2ecf20Sopenharmony_ci int (*pptable_fini)(struct pp_hwmgr *hw_mgr); 3748c2ecf20Sopenharmony_ci int (*pptable_get_number_of_vce_state_table_entries)(struct pp_hwmgr *hw_mgr); 3758c2ecf20Sopenharmony_ci int (*pptable_get_vce_state_table_entry)( 3768c2ecf20Sopenharmony_ci struct pp_hwmgr *hwmgr, 3778c2ecf20Sopenharmony_ci unsigned long i, 3788c2ecf20Sopenharmony_ci struct amd_vce_state *vce_state, 3798c2ecf20Sopenharmony_ci void **clock_info, 3808c2ecf20Sopenharmony_ci unsigned long *flag); 3818c2ecf20Sopenharmony_ci}; 3828c2ecf20Sopenharmony_ci 3838c2ecf20Sopenharmony_ciunion phm_cac_leakage_record { 3848c2ecf20Sopenharmony_ci struct { 3858c2ecf20Sopenharmony_ci uint16_t Vddc; /* in CI, we use it for StdVoltageHiSidd */ 3868c2ecf20Sopenharmony_ci uint32_t Leakage; /* in CI, we use it for StdVoltageLoSidd */ 3878c2ecf20Sopenharmony_ci }; 3888c2ecf20Sopenharmony_ci struct { 3898c2ecf20Sopenharmony_ci uint16_t Vddc1; 3908c2ecf20Sopenharmony_ci uint16_t Vddc2; 3918c2ecf20Sopenharmony_ci uint16_t Vddc3; 3928c2ecf20Sopenharmony_ci }; 3938c2ecf20Sopenharmony_ci}; 3948c2ecf20Sopenharmony_ci 3958c2ecf20Sopenharmony_cistruct phm_cac_leakage_table { 3968c2ecf20Sopenharmony_ci uint32_t count; 3978c2ecf20Sopenharmony_ci union phm_cac_leakage_record entries[1]; 3988c2ecf20Sopenharmony_ci}; 3998c2ecf20Sopenharmony_ci 4008c2ecf20Sopenharmony_cistruct phm_samu_clock_voltage_dependency_record { 4018c2ecf20Sopenharmony_ci uint32_t samclk; 4028c2ecf20Sopenharmony_ci uint32_t v; 4038c2ecf20Sopenharmony_ci}; 4048c2ecf20Sopenharmony_ci 4058c2ecf20Sopenharmony_ci 4068c2ecf20Sopenharmony_cistruct phm_samu_clock_voltage_dependency_table { 4078c2ecf20Sopenharmony_ci uint8_t count; 4088c2ecf20Sopenharmony_ci struct phm_samu_clock_voltage_dependency_record entries[1]; 4098c2ecf20Sopenharmony_ci}; 4108c2ecf20Sopenharmony_ci 4118c2ecf20Sopenharmony_cistruct phm_cac_tdp_table { 4128c2ecf20Sopenharmony_ci uint16_t usTDP; 4138c2ecf20Sopenharmony_ci uint16_t usConfigurableTDP; 4148c2ecf20Sopenharmony_ci uint16_t usTDC; 4158c2ecf20Sopenharmony_ci uint16_t usBatteryPowerLimit; 4168c2ecf20Sopenharmony_ci uint16_t usSmallPowerLimit; 4178c2ecf20Sopenharmony_ci uint16_t usLowCACLeakage; 4188c2ecf20Sopenharmony_ci uint16_t usHighCACLeakage; 4198c2ecf20Sopenharmony_ci uint16_t usMaximumPowerDeliveryLimit; 4208c2ecf20Sopenharmony_ci uint16_t usEDCLimit; 4218c2ecf20Sopenharmony_ci uint16_t usOperatingTempMinLimit; 4228c2ecf20Sopenharmony_ci uint16_t usOperatingTempMaxLimit; 4238c2ecf20Sopenharmony_ci uint16_t usOperatingTempStep; 4248c2ecf20Sopenharmony_ci uint16_t usOperatingTempHyst; 4258c2ecf20Sopenharmony_ci uint16_t usDefaultTargetOperatingTemp; 4268c2ecf20Sopenharmony_ci uint16_t usTargetOperatingTemp; 4278c2ecf20Sopenharmony_ci uint16_t usPowerTuneDataSetID; 4288c2ecf20Sopenharmony_ci uint16_t usSoftwareShutdownTemp; 4298c2ecf20Sopenharmony_ci uint16_t usClockStretchAmount; 4308c2ecf20Sopenharmony_ci uint16_t usTemperatureLimitHotspot; 4318c2ecf20Sopenharmony_ci uint16_t usTemperatureLimitLiquid1; 4328c2ecf20Sopenharmony_ci uint16_t usTemperatureLimitLiquid2; 4338c2ecf20Sopenharmony_ci uint16_t usTemperatureLimitVrVddc; 4348c2ecf20Sopenharmony_ci uint16_t usTemperatureLimitVrMvdd; 4358c2ecf20Sopenharmony_ci uint16_t usTemperatureLimitPlx; 4368c2ecf20Sopenharmony_ci uint8_t ucLiquid1_I2C_address; 4378c2ecf20Sopenharmony_ci uint8_t ucLiquid2_I2C_address; 4388c2ecf20Sopenharmony_ci uint8_t ucLiquid_I2C_Line; 4398c2ecf20Sopenharmony_ci uint8_t ucVr_I2C_address; 4408c2ecf20Sopenharmony_ci uint8_t ucVr_I2C_Line; 4418c2ecf20Sopenharmony_ci uint8_t ucPlx_I2C_address; 4428c2ecf20Sopenharmony_ci uint8_t ucPlx_I2C_Line; 4438c2ecf20Sopenharmony_ci uint32_t usBoostPowerLimit; 4448c2ecf20Sopenharmony_ci uint8_t ucCKS_LDO_REFSEL; 4458c2ecf20Sopenharmony_ci}; 4468c2ecf20Sopenharmony_ci 4478c2ecf20Sopenharmony_cistruct phm_tdp_table { 4488c2ecf20Sopenharmony_ci uint16_t usTDP; 4498c2ecf20Sopenharmony_ci uint16_t usConfigurableTDP; 4508c2ecf20Sopenharmony_ci uint16_t usTDC; 4518c2ecf20Sopenharmony_ci uint16_t usBatteryPowerLimit; 4528c2ecf20Sopenharmony_ci uint16_t usSmallPowerLimit; 4538c2ecf20Sopenharmony_ci uint16_t usLowCACLeakage; 4548c2ecf20Sopenharmony_ci uint16_t usHighCACLeakage; 4558c2ecf20Sopenharmony_ci uint16_t usMaximumPowerDeliveryLimit; 4568c2ecf20Sopenharmony_ci uint16_t usEDCLimit; 4578c2ecf20Sopenharmony_ci uint16_t usOperatingTempMinLimit; 4588c2ecf20Sopenharmony_ci uint16_t usOperatingTempMaxLimit; 4598c2ecf20Sopenharmony_ci uint16_t usOperatingTempStep; 4608c2ecf20Sopenharmony_ci uint16_t usOperatingTempHyst; 4618c2ecf20Sopenharmony_ci uint16_t usDefaultTargetOperatingTemp; 4628c2ecf20Sopenharmony_ci uint16_t usTargetOperatingTemp; 4638c2ecf20Sopenharmony_ci uint16_t usPowerTuneDataSetID; 4648c2ecf20Sopenharmony_ci uint16_t usSoftwareShutdownTemp; 4658c2ecf20Sopenharmony_ci uint16_t usClockStretchAmount; 4668c2ecf20Sopenharmony_ci uint16_t usTemperatureLimitTedge; 4678c2ecf20Sopenharmony_ci uint16_t usTemperatureLimitHotspot; 4688c2ecf20Sopenharmony_ci uint16_t usTemperatureLimitLiquid1; 4698c2ecf20Sopenharmony_ci uint16_t usTemperatureLimitLiquid2; 4708c2ecf20Sopenharmony_ci uint16_t usTemperatureLimitHBM; 4718c2ecf20Sopenharmony_ci uint16_t usTemperatureLimitVrVddc; 4728c2ecf20Sopenharmony_ci uint16_t usTemperatureLimitVrMvdd; 4738c2ecf20Sopenharmony_ci uint16_t usTemperatureLimitPlx; 4748c2ecf20Sopenharmony_ci uint8_t ucLiquid1_I2C_address; 4758c2ecf20Sopenharmony_ci uint8_t ucLiquid2_I2C_address; 4768c2ecf20Sopenharmony_ci uint8_t ucLiquid_I2C_Line; 4778c2ecf20Sopenharmony_ci uint8_t ucVr_I2C_address; 4788c2ecf20Sopenharmony_ci uint8_t ucVr_I2C_Line; 4798c2ecf20Sopenharmony_ci uint8_t ucPlx_I2C_address; 4808c2ecf20Sopenharmony_ci uint8_t ucPlx_I2C_Line; 4818c2ecf20Sopenharmony_ci uint8_t ucLiquid_I2C_LineSDA; 4828c2ecf20Sopenharmony_ci uint8_t ucVr_I2C_LineSDA; 4838c2ecf20Sopenharmony_ci uint8_t ucPlx_I2C_LineSDA; 4848c2ecf20Sopenharmony_ci uint32_t usBoostPowerLimit; 4858c2ecf20Sopenharmony_ci uint16_t usBoostStartTemperature; 4868c2ecf20Sopenharmony_ci uint16_t usBoostStopTemperature; 4878c2ecf20Sopenharmony_ci uint32_t ulBoostClock; 4888c2ecf20Sopenharmony_ci}; 4898c2ecf20Sopenharmony_ci 4908c2ecf20Sopenharmony_cistruct phm_ppm_table { 4918c2ecf20Sopenharmony_ci uint8_t ppm_design; 4928c2ecf20Sopenharmony_ci uint16_t cpu_core_number; 4938c2ecf20Sopenharmony_ci uint32_t platform_tdp; 4948c2ecf20Sopenharmony_ci uint32_t small_ac_platform_tdp; 4958c2ecf20Sopenharmony_ci uint32_t platform_tdc; 4968c2ecf20Sopenharmony_ci uint32_t small_ac_platform_tdc; 4978c2ecf20Sopenharmony_ci uint32_t apu_tdp; 4988c2ecf20Sopenharmony_ci uint32_t dgpu_tdp; 4998c2ecf20Sopenharmony_ci uint32_t dgpu_ulv_power; 5008c2ecf20Sopenharmony_ci uint32_t tj_max; 5018c2ecf20Sopenharmony_ci}; 5028c2ecf20Sopenharmony_ci 5038c2ecf20Sopenharmony_cistruct phm_vq_budgeting_record { 5048c2ecf20Sopenharmony_ci uint32_t ulCUs; 5058c2ecf20Sopenharmony_ci uint32_t ulSustainableSOCPowerLimitLow; 5068c2ecf20Sopenharmony_ci uint32_t ulSustainableSOCPowerLimitHigh; 5078c2ecf20Sopenharmony_ci uint32_t ulMinSclkLow; 5088c2ecf20Sopenharmony_ci uint32_t ulMinSclkHigh; 5098c2ecf20Sopenharmony_ci uint8_t ucDispConfig; 5108c2ecf20Sopenharmony_ci uint32_t ulDClk; 5118c2ecf20Sopenharmony_ci uint32_t ulEClk; 5128c2ecf20Sopenharmony_ci uint32_t ulSustainableSclk; 5138c2ecf20Sopenharmony_ci uint32_t ulSustainableCUs; 5148c2ecf20Sopenharmony_ci}; 5158c2ecf20Sopenharmony_ci 5168c2ecf20Sopenharmony_cistruct phm_vq_budgeting_table { 5178c2ecf20Sopenharmony_ci uint8_t numEntries; 5188c2ecf20Sopenharmony_ci struct phm_vq_budgeting_record entries[1]; 5198c2ecf20Sopenharmony_ci}; 5208c2ecf20Sopenharmony_ci 5218c2ecf20Sopenharmony_cistruct phm_clock_and_voltage_limits { 5228c2ecf20Sopenharmony_ci uint32_t sclk; 5238c2ecf20Sopenharmony_ci uint32_t mclk; 5248c2ecf20Sopenharmony_ci uint32_t gfxclk; 5258c2ecf20Sopenharmony_ci uint16_t vddc; 5268c2ecf20Sopenharmony_ci uint16_t vddci; 5278c2ecf20Sopenharmony_ci uint16_t vddgfx; 5288c2ecf20Sopenharmony_ci uint16_t vddmem; 5298c2ecf20Sopenharmony_ci}; 5308c2ecf20Sopenharmony_ci 5318c2ecf20Sopenharmony_ci/* Structure to hold PPTable information */ 5328c2ecf20Sopenharmony_ci 5338c2ecf20Sopenharmony_cistruct phm_ppt_v1_information { 5348c2ecf20Sopenharmony_ci struct phm_ppt_v1_clock_voltage_dependency_table *vdd_dep_on_sclk; 5358c2ecf20Sopenharmony_ci struct phm_ppt_v1_clock_voltage_dependency_table *vdd_dep_on_mclk; 5368c2ecf20Sopenharmony_ci struct phm_ppt_v1_clock_voltage_dependency_table *vdd_dep_on_socclk; 5378c2ecf20Sopenharmony_ci struct phm_ppt_v1_clock_voltage_dependency_table *vdd_dep_on_dcefclk; 5388c2ecf20Sopenharmony_ci struct phm_clock_array *valid_sclk_values; 5398c2ecf20Sopenharmony_ci struct phm_clock_array *valid_mclk_values; 5408c2ecf20Sopenharmony_ci struct phm_clock_array *valid_socclk_values; 5418c2ecf20Sopenharmony_ci struct phm_clock_array *valid_dcefclk_values; 5428c2ecf20Sopenharmony_ci struct phm_clock_and_voltage_limits max_clock_voltage_on_dc; 5438c2ecf20Sopenharmony_ci struct phm_clock_and_voltage_limits max_clock_voltage_on_ac; 5448c2ecf20Sopenharmony_ci struct phm_clock_voltage_dependency_table *vddc_dep_on_dal_pwrl; 5458c2ecf20Sopenharmony_ci struct phm_ppm_table *ppm_parameter_table; 5468c2ecf20Sopenharmony_ci struct phm_cac_tdp_table *cac_dtp_table; 5478c2ecf20Sopenharmony_ci struct phm_tdp_table *tdp_table; 5488c2ecf20Sopenharmony_ci struct phm_ppt_v1_mm_clock_voltage_dependency_table *mm_dep_table; 5498c2ecf20Sopenharmony_ci struct phm_ppt_v1_voltage_lookup_table *vddc_lookup_table; 5508c2ecf20Sopenharmony_ci struct phm_ppt_v1_voltage_lookup_table *vddgfx_lookup_table; 5518c2ecf20Sopenharmony_ci struct phm_ppt_v1_voltage_lookup_table *vddmem_lookup_table; 5528c2ecf20Sopenharmony_ci struct phm_ppt_v1_pcie_table *pcie_table; 5538c2ecf20Sopenharmony_ci struct phm_ppt_v1_gpio_table *gpio_table; 5548c2ecf20Sopenharmony_ci uint16_t us_ulv_voltage_offset; 5558c2ecf20Sopenharmony_ci uint16_t us_ulv_smnclk_did; 5568c2ecf20Sopenharmony_ci uint16_t us_ulv_mp1clk_did; 5578c2ecf20Sopenharmony_ci uint16_t us_ulv_gfxclk_bypass; 5588c2ecf20Sopenharmony_ci uint16_t us_gfxclk_slew_rate; 5598c2ecf20Sopenharmony_ci uint16_t us_min_gfxclk_freq_limit; 5608c2ecf20Sopenharmony_ci}; 5618c2ecf20Sopenharmony_ci 5628c2ecf20Sopenharmony_cistruct phm_ppt_v2_information { 5638c2ecf20Sopenharmony_ci struct phm_ppt_v1_clock_voltage_dependency_table *vdd_dep_on_sclk; 5648c2ecf20Sopenharmony_ci struct phm_ppt_v1_clock_voltage_dependency_table *vdd_dep_on_mclk; 5658c2ecf20Sopenharmony_ci struct phm_ppt_v1_clock_voltage_dependency_table *vdd_dep_on_socclk; 5668c2ecf20Sopenharmony_ci struct phm_ppt_v1_clock_voltage_dependency_table *vdd_dep_on_dcefclk; 5678c2ecf20Sopenharmony_ci struct phm_ppt_v1_clock_voltage_dependency_table *vdd_dep_on_pixclk; 5688c2ecf20Sopenharmony_ci struct phm_ppt_v1_clock_voltage_dependency_table *vdd_dep_on_dispclk; 5698c2ecf20Sopenharmony_ci struct phm_ppt_v1_clock_voltage_dependency_table *vdd_dep_on_phyclk; 5708c2ecf20Sopenharmony_ci struct phm_ppt_v1_mm_clock_voltage_dependency_table *mm_dep_table; 5718c2ecf20Sopenharmony_ci 5728c2ecf20Sopenharmony_ci struct phm_clock_voltage_dependency_table *vddc_dep_on_dalpwrl; 5738c2ecf20Sopenharmony_ci 5748c2ecf20Sopenharmony_ci struct phm_clock_array *valid_sclk_values; 5758c2ecf20Sopenharmony_ci struct phm_clock_array *valid_mclk_values; 5768c2ecf20Sopenharmony_ci struct phm_clock_array *valid_socclk_values; 5778c2ecf20Sopenharmony_ci struct phm_clock_array *valid_dcefclk_values; 5788c2ecf20Sopenharmony_ci 5798c2ecf20Sopenharmony_ci struct phm_clock_and_voltage_limits max_clock_voltage_on_dc; 5808c2ecf20Sopenharmony_ci struct phm_clock_and_voltage_limits max_clock_voltage_on_ac; 5818c2ecf20Sopenharmony_ci 5828c2ecf20Sopenharmony_ci struct phm_ppm_table *ppm_parameter_table; 5838c2ecf20Sopenharmony_ci struct phm_cac_tdp_table *cac_dtp_table; 5848c2ecf20Sopenharmony_ci struct phm_tdp_table *tdp_table; 5858c2ecf20Sopenharmony_ci 5868c2ecf20Sopenharmony_ci struct phm_ppt_v1_voltage_lookup_table *vddc_lookup_table; 5878c2ecf20Sopenharmony_ci struct phm_ppt_v1_voltage_lookup_table *vddgfx_lookup_table; 5888c2ecf20Sopenharmony_ci struct phm_ppt_v1_voltage_lookup_table *vddmem_lookup_table; 5898c2ecf20Sopenharmony_ci struct phm_ppt_v1_voltage_lookup_table *vddci_lookup_table; 5908c2ecf20Sopenharmony_ci 5918c2ecf20Sopenharmony_ci struct phm_ppt_v1_pcie_table *pcie_table; 5928c2ecf20Sopenharmony_ci 5938c2ecf20Sopenharmony_ci uint16_t us_ulv_voltage_offset; 5948c2ecf20Sopenharmony_ci uint16_t us_ulv_smnclk_did; 5958c2ecf20Sopenharmony_ci uint16_t us_ulv_mp1clk_did; 5968c2ecf20Sopenharmony_ci uint16_t us_ulv_gfxclk_bypass; 5978c2ecf20Sopenharmony_ci uint16_t us_gfxclk_slew_rate; 5988c2ecf20Sopenharmony_ci uint16_t us_min_gfxclk_freq_limit; 5998c2ecf20Sopenharmony_ci 6008c2ecf20Sopenharmony_ci uint8_t uc_gfx_dpm_voltage_mode; 6018c2ecf20Sopenharmony_ci uint8_t uc_soc_dpm_voltage_mode; 6028c2ecf20Sopenharmony_ci uint8_t uc_uclk_dpm_voltage_mode; 6038c2ecf20Sopenharmony_ci uint8_t uc_uvd_dpm_voltage_mode; 6048c2ecf20Sopenharmony_ci uint8_t uc_vce_dpm_voltage_mode; 6058c2ecf20Sopenharmony_ci uint8_t uc_mp0_dpm_voltage_mode; 6068c2ecf20Sopenharmony_ci uint8_t uc_dcef_dpm_voltage_mode; 6078c2ecf20Sopenharmony_ci}; 6088c2ecf20Sopenharmony_ci 6098c2ecf20Sopenharmony_cistruct phm_ppt_v3_information 6108c2ecf20Sopenharmony_ci{ 6118c2ecf20Sopenharmony_ci uint8_t uc_thermal_controller_type; 6128c2ecf20Sopenharmony_ci 6138c2ecf20Sopenharmony_ci uint16_t us_small_power_limit1; 6148c2ecf20Sopenharmony_ci uint16_t us_small_power_limit2; 6158c2ecf20Sopenharmony_ci uint16_t us_boost_power_limit; 6168c2ecf20Sopenharmony_ci 6178c2ecf20Sopenharmony_ci uint16_t us_od_turbo_power_limit; 6188c2ecf20Sopenharmony_ci uint16_t us_od_powersave_power_limit; 6198c2ecf20Sopenharmony_ci uint16_t us_software_shutdown_temp; 6208c2ecf20Sopenharmony_ci 6218c2ecf20Sopenharmony_ci uint32_t *power_saving_clock_max; 6228c2ecf20Sopenharmony_ci uint32_t *power_saving_clock_min; 6238c2ecf20Sopenharmony_ci 6248c2ecf20Sopenharmony_ci uint8_t *od_feature_capabilities; 6258c2ecf20Sopenharmony_ci uint32_t *od_settings_max; 6268c2ecf20Sopenharmony_ci uint32_t *od_settings_min; 6278c2ecf20Sopenharmony_ci 6288c2ecf20Sopenharmony_ci void *smc_pptable; 6298c2ecf20Sopenharmony_ci}; 6308c2ecf20Sopenharmony_ci 6318c2ecf20Sopenharmony_cistruct phm_dynamic_state_info { 6328c2ecf20Sopenharmony_ci struct phm_clock_voltage_dependency_table *vddc_dependency_on_sclk; 6338c2ecf20Sopenharmony_ci struct phm_clock_voltage_dependency_table *vddci_dependency_on_mclk; 6348c2ecf20Sopenharmony_ci struct phm_clock_voltage_dependency_table *vddc_dependency_on_mclk; 6358c2ecf20Sopenharmony_ci struct phm_clock_voltage_dependency_table *mvdd_dependency_on_mclk; 6368c2ecf20Sopenharmony_ci struct phm_clock_voltage_dependency_table *vddc_dep_on_dal_pwrl; 6378c2ecf20Sopenharmony_ci struct phm_clock_array *valid_sclk_values; 6388c2ecf20Sopenharmony_ci struct phm_clock_array *valid_mclk_values; 6398c2ecf20Sopenharmony_ci struct phm_clock_and_voltage_limits max_clock_voltage_on_dc; 6408c2ecf20Sopenharmony_ci struct phm_clock_and_voltage_limits max_clock_voltage_on_ac; 6418c2ecf20Sopenharmony_ci uint32_t mclk_sclk_ratio; 6428c2ecf20Sopenharmony_ci uint32_t sclk_mclk_delta; 6438c2ecf20Sopenharmony_ci uint32_t vddc_vddci_delta; 6448c2ecf20Sopenharmony_ci uint32_t min_vddc_for_pcie_gen2; 6458c2ecf20Sopenharmony_ci struct phm_cac_leakage_table *cac_leakage_table; 6468c2ecf20Sopenharmony_ci struct phm_phase_shedding_limits_table *vddc_phase_shed_limits_table; 6478c2ecf20Sopenharmony_ci 6488c2ecf20Sopenharmony_ci struct phm_vce_clock_voltage_dependency_table 6498c2ecf20Sopenharmony_ci *vce_clock_voltage_dependency_table; 6508c2ecf20Sopenharmony_ci struct phm_uvd_clock_voltage_dependency_table 6518c2ecf20Sopenharmony_ci *uvd_clock_voltage_dependency_table; 6528c2ecf20Sopenharmony_ci struct phm_acp_clock_voltage_dependency_table 6538c2ecf20Sopenharmony_ci *acp_clock_voltage_dependency_table; 6548c2ecf20Sopenharmony_ci struct phm_samu_clock_voltage_dependency_table 6558c2ecf20Sopenharmony_ci *samu_clock_voltage_dependency_table; 6568c2ecf20Sopenharmony_ci 6578c2ecf20Sopenharmony_ci struct phm_ppm_table *ppm_parameter_table; 6588c2ecf20Sopenharmony_ci struct phm_cac_tdp_table *cac_dtp_table; 6598c2ecf20Sopenharmony_ci struct phm_clock_voltage_dependency_table *vdd_gfx_dependency_on_sclk; 6608c2ecf20Sopenharmony_ci}; 6618c2ecf20Sopenharmony_ci 6628c2ecf20Sopenharmony_cistruct pp_fan_info { 6638c2ecf20Sopenharmony_ci bool bNoFan; 6648c2ecf20Sopenharmony_ci uint8_t ucTachometerPulsesPerRevolution; 6658c2ecf20Sopenharmony_ci uint32_t ulMinRPM; 6668c2ecf20Sopenharmony_ci uint32_t ulMaxRPM; 6678c2ecf20Sopenharmony_ci}; 6688c2ecf20Sopenharmony_ci 6698c2ecf20Sopenharmony_cistruct pp_advance_fan_control_parameters { 6708c2ecf20Sopenharmony_ci uint16_t usTMin; /* The temperature, in 0.01 centigrades, below which we just run at a minimal PWM. */ 6718c2ecf20Sopenharmony_ci uint16_t usTMed; /* The middle temperature where we change slopes. */ 6728c2ecf20Sopenharmony_ci uint16_t usTHigh; /* The high temperature for setting the second slope. */ 6738c2ecf20Sopenharmony_ci uint16_t usPWMMin; /* The minimum PWM value in percent (0.01% increments). */ 6748c2ecf20Sopenharmony_ci uint16_t usPWMMed; /* The PWM value (in percent) at TMed. */ 6758c2ecf20Sopenharmony_ci uint16_t usPWMHigh; /* The PWM value at THigh. */ 6768c2ecf20Sopenharmony_ci uint8_t ucTHyst; /* Temperature hysteresis. Integer. */ 6778c2ecf20Sopenharmony_ci uint32_t ulCycleDelay; /* The time between two invocations of the fan control routine in microseconds. */ 6788c2ecf20Sopenharmony_ci uint16_t usTMax; /* The max temperature */ 6798c2ecf20Sopenharmony_ci uint8_t ucFanControlMode; 6808c2ecf20Sopenharmony_ci uint16_t usFanPWMMinLimit; 6818c2ecf20Sopenharmony_ci uint16_t usFanPWMMaxLimit; 6828c2ecf20Sopenharmony_ci uint16_t usFanPWMStep; 6838c2ecf20Sopenharmony_ci uint16_t usDefaultMaxFanPWM; 6848c2ecf20Sopenharmony_ci uint16_t usFanOutputSensitivity; 6858c2ecf20Sopenharmony_ci uint16_t usDefaultFanOutputSensitivity; 6868c2ecf20Sopenharmony_ci uint16_t usMaxFanPWM; /* The max Fan PWM value for Fuzzy Fan Control feature */ 6878c2ecf20Sopenharmony_ci uint16_t usFanRPMMinLimit; /* Minimum limit range in percentage, need to calculate based on minRPM/MaxRpm */ 6888c2ecf20Sopenharmony_ci uint16_t usFanRPMMaxLimit; /* Maximum limit range in percentage, usually set to 100% by default */ 6898c2ecf20Sopenharmony_ci uint16_t usFanRPMStep; /* Step increments/decerements, in percent */ 6908c2ecf20Sopenharmony_ci uint16_t usDefaultMaxFanRPM; /* The max Fan RPM value for Fuzzy Fan Control feature, default from PPTable */ 6918c2ecf20Sopenharmony_ci uint16_t usMaxFanRPM; /* The max Fan RPM value for Fuzzy Fan Control feature, user defined */ 6928c2ecf20Sopenharmony_ci uint16_t usFanCurrentLow; /* Low current */ 6938c2ecf20Sopenharmony_ci uint16_t usFanCurrentHigh; /* High current */ 6948c2ecf20Sopenharmony_ci uint16_t usFanRPMLow; /* Low RPM */ 6958c2ecf20Sopenharmony_ci uint16_t usFanRPMHigh; /* High RPM */ 6968c2ecf20Sopenharmony_ci uint32_t ulMinFanSCLKAcousticLimit; /* Minimum Fan Controller SCLK Frequency Acoustic Limit. */ 6978c2ecf20Sopenharmony_ci uint8_t ucTargetTemperature; /* Advanced fan controller target temperature. */ 6988c2ecf20Sopenharmony_ci uint8_t ucMinimumPWMLimit; /* The minimum PWM that the advanced fan controller can set. This should be set to the highest PWM that will run the fan at its lowest RPM. */ 6998c2ecf20Sopenharmony_ci uint16_t usFanGainEdge; /* The following is added for Fiji */ 7008c2ecf20Sopenharmony_ci uint16_t usFanGainHotspot; 7018c2ecf20Sopenharmony_ci uint16_t usFanGainLiquid; 7028c2ecf20Sopenharmony_ci uint16_t usFanGainVrVddc; 7038c2ecf20Sopenharmony_ci uint16_t usFanGainVrMvdd; 7048c2ecf20Sopenharmony_ci uint16_t usFanGainPlx; 7058c2ecf20Sopenharmony_ci uint16_t usFanGainHbm; 7068c2ecf20Sopenharmony_ci uint8_t ucEnableZeroRPM; 7078c2ecf20Sopenharmony_ci uint8_t ucFanStopTemperature; 7088c2ecf20Sopenharmony_ci uint8_t ucFanStartTemperature; 7098c2ecf20Sopenharmony_ci uint32_t ulMaxFanSCLKAcousticLimit; /* Maximum Fan Controller SCLK Frequency Acoustic Limit. */ 7108c2ecf20Sopenharmony_ci uint32_t ulTargetGfxClk; 7118c2ecf20Sopenharmony_ci uint16_t usZeroRPMStartTemperature; 7128c2ecf20Sopenharmony_ci uint16_t usZeroRPMStopTemperature; 7138c2ecf20Sopenharmony_ci uint16_t usMGpuThrottlingRPMLimit; 7148c2ecf20Sopenharmony_ci}; 7158c2ecf20Sopenharmony_ci 7168c2ecf20Sopenharmony_cistruct pp_thermal_controller_info { 7178c2ecf20Sopenharmony_ci uint8_t ucType; 7188c2ecf20Sopenharmony_ci uint8_t ucI2cLine; 7198c2ecf20Sopenharmony_ci uint8_t ucI2cAddress; 7208c2ecf20Sopenharmony_ci uint8_t use_hw_fan_control; 7218c2ecf20Sopenharmony_ci struct pp_fan_info fanInfo; 7228c2ecf20Sopenharmony_ci struct pp_advance_fan_control_parameters advanceFanControlParameters; 7238c2ecf20Sopenharmony_ci}; 7248c2ecf20Sopenharmony_ci 7258c2ecf20Sopenharmony_cistruct phm_microcode_version_info { 7268c2ecf20Sopenharmony_ci uint32_t SMC; 7278c2ecf20Sopenharmony_ci uint32_t DMCU; 7288c2ecf20Sopenharmony_ci uint32_t MC; 7298c2ecf20Sopenharmony_ci uint32_t NB; 7308c2ecf20Sopenharmony_ci}; 7318c2ecf20Sopenharmony_ci 7328c2ecf20Sopenharmony_cienum PP_TABLE_VERSION { 7338c2ecf20Sopenharmony_ci PP_TABLE_V0 = 0, 7348c2ecf20Sopenharmony_ci PP_TABLE_V1, 7358c2ecf20Sopenharmony_ci PP_TABLE_V2, 7368c2ecf20Sopenharmony_ci PP_TABLE_MAX 7378c2ecf20Sopenharmony_ci}; 7388c2ecf20Sopenharmony_ci 7398c2ecf20Sopenharmony_ci/** 7408c2ecf20Sopenharmony_ci * The main hardware manager structure. 7418c2ecf20Sopenharmony_ci */ 7428c2ecf20Sopenharmony_ci#define Workload_Policy_Max 6 7438c2ecf20Sopenharmony_ci 7448c2ecf20Sopenharmony_cistruct pp_hwmgr { 7458c2ecf20Sopenharmony_ci void *adev; 7468c2ecf20Sopenharmony_ci uint32_t chip_family; 7478c2ecf20Sopenharmony_ci uint32_t chip_id; 7488c2ecf20Sopenharmony_ci uint32_t smu_version; 7498c2ecf20Sopenharmony_ci bool not_vf; 7508c2ecf20Sopenharmony_ci bool pm_en; 7518c2ecf20Sopenharmony_ci bool pp_one_vf; 7528c2ecf20Sopenharmony_ci struct mutex smu_lock; 7538c2ecf20Sopenharmony_ci struct mutex msg_lock; 7548c2ecf20Sopenharmony_ci 7558c2ecf20Sopenharmony_ci uint32_t pp_table_version; 7568c2ecf20Sopenharmony_ci void *device; 7578c2ecf20Sopenharmony_ci struct pp_smumgr *smumgr; 7588c2ecf20Sopenharmony_ci const void *soft_pp_table; 7598c2ecf20Sopenharmony_ci uint32_t soft_pp_table_size; 7608c2ecf20Sopenharmony_ci void *hardcode_pp_table; 7618c2ecf20Sopenharmony_ci bool need_pp_table_upload; 7628c2ecf20Sopenharmony_ci 7638c2ecf20Sopenharmony_ci struct amd_vce_state vce_states[AMD_MAX_VCE_LEVELS]; 7648c2ecf20Sopenharmony_ci uint32_t num_vce_state_tables; 7658c2ecf20Sopenharmony_ci 7668c2ecf20Sopenharmony_ci enum amd_dpm_forced_level dpm_level; 7678c2ecf20Sopenharmony_ci enum amd_dpm_forced_level saved_dpm_level; 7688c2ecf20Sopenharmony_ci enum amd_dpm_forced_level request_dpm_level; 7698c2ecf20Sopenharmony_ci uint32_t usec_timeout; 7708c2ecf20Sopenharmony_ci void *pptable; 7718c2ecf20Sopenharmony_ci struct phm_platform_descriptor platform_descriptor; 7728c2ecf20Sopenharmony_ci void *backend; 7738c2ecf20Sopenharmony_ci 7748c2ecf20Sopenharmony_ci void *smu_backend; 7758c2ecf20Sopenharmony_ci const struct pp_smumgr_func *smumgr_funcs; 7768c2ecf20Sopenharmony_ci bool is_kicker; 7778c2ecf20Sopenharmony_ci 7788c2ecf20Sopenharmony_ci enum PP_DAL_POWERLEVEL dal_power_level; 7798c2ecf20Sopenharmony_ci struct phm_dynamic_state_info dyn_state; 7808c2ecf20Sopenharmony_ci const struct pp_hwmgr_func *hwmgr_func; 7818c2ecf20Sopenharmony_ci const struct pp_table_func *pptable_func; 7828c2ecf20Sopenharmony_ci 7838c2ecf20Sopenharmony_ci struct pp_power_state *ps; 7848c2ecf20Sopenharmony_ci uint32_t num_ps; 7858c2ecf20Sopenharmony_ci struct pp_thermal_controller_info thermal_controller; 7868c2ecf20Sopenharmony_ci bool fan_ctrl_is_in_default_mode; 7878c2ecf20Sopenharmony_ci uint32_t fan_ctrl_default_mode; 7888c2ecf20Sopenharmony_ci bool fan_ctrl_enabled; 7898c2ecf20Sopenharmony_ci uint32_t tmin; 7908c2ecf20Sopenharmony_ci struct phm_microcode_version_info microcode_version_info; 7918c2ecf20Sopenharmony_ci uint32_t ps_size; 7928c2ecf20Sopenharmony_ci struct pp_power_state *current_ps; 7938c2ecf20Sopenharmony_ci struct pp_power_state *request_ps; 7948c2ecf20Sopenharmony_ci struct pp_power_state *boot_ps; 7958c2ecf20Sopenharmony_ci struct pp_power_state *uvd_ps; 7968c2ecf20Sopenharmony_ci const struct amd_pp_display_configuration *display_config; 7978c2ecf20Sopenharmony_ci uint32_t feature_mask; 7988c2ecf20Sopenharmony_ci bool avfs_supported; 7998c2ecf20Sopenharmony_ci /* UMD Pstate */ 8008c2ecf20Sopenharmony_ci bool en_umd_pstate; 8018c2ecf20Sopenharmony_ci uint32_t power_profile_mode; 8028c2ecf20Sopenharmony_ci uint32_t default_power_profile_mode; 8038c2ecf20Sopenharmony_ci uint32_t pstate_sclk; 8048c2ecf20Sopenharmony_ci uint32_t pstate_mclk; 8058c2ecf20Sopenharmony_ci bool od_enabled; 8068c2ecf20Sopenharmony_ci uint32_t power_limit; 8078c2ecf20Sopenharmony_ci uint32_t default_power_limit; 8088c2ecf20Sopenharmony_ci uint32_t workload_mask; 8098c2ecf20Sopenharmony_ci uint32_t workload_prority[Workload_Policy_Max]; 8108c2ecf20Sopenharmony_ci uint32_t workload_setting[Workload_Policy_Max]; 8118c2ecf20Sopenharmony_ci bool gfxoff_state_changed_by_workload; 8128c2ecf20Sopenharmony_ci}; 8138c2ecf20Sopenharmony_ci 8148c2ecf20Sopenharmony_ciint hwmgr_early_init(struct pp_hwmgr *hwmgr); 8158c2ecf20Sopenharmony_ciint hwmgr_sw_init(struct pp_hwmgr *hwmgr); 8168c2ecf20Sopenharmony_ciint hwmgr_sw_fini(struct pp_hwmgr *hwmgr); 8178c2ecf20Sopenharmony_ciint hwmgr_hw_init(struct pp_hwmgr *hwmgr); 8188c2ecf20Sopenharmony_ciint hwmgr_hw_fini(struct pp_hwmgr *hwmgr); 8198c2ecf20Sopenharmony_ciint hwmgr_suspend(struct pp_hwmgr *hwmgr); 8208c2ecf20Sopenharmony_ciint hwmgr_resume(struct pp_hwmgr *hwmgr); 8218c2ecf20Sopenharmony_ci 8228c2ecf20Sopenharmony_ciint hwmgr_handle_task(struct pp_hwmgr *hwmgr, 8238c2ecf20Sopenharmony_ci enum amd_pp_task task_id, 8248c2ecf20Sopenharmony_ci enum amd_pm_state_type *user_state); 8258c2ecf20Sopenharmony_ci 8268c2ecf20Sopenharmony_ci 8278c2ecf20Sopenharmony_ci#define PHM_ENTIRE_REGISTER_MASK 0xFFFFFFFFU 8288c2ecf20Sopenharmony_ci 8298c2ecf20Sopenharmony_ci 8308c2ecf20Sopenharmony_ci#endif /* _HWMGR_H_ */ 831