Path: blob/master/drivers/gpu/drm/amd/pm/powerplay/inc/hwmgr.h
26552 views
/*1* Copyright 2015 Advanced Micro Devices, Inc.2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice shall be included in11* all copies or substantial portions of the Software.12*13* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR14* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,15* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL16* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR17* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,18* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR19* OTHER DEALINGS IN THE SOFTWARE.20*21*/22#ifndef _HWMGR_H_23#define _HWMGR_H_2425#include <linux/seq_file.h>26#include "amd_powerplay.h"27#include "hardwaremanager.h"28#include "hwmgr_ppt.h"29#include "ppatomctrl.h"30#include "power_state.h"31#include "smu_helper.h"3233struct pp_hwmgr;34struct phm_fan_speed_info;35struct pp_atomctrl_voltage_table;3637#define VOLTAGE_SCALE 438#define VOLTAGE_VID_OFFSET_SCALE1 62539#define VOLTAGE_VID_OFFSET_SCALE2 1004041enum DISPLAY_GAP {42DISPLAY_GAP_VBLANK_OR_WM = 0, /* Wait for vblank or MCHG watermark. */43DISPLAY_GAP_VBLANK = 1, /* Wait for vblank. */44DISPLAY_GAP_WATERMARK = 2, /* Wait for MCHG watermark. (Note that HW may deassert WM in VBI depending on DC_STUTTER_CNTL.) */45DISPLAY_GAP_IGNORE = 3 /* Do not wait. */46};47typedef enum DISPLAY_GAP DISPLAY_GAP;4849enum BACO_STATE {50BACO_STATE_OUT = 0,51BACO_STATE_IN,52};5354struct vi_dpm_level {55bool enabled;56uint32_t value;57uint32_t param1;58};5960struct vi_dpm_table {61uint32_t count;62struct vi_dpm_level dpm_level[];63};6465#define PCIE_PERF_REQ_REMOVE_REGISTRY 066#define PCIE_PERF_REQ_FORCE_LOWPOWER 167#define PCIE_PERF_REQ_GEN1 268#define PCIE_PERF_REQ_GEN2 369#define PCIE_PERF_REQ_GEN3 47071enum PHM_BackEnd_Magic {72PHM_Dummy_Magic = 0xAA5555AA,73PHM_RV770_Magic = 0xDCBAABCD,74PHM_Kong_Magic = 0x239478DF,75PHM_NIslands_Magic = 0x736C494E,76PHM_Sumo_Magic = 0x8339FA11,77PHM_SIslands_Magic = 0x369431AC,78PHM_Trinity_Magic = 0x96751873,79PHM_CIslands_Magic = 0x38AC78B0,80PHM_Kv_Magic = 0xDCBBABC0,81PHM_VIslands_Magic = 0x20130307,82PHM_Cz_Magic = 0x67DCBA25,83PHM_Rv_Magic = 0x2016112184};8586struct phm_set_power_state_input {87const struct pp_hw_power_state *pcurrent_state;88const struct pp_hw_power_state *pnew_state;89};9091struct phm_clock_array {92uint32_t count;93uint32_t values[];94};9596struct phm_clock_voltage_dependency_record {97uint32_t clk;98uint32_t v;99};100101struct phm_vceclock_voltage_dependency_record {102uint32_t ecclk;103uint32_t evclk;104uint32_t v;105};106107struct phm_uvdclock_voltage_dependency_record {108uint32_t vclk;109uint32_t dclk;110uint32_t v;111};112113struct phm_samuclock_voltage_dependency_record {114uint32_t samclk;115uint32_t v;116};117118struct phm_acpclock_voltage_dependency_record {119uint32_t acpclk;120uint32_t v;121};122123struct phm_clock_voltage_dependency_table {124uint32_t count;125struct phm_clock_voltage_dependency_record entries[];126};127128struct phm_phase_shedding_limits_record {129uint32_t Voltage;130uint32_t Sclk;131uint32_t Mclk;132};133134struct phm_uvd_clock_voltage_dependency_record {135uint32_t vclk;136uint32_t dclk;137uint32_t v;138};139140struct phm_uvd_clock_voltage_dependency_table {141uint8_t count;142struct phm_uvd_clock_voltage_dependency_record entries[];143};144145struct phm_acp_clock_voltage_dependency_record {146uint32_t acpclk;147uint32_t v;148};149150struct phm_acp_clock_voltage_dependency_table {151uint32_t count;152struct phm_acp_clock_voltage_dependency_record entries[];153};154155struct phm_vce_clock_voltage_dependency_record {156uint32_t ecclk;157uint32_t evclk;158uint32_t v;159};160161struct phm_phase_shedding_limits_table {162uint32_t count;163struct phm_phase_shedding_limits_record entries[];164};165166struct phm_vceclock_voltage_dependency_table {167uint8_t count;168struct phm_vceclock_voltage_dependency_record entries[];169};170171struct phm_uvdclock_voltage_dependency_table {172uint8_t count;173struct phm_uvdclock_voltage_dependency_record entries[];174};175176struct phm_samuclock_voltage_dependency_table {177uint8_t count;178struct phm_samuclock_voltage_dependency_record entries[];179};180181struct phm_acpclock_voltage_dependency_table {182uint32_t count;183struct phm_acpclock_voltage_dependency_record entries[];184};185186struct phm_vce_clock_voltage_dependency_table {187uint8_t count;188struct phm_vce_clock_voltage_dependency_record entries[];189};190191192enum SMU_ASIC_RESET_MODE {193SMU_ASIC_RESET_MODE_0,194SMU_ASIC_RESET_MODE_1,195SMU_ASIC_RESET_MODE_2,196};197198struct pp_smumgr_func {199char *name;200int (*smu_init)(struct pp_hwmgr *hwmgr);201int (*smu_fini)(struct pp_hwmgr *hwmgr);202int (*start_smu)(struct pp_hwmgr *hwmgr);203int (*check_fw_load_finish)(struct pp_hwmgr *hwmgr,204uint32_t firmware);205int (*request_smu_load_fw)(struct pp_hwmgr *hwmgr);206int (*request_smu_load_specific_fw)(struct pp_hwmgr *hwmgr,207uint32_t firmware);208uint32_t (*get_argument)(struct pp_hwmgr *hwmgr);209int (*send_msg_to_smc)(struct pp_hwmgr *hwmgr, uint16_t msg);210int (*send_msg_to_smc_with_parameter)(struct pp_hwmgr *hwmgr,211uint16_t msg, uint32_t parameter);212int (*download_pptable_settings)(struct pp_hwmgr *hwmgr,213void **table);214int (*upload_pptable_settings)(struct pp_hwmgr *hwmgr);215int (*update_smc_table)(struct pp_hwmgr *hwmgr, uint32_t type);216int (*process_firmware_header)(struct pp_hwmgr *hwmgr);217int (*update_sclk_threshold)(struct pp_hwmgr *hwmgr);218int (*thermal_setup_fan_table)(struct pp_hwmgr *hwmgr);219int (*thermal_avfs_enable)(struct pp_hwmgr *hwmgr);220int (*init_smc_table)(struct pp_hwmgr *hwmgr);221int (*populate_all_graphic_levels)(struct pp_hwmgr *hwmgr);222int (*populate_all_memory_levels)(struct pp_hwmgr *hwmgr);223int (*initialize_mc_reg_table)(struct pp_hwmgr *hwmgr);224uint32_t (*get_offsetof)(uint32_t type, uint32_t member);225uint32_t (*get_mac_definition)(uint32_t value);226bool (*is_dpm_running)(struct pp_hwmgr *hwmgr);227bool (*is_hw_avfs_present)(struct pp_hwmgr *hwmgr);228int (*update_dpm_settings)(struct pp_hwmgr *hwmgr, void *profile_setting);229int (*smc_table_manager)(struct pp_hwmgr *hwmgr, uint8_t *table, uint16_t table_id, bool rw); /*rw: true for read, false for write */230int (*stop_smc)(struct pp_hwmgr *hwmgr);231};232233struct pp_hwmgr_func {234int (*backend_init)(struct pp_hwmgr *hw_mgr);235int (*backend_fini)(struct pp_hwmgr *hw_mgr);236int (*asic_setup)(struct pp_hwmgr *hw_mgr);237int (*get_power_state_size)(struct pp_hwmgr *hw_mgr);238239int (*apply_state_adjust_rules)(struct pp_hwmgr *hwmgr,240struct pp_power_state *prequest_ps,241const struct pp_power_state *pcurrent_ps);242243int (*apply_clocks_adjust_rules)(struct pp_hwmgr *hwmgr);244245int (*force_dpm_level)(struct pp_hwmgr *hw_mgr,246enum amd_dpm_forced_level level);247248int (*dynamic_state_management_enable)(249struct pp_hwmgr *hw_mgr);250int (*dynamic_state_management_disable)(251struct pp_hwmgr *hw_mgr);252253int (*patch_boot_state)(struct pp_hwmgr *hwmgr,254struct pp_hw_power_state *hw_ps);255256int (*get_pp_table_entry)(struct pp_hwmgr *hwmgr,257unsigned long, struct pp_power_state *);258int (*get_num_of_pp_table_entries)(struct pp_hwmgr *hwmgr);259void (*powergate_vce)(struct pp_hwmgr *hwmgr, bool bgate);260void (*powergate_uvd)(struct pp_hwmgr *hwmgr, bool bgate);261void (*powergate_acp)(struct pp_hwmgr *hwmgr, bool bgate);262uint32_t (*get_mclk)(struct pp_hwmgr *hwmgr, bool low);263uint32_t (*get_sclk)(struct pp_hwmgr *hwmgr, bool low);264int (*power_state_set)(struct pp_hwmgr *hwmgr,265const void *state);266int (*notify_smc_display_config_after_ps_adjustment)(struct pp_hwmgr *hwmgr);267int (*pre_display_config_changed)(struct pp_hwmgr *hwmgr);268int (*display_config_changed)(struct pp_hwmgr *hwmgr);269int (*disable_clock_power_gating)(struct pp_hwmgr *hwmgr);270int (*update_clock_gatings)(struct pp_hwmgr *hwmgr,271const uint32_t *msg_id);272int (*set_max_fan_rpm_output)(struct pp_hwmgr *hwmgr, uint16_t us_max_fan_pwm);273int (*set_max_fan_pwm_output)(struct pp_hwmgr *hwmgr, uint16_t us_max_fan_pwm);274int (*stop_thermal_controller)(struct pp_hwmgr *hwmgr);275int (*get_fan_speed_info)(struct pp_hwmgr *hwmgr, struct phm_fan_speed_info *fan_speed_info);276void (*set_fan_control_mode)(struct pp_hwmgr *hwmgr, uint32_t mode);277uint32_t (*get_fan_control_mode)(struct pp_hwmgr *hwmgr);278int (*set_fan_speed_pwm)(struct pp_hwmgr *hwmgr, uint32_t speed);279int (*get_fan_speed_pwm)(struct pp_hwmgr *hwmgr, uint32_t *speed);280int (*set_fan_speed_rpm)(struct pp_hwmgr *hwmgr, uint32_t speed);281int (*get_fan_speed_rpm)(struct pp_hwmgr *hwmgr, uint32_t *speed);282int (*reset_fan_speed_to_default)(struct pp_hwmgr *hwmgr);283int (*uninitialize_thermal_controller)(struct pp_hwmgr *hwmgr);284int (*register_irq_handlers)(struct pp_hwmgr *hwmgr);285bool (*check_smc_update_required_for_display_configuration)(struct pp_hwmgr *hwmgr);286int (*check_states_equal)(struct pp_hwmgr *hwmgr,287const struct pp_hw_power_state *pstate1,288const struct pp_hw_power_state *pstate2,289bool *equal);290int (*set_cpu_power_state)(struct pp_hwmgr *hwmgr);291int (*store_cc6_data)(struct pp_hwmgr *hwmgr, uint32_t separation_time,292bool cc6_disable, bool pstate_disable,293bool pstate_switch_disable);294int (*get_dal_power_level)(struct pp_hwmgr *hwmgr,295struct amd_pp_simple_clock_info *info);296int (*get_performance_level)(struct pp_hwmgr *, const struct pp_hw_power_state *,297PHM_PerformanceLevelDesignation, uint32_t, PHM_PerformanceLevel *);298int (*get_current_shallow_sleep_clocks)(struct pp_hwmgr *hwmgr,299const struct pp_hw_power_state *state, struct pp_clock_info *clock_info);300int (*get_clock_by_type)(struct pp_hwmgr *hwmgr, enum amd_pp_clock_type type, struct amd_pp_clocks *clocks);301int (*get_clock_by_type_with_latency)(struct pp_hwmgr *hwmgr,302enum amd_pp_clock_type type,303struct pp_clock_levels_with_latency *clocks);304int (*get_clock_by_type_with_voltage)(struct pp_hwmgr *hwmgr,305enum amd_pp_clock_type type,306struct pp_clock_levels_with_voltage *clocks);307int (*set_watermarks_for_clocks_ranges)(struct pp_hwmgr *hwmgr, void *clock_ranges);308int (*display_clock_voltage_request)(struct pp_hwmgr *hwmgr,309struct pp_display_clock_request *clock);310int (*get_max_high_clocks)(struct pp_hwmgr *hwmgr, struct amd_pp_simple_clock_info *clocks);311int (*power_off_asic)(struct pp_hwmgr *hwmgr);312int (*force_clock_level)(struct pp_hwmgr *hwmgr, enum pp_clock_type type, uint32_t mask);313int (*emit_clock_levels)(struct pp_hwmgr *hwmgr,314enum pp_clock_type type, char *buf, int *offset);315int (*print_clock_levels)(struct pp_hwmgr *hwmgr, enum pp_clock_type type, char *buf);316int (*powergate_gfx)(struct pp_hwmgr *hwmgr, bool enable);317int (*get_sclk_od)(struct pp_hwmgr *hwmgr);318int (*set_sclk_od)(struct pp_hwmgr *hwmgr, uint32_t value);319int (*get_mclk_od)(struct pp_hwmgr *hwmgr);320int (*set_mclk_od)(struct pp_hwmgr *hwmgr, uint32_t value);321int (*read_sensor)(struct pp_hwmgr *hwmgr, int idx, void *value, int *size);322int (*avfs_control)(struct pp_hwmgr *hwmgr, bool enable);323int (*disable_smc_firmware_ctf)(struct pp_hwmgr *hwmgr);324int (*set_active_display_count)(struct pp_hwmgr *hwmgr, uint32_t count);325int (*set_min_deep_sleep_dcefclk)(struct pp_hwmgr *hwmgr, uint32_t clock);326int (*start_thermal_controller)(struct pp_hwmgr *hwmgr, struct PP_TemperatureRange *range);327int (*notify_cac_buffer_info)(struct pp_hwmgr *hwmgr,328uint32_t virtual_addr_low,329uint32_t virtual_addr_hi,330uint32_t mc_addr_low,331uint32_t mc_addr_hi,332uint32_t size);333int (*get_thermal_temperature_range)(struct pp_hwmgr *hwmgr,334struct PP_TemperatureRange *range);335int (*get_power_profile_mode)(struct pp_hwmgr *hwmgr, char *buf);336int (*set_power_profile_mode)(struct pp_hwmgr *hwmgr, long *input, uint32_t size);337int (*odn_edit_dpm_table)(struct pp_hwmgr *hwmgr,338enum PP_OD_DPM_TABLE_COMMAND type,339long *input, uint32_t size);340int (*set_fine_grain_clk_vol)(struct pp_hwmgr *hwmgr,341enum PP_OD_DPM_TABLE_COMMAND type,342long *input, uint32_t size);343int (*set_power_limit)(struct pp_hwmgr *hwmgr, uint32_t n);344int (*powergate_mmhub)(struct pp_hwmgr *hwmgr);345int (*smus_notify_pwe)(struct pp_hwmgr *hwmgr);346int (*powergate_sdma)(struct pp_hwmgr *hwmgr, bool bgate);347int (*enable_mgpu_fan_boost)(struct pp_hwmgr *hwmgr);348int (*set_hard_min_dcefclk_by_freq)(struct pp_hwmgr *hwmgr, uint32_t clock);349int (*set_hard_min_fclk_by_freq)(struct pp_hwmgr *hwmgr, uint32_t clock);350int (*set_hard_min_gfxclk_by_freq)(struct pp_hwmgr *hwmgr, uint32_t clock);351int (*set_soft_max_gfxclk_by_freq)(struct pp_hwmgr *hwmgr, uint32_t clock);352int (*get_bamaco_support)(struct pp_hwmgr *hwmgr);353int (*get_asic_baco_state)(struct pp_hwmgr *hwmgr, enum BACO_STATE *state);354int (*set_asic_baco_state)(struct pp_hwmgr *hwmgr, enum BACO_STATE state);355int (*get_ppfeature_status)(struct pp_hwmgr *hwmgr, char *buf);356int (*set_ppfeature_status)(struct pp_hwmgr *hwmgr, uint64_t ppfeature_masks);357int (*set_mp1_state)(struct pp_hwmgr *hwmgr, enum pp_mp1_state mp1_state);358int (*asic_reset)(struct pp_hwmgr *hwmgr, enum SMU_ASIC_RESET_MODE mode);359int (*smu_i2c_bus_access)(struct pp_hwmgr *hwmgr, bool acquire);360int (*set_df_cstate)(struct pp_hwmgr *hwmgr, enum pp_df_cstate state);361int (*set_xgmi_pstate)(struct pp_hwmgr *hwmgr, uint32_t pstate);362int (*disable_power_features_for_compute_performance)(struct pp_hwmgr *hwmgr,363bool disable);364ssize_t (*get_gpu_metrics)(struct pp_hwmgr *hwmgr, void **table);365int (*gfx_state_change)(struct pp_hwmgr *hwmgr, uint32_t state);366};367368struct pp_table_func {369int (*pptable_init)(struct pp_hwmgr *hw_mgr);370int (*pptable_fini)(struct pp_hwmgr *hw_mgr);371int (*pptable_get_number_of_vce_state_table_entries)(struct pp_hwmgr *hw_mgr);372int (*pptable_get_vce_state_table_entry)(373struct pp_hwmgr *hwmgr,374unsigned long i,375struct amd_vce_state *vce_state,376void **clock_info,377unsigned long *flag);378};379380union phm_cac_leakage_record {381struct {382uint16_t Vddc; /* in CI, we use it for StdVoltageHiSidd */383uint32_t Leakage; /* in CI, we use it for StdVoltageLoSidd */384};385struct {386uint16_t Vddc1;387uint16_t Vddc2;388uint16_t Vddc3;389};390};391392struct phm_cac_leakage_table {393uint32_t count;394union phm_cac_leakage_record entries[];395};396397struct phm_samu_clock_voltage_dependency_record {398uint32_t samclk;399uint32_t v;400};401402403struct phm_samu_clock_voltage_dependency_table {404uint8_t count;405struct phm_samu_clock_voltage_dependency_record entries[];406};407408struct phm_cac_tdp_table {409uint16_t usTDP;410uint16_t usConfigurableTDP;411uint16_t usTDC;412uint16_t usBatteryPowerLimit;413uint16_t usSmallPowerLimit;414uint16_t usLowCACLeakage;415uint16_t usHighCACLeakage;416uint16_t usMaximumPowerDeliveryLimit;417uint16_t usEDCLimit;418uint16_t usOperatingTempMinLimit;419uint16_t usOperatingTempMaxLimit;420uint16_t usOperatingTempStep;421uint16_t usOperatingTempHyst;422uint16_t usDefaultTargetOperatingTemp;423uint16_t usTargetOperatingTemp;424uint16_t usPowerTuneDataSetID;425uint16_t usSoftwareShutdownTemp;426uint16_t usClockStretchAmount;427uint16_t usTemperatureLimitHotspot;428uint16_t usTemperatureLimitLiquid1;429uint16_t usTemperatureLimitLiquid2;430uint16_t usTemperatureLimitVrVddc;431uint16_t usTemperatureLimitVrMvdd;432uint16_t usTemperatureLimitPlx;433uint8_t ucLiquid1_I2C_address;434uint8_t ucLiquid2_I2C_address;435uint8_t ucLiquid_I2C_Line;436uint8_t ucVr_I2C_address;437uint8_t ucVr_I2C_Line;438uint8_t ucPlx_I2C_address;439uint8_t ucPlx_I2C_Line;440uint32_t usBoostPowerLimit;441uint8_t ucCKS_LDO_REFSEL;442uint8_t ucHotSpotOnly;443};444445struct phm_tdp_table {446uint16_t usTDP;447uint16_t usConfigurableTDP;448uint16_t usTDC;449uint16_t usBatteryPowerLimit;450uint16_t usSmallPowerLimit;451uint16_t usLowCACLeakage;452uint16_t usHighCACLeakage;453uint16_t usMaximumPowerDeliveryLimit;454uint16_t usEDCLimit;455uint16_t usOperatingTempMinLimit;456uint16_t usOperatingTempMaxLimit;457uint16_t usOperatingTempStep;458uint16_t usOperatingTempHyst;459uint16_t usDefaultTargetOperatingTemp;460uint16_t usTargetOperatingTemp;461uint16_t usPowerTuneDataSetID;462uint16_t usSoftwareShutdownTemp;463uint16_t usClockStretchAmount;464uint16_t usTemperatureLimitTedge;465uint16_t usTemperatureLimitHotspot;466uint16_t usTemperatureLimitLiquid1;467uint16_t usTemperatureLimitLiquid2;468uint16_t usTemperatureLimitHBM;469uint16_t usTemperatureLimitVrVddc;470uint16_t usTemperatureLimitVrMvdd;471uint16_t usTemperatureLimitPlx;472uint8_t ucLiquid1_I2C_address;473uint8_t ucLiquid2_I2C_address;474uint8_t ucLiquid_I2C_Line;475uint8_t ucVr_I2C_address;476uint8_t ucVr_I2C_Line;477uint8_t ucPlx_I2C_address;478uint8_t ucPlx_I2C_Line;479uint8_t ucLiquid_I2C_LineSDA;480uint8_t ucVr_I2C_LineSDA;481uint8_t ucPlx_I2C_LineSDA;482uint32_t usBoostPowerLimit;483uint16_t usBoostStartTemperature;484uint16_t usBoostStopTemperature;485uint32_t ulBoostClock;486};487488struct phm_ppm_table {489uint8_t ppm_design;490uint16_t cpu_core_number;491uint32_t platform_tdp;492uint32_t small_ac_platform_tdp;493uint32_t platform_tdc;494uint32_t small_ac_platform_tdc;495uint32_t apu_tdp;496uint32_t dgpu_tdp;497uint32_t dgpu_ulv_power;498uint32_t tj_max;499};500501struct phm_vq_budgeting_record {502uint32_t ulCUs;503uint32_t ulSustainableSOCPowerLimitLow;504uint32_t ulSustainableSOCPowerLimitHigh;505uint32_t ulMinSclkLow;506uint32_t ulMinSclkHigh;507uint8_t ucDispConfig;508uint32_t ulDClk;509uint32_t ulEClk;510uint32_t ulSustainableSclk;511uint32_t ulSustainableCUs;512};513514struct phm_vq_budgeting_table {515uint8_t numEntries;516struct phm_vq_budgeting_record entries[0];517};518519struct phm_clock_and_voltage_limits {520uint32_t sclk;521uint32_t mclk;522uint32_t gfxclk;523uint16_t vddc;524uint16_t vddci;525uint16_t vddgfx;526uint16_t vddmem;527};528529/* Structure to hold PPTable information */530531struct phm_ppt_v1_information {532struct phm_ppt_v1_clock_voltage_dependency_table *vdd_dep_on_sclk;533struct phm_ppt_v1_clock_voltage_dependency_table *vdd_dep_on_mclk;534struct phm_ppt_v1_clock_voltage_dependency_table *vdd_dep_on_socclk;535struct phm_ppt_v1_clock_voltage_dependency_table *vdd_dep_on_dcefclk;536struct phm_clock_array *valid_sclk_values;537struct phm_clock_array *valid_mclk_values;538struct phm_clock_array *valid_socclk_values;539struct phm_clock_array *valid_dcefclk_values;540struct phm_clock_and_voltage_limits max_clock_voltage_on_dc;541struct phm_clock_and_voltage_limits max_clock_voltage_on_ac;542struct phm_clock_voltage_dependency_table *vddc_dep_on_dal_pwrl;543struct phm_ppm_table *ppm_parameter_table;544struct phm_cac_tdp_table *cac_dtp_table;545struct phm_tdp_table *tdp_table;546struct phm_ppt_v1_mm_clock_voltage_dependency_table *mm_dep_table;547struct phm_ppt_v1_voltage_lookup_table *vddc_lookup_table;548struct phm_ppt_v1_voltage_lookup_table *vddgfx_lookup_table;549struct phm_ppt_v1_voltage_lookup_table *vddmem_lookup_table;550struct phm_ppt_v1_pcie_table *pcie_table;551struct phm_ppt_v1_gpio_table *gpio_table;552uint16_t us_ulv_voltage_offset;553uint16_t us_ulv_smnclk_did;554uint16_t us_ulv_mp1clk_did;555uint16_t us_ulv_gfxclk_bypass;556uint16_t us_gfxclk_slew_rate;557uint16_t us_min_gfxclk_freq_limit;558};559560struct phm_ppt_v2_information {561struct phm_ppt_v1_clock_voltage_dependency_table *vdd_dep_on_sclk;562struct phm_ppt_v1_clock_voltage_dependency_table *vdd_dep_on_mclk;563struct phm_ppt_v1_clock_voltage_dependency_table *vdd_dep_on_socclk;564struct phm_ppt_v1_clock_voltage_dependency_table *vdd_dep_on_dcefclk;565struct phm_ppt_v1_clock_voltage_dependency_table *vdd_dep_on_pixclk;566struct phm_ppt_v1_clock_voltage_dependency_table *vdd_dep_on_dispclk;567struct phm_ppt_v1_clock_voltage_dependency_table *vdd_dep_on_phyclk;568struct phm_ppt_v1_mm_clock_voltage_dependency_table *mm_dep_table;569570struct phm_clock_voltage_dependency_table *vddc_dep_on_dalpwrl;571572struct phm_clock_array *valid_sclk_values;573struct phm_clock_array *valid_mclk_values;574struct phm_clock_array *valid_socclk_values;575struct phm_clock_array *valid_dcefclk_values;576577struct phm_clock_and_voltage_limits max_clock_voltage_on_dc;578struct phm_clock_and_voltage_limits max_clock_voltage_on_ac;579580struct phm_ppm_table *ppm_parameter_table;581struct phm_cac_tdp_table *cac_dtp_table;582struct phm_tdp_table *tdp_table;583584struct phm_ppt_v1_voltage_lookup_table *vddc_lookup_table;585struct phm_ppt_v1_voltage_lookup_table *vddgfx_lookup_table;586struct phm_ppt_v1_voltage_lookup_table *vddmem_lookup_table;587struct phm_ppt_v1_voltage_lookup_table *vddci_lookup_table;588589struct phm_ppt_v1_pcie_table *pcie_table;590591uint16_t us_ulv_voltage_offset;592uint16_t us_ulv_smnclk_did;593uint16_t us_ulv_mp1clk_did;594uint16_t us_ulv_gfxclk_bypass;595uint16_t us_gfxclk_slew_rate;596uint16_t us_min_gfxclk_freq_limit;597598uint8_t uc_gfx_dpm_voltage_mode;599uint8_t uc_soc_dpm_voltage_mode;600uint8_t uc_uclk_dpm_voltage_mode;601uint8_t uc_uvd_dpm_voltage_mode;602uint8_t uc_vce_dpm_voltage_mode;603uint8_t uc_mp0_dpm_voltage_mode;604uint8_t uc_dcef_dpm_voltage_mode;605};606607struct phm_ppt_v3_information {608uint8_t uc_thermal_controller_type;609610uint16_t us_small_power_limit1;611uint16_t us_small_power_limit2;612uint16_t us_boost_power_limit;613614uint16_t us_od_turbo_power_limit;615uint16_t us_od_powersave_power_limit;616uint16_t us_software_shutdown_temp;617618uint32_t *power_saving_clock_max;619uint32_t *power_saving_clock_min;620621uint8_t *od_feature_capabilities;622uint32_t *od_settings_max;623uint32_t *od_settings_min;624625void *smc_pptable;626};627628struct phm_dynamic_state_info {629struct phm_clock_voltage_dependency_table *vddc_dependency_on_sclk;630struct phm_clock_voltage_dependency_table *vddci_dependency_on_mclk;631struct phm_clock_voltage_dependency_table *vddc_dependency_on_mclk;632struct phm_clock_voltage_dependency_table *mvdd_dependency_on_mclk;633struct phm_clock_voltage_dependency_table *vddc_dep_on_dal_pwrl;634struct phm_clock_array *valid_sclk_values;635struct phm_clock_array *valid_mclk_values;636struct phm_clock_and_voltage_limits max_clock_voltage_on_dc;637struct phm_clock_and_voltage_limits max_clock_voltage_on_ac;638uint32_t mclk_sclk_ratio;639uint32_t sclk_mclk_delta;640uint32_t vddc_vddci_delta;641uint32_t min_vddc_for_pcie_gen2;642struct phm_cac_leakage_table *cac_leakage_table;643struct phm_phase_shedding_limits_table *vddc_phase_shed_limits_table;644645struct phm_vce_clock_voltage_dependency_table646*vce_clock_voltage_dependency_table;647struct phm_uvd_clock_voltage_dependency_table648*uvd_clock_voltage_dependency_table;649struct phm_acp_clock_voltage_dependency_table650*acp_clock_voltage_dependency_table;651struct phm_samu_clock_voltage_dependency_table652*samu_clock_voltage_dependency_table;653654struct phm_ppm_table *ppm_parameter_table;655struct phm_cac_tdp_table *cac_dtp_table;656struct phm_clock_voltage_dependency_table *vdd_gfx_dependency_on_sclk;657};658659struct pp_fan_info {660bool bNoFan;661uint8_t ucTachometerPulsesPerRevolution;662uint32_t ulMinRPM;663uint32_t ulMaxRPM;664};665666struct pp_advance_fan_control_parameters {667uint16_t usTMin; /* The temperature, in 0.01 centigrades, below which we just run at a minimal PWM. */668uint16_t usTMed; /* The middle temperature where we change slopes. */669uint16_t usTHigh; /* The high temperature for setting the second slope. */670uint16_t usPWMMin; /* The minimum PWM value in percent (0.01% increments). */671uint16_t usPWMMed; /* The PWM value (in percent) at TMed. */672uint16_t usPWMHigh; /* The PWM value at THigh. */673uint8_t ucTHyst; /* Temperature hysteresis. Integer. */674uint32_t ulCycleDelay; /* The time between two invocations of the fan control routine in microseconds. */675uint16_t usTMax; /* The max temperature */676uint8_t ucFanControlMode;677uint16_t usFanPWMMinLimit;678uint16_t usFanPWMMaxLimit;679uint16_t usFanPWMStep;680uint16_t usDefaultMaxFanPWM;681uint16_t usFanOutputSensitivity;682uint16_t usDefaultFanOutputSensitivity;683uint16_t usMaxFanPWM; /* The max Fan PWM value for Fuzzy Fan Control feature */684uint16_t usFanRPMMinLimit; /* Minimum limit range in percentage, need to calculate based on minRPM/MaxRpm */685uint16_t usFanRPMMaxLimit; /* Maximum limit range in percentage, usually set to 100% by default */686uint16_t usFanRPMStep; /* Step increments/decerements, in percent */687uint16_t usDefaultMaxFanRPM; /* The max Fan RPM value for Fuzzy Fan Control feature, default from PPTable */688uint16_t usMaxFanRPM; /* The max Fan RPM value for Fuzzy Fan Control feature, user defined */689uint16_t usFanCurrentLow; /* Low current */690uint16_t usFanCurrentHigh; /* High current */691uint16_t usFanRPMLow; /* Low RPM */692uint16_t usFanRPMHigh; /* High RPM */693uint32_t ulMinFanSCLKAcousticLimit; /* Minimum Fan Controller SCLK Frequency Acoustic Limit. */694uint8_t ucTargetTemperature; /* Advanced fan controller target temperature. */695uint8_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. */696uint16_t usFanGainEdge; /* The following is added for Fiji */697uint16_t usFanGainHotspot;698uint16_t usFanGainLiquid;699uint16_t usFanGainVrVddc;700uint16_t usFanGainVrMvdd;701uint16_t usFanGainPlx;702uint16_t usFanGainHbm;703uint8_t ucEnableZeroRPM;704uint8_t ucFanStopTemperature;705uint8_t ucFanStartTemperature;706uint32_t ulMaxFanSCLKAcousticLimit; /* Maximum Fan Controller SCLK Frequency Acoustic Limit. */707uint32_t ulTargetGfxClk;708uint16_t usZeroRPMStartTemperature;709uint16_t usZeroRPMStopTemperature;710uint16_t usMGpuThrottlingRPMLimit;711};712713struct pp_thermal_controller_info {714uint8_t ucType;715uint8_t ucI2cLine;716uint8_t ucI2cAddress;717uint8_t use_hw_fan_control;718struct pp_fan_info fanInfo;719struct pp_advance_fan_control_parameters advanceFanControlParameters;720};721722struct phm_microcode_version_info {723uint32_t SMC;724uint32_t DMCU;725uint32_t MC;726uint32_t NB;727};728729enum PP_TABLE_VERSION {730PP_TABLE_V0 = 0,731PP_TABLE_V1,732PP_TABLE_V2,733PP_TABLE_MAX734};735736/**737* The main hardware manager structure.738*/739#define Workload_Policy_Max 6740741struct pp_hwmgr {742void *adev;743uint32_t chip_family;744uint32_t chip_id;745uint32_t smu_version;746bool not_vf;747bool pm_en;748bool pp_one_vf;749struct mutex msg_lock;750751uint32_t pp_table_version;752void *device;753struct pp_smumgr *smumgr;754const void *soft_pp_table;755uint32_t soft_pp_table_size;756void *hardcode_pp_table;757bool need_pp_table_upload;758759struct amd_vce_state vce_states[AMD_MAX_VCE_LEVELS];760uint32_t num_vce_state_tables;761762enum amd_dpm_forced_level dpm_level;763enum amd_dpm_forced_level saved_dpm_level;764enum amd_dpm_forced_level request_dpm_level;765uint32_t usec_timeout;766void *pptable;767struct phm_platform_descriptor platform_descriptor;768void *backend;769770void *smu_backend;771const struct pp_smumgr_func *smumgr_funcs;772bool is_kicker;773774enum PP_DAL_POWERLEVEL dal_power_level;775struct phm_dynamic_state_info dyn_state;776const struct pp_hwmgr_func *hwmgr_func;777const struct pp_table_func *pptable_func;778779struct pp_power_state *ps;780uint32_t num_ps;781struct pp_thermal_controller_info thermal_controller;782bool fan_ctrl_is_in_default_mode;783uint32_t fan_ctrl_default_mode;784bool fan_ctrl_enabled;785uint32_t tmin;786struct phm_microcode_version_info microcode_version_info;787uint32_t ps_size;788struct pp_power_state *current_ps;789struct pp_power_state *request_ps;790struct pp_power_state *boot_ps;791struct pp_power_state *uvd_ps;792const struct amd_pp_display_configuration *display_config;793uint32_t feature_mask;794bool avfs_supported;795/* UMD Pstate */796bool en_umd_pstate;797uint32_t power_profile_mode;798uint32_t default_power_profile_mode;799uint32_t pstate_sclk;800uint32_t pstate_mclk;801bool od_enabled;802uint32_t power_limit;803uint32_t default_power_limit;804uint32_t workload_mask;805uint32_t workload_prority[Workload_Policy_Max];806uint32_t workload_setting[Workload_Policy_Max];807bool gfxoff_state_changed_by_workload;808uint32_t pstate_sclk_peak;809uint32_t pstate_mclk_peak;810811struct delayed_work swctf_delayed_work;812};813814int hwmgr_early_init(struct pp_hwmgr *hwmgr);815int hwmgr_sw_init(struct pp_hwmgr *hwmgr);816int hwmgr_sw_fini(struct pp_hwmgr *hwmgr);817int hwmgr_hw_init(struct pp_hwmgr *hwmgr);818int hwmgr_hw_fini(struct pp_hwmgr *hwmgr);819int hwmgr_suspend(struct pp_hwmgr *hwmgr);820int hwmgr_resume(struct pp_hwmgr *hwmgr);821822int hwmgr_handle_task(struct pp_hwmgr *hwmgr,823enum amd_pp_task task_id,824enum amd_pm_state_type *user_state);825826827#define PHM_ENTIRE_REGISTER_MASK 0xFFFFFFFFU828829int smu7_init_function_pointers(struct pp_hwmgr *hwmgr);830int smu8_init_function_pointers(struct pp_hwmgr *hwmgr);831int vega12_hwmgr_init(struct pp_hwmgr *hwmgr);832int vega20_hwmgr_init(struct pp_hwmgr *hwmgr);833834#endif /* _HWMGR_H_ */835836837