0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 #ifndef _HARDWARE_MANAGER_H_
0024 #define _HARDWARE_MANAGER_H_
0025
0026
0027
0028 struct pp_hwmgr;
0029 struct pp_hw_power_state;
0030 struct pp_power_state;
0031 enum amd_dpm_forced_level;
0032 struct PP_TemperatureRange;
0033
0034
0035 struct phm_fan_speed_info {
0036 uint32_t min_percent;
0037 uint32_t max_percent;
0038 uint32_t min_rpm;
0039 uint32_t max_rpm;
0040 bool supports_percent_read;
0041 bool supports_percent_write;
0042 bool supports_rpm_read;
0043 bool supports_rpm_write;
0044 };
0045
0046
0047 enum PHM_AutoThrottleSource
0048 {
0049 PHM_AutoThrottleSource_Thermal,
0050 PHM_AutoThrottleSource_External
0051 };
0052
0053 typedef enum PHM_AutoThrottleSource PHM_AutoThrottleSource;
0054
0055 enum phm_platform_caps {
0056 PHM_PlatformCaps_AtomBiosPpV1 = 0,
0057 PHM_PlatformCaps_PowerPlaySupport,
0058 PHM_PlatformCaps_ACOverdriveSupport,
0059 PHM_PlatformCaps_BacklightSupport,
0060 PHM_PlatformCaps_ThermalController,
0061 PHM_PlatformCaps_BiosPowerSourceControl,
0062 PHM_PlatformCaps_DisableVoltageTransition,
0063 PHM_PlatformCaps_DisableEngineTransition,
0064 PHM_PlatformCaps_DisableMemoryTransition,
0065 PHM_PlatformCaps_DynamicPowerManagement,
0066 PHM_PlatformCaps_EnableASPML0s,
0067 PHM_PlatformCaps_EnableASPML1,
0068 PHM_PlatformCaps_OD5inACSupport,
0069 PHM_PlatformCaps_OD5inDCSupport,
0070 PHM_PlatformCaps_SoftStateOD5,
0071 PHM_PlatformCaps_NoOD5Support,
0072 PHM_PlatformCaps_ContinuousHardwarePerformanceRange,
0073 PHM_PlatformCaps_ActivityReporting,
0074 PHM_PlatformCaps_EnableBackbias,
0075 PHM_PlatformCaps_OverdriveDisabledByPowerBudget,
0076 PHM_PlatformCaps_ShowPowerBudgetWarning,
0077 PHM_PlatformCaps_PowerBudgetWaiverAvailable,
0078 PHM_PlatformCaps_GFXClockGatingSupport,
0079 PHM_PlatformCaps_MMClockGatingSupport,
0080 PHM_PlatformCaps_AutomaticDCTransition,
0081 PHM_PlatformCaps_GeminiPrimary,
0082 PHM_PlatformCaps_MemorySpreadSpectrumSupport,
0083 PHM_PlatformCaps_EngineSpreadSpectrumSupport,
0084 PHM_PlatformCaps_StepVddc,
0085 PHM_PlatformCaps_DynamicPCIEGen2Support,
0086 PHM_PlatformCaps_SMC,
0087 PHM_PlatformCaps_FaultyInternalThermalReading,
0088 PHM_PlatformCaps_EnableVoltageControl,
0089 PHM_PlatformCaps_EnableSideportControl,
0090 PHM_PlatformCaps_VideoPlaybackEEUNotification,
0091 PHM_PlatformCaps_TurnOffPll_ASPML1,
0092 PHM_PlatformCaps_EnableHTLinkControl,
0093 PHM_PlatformCaps_PerformanceStateOnly,
0094 PHM_PlatformCaps_ExclusiveModeAlwaysHigh,
0095 PHM_PlatformCaps_DisableMGClockGating,
0096 PHM_PlatformCaps_DisableMGCGTSSM,
0097 PHM_PlatformCaps_UVDAlwaysHigh,
0098 PHM_PlatformCaps_DisablePowerGating,
0099 PHM_PlatformCaps_CustomThermalPolicy,
0100 PHM_PlatformCaps_StayInBootState,
0101 PHM_PlatformCaps_SMCAllowSeparateSWThermalState,
0102 PHM_PlatformCaps_MultiUVDStateSupport,
0103 PHM_PlatformCaps_EnableSCLKDeepSleepForUVD,
0104 PHM_PlatformCaps_EnableMCUHTLinkControl,
0105 PHM_PlatformCaps_ABM,
0106 PHM_PlatformCaps_KongThermalPolicy,
0107 PHM_PlatformCaps_SwitchVDDNB,
0108 PHM_PlatformCaps_ULPS,
0109 PHM_PlatformCaps_NativeULPS,
0110 PHM_PlatformCaps_EnableMVDDControl,
0111 PHM_PlatformCaps_ControlVDDCI,
0112 PHM_PlatformCaps_DisableDCODT,
0113 PHM_PlatformCaps_DynamicACTiming,
0114 PHM_PlatformCaps_EnableThermalIntByGPIO,
0115 PHM_PlatformCaps_BootStateOnAlert,
0116 PHM_PlatformCaps_DontWaitForVBlankOnAlert,
0117 PHM_PlatformCaps_Force3DClockSupport,
0118 PHM_PlatformCaps_MicrocodeFanControl,
0119 PHM_PlatformCaps_AdjustUVDPriorityForSP,
0120 PHM_PlatformCaps_DisableLightSleep,
0121 PHM_PlatformCaps_DisableMCLS,
0122 PHM_PlatformCaps_RegulatorHot,
0123 PHM_PlatformCaps_BACO,
0124 PHM_PlatformCaps_DisableDPM,
0125 PHM_PlatformCaps_DynamicM3Arbiter,
0126 PHM_PlatformCaps_SclkDeepSleep,
0127 PHM_PlatformCaps_DynamicPatchPowerState,
0128 PHM_PlatformCaps_ThermalAutoThrottling,
0129 PHM_PlatformCaps_SumoThermalPolicy,
0130 PHM_PlatformCaps_PCIEPerformanceRequest,
0131 PHM_PlatformCaps_BLControlledByGPU,
0132 PHM_PlatformCaps_PowerContainment,
0133 PHM_PlatformCaps_SQRamping,
0134 PHM_PlatformCaps_CAC,
0135 PHM_PlatformCaps_NIChipsets,
0136 PHM_PlatformCaps_TrinityChipsets,
0137 PHM_PlatformCaps_EvergreenChipsets,
0138 PHM_PlatformCaps_PowerControl,
0139 PHM_PlatformCaps_DisableLSClockGating,
0140 PHM_PlatformCaps_BoostState,
0141 PHM_PlatformCaps_UserMaxClockForMultiDisplays,
0142 PHM_PlatformCaps_RegWriteDelay,
0143 PHM_PlatformCaps_NonABMSupportInPPLib,
0144 PHM_PlatformCaps_GFXDynamicMGPowerGating,
0145 PHM_PlatformCaps_DisableSMUUVDHandshake,
0146 PHM_PlatformCaps_DTE,
0147 PHM_PlatformCaps_W5100Specifc_SmuSkipMsgDTE,
0148 PHM_PlatformCaps_UVDPowerGating,
0149 PHM_PlatformCaps_UVDDynamicPowerGating,
0150 PHM_PlatformCaps_VCEPowerGating,
0151 PHM_PlatformCaps_SamuPowerGating,
0152 PHM_PlatformCaps_UVDDPM,
0153 PHM_PlatformCaps_VCEDPM,
0154 PHM_PlatformCaps_SamuDPM,
0155 PHM_PlatformCaps_AcpDPM,
0156 PHM_PlatformCaps_SclkDeepSleepAboveLow,
0157 PHM_PlatformCaps_DynamicUVDState,
0158 PHM_PlatformCaps_WantSAMClkWithDummyBackEnd,
0159 PHM_PlatformCaps_WantUVDClkWithDummyBackEnd,
0160 PHM_PlatformCaps_WantVCEClkWithDummyBackEnd,
0161 PHM_PlatformCaps_WantACPClkWithDummyBackEnd,
0162 PHM_PlatformCaps_OD6inACSupport,
0163 PHM_PlatformCaps_OD6inDCSupport,
0164 PHM_PlatformCaps_EnablePlatformPowerManagement,
0165 PHM_PlatformCaps_SurpriseRemoval,
0166 PHM_PlatformCaps_NewCACVoltage,
0167 PHM_PlatformCaps_DiDtSupport,
0168 PHM_PlatformCaps_DBRamping,
0169 PHM_PlatformCaps_TDRamping,
0170 PHM_PlatformCaps_TCPRamping,
0171 PHM_PlatformCaps_DBRRamping,
0172 PHM_PlatformCaps_DiDtEDCEnable,
0173 PHM_PlatformCaps_GCEDC,
0174 PHM_PlatformCaps_PSM,
0175 PHM_PlatformCaps_EnableSMU7ThermalManagement,
0176 PHM_PlatformCaps_FPS,
0177 PHM_PlatformCaps_ACP,
0178 PHM_PlatformCaps_SclkThrottleLowNotification,
0179 PHM_PlatformCaps_XDMAEnabled,
0180 PHM_PlatformCaps_UseDummyBackEnd,
0181 PHM_PlatformCaps_EnableDFSBypass,
0182 PHM_PlatformCaps_VddNBDirectRequest,
0183 PHM_PlatformCaps_PauseMMSessions,
0184 PHM_PlatformCaps_UnTabledHardwareInterface,
0185 PHM_PlatformCaps_SMU7,
0186 PHM_PlatformCaps_RevertGPIO5Polarity,
0187 PHM_PlatformCaps_Thermal2GPIO17,
0188 PHM_PlatformCaps_ThermalOutGPIO,
0189 PHM_PlatformCaps_DisableMclkSwitchingForFrameLock,
0190 PHM_PlatformCaps_ForceMclkHigh,
0191 PHM_PlatformCaps_VRHotGPIOConfigurable,
0192 PHM_PlatformCaps_TempInversion,
0193 PHM_PlatformCaps_IOIC3,
0194 PHM_PlatformCaps_ConnectedStandby,
0195 PHM_PlatformCaps_EVV,
0196 PHM_PlatformCaps_EnableLongIdleBACOSupport,
0197 PHM_PlatformCaps_CombinePCCWithThermalSignal,
0198 PHM_PlatformCaps_DisableUsingActualTemperatureForPowerCalc,
0199 PHM_PlatformCaps_StablePState,
0200 PHM_PlatformCaps_OD6PlusinACSupport,
0201 PHM_PlatformCaps_OD6PlusinDCSupport,
0202 PHM_PlatformCaps_ODThermalLimitUnlock,
0203 PHM_PlatformCaps_ReducePowerLimit,
0204 PHM_PlatformCaps_ODFuzzyFanControlSupport,
0205 PHM_PlatformCaps_GeminiRegulatorFanControlSupport,
0206 PHM_PlatformCaps_ControlVDDGFX,
0207 PHM_PlatformCaps_BBBSupported,
0208 PHM_PlatformCaps_DisableVoltageIsland,
0209 PHM_PlatformCaps_FanSpeedInTableIsRPM,
0210 PHM_PlatformCaps_GFXClockGatingManagedInCAIL,
0211 PHM_PlatformCaps_IcelandULPSSWWorkAround,
0212 PHM_PlatformCaps_FPSEnhancement,
0213 PHM_PlatformCaps_LoadPostProductionFirmware,
0214 PHM_PlatformCaps_VpuRecoveryInProgress,
0215 PHM_PlatformCaps_Falcon_QuickTransition,
0216 PHM_PlatformCaps_AVFS,
0217 PHM_PlatformCaps_ClockStretcher,
0218 PHM_PlatformCaps_TablelessHardwareInterface,
0219 PHM_PlatformCaps_EnableDriverEVV,
0220 PHM_PlatformCaps_SPLLShutdownSupport,
0221 PHM_PlatformCaps_VirtualBatteryState,
0222 PHM_PlatformCaps_IgnoreForceHighClockRequestsInAPUs,
0223 PHM_PlatformCaps_DisableMclkSwitchForVR,
0224 PHM_PlatformCaps_SMU8,
0225 PHM_PlatformCaps_VRHotPolarityHigh,
0226 PHM_PlatformCaps_IPS_UlpsExclusive,
0227 PHM_PlatformCaps_SMCtoPPLIBAcdcGpioScheme,
0228 PHM_PlatformCaps_GeminiAsymmetricPower,
0229 PHM_PlatformCaps_OCLPowerOptimization,
0230 PHM_PlatformCaps_MaxPCIEBandWidth,
0231 PHM_PlatformCaps_PerfPerWattOptimizationSupport,
0232 PHM_PlatformCaps_UVDClientMCTuning,
0233 PHM_PlatformCaps_ODNinACSupport,
0234 PHM_PlatformCaps_ODNinDCSupport,
0235 PHM_PlatformCaps_OD8inACSupport,
0236 PHM_PlatformCaps_OD8inDCSupport,
0237 PHM_PlatformCaps_UMDPState,
0238 PHM_PlatformCaps_AutoWattmanSupport,
0239 PHM_PlatformCaps_AutoWattmanEnable_CCCState,
0240 PHM_PlatformCaps_FreeSyncActive,
0241 PHM_PlatformCaps_EnableShadowPstate,
0242 PHM_PlatformCaps_customThermalManagement,
0243 PHM_PlatformCaps_staticFanControl,
0244 PHM_PlatformCaps_Virtual_System,
0245 PHM_PlatformCaps_LowestUclkReservedForUlv,
0246 PHM_PlatformCaps_EnableBoostState,
0247 PHM_PlatformCaps_AVFSSupport,
0248 PHM_PlatformCaps_ThermalPolicyDelay,
0249 PHM_PlatformCaps_CustomFanControlSupport,
0250 PHM_PlatformCaps_BAMACO,
0251 PHM_PlatformCaps_Max
0252 };
0253
0254 #define PHM_MAX_NUM_CAPS_BITS_PER_FIELD (sizeof(uint32_t)*8)
0255
0256
0257 #define PHM_MAX_NUM_CAPS_ULONG_ENTRIES \
0258 ((PHM_PlatformCaps_Max + ((PHM_MAX_NUM_CAPS_BITS_PER_FIELD) - 1)) / (PHM_MAX_NUM_CAPS_BITS_PER_FIELD))
0259
0260 struct pp_hw_descriptor {
0261 uint32_t hw_caps[PHM_MAX_NUM_CAPS_ULONG_ENTRIES];
0262 };
0263
0264 enum PHM_PerformanceLevelDesignation {
0265 PHM_PerformanceLevelDesignation_Activity,
0266 PHM_PerformanceLevelDesignation_PowerContainment
0267 };
0268
0269 typedef enum PHM_PerformanceLevelDesignation PHM_PerformanceLevelDesignation;
0270
0271 struct PHM_PerformanceLevel {
0272 uint32_t coreClock;
0273 uint32_t memory_clock;
0274 uint32_t vddc;
0275 uint32_t vddci;
0276 uint32_t nonLocalMemoryFreq;
0277 uint32_t nonLocalMemoryWidth;
0278 };
0279
0280 typedef struct PHM_PerformanceLevel PHM_PerformanceLevel;
0281
0282
0283 static inline void phm_cap_set(uint32_t *caps,
0284 enum phm_platform_caps c)
0285 {
0286 caps[c / PHM_MAX_NUM_CAPS_BITS_PER_FIELD] |= (1UL <<
0287 (c & (PHM_MAX_NUM_CAPS_BITS_PER_FIELD - 1)));
0288 }
0289
0290 static inline void phm_cap_unset(uint32_t *caps,
0291 enum phm_platform_caps c)
0292 {
0293 caps[c / PHM_MAX_NUM_CAPS_BITS_PER_FIELD] &= ~(1UL << (c & (PHM_MAX_NUM_CAPS_BITS_PER_FIELD - 1)));
0294 }
0295
0296 static inline bool phm_cap_enabled(const uint32_t *caps, enum phm_platform_caps c)
0297 {
0298 return (0 != (caps[c / PHM_MAX_NUM_CAPS_BITS_PER_FIELD] &
0299 (1UL << (c & (PHM_MAX_NUM_CAPS_BITS_PER_FIELD - 1)))));
0300 }
0301
0302 #define PP_CAP(c) phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, (c))
0303
0304 #define PP_PCIEGenInvalid 0xffff
0305 enum PP_PCIEGen {
0306 PP_PCIEGen1 = 0,
0307 PP_PCIEGen2,
0308 PP_PCIEGen3
0309 };
0310
0311 typedef enum PP_PCIEGen PP_PCIEGen;
0312
0313 #define PP_Min_PCIEGen PP_PCIEGen1
0314 #define PP_Max_PCIEGen PP_PCIEGen3
0315 #define PP_Min_PCIELane 1
0316 #define PP_Max_PCIELane 16
0317
0318 enum phm_clock_Type {
0319 PHM_DispClock = 1,
0320 PHM_SClock,
0321 PHM_MemClock
0322 };
0323
0324 #define MAX_NUM_CLOCKS 16
0325
0326 struct PP_Clocks {
0327 uint32_t engineClock;
0328 uint32_t memoryClock;
0329 uint32_t BusBandwidth;
0330 uint32_t engineClockInSR;
0331 uint32_t dcefClock;
0332 uint32_t dcefClockInSR;
0333 };
0334
0335 struct pp_clock_info {
0336 uint32_t min_mem_clk;
0337 uint32_t max_mem_clk;
0338 uint32_t min_eng_clk;
0339 uint32_t max_eng_clk;
0340 uint32_t min_bus_bandwidth;
0341 uint32_t max_bus_bandwidth;
0342 };
0343
0344 struct phm_platform_descriptor {
0345 uint32_t platformCaps[PHM_MAX_NUM_CAPS_ULONG_ENTRIES];
0346 uint32_t vbiosInterruptId;
0347 struct PP_Clocks overdriveLimit;
0348 struct PP_Clocks clockStep;
0349 uint32_t hardwareActivityPerformanceLevels;
0350 uint32_t minimumClocksReductionPercentage;
0351 uint32_t minOverdriveVDDC;
0352 uint32_t maxOverdriveVDDC;
0353 uint32_t overdriveVDDCStep;
0354 uint32_t hardwarePerformanceLevels;
0355 uint16_t powerBudget;
0356 uint32_t TDPLimit;
0357 uint32_t nearTDPLimit;
0358 uint32_t nearTDPLimitAdjusted;
0359 uint32_t SQRampingThreshold;
0360 uint32_t CACLeakage;
0361 uint16_t TDPODLimit;
0362 uint32_t TDPAdjustment;
0363 bool TDPAdjustmentPolarity;
0364 uint16_t LoadLineSlope;
0365 uint32_t VidMinLimit;
0366 uint32_t VidMaxLimit;
0367 uint32_t VidStep;
0368 uint32_t VidAdjustment;
0369 bool VidAdjustmentPolarity;
0370 };
0371
0372 struct phm_clocks {
0373 uint32_t num_of_entries;
0374 uint32_t clock[MAX_NUM_CLOCKS];
0375 };
0376
0377 #define DPMTABLE_OD_UPDATE_SCLK 0x00000001
0378 #define DPMTABLE_OD_UPDATE_MCLK 0x00000002
0379 #define DPMTABLE_UPDATE_SCLK 0x00000004
0380 #define DPMTABLE_UPDATE_MCLK 0x00000008
0381 #define DPMTABLE_OD_UPDATE_VDDC 0x00000010
0382 #define DPMTABLE_UPDATE_SOCCLK 0x00000020
0383
0384 struct phm_odn_performance_level {
0385 uint32_t clock;
0386 uint32_t vddc;
0387 bool enabled;
0388 };
0389
0390 struct phm_odn_clock_levels {
0391 uint32_t size;
0392 uint32_t options;
0393 uint32_t flags;
0394 uint32_t num_of_pl;
0395
0396 struct phm_odn_performance_level entries[8];
0397 };
0398
0399 extern int phm_disable_clock_power_gatings(struct pp_hwmgr *hwmgr);
0400 extern int phm_powerdown_uvd(struct pp_hwmgr *hwmgr);
0401 extern int phm_setup_asic(struct pp_hwmgr *hwmgr);
0402 extern int phm_enable_dynamic_state_management(struct pp_hwmgr *hwmgr);
0403 extern int phm_disable_dynamic_state_management(struct pp_hwmgr *hwmgr);
0404 extern bool phm_is_hw_access_blocked(struct pp_hwmgr *hwmgr);
0405 extern int phm_block_hw_access(struct pp_hwmgr *hwmgr, bool block);
0406 extern int phm_set_power_state(struct pp_hwmgr *hwmgr,
0407 const struct pp_hw_power_state *pcurrent_state,
0408 const struct pp_hw_power_state *pnew_power_state);
0409
0410 extern int phm_apply_state_adjust_rules(struct pp_hwmgr *hwmgr,
0411 struct pp_power_state *adjusted_ps,
0412 const struct pp_power_state *current_ps);
0413
0414 extern int phm_apply_clock_adjust_rules(struct pp_hwmgr *hwmgr);
0415
0416 extern int phm_force_dpm_levels(struct pp_hwmgr *hwmgr, enum amd_dpm_forced_level level);
0417 extern int phm_pre_display_configuration_changed(struct pp_hwmgr *hwmgr);
0418 extern int phm_display_configuration_changed(struct pp_hwmgr *hwmgr);
0419 extern int phm_notify_smc_display_config_after_ps_adjustment(struct pp_hwmgr *hwmgr);
0420 extern int phm_register_irq_handlers(struct pp_hwmgr *hwmgr);
0421 extern int phm_start_thermal_controller(struct pp_hwmgr *hwmgr);
0422 extern int phm_stop_thermal_controller(struct pp_hwmgr *hwmgr);
0423 extern bool phm_check_smc_update_required_for_display_configuration(struct pp_hwmgr *hwmgr);
0424
0425 extern int phm_check_states_equal(struct pp_hwmgr *hwmgr,
0426 const struct pp_hw_power_state *pstate1,
0427 const struct pp_hw_power_state *pstate2,
0428 bool *equal);
0429
0430 extern int phm_store_dal_configuration_data(struct pp_hwmgr *hwmgr,
0431 const struct amd_pp_display_configuration *display_config);
0432
0433 extern int phm_get_dal_power_level(struct pp_hwmgr *hwmgr,
0434 struct amd_pp_simple_clock_info *info);
0435
0436 extern int phm_set_cpu_power_state(struct pp_hwmgr *hwmgr);
0437
0438 extern int phm_power_down_asic(struct pp_hwmgr *hwmgr);
0439
0440 extern int phm_get_performance_level(struct pp_hwmgr *hwmgr, const struct pp_hw_power_state *state,
0441 PHM_PerformanceLevelDesignation designation, uint32_t index,
0442 PHM_PerformanceLevel *level);
0443
0444 extern int phm_get_clock_info(struct pp_hwmgr *hwmgr, const struct pp_hw_power_state *state,
0445 struct pp_clock_info *pclock_info,
0446 PHM_PerformanceLevelDesignation designation);
0447
0448 extern int phm_get_current_shallow_sleep_clocks(struct pp_hwmgr *hwmgr, const struct pp_hw_power_state *state, struct pp_clock_info *clock_info);
0449
0450 extern int phm_get_clock_by_type(struct pp_hwmgr *hwmgr, enum amd_pp_clock_type type, struct amd_pp_clocks *clocks);
0451
0452 extern int phm_get_clock_by_type_with_latency(struct pp_hwmgr *hwmgr,
0453 enum amd_pp_clock_type type,
0454 struct pp_clock_levels_with_latency *clocks);
0455 extern int phm_get_clock_by_type_with_voltage(struct pp_hwmgr *hwmgr,
0456 enum amd_pp_clock_type type,
0457 struct pp_clock_levels_with_voltage *clocks);
0458 extern int phm_set_watermarks_for_clocks_ranges(struct pp_hwmgr *hwmgr,
0459 void *clock_ranges);
0460 extern int phm_display_clock_voltage_request(struct pp_hwmgr *hwmgr,
0461 struct pp_display_clock_request *clock);
0462
0463 extern int phm_get_max_high_clocks(struct pp_hwmgr *hwmgr, struct amd_pp_simple_clock_info *clocks);
0464 extern int phm_disable_smc_firmware_ctf(struct pp_hwmgr *hwmgr);
0465
0466 extern int phm_set_active_display_count(struct pp_hwmgr *hwmgr, uint32_t count);
0467
0468 #endif
0469