1 /*	$NetBSD: hardwaremanager.h,v 1.2 2021/12/18 23:45:26 riastradh Exp $	*/
2 
3 /*
4  * Copyright 2015 Advanced Micro Devices, Inc.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
20  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22  * OTHER DEALINGS IN THE SOFTWARE.
23  *
24  */
25 #ifndef _HARDWARE_MANAGER_H_
26 #define _HARDWARE_MANAGER_H_
27 
28 
29 
30 struct pp_hwmgr;
31 struct pp_hw_power_state;
32 struct pp_power_state;
33 enum amd_dpm_forced_level;
34 struct PP_TemperatureRange;
35 
36 
37 struct phm_fan_speed_info {
38 	uint32_t min_percent;
39 	uint32_t max_percent;
40 	uint32_t min_rpm;
41 	uint32_t max_rpm;
42 	bool supports_percent_read;
43 	bool supports_percent_write;
44 	bool supports_rpm_read;
45 	bool supports_rpm_write;
46 };
47 
48 /* Automatic Power State Throttling */
49 enum PHM_AutoThrottleSource
50 {
51     PHM_AutoThrottleSource_Thermal,
52     PHM_AutoThrottleSource_External
53 };
54 
55 typedef enum PHM_AutoThrottleSource PHM_AutoThrottleSource;
56 
57 enum phm_platform_caps {
58 	PHM_PlatformCaps_AtomBiosPpV1 = 0,
59 	PHM_PlatformCaps_PowerPlaySupport,
60 	PHM_PlatformCaps_ACOverdriveSupport,
61 	PHM_PlatformCaps_BacklightSupport,
62 	PHM_PlatformCaps_ThermalController,
63 	PHM_PlatformCaps_BiosPowerSourceControl,
64 	PHM_PlatformCaps_DisableVoltageTransition,
65 	PHM_PlatformCaps_DisableEngineTransition,
66 	PHM_PlatformCaps_DisableMemoryTransition,
67 	PHM_PlatformCaps_DynamicPowerManagement,
68 	PHM_PlatformCaps_EnableASPML0s,
69 	PHM_PlatformCaps_EnableASPML1,
70 	PHM_PlatformCaps_OD5inACSupport,
71 	PHM_PlatformCaps_OD5inDCSupport,
72 	PHM_PlatformCaps_SoftStateOD5,
73 	PHM_PlatformCaps_NoOD5Support,
74 	PHM_PlatformCaps_ContinuousHardwarePerformanceRange,
75 	PHM_PlatformCaps_ActivityReporting,
76 	PHM_PlatformCaps_EnableBackbias,
77 	PHM_PlatformCaps_OverdriveDisabledByPowerBudget,
78 	PHM_PlatformCaps_ShowPowerBudgetWarning,
79 	PHM_PlatformCaps_PowerBudgetWaiverAvailable,
80 	PHM_PlatformCaps_GFXClockGatingSupport,
81 	PHM_PlatformCaps_MMClockGatingSupport,
82 	PHM_PlatformCaps_AutomaticDCTransition,
83 	PHM_PlatformCaps_GeminiPrimary,
84 	PHM_PlatformCaps_MemorySpreadSpectrumSupport,
85 	PHM_PlatformCaps_EngineSpreadSpectrumSupport,
86 	PHM_PlatformCaps_StepVddc,
87 	PHM_PlatformCaps_DynamicPCIEGen2Support,
88 	PHM_PlatformCaps_SMC,
89 	PHM_PlatformCaps_FaultyInternalThermalReading,          /* Internal thermal controller reports faulty temperature value when DAC2 is active */
90 	PHM_PlatformCaps_EnableVoltageControl,                  /* indicates voltage can be controlled */
91 	PHM_PlatformCaps_EnableSideportControl,                 /* indicates Sideport can be controlled */
92 	PHM_PlatformCaps_VideoPlaybackEEUNotification,          /* indicates EEU notification of video start/stop is required */
93 	PHM_PlatformCaps_TurnOffPll_ASPML1,                     /* PCIE Turn Off PLL in ASPM L1 */
94 	PHM_PlatformCaps_EnableHTLinkControl,                   /* indicates HT Link can be controlled by ACPI or CLMC overridden/automated mode. */
95 	PHM_PlatformCaps_PerformanceStateOnly,                  /* indicates only performance power state to be used on current system. */
96 	PHM_PlatformCaps_ExclusiveModeAlwaysHigh,               /* In Exclusive (3D) mode always stay in High state. */
97 	PHM_PlatformCaps_DisableMGClockGating,                  /* to disable Medium Grain Clock Gating or not */
98 	PHM_PlatformCaps_DisableMGCGTSSM,                       /* TO disable Medium Grain Clock Gating Shader Complex control */
99 	PHM_PlatformCaps_UVDAlwaysHigh,                         /* In UVD mode always stay in High state */
100 	PHM_PlatformCaps_DisablePowerGating,                    /* to disable power gating */
101 	PHM_PlatformCaps_CustomThermalPolicy,                   /* indicates only performance power state to be used on current system. */
102 	PHM_PlatformCaps_StayInBootState,                       /* Stay in Boot State, do not do clock/voltage or PCIe Lane and Gen switching (RV7xx and up). */
103 	PHM_PlatformCaps_SMCAllowSeparateSWThermalState,        /* SMC use separate SW thermal state, instead of the default SMC thermal policy. */
104 	PHM_PlatformCaps_MultiUVDStateSupport,                  /* Powerplay state table supports multi UVD states. */
105 	PHM_PlatformCaps_EnableSCLKDeepSleepForUVD,             /* With HW ECOs, we don't need to disable SCLK Deep Sleep for UVD state. */
106 	PHM_PlatformCaps_EnableMCUHTLinkControl,                /* Enable HT link control by MCU */
107 	PHM_PlatformCaps_ABM,                                   /* ABM support.*/
108 	PHM_PlatformCaps_KongThermalPolicy,                     /* A thermal policy specific for Kong */
109 	PHM_PlatformCaps_SwitchVDDNB,                           /* if the users want to switch VDDNB */
110 	PHM_PlatformCaps_ULPS,                                  /* support ULPS mode either through ACPI state or ULPS state */
111 	PHM_PlatformCaps_NativeULPS,                            /* hardware capable of ULPS state (other than through the ACPI state) */
112 	PHM_PlatformCaps_EnableMVDDControl,                     /* indicates that memory voltage can be controlled */
113 	PHM_PlatformCaps_ControlVDDCI,                          /* Control VDDCI separately from VDDC. */
114 	PHM_PlatformCaps_DisableDCODT,                          /* indicates if DC ODT apply or not */
115 	PHM_PlatformCaps_DynamicACTiming,                       /* if the SMC dynamically re-programs MC SEQ register values */
116 	PHM_PlatformCaps_EnableThermalIntByGPIO,                /* enable throttle control through GPIO */
117 	PHM_PlatformCaps_BootStateOnAlert,                      /* Go to boot state on alerts, e.g. on an AC->DC transition. */
118 	PHM_PlatformCaps_DontWaitForVBlankOnAlert,              /* Do NOT wait for VBLANK during an alert (e.g. AC->DC transition). */
119 	PHM_PlatformCaps_Force3DClockSupport,                   /* indicates if the platform supports force 3D clock. */
120 	PHM_PlatformCaps_MicrocodeFanControl,                   /* Fan is controlled by the SMC microcode. */
121 	PHM_PlatformCaps_AdjustUVDPriorityForSP,
122 	PHM_PlatformCaps_DisableLightSleep,                     /* Light sleep for evergreen family. */
123 	PHM_PlatformCaps_DisableMCLS,                           /* MC Light sleep */
124 	PHM_PlatformCaps_RegulatorHot,                          /* Enable throttling on 'regulator hot' events. */
125 	PHM_PlatformCaps_BACO,                                  /* Support Bus Alive Chip Off mode */
126 	PHM_PlatformCaps_DisableDPM,                            /* Disable DPM, supported from Llano */
127 	PHM_PlatformCaps_DynamicM3Arbiter,                      /* support dynamically change m3 arbitor parameters */
128 	PHM_PlatformCaps_SclkDeepSleep,                         /* support sclk deep sleep */
129 	PHM_PlatformCaps_DynamicPatchPowerState,                /* this ASIC supports to patch power state dynamically */
130 	PHM_PlatformCaps_ThermalAutoThrottling,                 /* enabling auto thermal throttling, */
131 	PHM_PlatformCaps_SumoThermalPolicy,                     /* A thermal policy specific for Sumo */
132 	PHM_PlatformCaps_PCIEPerformanceRequest,                /* support to change RC voltage */
133 	PHM_PlatformCaps_BLControlledByGPU,                     /* support varibright */
134 	PHM_PlatformCaps_PowerContainment,                      /* support DPM2 power containment (AKA TDP clamping) */
135 	PHM_PlatformCaps_SQRamping,                             /* support DPM2 SQ power throttle */
136 	PHM_PlatformCaps_CAC,                                   /* support Capacitance * Activity power estimation */
137 	PHM_PlatformCaps_NIChipsets,                            /* Northern Island and beyond chipsets */
138 	PHM_PlatformCaps_TrinityChipsets,                       /* Trinity chipset */
139 	PHM_PlatformCaps_EvergreenChipsets,                     /* Evergreen family chipset */
140 	PHM_PlatformCaps_PowerControl,                          /* Cayman and beyond chipsets */
141 	PHM_PlatformCaps_DisableLSClockGating,                  /* to disable Light Sleep control for HDP memories */
142 	PHM_PlatformCaps_BoostState,                            /* this ASIC supports boost state */
143 	PHM_PlatformCaps_UserMaxClockForMultiDisplays,          /* indicates if max memory clock is used for all status when multiple displays are connected */
144 	PHM_PlatformCaps_RegWriteDelay,                         /* indicates if back to back reg write delay is required */
145 	PHM_PlatformCaps_NonABMSupportInPPLib,                  /* ABM is not supported in PPLIB, (moved from PPLIB to DAL) */
146 	PHM_PlatformCaps_GFXDynamicMGPowerGating,               /* Enable Dynamic MG PowerGating on Trinity */
147 	PHM_PlatformCaps_DisableSMUUVDHandshake,                /* Disable SMU UVD Handshake */
148 	PHM_PlatformCaps_DTE,                                   /* Support Digital Temperature Estimation */
149 	PHM_PlatformCaps_W5100Specifc_SmuSkipMsgDTE,            /* This is for the feature requested by David B., and Tonny W.*/
150 	PHM_PlatformCaps_UVDPowerGating,                        /* enable UVD power gating, supported from Llano */
151 	PHM_PlatformCaps_UVDDynamicPowerGating,                 /* enable UVD Dynamic power gating, supported from UVD5 */
152 	PHM_PlatformCaps_VCEPowerGating,                        /* Enable VCE power gating, supported for TN and later ASICs */
153 	PHM_PlatformCaps_SamuPowerGating,                       /* Enable SAMU power gating, supported for KV and later ASICs */
154 	PHM_PlatformCaps_UVDDPM,                                /* UVD clock DPM */
155 	PHM_PlatformCaps_VCEDPM,                                /* VCE clock DPM */
156 	PHM_PlatformCaps_SamuDPM,                               /* SAMU clock DPM */
157 	PHM_PlatformCaps_AcpDPM,                                /* ACP clock DPM */
158 	PHM_PlatformCaps_SclkDeepSleepAboveLow,                 /* Enable SCLK Deep Sleep on all DPM states */
159 	PHM_PlatformCaps_DynamicUVDState,                       /* Dynamic UVD State */
160 	PHM_PlatformCaps_WantSAMClkWithDummyBackEnd,            /* Set SAM Clk With Dummy Back End */
161 	PHM_PlatformCaps_WantUVDClkWithDummyBackEnd,            /* Set UVD Clk With Dummy Back End */
162 	PHM_PlatformCaps_WantVCEClkWithDummyBackEnd,            /* Set VCE Clk With Dummy Back End */
163 	PHM_PlatformCaps_WantACPClkWithDummyBackEnd,            /* Set SAM Clk With Dummy Back End */
164 	PHM_PlatformCaps_OD6inACSupport,                        /* indicates that the ASIC/back end supports OD6 */
165 	PHM_PlatformCaps_OD6inDCSupport,                        /* indicates that the ASIC/back end supports OD6 in DC */
166 	PHM_PlatformCaps_EnablePlatformPowerManagement,         /* indicates that Platform Power Management feature is supported */
167 	PHM_PlatformCaps_SurpriseRemoval,                       /* indicates that surprise removal feature is requested */
168 	PHM_PlatformCaps_NewCACVoltage,                         /* indicates new CAC voltage table support */
169 	PHM_PlatformCaps_DiDtSupport,                           /* for dI/dT feature */
170 	PHM_PlatformCaps_DBRamping,                             /* for dI/dT feature */
171 	PHM_PlatformCaps_TDRamping,                             /* for dI/dT feature */
172 	PHM_PlatformCaps_TCPRamping,                            /* for dI/dT feature */
173 	PHM_PlatformCaps_DBRRamping,                            /* for dI/dT feature */
174 	PHM_PlatformCaps_DiDtEDCEnable,                         /* for dI/dT feature */
175 	PHM_PlatformCaps_GCEDC,                                 /* for dI/dT feature */
176 	PHM_PlatformCaps_PSM,                                   /* for dI/dT feature */
177 	PHM_PlatformCaps_EnableSMU7ThermalManagement,           /* SMC will manage thermal events */
178 	PHM_PlatformCaps_FPS,                                   /* FPS support */
179 	PHM_PlatformCaps_ACP,                                   /* ACP support */
180 	PHM_PlatformCaps_SclkThrottleLowNotification,           /* SCLK Throttle Low Notification */
181 	PHM_PlatformCaps_XDMAEnabled,                           /* XDMA engine is enabled */
182 	PHM_PlatformCaps_UseDummyBackEnd,                       /* use dummy back end */
183 	PHM_PlatformCaps_EnableDFSBypass,                       /* Enable DFS bypass */
184 	PHM_PlatformCaps_VddNBDirectRequest,
185 	PHM_PlatformCaps_PauseMMSessions,
186 	PHM_PlatformCaps_UnTabledHardwareInterface,             /* Tableless/direct call hardware interface for CI and newer ASICs */
187 	PHM_PlatformCaps_SMU7,                                  /* indicates that vpuRecoveryBegin without SMU shutdown */
188 	PHM_PlatformCaps_RevertGPIO5Polarity,                   /* indicates revert GPIO5 plarity table support */
189 	PHM_PlatformCaps_Thermal2GPIO17,                        /* indicates thermal2GPIO17 table support */
190 	PHM_PlatformCaps_ThermalOutGPIO,                        /* indicates ThermalOutGPIO support, pin number is assigned by VBIOS */
191 	PHM_PlatformCaps_DisableMclkSwitchingForFrameLock,      /* Disable memory clock switch during Framelock */
192 	PHM_PlatformCaps_ForceMclkHigh,                         /* Disable memory clock switching by forcing memory clock high */
193 	PHM_PlatformCaps_VRHotGPIOConfigurable,                 /* indicates VR_HOT GPIO configurable */
194 	PHM_PlatformCaps_TempInversion,                         /* enable Temp Inversion feature */
195 	PHM_PlatformCaps_IOIC3,
196 	PHM_PlatformCaps_ConnectedStandby,
197 	PHM_PlatformCaps_EVV,
198 	PHM_PlatformCaps_EnableLongIdleBACOSupport,
199 	PHM_PlatformCaps_CombinePCCWithThermalSignal,
200 	PHM_PlatformCaps_DisableUsingActualTemperatureForPowerCalc,
201 	PHM_PlatformCaps_StablePState,
202 	PHM_PlatformCaps_OD6PlusinACSupport,
203 	PHM_PlatformCaps_OD6PlusinDCSupport,
204 	PHM_PlatformCaps_ODThermalLimitUnlock,
205 	PHM_PlatformCaps_ReducePowerLimit,
206 	PHM_PlatformCaps_ODFuzzyFanControlSupport,
207 	PHM_PlatformCaps_GeminiRegulatorFanControlSupport,
208 	PHM_PlatformCaps_ControlVDDGFX,
209 	PHM_PlatformCaps_BBBSupported,
210 	PHM_PlatformCaps_DisableVoltageIsland,
211 	PHM_PlatformCaps_FanSpeedInTableIsRPM,
212 	PHM_PlatformCaps_GFXClockGatingManagedInCAIL,
213 	PHM_PlatformCaps_IcelandULPSSWWorkAround,
214 	PHM_PlatformCaps_FPSEnhancement,
215 	PHM_PlatformCaps_LoadPostProductionFirmware,
216 	PHM_PlatformCaps_VpuRecoveryInProgress,
217 	PHM_PlatformCaps_Falcon_QuickTransition,
218 	PHM_PlatformCaps_AVFS,
219 	PHM_PlatformCaps_ClockStretcher,
220 	PHM_PlatformCaps_TablelessHardwareInterface,
221 	PHM_PlatformCaps_EnableDriverEVV,
222 	PHM_PlatformCaps_SPLLShutdownSupport,
223 	PHM_PlatformCaps_VirtualBatteryState,
224 	PHM_PlatformCaps_IgnoreForceHighClockRequestsInAPUs,
225 	PHM_PlatformCaps_DisableMclkSwitchForVR,
226 	PHM_PlatformCaps_SMU8,
227 	PHM_PlatformCaps_VRHotPolarityHigh,
228 	PHM_PlatformCaps_IPS_UlpsExclusive,
229 	PHM_PlatformCaps_SMCtoPPLIBAcdcGpioScheme,
230 	PHM_PlatformCaps_GeminiAsymmetricPower,
231 	PHM_PlatformCaps_OCLPowerOptimization,
232 	PHM_PlatformCaps_MaxPCIEBandWidth,
233 	PHM_PlatformCaps_PerfPerWattOptimizationSupport,
234 	PHM_PlatformCaps_UVDClientMCTuning,
235 	PHM_PlatformCaps_ODNinACSupport,
236 	PHM_PlatformCaps_ODNinDCSupport,
237 	PHM_PlatformCaps_OD8inACSupport,
238 	PHM_PlatformCaps_OD8inDCSupport,
239 	PHM_PlatformCaps_UMDPState,
240 	PHM_PlatformCaps_AutoWattmanSupport,
241 	PHM_PlatformCaps_AutoWattmanEnable_CCCState,
242 	PHM_PlatformCaps_FreeSyncActive,
243 	PHM_PlatformCaps_EnableShadowPstate,
244 	PHM_PlatformCaps_customThermalManagement,
245 	PHM_PlatformCaps_staticFanControl,
246 	PHM_PlatformCaps_Virtual_System,
247 	PHM_PlatformCaps_LowestUclkReservedForUlv,
248 	PHM_PlatformCaps_EnableBoostState,
249 	PHM_PlatformCaps_AVFSSupport,
250 	PHM_PlatformCaps_ThermalPolicyDelay,
251 	PHM_PlatformCaps_CustomFanControlSupport,
252 	PHM_PlatformCaps_BAMACO,
253 	PHM_PlatformCaps_Max
254 };
255 
256 #define PHM_MAX_NUM_CAPS_BITS_PER_FIELD (sizeof(uint32_t)*8)
257 
258 /* Number of uint32_t entries used by CAPS table */
259 #define PHM_MAX_NUM_CAPS_ULONG_ENTRIES \
260 	((PHM_PlatformCaps_Max + ((PHM_MAX_NUM_CAPS_BITS_PER_FIELD) - 1)) / (PHM_MAX_NUM_CAPS_BITS_PER_FIELD))
261 
262 struct pp_hw_descriptor {
263 	uint32_t hw_caps[PHM_MAX_NUM_CAPS_ULONG_ENTRIES];
264 };
265 
266 enum PHM_PerformanceLevelDesignation {
267 	PHM_PerformanceLevelDesignation_Activity,
268 	PHM_PerformanceLevelDesignation_PowerContainment
269 };
270 
271 typedef enum PHM_PerformanceLevelDesignation PHM_PerformanceLevelDesignation;
272 
273 struct PHM_PerformanceLevel {
274     uint32_t    coreClock;
275     uint32_t    memory_clock;
276     uint32_t  vddc;
277     uint32_t  vddci;
278     uint32_t    nonLocalMemoryFreq;
279     uint32_t nonLocalMemoryWidth;
280 };
281 
282 typedef struct PHM_PerformanceLevel PHM_PerformanceLevel;
283 
284 /* Function for setting a platform cap */
phm_cap_set(uint32_t * caps,enum phm_platform_caps c)285 static inline void phm_cap_set(uint32_t *caps,
286 			enum phm_platform_caps c)
287 {
288 	caps[c / PHM_MAX_NUM_CAPS_BITS_PER_FIELD] |= (1UL <<
289 			     (c & (PHM_MAX_NUM_CAPS_BITS_PER_FIELD - 1)));
290 }
291 
phm_cap_unset(uint32_t * caps,enum phm_platform_caps c)292 static inline void phm_cap_unset(uint32_t *caps,
293 			enum phm_platform_caps c)
294 {
295 	caps[c / PHM_MAX_NUM_CAPS_BITS_PER_FIELD] &= ~(1UL << (c & (PHM_MAX_NUM_CAPS_BITS_PER_FIELD - 1)));
296 }
297 
phm_cap_enabled(const uint32_t * caps,enum phm_platform_caps c)298 static inline bool phm_cap_enabled(const uint32_t *caps, enum phm_platform_caps c)
299 {
300 	return (0 != (caps[c / PHM_MAX_NUM_CAPS_BITS_PER_FIELD] &
301 		  (1UL << (c & (PHM_MAX_NUM_CAPS_BITS_PER_FIELD - 1)))));
302 }
303 
304 #define PP_CAP(c) phm_cap_enabled(hwmgr->platform_descriptor.platformCaps, (c))
305 
306 #define PP_PCIEGenInvalid  0xffff
307 enum PP_PCIEGen {
308     PP_PCIEGen1 = 0,                /* PCIE 1.0 - Transfer rate of 2.5 GT/s */
309     PP_PCIEGen2,                    /*PCIE 2.0 - Transfer rate of 5.0 GT/s */
310     PP_PCIEGen3                     /*PCIE 3.0 - Transfer rate of 8.0 GT/s */
311 };
312 
313 typedef enum PP_PCIEGen PP_PCIEGen;
314 
315 #define PP_Min_PCIEGen     PP_PCIEGen1
316 #define PP_Max_PCIEGen     PP_PCIEGen3
317 #define PP_Min_PCIELane    1
318 #define PP_Max_PCIELane    16
319 
320 enum phm_clock_Type {
321 	PHM_DispClock = 1,
322 	PHM_SClock,
323 	PHM_MemClock
324 };
325 
326 #define MAX_NUM_CLOCKS 16
327 
328 struct PP_Clocks {
329 	uint32_t engineClock;
330 	uint32_t memoryClock;
331 	uint32_t BusBandwidth;
332 	uint32_t engineClockInSR;
333 	uint32_t dcefClock;
334 	uint32_t dcefClockInSR;
335 };
336 
337 struct pp_clock_info {
338 	uint32_t min_mem_clk;
339 	uint32_t max_mem_clk;
340 	uint32_t min_eng_clk;
341 	uint32_t max_eng_clk;
342 	uint32_t min_bus_bandwidth;
343 	uint32_t max_bus_bandwidth;
344 };
345 
346 struct phm_platform_descriptor {
347 	uint32_t platformCaps[PHM_MAX_NUM_CAPS_ULONG_ENTRIES];
348 	uint32_t vbiosInterruptId;
349 	struct PP_Clocks overdriveLimit;
350 	struct PP_Clocks clockStep;
351 	uint32_t hardwareActivityPerformanceLevels;
352 	uint32_t minimumClocksReductionPercentage;
353 	uint32_t minOverdriveVDDC;
354 	uint32_t maxOverdriveVDDC;
355 	uint32_t overdriveVDDCStep;
356 	uint32_t hardwarePerformanceLevels;
357 	uint16_t powerBudget;
358 	uint32_t TDPLimit;
359 	uint32_t nearTDPLimit;
360 	uint32_t nearTDPLimitAdjusted;
361 	uint32_t SQRampingThreshold;
362 	uint32_t CACLeakage;
363 	uint16_t TDPODLimit;
364 	uint32_t TDPAdjustment;
365 	bool TDPAdjustmentPolarity;
366 	uint16_t LoadLineSlope;
367 	uint32_t  VidMinLimit;
368 	uint32_t  VidMaxLimit;
369 	uint32_t  VidStep;
370 	uint32_t  VidAdjustment;
371 	bool VidAdjustmentPolarity;
372 };
373 
374 struct phm_clocks {
375 	uint32_t num_of_entries;
376 	uint32_t clock[MAX_NUM_CLOCKS];
377 };
378 
379 #define DPMTABLE_OD_UPDATE_SCLK     0x00000001
380 #define DPMTABLE_OD_UPDATE_MCLK     0x00000002
381 #define DPMTABLE_UPDATE_SCLK        0x00000004
382 #define DPMTABLE_UPDATE_MCLK        0x00000008
383 #define DPMTABLE_OD_UPDATE_VDDC     0x00000010
384 #define DPMTABLE_UPDATE_SOCCLK      0x00000020
385 
386 struct phm_odn_performance_level {
387 	uint32_t clock;
388 	uint32_t vddc;
389 	bool enabled;
390 };
391 
392 struct phm_odn_clock_levels {
393 	uint32_t size;
394 	uint32_t options;
395 	uint32_t flags;
396 	uint32_t num_of_pl;
397 	/* variable-sized array, specify by num_of_pl. */
398 	struct phm_odn_performance_level entries[8];
399 };
400 
401 extern int phm_disable_clock_power_gatings(struct pp_hwmgr *hwmgr);
402 extern int phm_powerdown_uvd(struct pp_hwmgr *hwmgr);
403 extern int phm_setup_asic(struct pp_hwmgr *hwmgr);
404 extern int phm_enable_dynamic_state_management(struct pp_hwmgr *hwmgr);
405 extern int phm_disable_dynamic_state_management(struct pp_hwmgr *hwmgr);
406 extern bool phm_is_hw_access_blocked(struct pp_hwmgr *hwmgr);
407 extern int phm_block_hw_access(struct pp_hwmgr *hwmgr, bool block);
408 extern int phm_set_power_state(struct pp_hwmgr *hwmgr,
409 		    const struct pp_hw_power_state *pcurrent_state,
410 		 const struct pp_hw_power_state *pnew_power_state);
411 
412 extern int phm_apply_state_adjust_rules(struct pp_hwmgr *hwmgr,
413 				   struct pp_power_state *adjusted_ps,
414 			     const struct pp_power_state *current_ps);
415 
416 extern int phm_apply_clock_adjust_rules(struct pp_hwmgr *hwmgr);
417 
418 extern int phm_force_dpm_levels(struct pp_hwmgr *hwmgr, enum amd_dpm_forced_level level);
419 extern int phm_pre_display_configuration_changed(struct pp_hwmgr *hwmgr);
420 extern int phm_display_configuration_changed(struct pp_hwmgr *hwmgr);
421 extern int phm_notify_smc_display_config_after_ps_adjustment(struct pp_hwmgr *hwmgr);
422 extern int phm_register_irq_handlers(struct pp_hwmgr *hwmgr);
423 extern int phm_start_thermal_controller(struct pp_hwmgr *hwmgr);
424 extern int phm_stop_thermal_controller(struct pp_hwmgr *hwmgr);
425 extern bool phm_check_smc_update_required_for_display_configuration(struct pp_hwmgr *hwmgr);
426 
427 extern int phm_check_states_equal(struct pp_hwmgr *hwmgr,
428 				 const struct pp_hw_power_state *pstate1,
429 				 const struct pp_hw_power_state *pstate2,
430 				 bool *equal);
431 
432 extern int phm_store_dal_configuration_data(struct pp_hwmgr *hwmgr,
433 		const struct amd_pp_display_configuration *display_config);
434 
435 extern int phm_get_dal_power_level(struct pp_hwmgr *hwmgr,
436 		struct amd_pp_simple_clock_info *info);
437 
438 extern int phm_set_cpu_power_state(struct pp_hwmgr *hwmgr);
439 
440 extern int phm_power_down_asic(struct pp_hwmgr *hwmgr);
441 
442 extern int phm_get_performance_level(struct pp_hwmgr *hwmgr, const struct pp_hw_power_state *state,
443 				PHM_PerformanceLevelDesignation designation, uint32_t index,
444 				PHM_PerformanceLevel *level);
445 
446 extern int phm_get_clock_info(struct pp_hwmgr *hwmgr, const struct pp_hw_power_state *state,
447 			struct pp_clock_info *pclock_info,
448 			PHM_PerformanceLevelDesignation designation);
449 
450 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);
451 
452 extern int phm_get_clock_by_type(struct pp_hwmgr *hwmgr, enum amd_pp_clock_type type, struct amd_pp_clocks *clocks);
453 
454 extern int phm_get_clock_by_type_with_latency(struct pp_hwmgr *hwmgr,
455 		enum amd_pp_clock_type type,
456 		struct pp_clock_levels_with_latency *clocks);
457 extern int phm_get_clock_by_type_with_voltage(struct pp_hwmgr *hwmgr,
458 		enum amd_pp_clock_type type,
459 		struct pp_clock_levels_with_voltage *clocks);
460 extern int phm_set_watermarks_for_clocks_ranges(struct pp_hwmgr *hwmgr,
461 						void *clock_ranges);
462 extern int phm_display_clock_voltage_request(struct pp_hwmgr *hwmgr,
463 		struct pp_display_clock_request *clock);
464 
465 extern int phm_get_max_high_clocks(struct pp_hwmgr *hwmgr, struct amd_pp_simple_clock_info *clocks);
466 extern int phm_disable_smc_firmware_ctf(struct pp_hwmgr *hwmgr);
467 
468 extern int phm_set_active_display_count(struct pp_hwmgr *hwmgr, uint32_t count);
469 
470 #endif /* _HARDWARE_MANAGER_H_ */
471 
472