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