1837d542aSEvan Quan /*
2837d542aSEvan Quan  * Copyright 2016 Advanced Micro Devices, Inc.
3837d542aSEvan Quan  *
4837d542aSEvan Quan  * Permission is hereby granted, free of charge, to any person obtaining a
5837d542aSEvan Quan  * copy of this software and associated documentation files (the "Software"),
6837d542aSEvan Quan  * to deal in the Software without restriction, including without limitation
7837d542aSEvan Quan  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8837d542aSEvan Quan  * and/or sell copies of the Software, and to permit persons to whom the
9837d542aSEvan Quan  * Software is furnished to do so, subject to the following conditions:
10837d542aSEvan Quan  *
11837d542aSEvan Quan  * The above copyright notice and this permission notice shall be included in
12837d542aSEvan Quan  * all copies or substantial portions of the Software.
13837d542aSEvan Quan  *
14837d542aSEvan Quan  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15837d542aSEvan Quan  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16837d542aSEvan Quan  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17837d542aSEvan Quan  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18837d542aSEvan Quan  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19837d542aSEvan Quan  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20837d542aSEvan Quan  * OTHER DEALINGS IN THE SOFTWARE.
21837d542aSEvan Quan  *
22837d542aSEvan Quan  */
23837d542aSEvan Quan #ifndef SMU71_DISCRETE_H
24837d542aSEvan Quan #define SMU71_DISCRETE_H
25837d542aSEvan Quan 
26837d542aSEvan Quan #include "smu71.h"
27837d542aSEvan Quan 
28837d542aSEvan Quan #if !defined(SMC_MICROCODE)
29837d542aSEvan Quan #pragma pack(push, 1)
30837d542aSEvan Quan #endif
31837d542aSEvan Quan 
32837d542aSEvan Quan #define VDDC_ON_SVI2  0x1
33837d542aSEvan Quan #define VDDCI_ON_SVI2 0x2
34837d542aSEvan Quan #define MVDD_ON_SVI2  0x4
35837d542aSEvan Quan 
36837d542aSEvan Quan struct SMU71_Discrete_VoltageLevel
37837d542aSEvan Quan {
38837d542aSEvan Quan     uint16_t    Voltage;
39837d542aSEvan Quan     uint16_t    StdVoltageHiSidd;
40837d542aSEvan Quan     uint16_t    StdVoltageLoSidd;
41837d542aSEvan Quan     uint8_t     Smio;
42837d542aSEvan Quan     uint8_t     padding;
43837d542aSEvan Quan };
44837d542aSEvan Quan 
45837d542aSEvan Quan typedef struct SMU71_Discrete_VoltageLevel SMU71_Discrete_VoltageLevel;
46837d542aSEvan Quan 
47837d542aSEvan Quan struct SMU71_Discrete_GraphicsLevel
48837d542aSEvan Quan {
49837d542aSEvan Quan     uint32_t    MinVddc;
50837d542aSEvan Quan     uint32_t    MinVddcPhases;
51837d542aSEvan Quan 
52837d542aSEvan Quan     uint32_t    SclkFrequency;
53837d542aSEvan Quan 
54837d542aSEvan Quan     uint8_t     pcieDpmLevel;
55837d542aSEvan Quan     uint8_t     DeepSleepDivId;
56837d542aSEvan Quan     uint16_t    ActivityLevel;
57837d542aSEvan Quan 
58837d542aSEvan Quan     uint32_t    CgSpllFuncCntl3;
59837d542aSEvan Quan     uint32_t    CgSpllFuncCntl4;
60837d542aSEvan Quan     uint32_t    SpllSpreadSpectrum;
61837d542aSEvan Quan     uint32_t    SpllSpreadSpectrum2;
62837d542aSEvan Quan     uint32_t    CcPwrDynRm;
63837d542aSEvan Quan     uint32_t    CcPwrDynRm1;
64837d542aSEvan Quan     uint8_t     SclkDid;
65837d542aSEvan Quan     uint8_t     DisplayWatermark;
66837d542aSEvan Quan     uint8_t     EnabledForActivity;
67837d542aSEvan Quan     uint8_t     EnabledForThrottle;
68837d542aSEvan Quan     uint8_t     UpHyst;
69837d542aSEvan Quan     uint8_t     DownHyst;
70837d542aSEvan Quan     uint8_t     VoltageDownHyst;
71837d542aSEvan Quan     uint8_t     PowerThrottle;
72837d542aSEvan Quan };
73837d542aSEvan Quan 
74837d542aSEvan Quan typedef struct SMU71_Discrete_GraphicsLevel SMU71_Discrete_GraphicsLevel;
75837d542aSEvan Quan 
76837d542aSEvan Quan struct SMU71_Discrete_ACPILevel
77837d542aSEvan Quan {
78837d542aSEvan Quan     uint32_t    Flags;
79837d542aSEvan Quan     uint32_t    MinVddc;
80837d542aSEvan Quan     uint32_t    MinVddcPhases;
81837d542aSEvan Quan     uint32_t    SclkFrequency;
82837d542aSEvan Quan     uint8_t     SclkDid;
83837d542aSEvan Quan     uint8_t     DisplayWatermark;
84837d542aSEvan Quan     uint8_t     DeepSleepDivId;
85837d542aSEvan Quan     uint8_t     padding;
86837d542aSEvan Quan     uint32_t    CgSpllFuncCntl;
87837d542aSEvan Quan     uint32_t    CgSpllFuncCntl2;
88837d542aSEvan Quan     uint32_t    CgSpllFuncCntl3;
89837d542aSEvan Quan     uint32_t    CgSpllFuncCntl4;
90837d542aSEvan Quan     uint32_t    SpllSpreadSpectrum;
91837d542aSEvan Quan     uint32_t    SpllSpreadSpectrum2;
92837d542aSEvan Quan     uint32_t    CcPwrDynRm;
93837d542aSEvan Quan     uint32_t    CcPwrDynRm1;
94837d542aSEvan Quan };
95837d542aSEvan Quan 
96837d542aSEvan Quan typedef struct SMU71_Discrete_ACPILevel SMU71_Discrete_ACPILevel;
97837d542aSEvan Quan 
98837d542aSEvan Quan struct SMU71_Discrete_Ulv
99837d542aSEvan Quan {
100837d542aSEvan Quan     uint32_t    CcPwrDynRm;
101837d542aSEvan Quan     uint32_t    CcPwrDynRm1;
102837d542aSEvan Quan     uint16_t    VddcOffset;
103837d542aSEvan Quan     uint8_t     VddcOffsetVid;
104837d542aSEvan Quan     uint8_t     VddcPhase;
105837d542aSEvan Quan     uint32_t    Reserved;
106837d542aSEvan Quan };
107837d542aSEvan Quan 
108837d542aSEvan Quan typedef struct SMU71_Discrete_Ulv SMU71_Discrete_Ulv;
109837d542aSEvan Quan 
110837d542aSEvan Quan struct SMU71_Discrete_MemoryLevel
111837d542aSEvan Quan {
112837d542aSEvan Quan     uint32_t    MinVddc;
113837d542aSEvan Quan     uint32_t    MinVddcPhases;
114837d542aSEvan Quan     uint32_t    MinVddci;
115837d542aSEvan Quan     uint32_t    MinMvdd;
116837d542aSEvan Quan 
117837d542aSEvan Quan     uint32_t    MclkFrequency;
118837d542aSEvan Quan 
119837d542aSEvan Quan     uint8_t     EdcReadEnable;
120837d542aSEvan Quan     uint8_t     EdcWriteEnable;
121837d542aSEvan Quan     uint8_t     RttEnable;
122837d542aSEvan Quan     uint8_t     StutterEnable;
123837d542aSEvan Quan 
124837d542aSEvan Quan     uint8_t     StrobeEnable;
125837d542aSEvan Quan     uint8_t     StrobeRatio;
126837d542aSEvan Quan     uint8_t     EnabledForThrottle;
127837d542aSEvan Quan     uint8_t     EnabledForActivity;
128837d542aSEvan Quan 
129837d542aSEvan Quan     uint8_t     UpHyst;
130837d542aSEvan Quan     uint8_t     DownHyst;
131837d542aSEvan Quan     uint8_t     VoltageDownHyst;
132837d542aSEvan Quan     uint8_t     padding;
133837d542aSEvan Quan 
134837d542aSEvan Quan     uint16_t    ActivityLevel;
135837d542aSEvan Quan     uint8_t     DisplayWatermark;
136837d542aSEvan Quan     uint8_t     padding1;
137837d542aSEvan Quan 
138837d542aSEvan Quan     uint32_t    MpllFuncCntl;
139837d542aSEvan Quan     uint32_t    MpllFuncCntl_1;
140837d542aSEvan Quan     uint32_t    MpllFuncCntl_2;
141837d542aSEvan Quan     uint32_t    MpllAdFuncCntl;
142837d542aSEvan Quan     uint32_t    MpllDqFuncCntl;
143837d542aSEvan Quan     uint32_t    MclkPwrmgtCntl;
144837d542aSEvan Quan     uint32_t    DllCntl;
145837d542aSEvan Quan     uint32_t    MpllSs1;
146837d542aSEvan Quan     uint32_t    MpllSs2;
147837d542aSEvan Quan };
148837d542aSEvan Quan 
149837d542aSEvan Quan typedef struct SMU71_Discrete_MemoryLevel SMU71_Discrete_MemoryLevel;
150837d542aSEvan Quan 
151837d542aSEvan Quan struct SMU71_Discrete_LinkLevel
152837d542aSEvan Quan {
153837d542aSEvan Quan     uint8_t     PcieGenSpeed;           ///< 0:PciE-gen1 1:PciE-gen2 2:PciE-gen3
154837d542aSEvan Quan     uint8_t     PcieLaneCount;          ///< 1=x1, 2=x2, 3=x4, 4=x8, 5=x12, 6=x16
155837d542aSEvan Quan     uint8_t     EnabledForActivity;
156837d542aSEvan Quan     uint8_t     SPC;
157837d542aSEvan Quan     uint32_t    DownThreshold;
158837d542aSEvan Quan     uint32_t    UpThreshold;
159837d542aSEvan Quan     uint32_t    Reserved;
160837d542aSEvan Quan };
161837d542aSEvan Quan 
162837d542aSEvan Quan typedef struct SMU71_Discrete_LinkLevel SMU71_Discrete_LinkLevel;
163837d542aSEvan Quan 
164837d542aSEvan Quan 
165837d542aSEvan Quan #ifdef SMU__DYNAMIC_MCARB_SETTINGS
166837d542aSEvan Quan // MC ARB DRAM Timing registers.
167837d542aSEvan Quan struct SMU71_Discrete_MCArbDramTimingTableEntry
168837d542aSEvan Quan {
169837d542aSEvan Quan     uint32_t McArbDramTiming;
170837d542aSEvan Quan     uint32_t McArbDramTiming2;
171837d542aSEvan Quan     uint8_t  McArbBurstTime;
172837d542aSEvan Quan     uint8_t  padding[3];
173837d542aSEvan Quan };
174837d542aSEvan Quan 
175837d542aSEvan Quan typedef struct SMU71_Discrete_MCArbDramTimingTableEntry SMU71_Discrete_MCArbDramTimingTableEntry;
176837d542aSEvan Quan 
177837d542aSEvan Quan struct SMU71_Discrete_MCArbDramTimingTable
178837d542aSEvan Quan {
179837d542aSEvan Quan     SMU71_Discrete_MCArbDramTimingTableEntry entries[SMU__NUM_SCLK_DPM_STATE][SMU__NUM_MCLK_DPM_LEVELS];
180837d542aSEvan Quan };
181837d542aSEvan Quan 
182837d542aSEvan Quan typedef struct SMU71_Discrete_MCArbDramTimingTable SMU71_Discrete_MCArbDramTimingTable;
183837d542aSEvan Quan #endif
184837d542aSEvan Quan 
185837d542aSEvan Quan // UVD VCLK/DCLK state (level) definition.
186837d542aSEvan Quan struct SMU71_Discrete_UvdLevel
187837d542aSEvan Quan {
188837d542aSEvan Quan     uint32_t VclkFrequency;
189837d542aSEvan Quan     uint32_t DclkFrequency;
190837d542aSEvan Quan     uint16_t MinVddc;
191837d542aSEvan Quan     uint8_t  MinVddcPhases;
192837d542aSEvan Quan     uint8_t  VclkDivider;
193837d542aSEvan Quan     uint8_t  DclkDivider;
194837d542aSEvan Quan     uint8_t  padding[3];
195837d542aSEvan Quan };
196837d542aSEvan Quan 
197837d542aSEvan Quan typedef struct SMU71_Discrete_UvdLevel SMU71_Discrete_UvdLevel;
198837d542aSEvan Quan 
199837d542aSEvan Quan // Clocks for other external blocks (VCE, ACP, SAMU).
200837d542aSEvan Quan struct SMU71_Discrete_ExtClkLevel
201837d542aSEvan Quan {
202837d542aSEvan Quan     uint32_t Frequency;
203837d542aSEvan Quan     uint16_t MinVoltage;
204837d542aSEvan Quan     uint8_t  MinPhases;
205837d542aSEvan Quan     uint8_t  Divider;
206837d542aSEvan Quan };
207837d542aSEvan Quan 
208837d542aSEvan Quan typedef struct SMU71_Discrete_ExtClkLevel SMU71_Discrete_ExtClkLevel;
209837d542aSEvan Quan 
210837d542aSEvan Quan // Everything that we need to keep track of about the current state.
211837d542aSEvan Quan // Use this instead of copies of the GraphicsLevel and MemoryLevel structures to keep track of state parameters
212837d542aSEvan Quan // that need to be checked later.
213837d542aSEvan Quan // We don't need to cache everything about a state, just a few parameters.
214837d542aSEvan Quan struct SMU71_Discrete_StateInfo
215837d542aSEvan Quan {
216837d542aSEvan Quan     uint32_t SclkFrequency;
217837d542aSEvan Quan     uint32_t MclkFrequency;
218837d542aSEvan Quan     uint32_t VclkFrequency;
219837d542aSEvan Quan     uint32_t DclkFrequency;
220837d542aSEvan Quan     uint32_t SamclkFrequency;
221837d542aSEvan Quan     uint32_t AclkFrequency;
222837d542aSEvan Quan     uint32_t EclkFrequency;
223837d542aSEvan Quan     uint16_t MvddVoltage;
224837d542aSEvan Quan     uint16_t padding16;
225837d542aSEvan Quan     uint8_t  DisplayWatermark;
226837d542aSEvan Quan     uint8_t  McArbIndex;
227837d542aSEvan Quan     uint8_t  McRegIndex;
228837d542aSEvan Quan     uint8_t  SeqIndex;
229837d542aSEvan Quan     uint8_t  SclkDid;
230837d542aSEvan Quan     int8_t   SclkIndex;
231837d542aSEvan Quan     int8_t   MclkIndex;
232837d542aSEvan Quan     uint8_t  PCIeGen;
233837d542aSEvan Quan 
234837d542aSEvan Quan };
235837d542aSEvan Quan 
236837d542aSEvan Quan typedef struct SMU71_Discrete_StateInfo SMU71_Discrete_StateInfo;
237837d542aSEvan Quan 
238837d542aSEvan Quan 
239837d542aSEvan Quan struct SMU71_Discrete_DpmTable
240837d542aSEvan Quan {
241837d542aSEvan Quan     // Multi-DPM controller settings
242837d542aSEvan Quan     SMU71_PIDController                  GraphicsPIDController;
243837d542aSEvan Quan     SMU71_PIDController                  MemoryPIDController;
244837d542aSEvan Quan     SMU71_PIDController                  LinkPIDController;
245837d542aSEvan Quan 
246837d542aSEvan Quan     uint32_t                            SystemFlags;
247837d542aSEvan Quan 
248837d542aSEvan Quan     // SMIO masks for voltage and phase controls
249837d542aSEvan Quan     uint32_t                            SmioMaskVddcVid;
250837d542aSEvan Quan     uint32_t                            SmioMaskVddcPhase;
251837d542aSEvan Quan     uint32_t                            SmioMaskVddciVid;
252837d542aSEvan Quan     uint32_t                            SmioMaskMvddVid;
253837d542aSEvan Quan 
254837d542aSEvan Quan     uint32_t                            VddcLevelCount;
255837d542aSEvan Quan     uint32_t                            VddciLevelCount;
256837d542aSEvan Quan     uint32_t                            MvddLevelCount;
257837d542aSEvan Quan 
258837d542aSEvan Quan     SMU71_Discrete_VoltageLevel          VddcLevel               [SMU71_MAX_LEVELS_VDDC];
259837d542aSEvan Quan     SMU71_Discrete_VoltageLevel          VddciLevel              [SMU71_MAX_LEVELS_VDDCI];
260837d542aSEvan Quan     SMU71_Discrete_VoltageLevel          MvddLevel               [SMU71_MAX_LEVELS_MVDD];
261837d542aSEvan Quan 
262837d542aSEvan Quan     uint8_t                             GraphicsDpmLevelCount;
263837d542aSEvan Quan     uint8_t                             MemoryDpmLevelCount;
264837d542aSEvan Quan     uint8_t                             LinkLevelCount;
265837d542aSEvan Quan     uint8_t                             MasterDeepSleepControl;
266837d542aSEvan Quan 
267837d542aSEvan Quan     uint32_t                            Reserved[5];
268837d542aSEvan Quan 
269837d542aSEvan Quan     // State table entries for each DPM state
270837d542aSEvan Quan     SMU71_Discrete_GraphicsLevel         GraphicsLevel           [SMU71_MAX_LEVELS_GRAPHICS];
271837d542aSEvan Quan     SMU71_Discrete_MemoryLevel           MemoryACPILevel;
272837d542aSEvan Quan     SMU71_Discrete_MemoryLevel           MemoryLevel             [SMU71_MAX_LEVELS_MEMORY];
273837d542aSEvan Quan     SMU71_Discrete_LinkLevel             LinkLevel               [SMU71_MAX_LEVELS_LINK];
274837d542aSEvan Quan     SMU71_Discrete_ACPILevel             ACPILevel;
275837d542aSEvan Quan 
276837d542aSEvan Quan     uint32_t                            SclkStepSize;
277837d542aSEvan Quan     uint32_t                            Smio                    [SMU71_MAX_ENTRIES_SMIO];
278837d542aSEvan Quan 
279837d542aSEvan Quan     uint8_t                             GraphicsBootLevel;
280837d542aSEvan Quan     uint8_t                             GraphicsVoltageChangeEnable;
281837d542aSEvan Quan     uint8_t                             GraphicsThermThrottleEnable;
282837d542aSEvan Quan     uint8_t                             GraphicsInterval;
283837d542aSEvan Quan 
284837d542aSEvan Quan     uint8_t                             VoltageInterval;
285837d542aSEvan Quan     uint8_t                             ThermalInterval;
286837d542aSEvan Quan     uint16_t                            TemperatureLimitHigh;
287837d542aSEvan Quan 
288837d542aSEvan Quan     uint16_t                            TemperatureLimitLow;
289837d542aSEvan Quan     uint8_t                             MemoryBootLevel;
290837d542aSEvan Quan     uint8_t                             MemoryVoltageChangeEnable;
291837d542aSEvan Quan 
292837d542aSEvan Quan     uint8_t                             MemoryInterval;
293837d542aSEvan Quan     uint8_t                             MemoryThermThrottleEnable;
294837d542aSEvan Quan     uint8_t                             MergedVddci;
295837d542aSEvan Quan     uint8_t                             padding2;
296837d542aSEvan Quan 
297837d542aSEvan Quan     uint16_t                            VoltageResponseTime;
298837d542aSEvan Quan     uint16_t                            PhaseResponseTime;
299837d542aSEvan Quan 
300837d542aSEvan Quan     uint8_t                             PCIeBootLinkLevel;
301837d542aSEvan Quan     uint8_t                             PCIeGenInterval;
302837d542aSEvan Quan     uint8_t                             DTEInterval;
303837d542aSEvan Quan     uint8_t                             DTEMode;
304837d542aSEvan Quan 
305837d542aSEvan Quan     uint8_t                             SVI2Enable;
306837d542aSEvan Quan     uint8_t                             VRHotGpio;
307837d542aSEvan Quan     uint8_t                             AcDcGpio;
308837d542aSEvan Quan     uint8_t                             ThermGpio;
309837d542aSEvan Quan 
310837d542aSEvan Quan     uint32_t                            DisplayCac;
311837d542aSEvan Quan 
312837d542aSEvan Quan     uint16_t                            MaxPwr;
313837d542aSEvan Quan     uint16_t                            NomPwr;
314837d542aSEvan Quan 
315837d542aSEvan Quan     uint16_t                            FpsHighThreshold;
316837d542aSEvan Quan     uint16_t                            FpsLowThreshold;
317837d542aSEvan Quan 
318837d542aSEvan Quan     uint16_t                            BAPMTI_R  [SMU71_DTE_ITERATIONS][SMU71_DTE_SOURCES][SMU71_DTE_SINKS];
319837d542aSEvan Quan     uint16_t                            BAPMTI_RC [SMU71_DTE_ITERATIONS][SMU71_DTE_SOURCES][SMU71_DTE_SINKS];
320837d542aSEvan Quan 
321837d542aSEvan Quan     uint8_t                             DTEAmbientTempBase;
322837d542aSEvan Quan     uint8_t                             DTETjOffset;
323837d542aSEvan Quan     uint8_t                             GpuTjMax;
324837d542aSEvan Quan     uint8_t                             GpuTjHyst;
325837d542aSEvan Quan 
326837d542aSEvan Quan     uint16_t                            BootVddc;
327837d542aSEvan Quan     uint16_t                            BootVddci;
328837d542aSEvan Quan 
329837d542aSEvan Quan     uint16_t                            BootMVdd;
330837d542aSEvan Quan     uint16_t                            padding;
331837d542aSEvan Quan 
332837d542aSEvan Quan     uint32_t                            BAPM_TEMP_GRADIENT;
333837d542aSEvan Quan 
334837d542aSEvan Quan     uint32_t                            LowSclkInterruptThreshold;
335837d542aSEvan Quan     uint32_t                            VddGfxReChkWait;
336837d542aSEvan Quan 
337837d542aSEvan Quan     uint16_t                            PPM_PkgPwrLimit;
338837d542aSEvan Quan     uint16_t                            PPM_TemperatureLimit;
339837d542aSEvan Quan 
340837d542aSEvan Quan     uint16_t                            DefaultTdp;
341837d542aSEvan Quan     uint16_t                            TargetTdp;
342837d542aSEvan Quan };
343837d542aSEvan Quan 
344837d542aSEvan Quan typedef struct SMU71_Discrete_DpmTable SMU71_Discrete_DpmTable;
345837d542aSEvan Quan 
346837d542aSEvan Quan // --------------------------------------------------- AC Timing Parameters ------------------------------------------------
347837d542aSEvan Quan #define SMU71_DISCRETE_MC_REGISTER_ARRAY_SIZE 16
348837d542aSEvan Quan #define SMU71_DISCRETE_MC_REGISTER_ARRAY_SET_COUNT SMU71_MAX_LEVELS_MEMORY
349837d542aSEvan Quan 
350837d542aSEvan Quan struct SMU71_Discrete_MCRegisterAddress
351837d542aSEvan Quan {
352837d542aSEvan Quan     uint16_t s0;
353837d542aSEvan Quan     uint16_t s1;
354837d542aSEvan Quan };
355837d542aSEvan Quan 
356837d542aSEvan Quan typedef struct SMU71_Discrete_MCRegisterAddress SMU71_Discrete_MCRegisterAddress;
357837d542aSEvan Quan 
358837d542aSEvan Quan struct SMU71_Discrete_MCRegisterSet
359837d542aSEvan Quan {
360837d542aSEvan Quan     uint32_t value[SMU71_DISCRETE_MC_REGISTER_ARRAY_SIZE];
361837d542aSEvan Quan };
362837d542aSEvan Quan 
363837d542aSEvan Quan typedef struct SMU71_Discrete_MCRegisterSet SMU71_Discrete_MCRegisterSet;
364837d542aSEvan Quan 
365837d542aSEvan Quan struct SMU71_Discrete_MCRegisters
366837d542aSEvan Quan {
367837d542aSEvan Quan     uint8_t                             last;
368837d542aSEvan Quan     uint8_t                             reserved[3];
369837d542aSEvan Quan     SMU71_Discrete_MCRegisterAddress     address[SMU71_DISCRETE_MC_REGISTER_ARRAY_SIZE];
370837d542aSEvan Quan     SMU71_Discrete_MCRegisterSet         data[SMU71_DISCRETE_MC_REGISTER_ARRAY_SET_COUNT];
371837d542aSEvan Quan };
372837d542aSEvan Quan 
373837d542aSEvan Quan typedef struct SMU71_Discrete_MCRegisters SMU71_Discrete_MCRegisters;
374837d542aSEvan Quan 
375837d542aSEvan Quan 
376837d542aSEvan Quan // --------------------------------------------------- Fan Table -----------------------------------------------------------
377837d542aSEvan Quan struct SMU71_Discrete_FanTable
378837d542aSEvan Quan {
379837d542aSEvan Quan     uint16_t FdoMode;
380837d542aSEvan Quan     int16_t  TempMin;
381837d542aSEvan Quan     int16_t  TempMed;
382837d542aSEvan Quan     int16_t  TempMax;
383837d542aSEvan Quan     int16_t  Slope1;
384837d542aSEvan Quan     int16_t  Slope2;
385837d542aSEvan Quan     int16_t  FdoMin;
386837d542aSEvan Quan     int16_t  HystUp;
387837d542aSEvan Quan     int16_t  HystDown;
388837d542aSEvan Quan     int16_t  HystSlope;
389837d542aSEvan Quan     int16_t  TempRespLim;
390837d542aSEvan Quan     int16_t  TempCurr;
391837d542aSEvan Quan     int16_t  SlopeCurr;
392837d542aSEvan Quan     int16_t  PwmCurr;
393837d542aSEvan Quan     uint32_t RefreshPeriod;
394837d542aSEvan Quan     int16_t  FdoMax;
395837d542aSEvan Quan     uint8_t  TempSrc;
396837d542aSEvan Quan     int8_t   Padding;
397837d542aSEvan Quan };
398837d542aSEvan Quan 
399837d542aSEvan Quan typedef struct SMU71_Discrete_FanTable SMU71_Discrete_FanTable;
400837d542aSEvan Quan 
401837d542aSEvan Quan #define SMU7_DISCRETE_GPIO_SCLK_DEBUG             4
402837d542aSEvan Quan #define SMU7_DISCRETE_GPIO_SCLK_DEBUG_BIT         (0x1 << SMU7_DISCRETE_GPIO_SCLK_DEBUG)
403837d542aSEvan Quan 
404837d542aSEvan Quan struct SMU71_MclkDpmScoreboard
405837d542aSEvan Quan {
406837d542aSEvan Quan 
407837d542aSEvan Quan     uint32_t PercentageBusy;
408837d542aSEvan Quan 
409837d542aSEvan Quan     int32_t  PIDError;
410837d542aSEvan Quan     int32_t  PIDIntegral;
411837d542aSEvan Quan     int32_t  PIDOutput;
412837d542aSEvan Quan 
413837d542aSEvan Quan     uint32_t SigmaDeltaAccum;
414837d542aSEvan Quan     uint32_t SigmaDeltaOutput;
415837d542aSEvan Quan     uint32_t SigmaDeltaLevel;
416837d542aSEvan Quan 
417837d542aSEvan Quan     uint32_t UtilizationSetpoint;
418837d542aSEvan Quan 
419837d542aSEvan Quan     uint8_t  TdpClampMode;
420837d542aSEvan Quan     uint8_t  TdcClampMode;
421837d542aSEvan Quan     uint8_t  ThermClampMode;
422837d542aSEvan Quan     uint8_t  VoltageBusy;
423837d542aSEvan Quan 
424837d542aSEvan Quan     int8_t   CurrLevel;
425837d542aSEvan Quan     int8_t   TargLevel;
426837d542aSEvan Quan     uint8_t  LevelChangeInProgress;
427837d542aSEvan Quan     uint8_t  UpHyst;
428837d542aSEvan Quan 
429837d542aSEvan Quan     uint8_t  DownHyst;
430837d542aSEvan Quan     uint8_t  VoltageDownHyst;
431837d542aSEvan Quan     uint8_t  DpmEnable;
432837d542aSEvan Quan     uint8_t  DpmRunning;
433837d542aSEvan Quan 
434837d542aSEvan Quan     uint8_t  DpmForce;
435837d542aSEvan Quan     uint8_t  DpmForceLevel;
436837d542aSEvan Quan     uint8_t  DisplayWatermark;
437837d542aSEvan Quan     uint8_t  McArbIndex;
438837d542aSEvan Quan 
439837d542aSEvan Quan     uint32_t MinimumPerfMclk;
440837d542aSEvan Quan 
441837d542aSEvan Quan     uint8_t  AcpiReq;
442837d542aSEvan Quan     uint8_t  AcpiAck;
443837d542aSEvan Quan     uint8_t  MclkSwitchInProgress;
444837d542aSEvan Quan     uint8_t  MclkSwitchCritical;
445837d542aSEvan Quan 
446837d542aSEvan Quan     uint8_t  TargetMclkIndex;
447837d542aSEvan Quan     uint8_t  TargetMvddIndex;
448837d542aSEvan Quan     uint8_t  MclkSwitchResult;
449837d542aSEvan Quan 
450837d542aSEvan Quan     uint8_t  EnabledLevelsChange;
451837d542aSEvan Quan 
452837d542aSEvan Quan     uint16_t LevelResidencyCounters [SMU71_MAX_LEVELS_MEMORY];
453837d542aSEvan Quan     uint16_t LevelSwitchCounters [SMU71_MAX_LEVELS_MEMORY];
454837d542aSEvan Quan 
455837d542aSEvan Quan     void     (*TargetStateCalculator)(uint8_t);
456837d542aSEvan Quan     void     (*SavedTargetStateCalculator)(uint8_t);
457837d542aSEvan Quan 
458837d542aSEvan Quan     uint16_t AutoDpmInterval;
459837d542aSEvan Quan     uint16_t AutoDpmRange;
460837d542aSEvan Quan 
461837d542aSEvan Quan     uint16_t  MclkSwitchingTime;
462837d542aSEvan Quan     uint8_t padding[2];
463837d542aSEvan Quan };
464837d542aSEvan Quan 
465837d542aSEvan Quan typedef struct SMU71_MclkDpmScoreboard SMU71_MclkDpmScoreboard;
466837d542aSEvan Quan 
467837d542aSEvan Quan struct SMU71_UlvScoreboard
468837d542aSEvan Quan {
469837d542aSEvan Quan     uint8_t     EnterUlv;
470837d542aSEvan Quan     uint8_t     ExitUlv;
471837d542aSEvan Quan     uint8_t     UlvActive;
472837d542aSEvan Quan     uint8_t     WaitingForUlv;
473837d542aSEvan Quan     uint8_t     UlvEnable;
474837d542aSEvan Quan     uint8_t     UlvRunning;
475837d542aSEvan Quan     uint8_t     UlvMasterEnable;
476837d542aSEvan Quan     uint8_t     padding;
477837d542aSEvan Quan     uint32_t    UlvAbortedCount;
478837d542aSEvan Quan     uint32_t    UlvTimeStamp;
479837d542aSEvan Quan };
480837d542aSEvan Quan 
481837d542aSEvan Quan typedef struct SMU71_UlvScoreboard SMU71_UlvScoreboard;
482837d542aSEvan Quan 
483837d542aSEvan Quan struct SMU71_VddGfxScoreboard
484837d542aSEvan Quan {
485837d542aSEvan Quan     uint8_t     VddGfxEnable;
486837d542aSEvan Quan     uint8_t     VddGfxActive;
487837d542aSEvan Quan     uint8_t     padding[2];
488837d542aSEvan Quan 
489837d542aSEvan Quan     uint32_t    VddGfxEnteredCount;
490837d542aSEvan Quan     uint32_t    VddGfxAbortedCount;
491837d542aSEvan Quan };
492837d542aSEvan Quan 
493837d542aSEvan Quan typedef struct SMU71_VddGfxScoreboard SMU71_VddGfxScoreboard;
494837d542aSEvan Quan 
495837d542aSEvan Quan struct SMU71_AcpiScoreboard {
496837d542aSEvan Quan   uint32_t SavedInterruptMask[2];
497837d542aSEvan Quan   uint8_t LastACPIRequest;
498837d542aSEvan Quan   uint8_t CgBifResp;
499837d542aSEvan Quan   uint8_t RequestType;
500837d542aSEvan Quan   uint8_t Padding;
501837d542aSEvan Quan   SMU71_Discrete_ACPILevel D0Level;
502837d542aSEvan Quan };
503837d542aSEvan Quan 
504837d542aSEvan Quan typedef struct SMU71_AcpiScoreboard SMU71_AcpiScoreboard;
505837d542aSEvan Quan 
506837d542aSEvan Quan 
507837d542aSEvan Quan struct SMU71_Discrete_PmFuses {
508837d542aSEvan Quan   // dw0-dw1
509837d542aSEvan Quan   uint8_t BapmVddCVidHiSidd[8];
510837d542aSEvan Quan 
511837d542aSEvan Quan   // dw2-dw3
512837d542aSEvan Quan   uint8_t BapmVddCVidLoSidd[8];
513837d542aSEvan Quan 
514837d542aSEvan Quan   // dw4-dw5
515837d542aSEvan Quan   uint8_t VddCVid[8];
516837d542aSEvan Quan 
517837d542aSEvan Quan   // dw6
518837d542aSEvan Quan   uint8_t SviLoadLineEn;
519837d542aSEvan Quan   uint8_t SviLoadLineVddC;
520837d542aSEvan Quan   uint8_t SviLoadLineTrimVddC;
521837d542aSEvan Quan   uint8_t SviLoadLineOffsetVddC;
522837d542aSEvan Quan 
523837d542aSEvan Quan   // dw7
524837d542aSEvan Quan   uint16_t TDC_VDDC_PkgLimit;
525837d542aSEvan Quan   uint8_t TDC_VDDC_ThrottleReleaseLimitPerc;
526837d542aSEvan Quan   uint8_t TDC_MAWt;
527837d542aSEvan Quan 
528837d542aSEvan Quan   // dw8
529837d542aSEvan Quan   uint8_t TdcWaterfallCtl;
530837d542aSEvan Quan   uint8_t LPMLTemperatureMin;
531837d542aSEvan Quan   uint8_t LPMLTemperatureMax;
532837d542aSEvan Quan   uint8_t Reserved;
533837d542aSEvan Quan 
534837d542aSEvan Quan   // dw9-dw12
535837d542aSEvan Quan   uint8_t LPMLTemperatureScaler[16];
536837d542aSEvan Quan 
537837d542aSEvan Quan   // dw13-dw14
538837d542aSEvan Quan   int16_t FuzzyFan_ErrorSetDelta;
539837d542aSEvan Quan   int16_t FuzzyFan_ErrorRateSetDelta;
540837d542aSEvan Quan   int16_t FuzzyFan_PwmSetDelta;
541837d542aSEvan Quan   uint16_t Reserved6;
542837d542aSEvan Quan 
543837d542aSEvan Quan   // dw15
544837d542aSEvan Quan   uint8_t GnbLPML[16];
545837d542aSEvan Quan 
546837d542aSEvan Quan   // dw15
547837d542aSEvan Quan   uint8_t GnbLPMLMaxVid;
548837d542aSEvan Quan   uint8_t GnbLPMLMinVid;
549837d542aSEvan Quan   uint8_t Reserved1[2];
550837d542aSEvan Quan 
551837d542aSEvan Quan   // dw16
552837d542aSEvan Quan   uint16_t BapmVddCBaseLeakageHiSidd;
553837d542aSEvan Quan   uint16_t BapmVddCBaseLeakageLoSidd;
554837d542aSEvan Quan };
555837d542aSEvan Quan 
556837d542aSEvan Quan typedef struct SMU71_Discrete_PmFuses SMU71_Discrete_PmFuses;
557837d542aSEvan Quan 
558837d542aSEvan Quan struct SMU71_Discrete_Log_Header_Table {
559837d542aSEvan Quan   uint32_t    version;
560837d542aSEvan Quan   uint32_t    asic_id;
561837d542aSEvan Quan   uint16_t    flags;
562837d542aSEvan Quan   uint16_t    entry_size;
563837d542aSEvan Quan   uint32_t    total_size;
564837d542aSEvan Quan   uint32_t    num_of_entries;
565837d542aSEvan Quan   uint8_t     type;
566837d542aSEvan Quan   uint8_t     mode;
567837d542aSEvan Quan   uint8_t     filler_0[2];
568837d542aSEvan Quan   uint32_t    filler_1[2];
569837d542aSEvan Quan };
570837d542aSEvan Quan 
571837d542aSEvan Quan typedef struct SMU71_Discrete_Log_Header_Table SMU71_Discrete_Log_Header_Table;
572837d542aSEvan Quan 
573837d542aSEvan Quan struct SMU71_Discrete_Log_Cntl {
574837d542aSEvan Quan     uint8_t             Enabled;
575837d542aSEvan Quan     uint8_t             Type;
576837d542aSEvan Quan     uint8_t             padding[2];
577837d542aSEvan Quan     uint32_t            BufferSize;
578837d542aSEvan Quan     uint32_t            SamplesLogged;
579837d542aSEvan Quan     uint32_t            SampleSize;
580837d542aSEvan Quan     uint32_t            AddrL;
581837d542aSEvan Quan     uint32_t            AddrH;
582837d542aSEvan Quan };
583837d542aSEvan Quan 
584837d542aSEvan Quan typedef struct SMU71_Discrete_Log_Cntl SMU71_Discrete_Log_Cntl;
585837d542aSEvan Quan 
586837d542aSEvan Quan #if defined SMU__DGPU_ONLY
587837d542aSEvan Quan   #define CAC_ACC_NW_NUM_OF_SIGNALS 83
588837d542aSEvan Quan #endif
589837d542aSEvan Quan 
590837d542aSEvan Quan 
591837d542aSEvan Quan struct SMU71_Discrete_Cac_Collection_Table {
592837d542aSEvan Quan   uint32_t temperature;
593837d542aSEvan Quan   uint32_t cac_acc_nw[CAC_ACC_NW_NUM_OF_SIGNALS];
594837d542aSEvan Quan   uint32_t filler[4];
595837d542aSEvan Quan };
596837d542aSEvan Quan 
597837d542aSEvan Quan typedef struct SMU71_Discrete_Cac_Collection_Table SMU71_Discrete_Cac_Collection_Table;
598837d542aSEvan Quan 
599837d542aSEvan Quan struct SMU71_Discrete_Cac_Verification_Table {
600837d542aSEvan Quan   uint32_t VddcTotalPower;
601837d542aSEvan Quan   uint32_t VddcLeakagePower;
602837d542aSEvan Quan   uint32_t VddcConstantPower;
603837d542aSEvan Quan   uint32_t VddcGfxDynamicPower;
604837d542aSEvan Quan   uint32_t VddcUvdDynamicPower;
605837d542aSEvan Quan   uint32_t VddcVceDynamicPower;
606837d542aSEvan Quan   uint32_t VddcAcpDynamicPower;
607837d542aSEvan Quan   uint32_t VddcPcieDynamicPower;
608837d542aSEvan Quan   uint32_t VddcDceDynamicPower;
609837d542aSEvan Quan   uint32_t VddcCurrent;
610837d542aSEvan Quan   uint32_t VddcVoltage;
611837d542aSEvan Quan   uint32_t VddciTotalPower;
612837d542aSEvan Quan   uint32_t VddciLeakagePower;
613837d542aSEvan Quan   uint32_t VddciConstantPower;
614837d542aSEvan Quan   uint32_t VddciDynamicPower;
615837d542aSEvan Quan   uint32_t Vddr1TotalPower;
616837d542aSEvan Quan   uint32_t Vddr1LeakagePower;
617837d542aSEvan Quan   uint32_t Vddr1ConstantPower;
618837d542aSEvan Quan   uint32_t Vddr1DynamicPower;
619837d542aSEvan Quan   uint32_t spare[8];
620837d542aSEvan Quan   uint32_t temperature;
621837d542aSEvan Quan };
622837d542aSEvan Quan 
623837d542aSEvan Quan typedef struct SMU71_Discrete_Cac_Verification_Table SMU71_Discrete_Cac_Verification_Table;
624837d542aSEvan Quan 
625837d542aSEvan Quan #if !defined(SMC_MICROCODE)
626837d542aSEvan Quan #pragma pack(pop)
627837d542aSEvan Quan #endif
628837d542aSEvan Quan 
629837d542aSEvan Quan 
630837d542aSEvan Quan #endif
631837d542aSEvan Quan 
632