Home | History | Annotate | Line # | Download | only in inc
      1 /*	$NetBSD: smu7_discrete.h,v 1.2 2021/12/18 23:45:26 riastradh Exp $	*/
      2 
      3 /*
      4  * Copyright 2013 Advanced Micro Devices, Inc.
      5  *
      6  * Permission is hereby granted, free of charge, to any person obtaining a
      7  * copy of this software and associated documentation files (the "Software"),
      8  * to deal in the Software without restriction, including without limitation
      9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
     10  * and/or sell copies of the Software, and to permit persons to whom the
     11  * Software is furnished to do so, subject to the following conditions:
     12  *
     13  * The above copyright notice and this permission notice shall be included in
     14  * all copies or substantial portions of the Software.
     15  *
     16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     19  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
     20  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
     21  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
     22  * OTHER DEALINGS IN THE SOFTWARE.
     23  *
     24  */
     25 
     26 #ifndef SMU7_DISCRETE_H
     27 #define SMU7_DISCRETE_H
     28 
     29 #include "smu7.h"
     30 
     31 #pragma pack(push, 1)
     32 
     33 #define SMU7_DTE_ITERATIONS 5
     34 #define SMU7_DTE_SOURCES 3
     35 #define SMU7_DTE_SINKS 1
     36 #define SMU7_NUM_CPU_TES 0
     37 #define SMU7_NUM_GPU_TES 1
     38 #define SMU7_NUM_NON_TES 2
     39 
     40 struct SMU7_SoftRegisters
     41 {
     42     uint32_t        RefClockFrequency;
     43     uint32_t        PmTimerP;
     44     uint32_t        FeatureEnables;
     45     uint32_t        PreVBlankGap;
     46     uint32_t        VBlankTimeout;
     47     uint32_t        TrainTimeGap;
     48 
     49     uint32_t        MvddSwitchTime;
     50     uint32_t        LongestAcpiTrainTime;
     51     uint32_t        AcpiDelay;
     52     uint32_t        G5TrainTime;
     53     uint32_t        DelayMpllPwron;
     54     uint32_t        VoltageChangeTimeout;
     55     uint32_t        HandshakeDisables;
     56 
     57     uint8_t         DisplayPhy1Config;
     58     uint8_t         DisplayPhy2Config;
     59     uint8_t         DisplayPhy3Config;
     60     uint8_t         DisplayPhy4Config;
     61 
     62     uint8_t         DisplayPhy5Config;
     63     uint8_t         DisplayPhy6Config;
     64     uint8_t         DisplayPhy7Config;
     65     uint8_t         DisplayPhy8Config;
     66 
     67     uint32_t        AverageGraphicsA;
     68     uint32_t        AverageMemoryA;
     69     uint32_t        AverageGioA;
     70 
     71     uint8_t         SClkDpmEnabledLevels;
     72     uint8_t         MClkDpmEnabledLevels;
     73     uint8_t         LClkDpmEnabledLevels;
     74     uint8_t         PCIeDpmEnabledLevels;
     75 
     76     uint8_t         UVDDpmEnabledLevels;
     77     uint8_t         SAMUDpmEnabledLevels;
     78     uint8_t         ACPDpmEnabledLevels;
     79     uint8_t         VCEDpmEnabledLevels;
     80 
     81     uint32_t        DRAM_LOG_ADDR_H;
     82     uint32_t        DRAM_LOG_ADDR_L;
     83     uint32_t        DRAM_LOG_PHY_ADDR_H;
     84     uint32_t        DRAM_LOG_PHY_ADDR_L;
     85     uint32_t        DRAM_LOG_BUFF_SIZE;
     86     uint32_t        UlvEnterC;
     87     uint32_t        UlvTime;
     88     uint32_t        Reserved[3];
     89 
     90 };
     91 
     92 typedef struct SMU7_SoftRegisters SMU7_SoftRegisters;
     93 
     94 struct SMU7_Discrete_VoltageLevel
     95 {
     96     uint16_t    Voltage;
     97     uint16_t    StdVoltageHiSidd;
     98     uint16_t    StdVoltageLoSidd;
     99     uint8_t     Smio;
    100     uint8_t     padding;
    101 };
    102 
    103 typedef struct SMU7_Discrete_VoltageLevel SMU7_Discrete_VoltageLevel;
    104 
    105 struct SMU7_Discrete_GraphicsLevel
    106 {
    107     uint32_t    Flags;
    108     uint32_t    MinVddc;
    109     uint32_t    MinVddcPhases;
    110 
    111     uint32_t    SclkFrequency;
    112 
    113     uint8_t     padding1[2];
    114     uint16_t    ActivityLevel;
    115 
    116     uint32_t    CgSpllFuncCntl3;
    117     uint32_t    CgSpllFuncCntl4;
    118     uint32_t    SpllSpreadSpectrum;
    119     uint32_t    SpllSpreadSpectrum2;
    120     uint32_t    CcPwrDynRm;
    121     uint32_t    CcPwrDynRm1;
    122     uint8_t     SclkDid;
    123     uint8_t     DisplayWatermark;
    124     uint8_t     EnabledForActivity;
    125     uint8_t     EnabledForThrottle;
    126     uint8_t     UpH;
    127     uint8_t     DownH;
    128     uint8_t     VoltageDownH;
    129     uint8_t     PowerThrottle;
    130     uint8_t     DeepSleepDivId;
    131     uint8_t     padding[3];
    132 };
    133 
    134 typedef struct SMU7_Discrete_GraphicsLevel SMU7_Discrete_GraphicsLevel;
    135 
    136 struct SMU7_Discrete_ACPILevel
    137 {
    138     uint32_t    Flags;
    139     uint32_t    MinVddc;
    140     uint32_t    MinVddcPhases;
    141     uint32_t    SclkFrequency;
    142     uint8_t     SclkDid;
    143     uint8_t     DisplayWatermark;
    144     uint8_t     DeepSleepDivId;
    145     uint8_t     padding;
    146     uint32_t    CgSpllFuncCntl;
    147     uint32_t    CgSpllFuncCntl2;
    148     uint32_t    CgSpllFuncCntl3;
    149     uint32_t    CgSpllFuncCntl4;
    150     uint32_t    SpllSpreadSpectrum;
    151     uint32_t    SpllSpreadSpectrum2;
    152     uint32_t    CcPwrDynRm;
    153     uint32_t    CcPwrDynRm1;
    154 };
    155 
    156 typedef struct SMU7_Discrete_ACPILevel SMU7_Discrete_ACPILevel;
    157 
    158 struct SMU7_Discrete_Ulv
    159 {
    160     uint32_t    CcPwrDynRm;
    161     uint32_t    CcPwrDynRm1;
    162     uint16_t    VddcOffset;
    163     uint8_t     VddcOffsetVid;
    164     uint8_t     VddcPhase;
    165     uint32_t    Reserved;
    166 };
    167 
    168 typedef struct SMU7_Discrete_Ulv SMU7_Discrete_Ulv;
    169 
    170 struct SMU7_Discrete_MemoryLevel
    171 {
    172     uint32_t    MinVddc;
    173     uint32_t    MinVddcPhases;
    174     uint32_t    MinVddci;
    175     uint32_t    MinMvdd;
    176 
    177     uint32_t    MclkFrequency;
    178 
    179     uint8_t     EdcReadEnable;
    180     uint8_t     EdcWriteEnable;
    181     uint8_t     RttEnable;
    182     uint8_t     StutterEnable;
    183 
    184     uint8_t     StrobeEnable;
    185     uint8_t     StrobeRatio;
    186     uint8_t     EnabledForThrottle;
    187     uint8_t     EnabledForActivity;
    188 
    189     uint8_t     UpH;
    190     uint8_t     DownH;
    191     uint8_t     VoltageDownH;
    192     uint8_t     padding;
    193 
    194     uint16_t    ActivityLevel;
    195     uint8_t     DisplayWatermark;
    196     uint8_t     padding1;
    197 
    198     uint32_t    MpllFuncCntl;
    199     uint32_t    MpllFuncCntl_1;
    200     uint32_t    MpllFuncCntl_2;
    201     uint32_t    MpllAdFuncCntl;
    202     uint32_t    MpllDqFuncCntl;
    203     uint32_t    MclkPwrmgtCntl;
    204     uint32_t    DllCntl;
    205     uint32_t    MpllSs1;
    206     uint32_t    MpllSs2;
    207 };
    208 
    209 typedef struct SMU7_Discrete_MemoryLevel SMU7_Discrete_MemoryLevel;
    210 
    211 struct SMU7_Discrete_LinkLevel
    212 {
    213     uint8_t     PcieGenSpeed;
    214     uint8_t     PcieLaneCount;
    215     uint8_t     EnabledForActivity;
    216     uint8_t     Padding;
    217     uint32_t    DownT;
    218     uint32_t    UpT;
    219     uint32_t    Reserved;
    220 };
    221 
    222 typedef struct SMU7_Discrete_LinkLevel SMU7_Discrete_LinkLevel;
    223 
    224 
    225 struct SMU7_Discrete_MCArbDramTimingTableEntry
    226 {
    227     uint32_t McArbDramTiming;
    228     uint32_t McArbDramTiming2;
    229     uint8_t  McArbBurstTime;
    230     uint8_t  padding[3];
    231 };
    232 
    233 typedef struct SMU7_Discrete_MCArbDramTimingTableEntry SMU7_Discrete_MCArbDramTimingTableEntry;
    234 
    235 struct SMU7_Discrete_MCArbDramTimingTable
    236 {
    237     SMU7_Discrete_MCArbDramTimingTableEntry entries[SMU__NUM_SCLK_DPM_STATE][SMU__NUM_MCLK_DPM_LEVELS];
    238 };
    239 
    240 typedef struct SMU7_Discrete_MCArbDramTimingTable SMU7_Discrete_MCArbDramTimingTable;
    241 
    242 struct SMU7_Discrete_UvdLevel
    243 {
    244     uint32_t VclkFrequency;
    245     uint32_t DclkFrequency;
    246     uint16_t MinVddc;
    247     uint8_t  MinVddcPhases;
    248     uint8_t  VclkDivider;
    249     uint8_t  DclkDivider;
    250     uint8_t  padding[3];
    251 };
    252 
    253 typedef struct SMU7_Discrete_UvdLevel SMU7_Discrete_UvdLevel;
    254 
    255 struct SMU7_Discrete_ExtClkLevel
    256 {
    257     uint32_t Frequency;
    258     uint16_t MinVoltage;
    259     uint8_t  MinPhases;
    260     uint8_t  Divider;
    261 };
    262 
    263 typedef struct SMU7_Discrete_ExtClkLevel SMU7_Discrete_ExtClkLevel;
    264 
    265 struct SMU7_Discrete_StateInfo
    266 {
    267     uint32_t SclkFrequency;
    268     uint32_t MclkFrequency;
    269     uint32_t VclkFrequency;
    270     uint32_t DclkFrequency;
    271     uint32_t SamclkFrequency;
    272     uint32_t AclkFrequency;
    273     uint32_t EclkFrequency;
    274     uint16_t MvddVoltage;
    275     uint16_t padding16;
    276     uint8_t  DisplayWatermark;
    277     uint8_t  McArbIndex;
    278     uint8_t  McRegIndex;
    279     uint8_t  SeqIndex;
    280     uint8_t  SclkDid;
    281     int8_t   SclkIndex;
    282     int8_t   MclkIndex;
    283     uint8_t  PCIeGen;
    284 
    285 };
    286 
    287 typedef struct SMU7_Discrete_StateInfo SMU7_Discrete_StateInfo;
    288 
    289 
    290 struct SMU7_Discrete_DpmTable
    291 {
    292     SMU7_PIDController                  GraphicsPIDController;
    293     SMU7_PIDController                  MemoryPIDController;
    294     SMU7_PIDController                  LinkPIDController;
    295 
    296     uint32_t                            SystemFlags;
    297 
    298 
    299     uint32_t                            SmioMaskVddcVid;
    300     uint32_t                            SmioMaskVddcPhase;
    301     uint32_t                            SmioMaskVddciVid;
    302     uint32_t                            SmioMaskMvddVid;
    303 
    304     uint32_t                            VddcLevelCount;
    305     uint32_t                            VddciLevelCount;
    306     uint32_t                            MvddLevelCount;
    307 
    308     SMU7_Discrete_VoltageLevel          VddcLevel               [SMU7_MAX_LEVELS_VDDC];
    309 //    SMU7_Discrete_VoltageLevel          VddcStandardReference   [SMU7_MAX_LEVELS_VDDC];
    310     SMU7_Discrete_VoltageLevel          VddciLevel              [SMU7_MAX_LEVELS_VDDCI];
    311     SMU7_Discrete_VoltageLevel          MvddLevel               [SMU7_MAX_LEVELS_MVDD];
    312 
    313     uint8_t                             GraphicsDpmLevelCount;
    314     uint8_t                             MemoryDpmLevelCount;
    315     uint8_t                             LinkLevelCount;
    316     uint8_t                             UvdLevelCount;
    317     uint8_t                             VceLevelCount;
    318     uint8_t                             AcpLevelCount;
    319     uint8_t                             SamuLevelCount;
    320     uint8_t                             MasterDeepSleepControl;
    321     uint32_t                            VRConfig;
    322     uint32_t                            Reserved[4];
    323 //    uint32_t                            SamuDefaultLevel;
    324 
    325     SMU7_Discrete_GraphicsLevel         GraphicsLevel           [SMU7_MAX_LEVELS_GRAPHICS];
    326     SMU7_Discrete_MemoryLevel           MemoryACPILevel;
    327     SMU7_Discrete_MemoryLevel           MemoryLevel             [SMU7_MAX_LEVELS_MEMORY];
    328     SMU7_Discrete_LinkLevel             LinkLevel               [SMU7_MAX_LEVELS_LINK];
    329     SMU7_Discrete_ACPILevel             ACPILevel;
    330     SMU7_Discrete_UvdLevel              UvdLevel                [SMU7_MAX_LEVELS_UVD];
    331     SMU7_Discrete_ExtClkLevel           VceLevel                [SMU7_MAX_LEVELS_VCE];
    332     SMU7_Discrete_ExtClkLevel           AcpLevel                [SMU7_MAX_LEVELS_ACP];
    333     SMU7_Discrete_ExtClkLevel           SamuLevel               [SMU7_MAX_LEVELS_SAMU];
    334     SMU7_Discrete_Ulv                   Ulv;
    335 
    336     uint32_t                            SclkStepSize;
    337     uint32_t                            Smio                    [SMU7_MAX_ENTRIES_SMIO];
    338 
    339     uint8_t                             UvdBootLevel;
    340     uint8_t                             VceBootLevel;
    341     uint8_t                             AcpBootLevel;
    342     uint8_t                             SamuBootLevel;
    343 
    344     uint8_t                             UVDInterval;
    345     uint8_t                             VCEInterval;
    346     uint8_t                             ACPInterval;
    347     uint8_t                             SAMUInterval;
    348 
    349     uint8_t                             GraphicsBootLevel;
    350     uint8_t                             GraphicsVoltageChangeEnable;
    351     uint8_t                             GraphicsThermThrottleEnable;
    352     uint8_t                             GraphicsInterval;
    353 
    354     uint8_t                             VoltageInterval;
    355     uint8_t                             ThermalInterval;
    356     uint16_t                            TemperatureLimitHigh;
    357 
    358     uint16_t                            TemperatureLimitLow;
    359     uint8_t                             MemoryBootLevel;
    360     uint8_t                             MemoryVoltageChangeEnable;
    361 
    362     uint8_t                             MemoryInterval;
    363     uint8_t                             MemoryThermThrottleEnable;
    364     uint16_t                            VddcVddciDelta;
    365 
    366     uint16_t                            VoltageResponseTime;
    367     uint16_t                            PhaseResponseTime;
    368 
    369     uint8_t                             PCIeBootLinkLevel;
    370     uint8_t                             PCIeGenInterval;
    371     uint8_t                             DTEInterval;
    372     uint8_t                             DTEMode;
    373 
    374     uint8_t                             SVI2Enable;
    375     uint8_t                             VRHotGpio;
    376     uint8_t                             AcDcGpio;
    377     uint8_t                             ThermGpio;
    378 
    379     uint16_t                            PPM_PkgPwrLimit;
    380     uint16_t                            PPM_TemperatureLimit;
    381 
    382     uint16_t                            DefaultTdp;
    383     uint16_t                            TargetTdp;
    384 
    385     uint16_t                            FpsHighT;
    386     uint16_t                            FpsLowT;
    387 
    388     uint16_t                            BAPMTI_R  [SMU7_DTE_ITERATIONS][SMU7_DTE_SOURCES][SMU7_DTE_SINKS];
    389     uint16_t                            BAPMTI_RC [SMU7_DTE_ITERATIONS][SMU7_DTE_SOURCES][SMU7_DTE_SINKS];
    390 
    391     uint8_t                             DTEAmbientTempBase;
    392     uint8_t                             DTETjOffset;
    393     uint8_t                             GpuTjMax;
    394     uint8_t                             GpuTjHyst;
    395 
    396     uint16_t                            BootVddc;
    397     uint16_t                            BootVddci;
    398 
    399     uint16_t                            BootMVdd;
    400     uint16_t                            padding;
    401 
    402     uint32_t                            BAPM_TEMP_GRADIENT;
    403 
    404     uint32_t                            LowSclkInterruptT;
    405 };
    406 
    407 typedef struct SMU7_Discrete_DpmTable SMU7_Discrete_DpmTable;
    408 
    409 #define SMU7_DISCRETE_MC_REGISTER_ARRAY_SIZE 16
    410 #define SMU7_DISCRETE_MC_REGISTER_ARRAY_SET_COUNT SMU7_MAX_LEVELS_MEMORY
    411 
    412 struct SMU7_Discrete_MCRegisterAddress
    413 {
    414     uint16_t s0;
    415     uint16_t s1;
    416 };
    417 
    418 typedef struct SMU7_Discrete_MCRegisterAddress SMU7_Discrete_MCRegisterAddress;
    419 
    420 struct SMU7_Discrete_MCRegisterSet
    421 {
    422     uint32_t value[SMU7_DISCRETE_MC_REGISTER_ARRAY_SIZE];
    423 };
    424 
    425 typedef struct SMU7_Discrete_MCRegisterSet SMU7_Discrete_MCRegisterSet;
    426 
    427 struct SMU7_Discrete_MCRegisters
    428 {
    429     uint8_t                             last;
    430     uint8_t                             reserved[3];
    431     SMU7_Discrete_MCRegisterAddress     address[SMU7_DISCRETE_MC_REGISTER_ARRAY_SIZE];
    432     SMU7_Discrete_MCRegisterSet         data[SMU7_DISCRETE_MC_REGISTER_ARRAY_SET_COUNT];
    433 };
    434 
    435 typedef struct SMU7_Discrete_MCRegisters SMU7_Discrete_MCRegisters;
    436 
    437 struct SMU7_Discrete_FanTable
    438 {
    439 	uint16_t FdoMode;
    440 	int16_t  TempMin;
    441 	int16_t  TempMed;
    442 	int16_t  TempMax;
    443 	int16_t  Slope1;
    444 	int16_t  Slope2;
    445 	int16_t  FdoMin;
    446 	int16_t  HystUp;
    447 	int16_t  HystDown;
    448 	int16_t  HystSlope;
    449 	int16_t  TempRespLim;
    450 	int16_t  TempCurr;
    451 	int16_t  SlopeCurr;
    452 	int16_t  PwmCurr;
    453 	uint32_t RefreshPeriod;
    454 	int16_t  FdoMax;
    455 	uint8_t  TempSrc;
    456 	int8_t   Padding;
    457 };
    458 
    459 typedef struct SMU7_Discrete_FanTable SMU7_Discrete_FanTable;
    460 
    461 
    462 struct SMU7_Discrete_PmFuses {
    463   // dw0-dw1
    464   uint8_t BapmVddCVidHiSidd[8];
    465 
    466   // dw2-dw3
    467   uint8_t BapmVddCVidLoSidd[8];
    468 
    469   // dw4-dw5
    470   uint8_t VddCVid[8];
    471 
    472   // dw6
    473   uint8_t SviLoadLineEn;
    474   uint8_t SviLoadLineVddC;
    475   uint8_t SviLoadLineTrimVddC;
    476   uint8_t SviLoadLineOffsetVddC;
    477 
    478   // dw7
    479   uint16_t TDC_VDDC_PkgLimit;
    480   uint8_t TDC_VDDC_ThrottleReleaseLimitPerc;
    481   uint8_t TDC_MAWt;
    482 
    483   // dw8
    484   uint8_t TdcWaterfallCtl;
    485   uint8_t LPMLTemperatureMin;
    486   uint8_t LPMLTemperatureMax;
    487   uint8_t Reserved;
    488 
    489   // dw9-dw10
    490   uint8_t BapmVddCVidHiSidd2[8];
    491 
    492   // dw11-dw12
    493   int16_t FuzzyFan_ErrorSetDelta;
    494   int16_t FuzzyFan_ErrorRateSetDelta;
    495   int16_t FuzzyFan_PwmSetDelta;
    496   uint16_t CalcMeasPowerBlend;
    497 
    498   // dw13-dw16
    499   uint8_t GnbLPML[16];
    500 
    501   // dw17
    502   uint8_t GnbLPMLMaxVid;
    503   uint8_t GnbLPMLMinVid;
    504   uint8_t Reserved1[2];
    505 
    506   // dw18
    507   uint16_t BapmVddCBaseLeakageHiSidd;
    508   uint16_t BapmVddCBaseLeakageLoSidd;
    509 };
    510 
    511 typedef struct SMU7_Discrete_PmFuses SMU7_Discrete_PmFuses;
    512 
    513 
    514 #pragma pack(pop)
    515 
    516 #endif
    517 
    518