18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright 2013 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
248c2ecf20Sopenharmony_ci#ifndef SMU7_FUSION_H
258c2ecf20Sopenharmony_ci#define SMU7_FUSION_H
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci#include "smu7.h"
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci#pragma pack(push, 1)
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci#define SMU7_DTE_ITERATIONS 5
328c2ecf20Sopenharmony_ci#define SMU7_DTE_SOURCES 5
338c2ecf20Sopenharmony_ci#define SMU7_DTE_SINKS 3
348c2ecf20Sopenharmony_ci#define SMU7_NUM_CPU_TES 2
358c2ecf20Sopenharmony_ci#define SMU7_NUM_GPU_TES 1
368c2ecf20Sopenharmony_ci#define SMU7_NUM_NON_TES 2
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci// All 'soft registers' should be uint32_t.
398c2ecf20Sopenharmony_cistruct SMU7_SoftRegisters
408c2ecf20Sopenharmony_ci{
418c2ecf20Sopenharmony_ci    uint32_t        RefClockFrequency;
428c2ecf20Sopenharmony_ci    uint32_t        PmTimerP;
438c2ecf20Sopenharmony_ci    uint32_t        FeatureEnables;
448c2ecf20Sopenharmony_ci    uint32_t        HandshakeDisables;
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci    uint8_t         DisplayPhy1Config;
478c2ecf20Sopenharmony_ci    uint8_t         DisplayPhy2Config;
488c2ecf20Sopenharmony_ci    uint8_t         DisplayPhy3Config;
498c2ecf20Sopenharmony_ci    uint8_t         DisplayPhy4Config;
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci    uint8_t         DisplayPhy5Config;
528c2ecf20Sopenharmony_ci    uint8_t         DisplayPhy6Config;
538c2ecf20Sopenharmony_ci    uint8_t         DisplayPhy7Config;
548c2ecf20Sopenharmony_ci    uint8_t         DisplayPhy8Config;
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci    uint32_t        AverageGraphicsA;
578c2ecf20Sopenharmony_ci    uint32_t        AverageMemoryA;
588c2ecf20Sopenharmony_ci    uint32_t        AverageGioA;
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci    uint8_t         SClkDpmEnabledLevels;
618c2ecf20Sopenharmony_ci    uint8_t         MClkDpmEnabledLevels;
628c2ecf20Sopenharmony_ci    uint8_t         LClkDpmEnabledLevels;
638c2ecf20Sopenharmony_ci    uint8_t         PCIeDpmEnabledLevels;
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci    uint8_t         UVDDpmEnabledLevels;
668c2ecf20Sopenharmony_ci    uint8_t         SAMUDpmEnabledLevels;
678c2ecf20Sopenharmony_ci    uint8_t         ACPDpmEnabledLevels;
688c2ecf20Sopenharmony_ci    uint8_t         VCEDpmEnabledLevels;
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_ci    uint32_t        DRAM_LOG_ADDR_H;
718c2ecf20Sopenharmony_ci    uint32_t        DRAM_LOG_ADDR_L;
728c2ecf20Sopenharmony_ci    uint32_t        DRAM_LOG_PHY_ADDR_H;
738c2ecf20Sopenharmony_ci    uint32_t        DRAM_LOG_PHY_ADDR_L;
748c2ecf20Sopenharmony_ci    uint32_t        DRAM_LOG_BUFF_SIZE;
758c2ecf20Sopenharmony_ci    uint32_t        UlvEnterC;
768c2ecf20Sopenharmony_ci    uint32_t        UlvTime;
778c2ecf20Sopenharmony_ci    uint32_t        Reserved[3];
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ci};
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_citypedef struct SMU7_SoftRegisters SMU7_SoftRegisters;
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_cistruct SMU7_Fusion_GraphicsLevel
848c2ecf20Sopenharmony_ci{
858c2ecf20Sopenharmony_ci    uint32_t    MinVddNb;
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_ci    uint32_t    SclkFrequency;
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci    uint8_t     Vid;
908c2ecf20Sopenharmony_ci    uint8_t     VidOffset;
918c2ecf20Sopenharmony_ci    uint16_t    AT;
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ci    uint8_t     PowerThrottle;
948c2ecf20Sopenharmony_ci    uint8_t     GnbSlow;
958c2ecf20Sopenharmony_ci    uint8_t     ForceNbPs1;
968c2ecf20Sopenharmony_ci    uint8_t     SclkDid;
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ci    uint8_t     DisplayWatermark;
998c2ecf20Sopenharmony_ci    uint8_t     EnabledForActivity;
1008c2ecf20Sopenharmony_ci    uint8_t     EnabledForThrottle;
1018c2ecf20Sopenharmony_ci    uint8_t     UpH;
1028c2ecf20Sopenharmony_ci
1038c2ecf20Sopenharmony_ci    uint8_t     DownH;
1048c2ecf20Sopenharmony_ci    uint8_t     VoltageDownH;
1058c2ecf20Sopenharmony_ci    uint8_t     DeepSleepDivId;
1068c2ecf20Sopenharmony_ci
1078c2ecf20Sopenharmony_ci    uint8_t     ClkBypassCntl;
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_ci    uint32_t    reserved;
1108c2ecf20Sopenharmony_ci};
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_citypedef struct SMU7_Fusion_GraphicsLevel SMU7_Fusion_GraphicsLevel;
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_cistruct SMU7_Fusion_GIOLevel
1158c2ecf20Sopenharmony_ci{
1168c2ecf20Sopenharmony_ci    uint8_t     EnabledForActivity;
1178c2ecf20Sopenharmony_ci    uint8_t     LclkDid;
1188c2ecf20Sopenharmony_ci    uint8_t     Vid;
1198c2ecf20Sopenharmony_ci    uint8_t     VoltageDownH;
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_ci    uint32_t    MinVddNb;
1228c2ecf20Sopenharmony_ci
1238c2ecf20Sopenharmony_ci    uint16_t    ResidencyCounter;
1248c2ecf20Sopenharmony_ci    uint8_t     UpH;
1258c2ecf20Sopenharmony_ci    uint8_t     DownH;
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_ci    uint32_t    LclkFrequency;
1288c2ecf20Sopenharmony_ci
1298c2ecf20Sopenharmony_ci    uint8_t     ActivityLevel;
1308c2ecf20Sopenharmony_ci    uint8_t     EnabledForThrottle;
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ci    uint8_t     ClkBypassCntl;
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_ci    uint8_t     padding;
1358c2ecf20Sopenharmony_ci};
1368c2ecf20Sopenharmony_ci
1378c2ecf20Sopenharmony_citypedef struct SMU7_Fusion_GIOLevel SMU7_Fusion_GIOLevel;
1388c2ecf20Sopenharmony_ci
1398c2ecf20Sopenharmony_ci// UVD VCLK/DCLK state (level) definition.
1408c2ecf20Sopenharmony_cistruct SMU7_Fusion_UvdLevel
1418c2ecf20Sopenharmony_ci{
1428c2ecf20Sopenharmony_ci    uint32_t VclkFrequency;
1438c2ecf20Sopenharmony_ci    uint32_t DclkFrequency;
1448c2ecf20Sopenharmony_ci    uint16_t MinVddNb;
1458c2ecf20Sopenharmony_ci    uint8_t  VclkDivider;
1468c2ecf20Sopenharmony_ci    uint8_t  DclkDivider;
1478c2ecf20Sopenharmony_ci
1488c2ecf20Sopenharmony_ci    uint8_t     VClkBypassCntl;
1498c2ecf20Sopenharmony_ci    uint8_t     DClkBypassCntl;
1508c2ecf20Sopenharmony_ci
1518c2ecf20Sopenharmony_ci    uint8_t     padding[2];
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_ci};
1548c2ecf20Sopenharmony_ci
1558c2ecf20Sopenharmony_citypedef struct SMU7_Fusion_UvdLevel SMU7_Fusion_UvdLevel;
1568c2ecf20Sopenharmony_ci
1578c2ecf20Sopenharmony_ci// Clocks for other external blocks (VCE, ACP, SAMU).
1588c2ecf20Sopenharmony_cistruct SMU7_Fusion_ExtClkLevel
1598c2ecf20Sopenharmony_ci{
1608c2ecf20Sopenharmony_ci    uint32_t Frequency;
1618c2ecf20Sopenharmony_ci    uint16_t MinVoltage;
1628c2ecf20Sopenharmony_ci    uint8_t  Divider;
1638c2ecf20Sopenharmony_ci    uint8_t  ClkBypassCntl;
1648c2ecf20Sopenharmony_ci
1658c2ecf20Sopenharmony_ci    uint32_t Reserved;
1668c2ecf20Sopenharmony_ci};
1678c2ecf20Sopenharmony_citypedef struct SMU7_Fusion_ExtClkLevel SMU7_Fusion_ExtClkLevel;
1688c2ecf20Sopenharmony_ci
1698c2ecf20Sopenharmony_cistruct SMU7_Fusion_ACPILevel
1708c2ecf20Sopenharmony_ci{
1718c2ecf20Sopenharmony_ci    uint32_t    Flags;
1728c2ecf20Sopenharmony_ci    uint32_t    MinVddNb;
1738c2ecf20Sopenharmony_ci    uint32_t    SclkFrequency;
1748c2ecf20Sopenharmony_ci    uint8_t     SclkDid;
1758c2ecf20Sopenharmony_ci    uint8_t     GnbSlow;
1768c2ecf20Sopenharmony_ci    uint8_t     ForceNbPs1;
1778c2ecf20Sopenharmony_ci    uint8_t     DisplayWatermark;
1788c2ecf20Sopenharmony_ci    uint8_t     DeepSleepDivId;
1798c2ecf20Sopenharmony_ci    uint8_t     padding[3];
1808c2ecf20Sopenharmony_ci};
1818c2ecf20Sopenharmony_ci
1828c2ecf20Sopenharmony_citypedef struct SMU7_Fusion_ACPILevel SMU7_Fusion_ACPILevel;
1838c2ecf20Sopenharmony_ci
1848c2ecf20Sopenharmony_cistruct SMU7_Fusion_NbDpm
1858c2ecf20Sopenharmony_ci{
1868c2ecf20Sopenharmony_ci    uint8_t DpmXNbPsHi;
1878c2ecf20Sopenharmony_ci    uint8_t DpmXNbPsLo;
1888c2ecf20Sopenharmony_ci    uint8_t Dpm0PgNbPsHi;
1898c2ecf20Sopenharmony_ci    uint8_t Dpm0PgNbPsLo;
1908c2ecf20Sopenharmony_ci    uint8_t EnablePsi1;
1918c2ecf20Sopenharmony_ci    uint8_t SkipDPM0;
1928c2ecf20Sopenharmony_ci    uint8_t SkipPG;
1938c2ecf20Sopenharmony_ci    uint8_t Hysteresis;
1948c2ecf20Sopenharmony_ci    uint8_t EnableDpmPstatePoll;
1958c2ecf20Sopenharmony_ci    uint8_t padding[3];
1968c2ecf20Sopenharmony_ci};
1978c2ecf20Sopenharmony_ci
1988c2ecf20Sopenharmony_citypedef struct SMU7_Fusion_NbDpm SMU7_Fusion_NbDpm;
1998c2ecf20Sopenharmony_ci
2008c2ecf20Sopenharmony_cistruct SMU7_Fusion_StateInfo
2018c2ecf20Sopenharmony_ci{
2028c2ecf20Sopenharmony_ci    uint32_t SclkFrequency;
2038c2ecf20Sopenharmony_ci    uint32_t LclkFrequency;
2048c2ecf20Sopenharmony_ci    uint32_t VclkFrequency;
2058c2ecf20Sopenharmony_ci    uint32_t DclkFrequency;
2068c2ecf20Sopenharmony_ci    uint32_t SamclkFrequency;
2078c2ecf20Sopenharmony_ci    uint32_t AclkFrequency;
2088c2ecf20Sopenharmony_ci    uint32_t EclkFrequency;
2098c2ecf20Sopenharmony_ci    uint8_t  DisplayWatermark;
2108c2ecf20Sopenharmony_ci    uint8_t  McArbIndex;
2118c2ecf20Sopenharmony_ci    int8_t   SclkIndex;
2128c2ecf20Sopenharmony_ci    int8_t   MclkIndex;
2138c2ecf20Sopenharmony_ci};
2148c2ecf20Sopenharmony_ci
2158c2ecf20Sopenharmony_citypedef struct SMU7_Fusion_StateInfo SMU7_Fusion_StateInfo;
2168c2ecf20Sopenharmony_ci
2178c2ecf20Sopenharmony_cistruct SMU7_Fusion_DpmTable
2188c2ecf20Sopenharmony_ci{
2198c2ecf20Sopenharmony_ci    uint32_t                            SystemFlags;
2208c2ecf20Sopenharmony_ci
2218c2ecf20Sopenharmony_ci    SMU7_PIDController                  GraphicsPIDController;
2228c2ecf20Sopenharmony_ci    SMU7_PIDController                  GioPIDController;
2238c2ecf20Sopenharmony_ci
2248c2ecf20Sopenharmony_ci    uint8_t                            GraphicsDpmLevelCount;
2258c2ecf20Sopenharmony_ci    uint8_t                            GIOLevelCount;
2268c2ecf20Sopenharmony_ci    uint8_t                            UvdLevelCount;
2278c2ecf20Sopenharmony_ci    uint8_t                            VceLevelCount;
2288c2ecf20Sopenharmony_ci
2298c2ecf20Sopenharmony_ci    uint8_t                            AcpLevelCount;
2308c2ecf20Sopenharmony_ci    uint8_t                            SamuLevelCount;
2318c2ecf20Sopenharmony_ci    uint16_t                           FpsHighT;
2328c2ecf20Sopenharmony_ci
2338c2ecf20Sopenharmony_ci    SMU7_Fusion_GraphicsLevel         GraphicsLevel           [SMU__NUM_SCLK_DPM_STATE];
2348c2ecf20Sopenharmony_ci    SMU7_Fusion_ACPILevel             ACPILevel;
2358c2ecf20Sopenharmony_ci    SMU7_Fusion_UvdLevel              UvdLevel                [SMU7_MAX_LEVELS_UVD];
2368c2ecf20Sopenharmony_ci    SMU7_Fusion_ExtClkLevel           VceLevel                [SMU7_MAX_LEVELS_VCE];
2378c2ecf20Sopenharmony_ci    SMU7_Fusion_ExtClkLevel           AcpLevel                [SMU7_MAX_LEVELS_ACP];
2388c2ecf20Sopenharmony_ci    SMU7_Fusion_ExtClkLevel           SamuLevel               [SMU7_MAX_LEVELS_SAMU];
2398c2ecf20Sopenharmony_ci
2408c2ecf20Sopenharmony_ci    uint8_t                           UvdBootLevel;
2418c2ecf20Sopenharmony_ci    uint8_t                           VceBootLevel;
2428c2ecf20Sopenharmony_ci    uint8_t                           AcpBootLevel;
2438c2ecf20Sopenharmony_ci    uint8_t                           SamuBootLevel;
2448c2ecf20Sopenharmony_ci    uint8_t                           UVDInterval;
2458c2ecf20Sopenharmony_ci    uint8_t                           VCEInterval;
2468c2ecf20Sopenharmony_ci    uint8_t                           ACPInterval;
2478c2ecf20Sopenharmony_ci    uint8_t                           SAMUInterval;
2488c2ecf20Sopenharmony_ci
2498c2ecf20Sopenharmony_ci    uint8_t                           GraphicsBootLevel;
2508c2ecf20Sopenharmony_ci    uint8_t                           GraphicsInterval;
2518c2ecf20Sopenharmony_ci    uint8_t                           GraphicsThermThrottleEnable;
2528c2ecf20Sopenharmony_ci    uint8_t                           GraphicsVoltageChangeEnable;
2538c2ecf20Sopenharmony_ci
2548c2ecf20Sopenharmony_ci    uint8_t                           GraphicsClkSlowEnable;
2558c2ecf20Sopenharmony_ci    uint8_t                           GraphicsClkSlowDivider;
2568c2ecf20Sopenharmony_ci    uint16_t                          FpsLowT;
2578c2ecf20Sopenharmony_ci
2588c2ecf20Sopenharmony_ci    uint32_t                          DisplayCac;
2598c2ecf20Sopenharmony_ci    uint32_t                          LowSclkInterruptT;
2608c2ecf20Sopenharmony_ci
2618c2ecf20Sopenharmony_ci    uint32_t                          DRAM_LOG_ADDR_H;
2628c2ecf20Sopenharmony_ci    uint32_t                          DRAM_LOG_ADDR_L;
2638c2ecf20Sopenharmony_ci    uint32_t                          DRAM_LOG_PHY_ADDR_H;
2648c2ecf20Sopenharmony_ci    uint32_t                          DRAM_LOG_PHY_ADDR_L;
2658c2ecf20Sopenharmony_ci    uint32_t                          DRAM_LOG_BUFF_SIZE;
2668c2ecf20Sopenharmony_ci
2678c2ecf20Sopenharmony_ci};
2688c2ecf20Sopenharmony_ci
2698c2ecf20Sopenharmony_cistruct SMU7_Fusion_GIODpmTable
2708c2ecf20Sopenharmony_ci{
2718c2ecf20Sopenharmony_ci
2728c2ecf20Sopenharmony_ci    SMU7_Fusion_GIOLevel              GIOLevel                [SMU7_MAX_LEVELS_GIO];
2738c2ecf20Sopenharmony_ci
2748c2ecf20Sopenharmony_ci    SMU7_PIDController                GioPIDController;
2758c2ecf20Sopenharmony_ci
2768c2ecf20Sopenharmony_ci    uint32_t                          GIOLevelCount;
2778c2ecf20Sopenharmony_ci
2788c2ecf20Sopenharmony_ci    uint8_t                           Enable;
2798c2ecf20Sopenharmony_ci    uint8_t                           GIOVoltageChangeEnable;
2808c2ecf20Sopenharmony_ci    uint8_t                           GIOBootLevel;
2818c2ecf20Sopenharmony_ci    uint8_t                           padding;
2828c2ecf20Sopenharmony_ci    uint8_t                           padding1[2];
2838c2ecf20Sopenharmony_ci    uint8_t                           TargetState;
2848c2ecf20Sopenharmony_ci    uint8_t                           CurrenttState;
2858c2ecf20Sopenharmony_ci    uint8_t                           ThrottleOnHtc;
2868c2ecf20Sopenharmony_ci    uint8_t                           ThermThrottleStatus;
2878c2ecf20Sopenharmony_ci    uint8_t                           ThermThrottleTempSelect;
2888c2ecf20Sopenharmony_ci    uint8_t                           ThermThrottleEnable;
2898c2ecf20Sopenharmony_ci    uint16_t                          TemperatureLimitHigh;
2908c2ecf20Sopenharmony_ci    uint16_t                          TemperatureLimitLow;
2918c2ecf20Sopenharmony_ci
2928c2ecf20Sopenharmony_ci};
2938c2ecf20Sopenharmony_ci
2948c2ecf20Sopenharmony_citypedef struct SMU7_Fusion_DpmTable SMU7_Fusion_DpmTable;
2958c2ecf20Sopenharmony_citypedef struct SMU7_Fusion_GIODpmTable SMU7_Fusion_GIODpmTable;
2968c2ecf20Sopenharmony_ci
2978c2ecf20Sopenharmony_ci#pragma pack(pop)
2988c2ecf20Sopenharmony_ci
2998c2ecf20Sopenharmony_ci#endif
3008c2ecf20Sopenharmony_ci
301