18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright 2016 Advanced Micro Devices, Inc.
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
58c2ecf20Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
68c2ecf20Sopenharmony_ci * to deal in the Software without restriction, including without limitation
78c2ecf20Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
88c2ecf20Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
98c2ecf20Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
108c2ecf20Sopenharmony_ci *
118c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice shall be included in
128c2ecf20Sopenharmony_ci * all copies or substantial portions of the Software.
138c2ecf20Sopenharmony_ci *
148c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
158c2ecf20Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
168c2ecf20Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
178c2ecf20Sopenharmony_ci * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
188c2ecf20Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
198c2ecf20Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
208c2ecf20Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE.
218c2ecf20Sopenharmony_ci *
228c2ecf20Sopenharmony_ci */
238c2ecf20Sopenharmony_ci#ifndef SMU71_H
248c2ecf20Sopenharmony_ci#define SMU71_H
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci#if !defined(SMC_MICROCODE)
278c2ecf20Sopenharmony_ci#pragma pack(push, 1)
288c2ecf20Sopenharmony_ci#endif
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci#define SMU__NUM_PCIE_DPM_LEVELS 8
318c2ecf20Sopenharmony_ci#define SMU__NUM_SCLK_DPM_STATE 8
328c2ecf20Sopenharmony_ci#define SMU__NUM_MCLK_DPM_LEVELS 4
338c2ecf20Sopenharmony_ci#define SMU__VARIANT__ICELAND 1
348c2ecf20Sopenharmony_ci#define SMU__DGPU_ONLY 1
358c2ecf20Sopenharmony_ci#define SMU__DYNAMIC_MCARB_SETTINGS 1
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_cienum SID_OPTION {
388c2ecf20Sopenharmony_ci  SID_OPTION_HI,
398c2ecf20Sopenharmony_ci  SID_OPTION_LO,
408c2ecf20Sopenharmony_ci  SID_OPTION_COUNT
418c2ecf20Sopenharmony_ci};
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_citypedef struct {
448c2ecf20Sopenharmony_ci  uint32_t high;
458c2ecf20Sopenharmony_ci  uint32_t low;
468c2ecf20Sopenharmony_ci} data_64_t;
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_citypedef struct {
498c2ecf20Sopenharmony_ci  data_64_t high;
508c2ecf20Sopenharmony_ci  data_64_t low;
518c2ecf20Sopenharmony_ci} data_128_t;
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci#define SMU7_CONTEXT_ID_SMC        1
548c2ecf20Sopenharmony_ci#define SMU7_CONTEXT_ID_VBIOS      2
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci#define SMU71_MAX_LEVELS_VDDC            8
578c2ecf20Sopenharmony_ci#define SMU71_MAX_LEVELS_VDDCI           4
588c2ecf20Sopenharmony_ci#define SMU71_MAX_LEVELS_MVDD            4
598c2ecf20Sopenharmony_ci#define SMU71_MAX_LEVELS_VDDNB           8
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci#define SMU71_MAX_LEVELS_GRAPHICS        SMU__NUM_SCLK_DPM_STATE
628c2ecf20Sopenharmony_ci#define SMU71_MAX_LEVELS_MEMORY          SMU__NUM_MCLK_DPM_LEVELS
638c2ecf20Sopenharmony_ci#define SMU71_MAX_LEVELS_GIO             SMU__NUM_LCLK_DPM_LEVELS
648c2ecf20Sopenharmony_ci#define SMU71_MAX_LEVELS_LINK            SMU__NUM_PCIE_DPM_LEVELS
658c2ecf20Sopenharmony_ci#define SMU71_MAX_ENTRIES_SMIO           32
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_ci#define DPM_NO_LIMIT 0
688c2ecf20Sopenharmony_ci#define DPM_NO_UP 1
698c2ecf20Sopenharmony_ci#define DPM_GO_DOWN 2
708c2ecf20Sopenharmony_ci#define DPM_GO_UP 3
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci#define SMU7_FIRST_DPM_GRAPHICS_LEVEL    0
738c2ecf20Sopenharmony_ci#define SMU7_FIRST_DPM_MEMORY_LEVEL      0
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_ci#define GPIO_CLAMP_MODE_VRHOT      1
768c2ecf20Sopenharmony_ci#define GPIO_CLAMP_MODE_THERM      2
778c2ecf20Sopenharmony_ci#define GPIO_CLAMP_MODE_DC         4
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ci#define SCRATCH_B_TARG_PCIE_INDEX_SHIFT 0
808c2ecf20Sopenharmony_ci#define SCRATCH_B_TARG_PCIE_INDEX_MASK  (0x7<<SCRATCH_B_TARG_PCIE_INDEX_SHIFT)
818c2ecf20Sopenharmony_ci#define SCRATCH_B_CURR_PCIE_INDEX_SHIFT 3
828c2ecf20Sopenharmony_ci#define SCRATCH_B_CURR_PCIE_INDEX_MASK  (0x7<<SCRATCH_B_CURR_PCIE_INDEX_SHIFT)
838c2ecf20Sopenharmony_ci#define SCRATCH_B_TARG_UVD_INDEX_SHIFT  6
848c2ecf20Sopenharmony_ci#define SCRATCH_B_TARG_UVD_INDEX_MASK   (0x7<<SCRATCH_B_TARG_UVD_INDEX_SHIFT)
858c2ecf20Sopenharmony_ci#define SCRATCH_B_CURR_UVD_INDEX_SHIFT  9
868c2ecf20Sopenharmony_ci#define SCRATCH_B_CURR_UVD_INDEX_MASK   (0x7<<SCRATCH_B_CURR_UVD_INDEX_SHIFT)
878c2ecf20Sopenharmony_ci#define SCRATCH_B_TARG_VCE_INDEX_SHIFT  12
888c2ecf20Sopenharmony_ci#define SCRATCH_B_TARG_VCE_INDEX_MASK   (0x7<<SCRATCH_B_TARG_VCE_INDEX_SHIFT)
898c2ecf20Sopenharmony_ci#define SCRATCH_B_CURR_VCE_INDEX_SHIFT  15
908c2ecf20Sopenharmony_ci#define SCRATCH_B_CURR_VCE_INDEX_MASK   (0x7<<SCRATCH_B_CURR_VCE_INDEX_SHIFT)
918c2ecf20Sopenharmony_ci#define SCRATCH_B_TARG_ACP_INDEX_SHIFT  18
928c2ecf20Sopenharmony_ci#define SCRATCH_B_TARG_ACP_INDEX_MASK   (0x7<<SCRATCH_B_TARG_ACP_INDEX_SHIFT)
938c2ecf20Sopenharmony_ci#define SCRATCH_B_CURR_ACP_INDEX_SHIFT  21
948c2ecf20Sopenharmony_ci#define SCRATCH_B_CURR_ACP_INDEX_MASK   (0x7<<SCRATCH_B_CURR_ACP_INDEX_SHIFT)
958c2ecf20Sopenharmony_ci#define SCRATCH_B_TARG_SAMU_INDEX_SHIFT 24
968c2ecf20Sopenharmony_ci#define SCRATCH_B_TARG_SAMU_INDEX_MASK  (0x7<<SCRATCH_B_TARG_SAMU_INDEX_SHIFT)
978c2ecf20Sopenharmony_ci#define SCRATCH_B_CURR_SAMU_INDEX_SHIFT 27
988c2ecf20Sopenharmony_ci#define SCRATCH_B_CURR_SAMU_INDEX_MASK  (0x7<<SCRATCH_B_CURR_SAMU_INDEX_SHIFT)
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_ci#if defined SMU__DGPU_ONLY
1028c2ecf20Sopenharmony_ci#define SMU71_DTE_ITERATIONS 5
1038c2ecf20Sopenharmony_ci#define SMU71_DTE_SOURCES 3
1048c2ecf20Sopenharmony_ci#define SMU71_DTE_SINKS 1
1058c2ecf20Sopenharmony_ci#define SMU71_NUM_CPU_TES 0
1068c2ecf20Sopenharmony_ci#define SMU71_NUM_GPU_TES 1
1078c2ecf20Sopenharmony_ci#define SMU71_NUM_NON_TES 2
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_ci#endif
1108c2ecf20Sopenharmony_ci
1118c2ecf20Sopenharmony_ci#if defined SMU__FUSION_ONLY
1128c2ecf20Sopenharmony_ci#define SMU7_DTE_ITERATIONS 5
1138c2ecf20Sopenharmony_ci#define SMU7_DTE_SOURCES 5
1148c2ecf20Sopenharmony_ci#define SMU7_DTE_SINKS 3
1158c2ecf20Sopenharmony_ci#define SMU7_NUM_CPU_TES 2
1168c2ecf20Sopenharmony_ci#define SMU7_NUM_GPU_TES 1
1178c2ecf20Sopenharmony_ci#define SMU7_NUM_NON_TES 2
1188c2ecf20Sopenharmony_ci
1198c2ecf20Sopenharmony_ci#endif
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_cistruct SMU71_PIDController
1228c2ecf20Sopenharmony_ci{
1238c2ecf20Sopenharmony_ci    uint32_t Ki;
1248c2ecf20Sopenharmony_ci    int32_t LFWindupUpperLim;
1258c2ecf20Sopenharmony_ci    int32_t LFWindupLowerLim;
1268c2ecf20Sopenharmony_ci    uint32_t StatePrecision;
1278c2ecf20Sopenharmony_ci    uint32_t LfPrecision;
1288c2ecf20Sopenharmony_ci    uint32_t LfOffset;
1298c2ecf20Sopenharmony_ci    uint32_t MaxState;
1308c2ecf20Sopenharmony_ci    uint32_t MaxLfFraction;
1318c2ecf20Sopenharmony_ci    uint32_t StateShift;
1328c2ecf20Sopenharmony_ci};
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_citypedef struct SMU71_PIDController SMU71_PIDController;
1358c2ecf20Sopenharmony_ci
1368c2ecf20Sopenharmony_cistruct SMU7_LocalDpmScoreboard
1378c2ecf20Sopenharmony_ci{
1388c2ecf20Sopenharmony_ci    uint32_t PercentageBusy;
1398c2ecf20Sopenharmony_ci
1408c2ecf20Sopenharmony_ci    int32_t  PIDError;
1418c2ecf20Sopenharmony_ci    int32_t  PIDIntegral;
1428c2ecf20Sopenharmony_ci    int32_t  PIDOutput;
1438c2ecf20Sopenharmony_ci
1448c2ecf20Sopenharmony_ci    uint32_t SigmaDeltaAccum;
1458c2ecf20Sopenharmony_ci    uint32_t SigmaDeltaOutput;
1468c2ecf20Sopenharmony_ci    uint32_t SigmaDeltaLevel;
1478c2ecf20Sopenharmony_ci
1488c2ecf20Sopenharmony_ci    uint32_t UtilizationSetpoint;
1498c2ecf20Sopenharmony_ci
1508c2ecf20Sopenharmony_ci    uint8_t  TdpClampMode;
1518c2ecf20Sopenharmony_ci    uint8_t  TdcClampMode;
1528c2ecf20Sopenharmony_ci    uint8_t  ThermClampMode;
1538c2ecf20Sopenharmony_ci    uint8_t  VoltageBusy;
1548c2ecf20Sopenharmony_ci
1558c2ecf20Sopenharmony_ci    int8_t   CurrLevel;
1568c2ecf20Sopenharmony_ci    int8_t   TargLevel;
1578c2ecf20Sopenharmony_ci    uint8_t  LevelChangeInProgress;
1588c2ecf20Sopenharmony_ci    uint8_t  UpHyst;
1598c2ecf20Sopenharmony_ci
1608c2ecf20Sopenharmony_ci    uint8_t  DownHyst;
1618c2ecf20Sopenharmony_ci    uint8_t  VoltageDownHyst;
1628c2ecf20Sopenharmony_ci    uint8_t  DpmEnable;
1638c2ecf20Sopenharmony_ci    uint8_t  DpmRunning;
1648c2ecf20Sopenharmony_ci
1658c2ecf20Sopenharmony_ci    uint8_t  DpmForce;
1668c2ecf20Sopenharmony_ci    uint8_t  DpmForceLevel;
1678c2ecf20Sopenharmony_ci    uint8_t  DisplayWatermark;
1688c2ecf20Sopenharmony_ci    uint8_t  McArbIndex;
1698c2ecf20Sopenharmony_ci
1708c2ecf20Sopenharmony_ci    uint32_t MinimumPerfSclk;
1718c2ecf20Sopenharmony_ci
1728c2ecf20Sopenharmony_ci    uint8_t  AcpiReq;
1738c2ecf20Sopenharmony_ci    uint8_t  AcpiAck;
1748c2ecf20Sopenharmony_ci    uint8_t  GfxClkSlow;
1758c2ecf20Sopenharmony_ci    uint8_t  GpioClampMode;
1768c2ecf20Sopenharmony_ci
1778c2ecf20Sopenharmony_ci    uint8_t  FpsFilterWeight;
1788c2ecf20Sopenharmony_ci    uint8_t  EnabledLevelsChange;
1798c2ecf20Sopenharmony_ci    uint8_t  DteClampMode;
1808c2ecf20Sopenharmony_ci    uint8_t  FpsClampMode;
1818c2ecf20Sopenharmony_ci
1828c2ecf20Sopenharmony_ci    uint16_t LevelResidencyCounters [SMU71_MAX_LEVELS_GRAPHICS];
1838c2ecf20Sopenharmony_ci    uint16_t LevelSwitchCounters [SMU71_MAX_LEVELS_GRAPHICS];
1848c2ecf20Sopenharmony_ci
1858c2ecf20Sopenharmony_ci    void     (*TargetStateCalculator)(uint8_t);
1868c2ecf20Sopenharmony_ci    void     (*SavedTargetStateCalculator)(uint8_t);
1878c2ecf20Sopenharmony_ci
1888c2ecf20Sopenharmony_ci    uint16_t AutoDpmInterval;
1898c2ecf20Sopenharmony_ci    uint16_t AutoDpmRange;
1908c2ecf20Sopenharmony_ci
1918c2ecf20Sopenharmony_ci    uint8_t  FpsEnabled;
1928c2ecf20Sopenharmony_ci    uint8_t  MaxPerfLevel;
1938c2ecf20Sopenharmony_ci    uint8_t  AllowLowClkInterruptToHost;
1948c2ecf20Sopenharmony_ci    uint8_t  FpsRunning;
1958c2ecf20Sopenharmony_ci
1968c2ecf20Sopenharmony_ci    uint32_t MaxAllowedFrequency;
1978c2ecf20Sopenharmony_ci};
1988c2ecf20Sopenharmony_ci
1998c2ecf20Sopenharmony_citypedef struct SMU7_LocalDpmScoreboard SMU7_LocalDpmScoreboard;
2008c2ecf20Sopenharmony_ci
2018c2ecf20Sopenharmony_ci#define SMU7_MAX_VOLTAGE_CLIENTS 12
2028c2ecf20Sopenharmony_ci
2038c2ecf20Sopenharmony_cistruct SMU7_VoltageScoreboard
2048c2ecf20Sopenharmony_ci{
2058c2ecf20Sopenharmony_ci    uint16_t CurrentVoltage;
2068c2ecf20Sopenharmony_ci    uint16_t HighestVoltage;
2078c2ecf20Sopenharmony_ci    uint16_t MaxVid;
2088c2ecf20Sopenharmony_ci    uint8_t  HighestVidOffset;
2098c2ecf20Sopenharmony_ci    uint8_t  CurrentVidOffset;
2108c2ecf20Sopenharmony_ci#if defined (SMU__DGPU_ONLY)
2118c2ecf20Sopenharmony_ci    uint8_t  CurrentPhases;
2128c2ecf20Sopenharmony_ci    uint8_t  HighestPhases;
2138c2ecf20Sopenharmony_ci#else
2148c2ecf20Sopenharmony_ci    uint8_t  AvsOffset;
2158c2ecf20Sopenharmony_ci    uint8_t  AvsOffsetApplied;
2168c2ecf20Sopenharmony_ci#endif
2178c2ecf20Sopenharmony_ci    uint8_t  ControllerBusy;
2188c2ecf20Sopenharmony_ci    uint8_t  CurrentVid;
2198c2ecf20Sopenharmony_ci    uint16_t RequestedVoltage[SMU7_MAX_VOLTAGE_CLIENTS];
2208c2ecf20Sopenharmony_ci#if defined (SMU__DGPU_ONLY)
2218c2ecf20Sopenharmony_ci    uint8_t  RequestedPhases[SMU7_MAX_VOLTAGE_CLIENTS];
2228c2ecf20Sopenharmony_ci#endif
2238c2ecf20Sopenharmony_ci    uint8_t  EnabledRequest[SMU7_MAX_VOLTAGE_CLIENTS];
2248c2ecf20Sopenharmony_ci    uint8_t  TargetIndex;
2258c2ecf20Sopenharmony_ci    uint8_t  Delay;
2268c2ecf20Sopenharmony_ci    uint8_t  ControllerEnable;
2278c2ecf20Sopenharmony_ci    uint8_t  ControllerRunning;
2288c2ecf20Sopenharmony_ci    uint16_t CurrentStdVoltageHiSidd;
2298c2ecf20Sopenharmony_ci    uint16_t CurrentStdVoltageLoSidd;
2308c2ecf20Sopenharmony_ci#if defined (SMU__DGPU_ONLY)
2318c2ecf20Sopenharmony_ci    uint16_t RequestedVddci;
2328c2ecf20Sopenharmony_ci    uint16_t CurrentVddci;
2338c2ecf20Sopenharmony_ci    uint16_t HighestVddci;
2348c2ecf20Sopenharmony_ci    uint8_t  CurrentVddciVid;
2358c2ecf20Sopenharmony_ci    uint8_t  TargetVddciIndex;
2368c2ecf20Sopenharmony_ci#endif
2378c2ecf20Sopenharmony_ci};
2388c2ecf20Sopenharmony_ci
2398c2ecf20Sopenharmony_citypedef struct SMU7_VoltageScoreboard SMU7_VoltageScoreboard;
2408c2ecf20Sopenharmony_ci
2418c2ecf20Sopenharmony_ci// -------------------------------------------------------------------------------------------------------------------------
2428c2ecf20Sopenharmony_ci#define SMU7_MAX_PCIE_LINK_SPEEDS 3 /* 0:Gen1 1:Gen2 2:Gen3 */
2438c2ecf20Sopenharmony_ci
2448c2ecf20Sopenharmony_cistruct SMU7_PCIeLinkSpeedScoreboard
2458c2ecf20Sopenharmony_ci{
2468c2ecf20Sopenharmony_ci    uint8_t     DpmEnable;
2478c2ecf20Sopenharmony_ci    uint8_t     DpmRunning;
2488c2ecf20Sopenharmony_ci    uint8_t     DpmForce;
2498c2ecf20Sopenharmony_ci    uint8_t     DpmForceLevel;
2508c2ecf20Sopenharmony_ci
2518c2ecf20Sopenharmony_ci    uint8_t     CurrentLinkSpeed;
2528c2ecf20Sopenharmony_ci    uint8_t     EnabledLevelsChange;
2538c2ecf20Sopenharmony_ci    uint16_t    AutoDpmInterval;
2548c2ecf20Sopenharmony_ci
2558c2ecf20Sopenharmony_ci    uint16_t    AutoDpmRange;
2568c2ecf20Sopenharmony_ci    uint16_t    AutoDpmCount;
2578c2ecf20Sopenharmony_ci
2588c2ecf20Sopenharmony_ci    uint8_t     DpmMode;
2598c2ecf20Sopenharmony_ci    uint8_t     AcpiReq;
2608c2ecf20Sopenharmony_ci    uint8_t     AcpiAck;
2618c2ecf20Sopenharmony_ci    uint8_t     CurrentLinkLevel;
2628c2ecf20Sopenharmony_ci
2638c2ecf20Sopenharmony_ci};
2648c2ecf20Sopenharmony_ci
2658c2ecf20Sopenharmony_citypedef struct SMU7_PCIeLinkSpeedScoreboard SMU7_PCIeLinkSpeedScoreboard;
2668c2ecf20Sopenharmony_ci
2678c2ecf20Sopenharmony_ci// -------------------------------------------------------- CAC table ------------------------------------------------------
2688c2ecf20Sopenharmony_ci#define SMU7_LKGE_LUT_NUM_OF_TEMP_ENTRIES 16
2698c2ecf20Sopenharmony_ci#define SMU7_LKGE_LUT_NUM_OF_VOLT_ENTRIES 16
2708c2ecf20Sopenharmony_ci
2718c2ecf20Sopenharmony_ci#define SMU7_SCALE_I  7
2728c2ecf20Sopenharmony_ci#define SMU7_SCALE_R 12
2738c2ecf20Sopenharmony_ci
2748c2ecf20Sopenharmony_cistruct SMU7_PowerScoreboard
2758c2ecf20Sopenharmony_ci{
2768c2ecf20Sopenharmony_ci    uint16_t   MinVoltage;
2778c2ecf20Sopenharmony_ci    uint16_t   MaxVoltage;
2788c2ecf20Sopenharmony_ci
2798c2ecf20Sopenharmony_ci    uint32_t   AvgGpuPower;
2808c2ecf20Sopenharmony_ci
2818c2ecf20Sopenharmony_ci    uint16_t   VddcLeakagePower[SID_OPTION_COUNT];
2828c2ecf20Sopenharmony_ci    uint16_t   VddcSclkConstantPower[SID_OPTION_COUNT];
2838c2ecf20Sopenharmony_ci    uint16_t   VddcSclkDynamicPower[SID_OPTION_COUNT];
2848c2ecf20Sopenharmony_ci    uint16_t   VddcNonSclkDynamicPower[SID_OPTION_COUNT];
2858c2ecf20Sopenharmony_ci    uint16_t   VddcTotalPower[SID_OPTION_COUNT];
2868c2ecf20Sopenharmony_ci    uint16_t   VddcTotalCurrent[SID_OPTION_COUNT];
2878c2ecf20Sopenharmony_ci    uint16_t   VddcLoadVoltage[SID_OPTION_COUNT];
2888c2ecf20Sopenharmony_ci    uint16_t   VddcNoLoadVoltage[SID_OPTION_COUNT];
2898c2ecf20Sopenharmony_ci
2908c2ecf20Sopenharmony_ci    uint16_t   DisplayPhyPower;
2918c2ecf20Sopenharmony_ci    uint16_t   PciePhyPower;
2928c2ecf20Sopenharmony_ci
2938c2ecf20Sopenharmony_ci    uint16_t   VddciTotalPower;
2948c2ecf20Sopenharmony_ci    uint16_t   Vddr1TotalPower;
2958c2ecf20Sopenharmony_ci
2968c2ecf20Sopenharmony_ci    uint32_t   RocPower;
2978c2ecf20Sopenharmony_ci
2988c2ecf20Sopenharmony_ci    uint32_t   last_power;
2998c2ecf20Sopenharmony_ci    uint32_t   enableWinAvg;
3008c2ecf20Sopenharmony_ci
3018c2ecf20Sopenharmony_ci    uint32_t   lkg_acc;
3028c2ecf20Sopenharmony_ci    uint16_t   VoltLkgeScaler;
3038c2ecf20Sopenharmony_ci    uint16_t   TempLkgeScaler;
3048c2ecf20Sopenharmony_ci
3058c2ecf20Sopenharmony_ci    uint32_t   uvd_cac_dclk;
3068c2ecf20Sopenharmony_ci    uint32_t   uvd_cac_vclk;
3078c2ecf20Sopenharmony_ci    uint32_t   vce_cac_eclk;
3088c2ecf20Sopenharmony_ci    uint32_t   samu_cac_samclk;
3098c2ecf20Sopenharmony_ci    uint32_t   display_cac_dispclk;
3108c2ecf20Sopenharmony_ci    uint32_t   acp_cac_aclk;
3118c2ecf20Sopenharmony_ci    uint32_t   unb_cac;
3128c2ecf20Sopenharmony_ci
3138c2ecf20Sopenharmony_ci    uint32_t   WinTime;
3148c2ecf20Sopenharmony_ci
3158c2ecf20Sopenharmony_ci    uint16_t  GpuPwr_MAWt;
3168c2ecf20Sopenharmony_ci    uint16_t  FilteredVddcTotalPower;
3178c2ecf20Sopenharmony_ci
3188c2ecf20Sopenharmony_ci    uint8_t   CalculationRepeats;
3198c2ecf20Sopenharmony_ci    uint8_t   WaterfallUp;
3208c2ecf20Sopenharmony_ci    uint8_t   WaterfallDown;
3218c2ecf20Sopenharmony_ci    uint8_t   WaterfallLimit;
3228c2ecf20Sopenharmony_ci};
3238c2ecf20Sopenharmony_ci
3248c2ecf20Sopenharmony_citypedef struct SMU7_PowerScoreboard SMU7_PowerScoreboard;
3258c2ecf20Sopenharmony_ci
3268c2ecf20Sopenharmony_ci// --------------------------------------------------------------------------------------------------
3278c2ecf20Sopenharmony_ci
3288c2ecf20Sopenharmony_cistruct SMU7_ThermalScoreboard
3298c2ecf20Sopenharmony_ci{
3308c2ecf20Sopenharmony_ci   int16_t  GpuLimit;
3318c2ecf20Sopenharmony_ci   int16_t  GpuHyst;
3328c2ecf20Sopenharmony_ci   uint16_t CurrGnbTemp;
3338c2ecf20Sopenharmony_ci   uint16_t FilteredGnbTemp;
3348c2ecf20Sopenharmony_ci   uint8_t  ControllerEnable;
3358c2ecf20Sopenharmony_ci   uint8_t  ControllerRunning;
3368c2ecf20Sopenharmony_ci   uint8_t  WaterfallUp;
3378c2ecf20Sopenharmony_ci   uint8_t  WaterfallDown;
3388c2ecf20Sopenharmony_ci   uint8_t  WaterfallLimit;
3398c2ecf20Sopenharmony_ci   uint8_t  padding[3];
3408c2ecf20Sopenharmony_ci};
3418c2ecf20Sopenharmony_ci
3428c2ecf20Sopenharmony_citypedef struct SMU7_ThermalScoreboard SMU7_ThermalScoreboard;
3438c2ecf20Sopenharmony_ci
3448c2ecf20Sopenharmony_ci// For FeatureEnables:
3458c2ecf20Sopenharmony_ci#define SMU7_SCLK_DPM_CONFIG_MASK                        0x01
3468c2ecf20Sopenharmony_ci#define SMU7_VOLTAGE_CONTROLLER_CONFIG_MASK              0x02
3478c2ecf20Sopenharmony_ci#define SMU7_THERMAL_CONTROLLER_CONFIG_MASK              0x04
3488c2ecf20Sopenharmony_ci#define SMU7_MCLK_DPM_CONFIG_MASK                        0x08
3498c2ecf20Sopenharmony_ci#define SMU7_UVD_DPM_CONFIG_MASK                         0x10
3508c2ecf20Sopenharmony_ci#define SMU7_VCE_DPM_CONFIG_MASK                         0x20
3518c2ecf20Sopenharmony_ci#define SMU7_ACP_DPM_CONFIG_MASK                         0x40
3528c2ecf20Sopenharmony_ci#define SMU7_SAMU_DPM_CONFIG_MASK                        0x80
3538c2ecf20Sopenharmony_ci#define SMU7_PCIEGEN_DPM_CONFIG_MASK                    0x100
3548c2ecf20Sopenharmony_ci
3558c2ecf20Sopenharmony_ci#define SMU7_ACP_MCLK_HANDSHAKE_DISABLE                  0x00000001
3568c2ecf20Sopenharmony_ci#define SMU7_ACP_SCLK_HANDSHAKE_DISABLE                  0x00000002
3578c2ecf20Sopenharmony_ci#define SMU7_UVD_MCLK_HANDSHAKE_DISABLE                  0x00000100
3588c2ecf20Sopenharmony_ci#define SMU7_UVD_SCLK_HANDSHAKE_DISABLE                  0x00000200
3598c2ecf20Sopenharmony_ci#define SMU7_VCE_MCLK_HANDSHAKE_DISABLE                  0x00010000
3608c2ecf20Sopenharmony_ci#define SMU7_VCE_SCLK_HANDSHAKE_DISABLE                  0x00020000
3618c2ecf20Sopenharmony_ci
3628c2ecf20Sopenharmony_ci// All 'soft registers' should be uint32_t.
3638c2ecf20Sopenharmony_cistruct SMU71_SoftRegisters
3648c2ecf20Sopenharmony_ci{
3658c2ecf20Sopenharmony_ci    uint32_t        RefClockFrequency;
3668c2ecf20Sopenharmony_ci    uint32_t        PmTimerPeriod;
3678c2ecf20Sopenharmony_ci    uint32_t        FeatureEnables;
3688c2ecf20Sopenharmony_ci#if defined (SMU__DGPU_ONLY)
3698c2ecf20Sopenharmony_ci    uint32_t        PreVBlankGap;
3708c2ecf20Sopenharmony_ci    uint32_t        VBlankTimeout;
3718c2ecf20Sopenharmony_ci    uint32_t        TrainTimeGap;
3728c2ecf20Sopenharmony_ci    uint32_t        MvddSwitchTime;
3738c2ecf20Sopenharmony_ci    uint32_t        LongestAcpiTrainTime;
3748c2ecf20Sopenharmony_ci    uint32_t        AcpiDelay;
3758c2ecf20Sopenharmony_ci    uint32_t        G5TrainTime;
3768c2ecf20Sopenharmony_ci    uint32_t        DelayMpllPwron;
3778c2ecf20Sopenharmony_ci    uint32_t        VoltageChangeTimeout;
3788c2ecf20Sopenharmony_ci#endif
3798c2ecf20Sopenharmony_ci    uint32_t        HandshakeDisables;
3808c2ecf20Sopenharmony_ci
3818c2ecf20Sopenharmony_ci    uint8_t         DisplayPhy1Config;
3828c2ecf20Sopenharmony_ci    uint8_t         DisplayPhy2Config;
3838c2ecf20Sopenharmony_ci    uint8_t         DisplayPhy3Config;
3848c2ecf20Sopenharmony_ci    uint8_t         DisplayPhy4Config;
3858c2ecf20Sopenharmony_ci
3868c2ecf20Sopenharmony_ci    uint8_t         DisplayPhy5Config;
3878c2ecf20Sopenharmony_ci    uint8_t         DisplayPhy6Config;
3888c2ecf20Sopenharmony_ci    uint8_t         DisplayPhy7Config;
3898c2ecf20Sopenharmony_ci    uint8_t         DisplayPhy8Config;
3908c2ecf20Sopenharmony_ci
3918c2ecf20Sopenharmony_ci    uint32_t        AverageGraphicsActivity;
3928c2ecf20Sopenharmony_ci    uint32_t        AverageMemoryActivity;
3938c2ecf20Sopenharmony_ci    uint32_t        AverageGioActivity;
3948c2ecf20Sopenharmony_ci
3958c2ecf20Sopenharmony_ci    uint8_t         SClkDpmEnabledLevels;
3968c2ecf20Sopenharmony_ci    uint8_t         MClkDpmEnabledLevels;
3978c2ecf20Sopenharmony_ci    uint8_t         LClkDpmEnabledLevels;
3988c2ecf20Sopenharmony_ci    uint8_t         PCIeDpmEnabledLevels;
3998c2ecf20Sopenharmony_ci
4008c2ecf20Sopenharmony_ci    uint32_t        DRAM_LOG_ADDR_H;
4018c2ecf20Sopenharmony_ci    uint32_t        DRAM_LOG_ADDR_L;
4028c2ecf20Sopenharmony_ci    uint32_t        DRAM_LOG_PHY_ADDR_H;
4038c2ecf20Sopenharmony_ci    uint32_t        DRAM_LOG_PHY_ADDR_L;
4048c2ecf20Sopenharmony_ci    uint32_t        DRAM_LOG_BUFF_SIZE;
4058c2ecf20Sopenharmony_ci    uint32_t        UlvEnterCount;
4068c2ecf20Sopenharmony_ci    uint32_t        UlvTime;
4078c2ecf20Sopenharmony_ci    uint32_t        UcodeLoadStatus;
4088c2ecf20Sopenharmony_ci    uint8_t         DPMFreezeAndForced;
4098c2ecf20Sopenharmony_ci    uint8_t         Activity_Weight;
4108c2ecf20Sopenharmony_ci    uint8_t         Reserved8[2];
4118c2ecf20Sopenharmony_ci    uint32_t        Reserved;
4128c2ecf20Sopenharmony_ci};
4138c2ecf20Sopenharmony_ci
4148c2ecf20Sopenharmony_citypedef struct SMU71_SoftRegisters SMU71_SoftRegisters;
4158c2ecf20Sopenharmony_ci
4168c2ecf20Sopenharmony_cistruct SMU71_Firmware_Header
4178c2ecf20Sopenharmony_ci{
4188c2ecf20Sopenharmony_ci    uint32_t Digest[5];
4198c2ecf20Sopenharmony_ci    uint32_t Version;
4208c2ecf20Sopenharmony_ci    uint32_t HeaderSize;
4218c2ecf20Sopenharmony_ci    uint32_t Flags;
4228c2ecf20Sopenharmony_ci    uint32_t EntryPoint;
4238c2ecf20Sopenharmony_ci    uint32_t CodeSize;
4248c2ecf20Sopenharmony_ci    uint32_t ImageSize;
4258c2ecf20Sopenharmony_ci
4268c2ecf20Sopenharmony_ci    uint32_t Rtos;
4278c2ecf20Sopenharmony_ci    uint32_t SoftRegisters;
4288c2ecf20Sopenharmony_ci    uint32_t DpmTable;
4298c2ecf20Sopenharmony_ci    uint32_t FanTable;
4308c2ecf20Sopenharmony_ci    uint32_t CacConfigTable;
4318c2ecf20Sopenharmony_ci    uint32_t CacStatusTable;
4328c2ecf20Sopenharmony_ci
4338c2ecf20Sopenharmony_ci    uint32_t mcRegisterTable;
4348c2ecf20Sopenharmony_ci
4358c2ecf20Sopenharmony_ci    uint32_t mcArbDramTimingTable;
4368c2ecf20Sopenharmony_ci
4378c2ecf20Sopenharmony_ci    uint32_t PmFuseTable;
4388c2ecf20Sopenharmony_ci    uint32_t Globals;
4398c2ecf20Sopenharmony_ci    uint32_t UvdDpmTable;
4408c2ecf20Sopenharmony_ci    uint32_t AcpDpmTable;
4418c2ecf20Sopenharmony_ci    uint32_t VceDpmTable;
4428c2ecf20Sopenharmony_ci    uint32_t SamuDpmTable;
4438c2ecf20Sopenharmony_ci    uint32_t UlvSettings;
4448c2ecf20Sopenharmony_ci    uint32_t Reserved[37];
4458c2ecf20Sopenharmony_ci    uint32_t Signature;
4468c2ecf20Sopenharmony_ci};
4478c2ecf20Sopenharmony_ci
4488c2ecf20Sopenharmony_citypedef struct SMU71_Firmware_Header SMU71_Firmware_Header;
4498c2ecf20Sopenharmony_ci
4508c2ecf20Sopenharmony_cistruct SMU7_HystController_Data
4518c2ecf20Sopenharmony_ci{
4528c2ecf20Sopenharmony_ci    uint8_t waterfall_up;
4538c2ecf20Sopenharmony_ci    uint8_t waterfall_down;
4548c2ecf20Sopenharmony_ci    uint8_t pstate;
4558c2ecf20Sopenharmony_ci    uint8_t clamp_mode;
4568c2ecf20Sopenharmony_ci};
4578c2ecf20Sopenharmony_ci
4588c2ecf20Sopenharmony_citypedef struct SMU7_HystController_Data SMU7_HystController_Data;
4598c2ecf20Sopenharmony_ci
4608c2ecf20Sopenharmony_ci#define SMU71_FIRMWARE_HEADER_LOCATION 0x20000
4618c2ecf20Sopenharmony_ci
4628c2ecf20Sopenharmony_cienum  DisplayConfig {
4638c2ecf20Sopenharmony_ci    PowerDown = 1,
4648c2ecf20Sopenharmony_ci    DP54x4,
4658c2ecf20Sopenharmony_ci    DP54x2,
4668c2ecf20Sopenharmony_ci    DP54x1,
4678c2ecf20Sopenharmony_ci    DP27x4,
4688c2ecf20Sopenharmony_ci    DP27x2,
4698c2ecf20Sopenharmony_ci    DP27x1,
4708c2ecf20Sopenharmony_ci    HDMI297,
4718c2ecf20Sopenharmony_ci    HDMI162,
4728c2ecf20Sopenharmony_ci    LVDS,
4738c2ecf20Sopenharmony_ci    DP324x4,
4748c2ecf20Sopenharmony_ci    DP324x2,
4758c2ecf20Sopenharmony_ci    DP324x1
4768c2ecf20Sopenharmony_ci};
4778c2ecf20Sopenharmony_ci
4788c2ecf20Sopenharmony_ci//#define SX_BLOCK_COUNT 8
4798c2ecf20Sopenharmony_ci//#define MC_BLOCK_COUNT 1
4808c2ecf20Sopenharmony_ci//#define CPL_BLOCK_COUNT 27
4818c2ecf20Sopenharmony_ci
4828c2ecf20Sopenharmony_ci#if defined SMU__VARIANT__ICELAND
4838c2ecf20Sopenharmony_ci  #define SX_BLOCK_COUNT 8
4848c2ecf20Sopenharmony_ci  #define MC_BLOCK_COUNT 1
4858c2ecf20Sopenharmony_ci  #define CPL_BLOCK_COUNT 29
4868c2ecf20Sopenharmony_ci#endif
4878c2ecf20Sopenharmony_ci
4888c2ecf20Sopenharmony_cistruct SMU7_Local_Cac {
4898c2ecf20Sopenharmony_ci  uint8_t BlockId;
4908c2ecf20Sopenharmony_ci  uint8_t SignalId;
4918c2ecf20Sopenharmony_ci  uint8_t Threshold;
4928c2ecf20Sopenharmony_ci  uint8_t Padding;
4938c2ecf20Sopenharmony_ci};
4948c2ecf20Sopenharmony_ci
4958c2ecf20Sopenharmony_citypedef struct SMU7_Local_Cac SMU7_Local_Cac;
4968c2ecf20Sopenharmony_ci
4978c2ecf20Sopenharmony_cistruct SMU7_Local_Cac_Table {
4988c2ecf20Sopenharmony_ci  SMU7_Local_Cac SxLocalCac[SX_BLOCK_COUNT];
4998c2ecf20Sopenharmony_ci  SMU7_Local_Cac CplLocalCac[CPL_BLOCK_COUNT];
5008c2ecf20Sopenharmony_ci  SMU7_Local_Cac McLocalCac[MC_BLOCK_COUNT];
5018c2ecf20Sopenharmony_ci};
5028c2ecf20Sopenharmony_ci
5038c2ecf20Sopenharmony_citypedef struct SMU7_Local_Cac_Table SMU7_Local_Cac_Table;
5048c2ecf20Sopenharmony_ci
5058c2ecf20Sopenharmony_ci#if !defined(SMC_MICROCODE)
5068c2ecf20Sopenharmony_ci#pragma pack(pop)
5078c2ecf20Sopenharmony_ci#endif
5088c2ecf20Sopenharmony_ci
5098c2ecf20Sopenharmony_ci#endif
5108c2ecf20Sopenharmony_ci
511