18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright 2014 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 258c2ecf20Sopenharmony_ci#ifndef SMU74_H 268c2ecf20Sopenharmony_ci#define SMU74_H 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci#pragma pack(push, 1) 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci#define SMU__DGPU_ONLY 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci#define SMU__NUM_SCLK_DPM_STATE 8 338c2ecf20Sopenharmony_ci#define SMU__NUM_MCLK_DPM_LEVELS 4 348c2ecf20Sopenharmony_ci#define SMU__NUM_LCLK_DPM_LEVELS 8 358c2ecf20Sopenharmony_ci#define SMU__NUM_PCIE_DPM_LEVELS 8 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci#define EXP_M1 35 388c2ecf20Sopenharmony_ci#define EXP_M2 92821 398c2ecf20Sopenharmony_ci#define EXP_B 66629747 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci#define EXP_M1_1 365 428c2ecf20Sopenharmony_ci#define EXP_M2_1 658700 438c2ecf20Sopenharmony_ci#define EXP_B_1 305506134 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci#define EXP_M1_2 189 468c2ecf20Sopenharmony_ci#define EXP_M2_2 379692 478c2ecf20Sopenharmony_ci#define EXP_B_2 194609469 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ci#define EXP_M1_3 99 508c2ecf20Sopenharmony_ci#define EXP_M2_3 217915 518c2ecf20Sopenharmony_ci#define EXP_B_3 122255994 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci#define EXP_M1_4 51 548c2ecf20Sopenharmony_ci#define EXP_M2_4 122643 558c2ecf20Sopenharmony_ci#define EXP_B_4 74893384 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci#define EXP_M1_5 423 588c2ecf20Sopenharmony_ci#define EXP_M2_5 1103326 598c2ecf20Sopenharmony_ci#define EXP_B_5 728122621 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_cienum SID_OPTION { 628c2ecf20Sopenharmony_ci SID_OPTION_HI, 638c2ecf20Sopenharmony_ci SID_OPTION_LO, 648c2ecf20Sopenharmony_ci SID_OPTION_COUNT 658c2ecf20Sopenharmony_ci}; 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_cienum Poly3rdOrderCoeff { 688c2ecf20Sopenharmony_ci LEAKAGE_TEMPERATURE_SCALAR, 698c2ecf20Sopenharmony_ci LEAKAGE_VOLTAGE_SCALAR, 708c2ecf20Sopenharmony_ci DYNAMIC_VOLTAGE_SCALAR, 718c2ecf20Sopenharmony_ci POLY_3RD_ORDER_COUNT 728c2ecf20Sopenharmony_ci}; 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_cistruct SMU7_Poly3rdOrder_Data { 758c2ecf20Sopenharmony_ci int32_t a; 768c2ecf20Sopenharmony_ci int32_t b; 778c2ecf20Sopenharmony_ci int32_t c; 788c2ecf20Sopenharmony_ci int32_t d; 798c2ecf20Sopenharmony_ci uint8_t a_shift; 808c2ecf20Sopenharmony_ci uint8_t b_shift; 818c2ecf20Sopenharmony_ci uint8_t c_shift; 828c2ecf20Sopenharmony_ci uint8_t x_shift; 838c2ecf20Sopenharmony_ci}; 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_citypedef struct SMU7_Poly3rdOrder_Data SMU7_Poly3rdOrder_Data; 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_cistruct Power_Calculator_Data { 888c2ecf20Sopenharmony_ci uint16_t NoLoadVoltage; 898c2ecf20Sopenharmony_ci uint16_t LoadVoltage; 908c2ecf20Sopenharmony_ci uint16_t Resistance; 918c2ecf20Sopenharmony_ci uint16_t Temperature; 928c2ecf20Sopenharmony_ci uint16_t BaseLeakage; 938c2ecf20Sopenharmony_ci uint16_t LkgTempScalar; 948c2ecf20Sopenharmony_ci uint16_t LkgVoltScalar; 958c2ecf20Sopenharmony_ci uint16_t LkgAreaScalar; 968c2ecf20Sopenharmony_ci uint16_t LkgPower; 978c2ecf20Sopenharmony_ci uint16_t DynVoltScalar; 988c2ecf20Sopenharmony_ci uint32_t Cac; 998c2ecf20Sopenharmony_ci uint32_t DynPower; 1008c2ecf20Sopenharmony_ci uint32_t TotalCurrent; 1018c2ecf20Sopenharmony_ci uint32_t TotalPower; 1028c2ecf20Sopenharmony_ci}; 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_citypedef struct Power_Calculator_Data PowerCalculatorData_t; 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_cistruct Gc_Cac_Weight_Data { 1078c2ecf20Sopenharmony_ci uint8_t index; 1088c2ecf20Sopenharmony_ci uint32_t value; 1098c2ecf20Sopenharmony_ci}; 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_citypedef struct Gc_Cac_Weight_Data GcCacWeight_Data; 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ci 1148c2ecf20Sopenharmony_citypedef struct { 1158c2ecf20Sopenharmony_ci uint32_t high; 1168c2ecf20Sopenharmony_ci uint32_t low; 1178c2ecf20Sopenharmony_ci} data_64_t; 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_citypedef struct { 1208c2ecf20Sopenharmony_ci data_64_t high; 1218c2ecf20Sopenharmony_ci data_64_t low; 1228c2ecf20Sopenharmony_ci} data_128_t; 1238c2ecf20Sopenharmony_ci 1248c2ecf20Sopenharmony_ci#define SMU7_CONTEXT_ID_SMC 1 1258c2ecf20Sopenharmony_ci#define SMU7_CONTEXT_ID_VBIOS 2 1268c2ecf20Sopenharmony_ci 1278c2ecf20Sopenharmony_ci#define SMU74_MAX_LEVELS_VDDC 16 1288c2ecf20Sopenharmony_ci#define SMU74_MAX_LEVELS_VDDGFX 16 1298c2ecf20Sopenharmony_ci#define SMU74_MAX_LEVELS_VDDCI 8 1308c2ecf20Sopenharmony_ci#define SMU74_MAX_LEVELS_MVDD 4 1318c2ecf20Sopenharmony_ci 1328c2ecf20Sopenharmony_ci#define SMU_MAX_SMIO_LEVELS 4 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_ci#define SMU74_MAX_LEVELS_GRAPHICS SMU__NUM_SCLK_DPM_STATE /* SCLK + SQ DPM + ULV */ 1358c2ecf20Sopenharmony_ci#define SMU74_MAX_LEVELS_MEMORY SMU__NUM_MCLK_DPM_LEVELS /* MCLK Levels DPM */ 1368c2ecf20Sopenharmony_ci#define SMU74_MAX_LEVELS_GIO SMU__NUM_LCLK_DPM_LEVELS /* LCLK Levels */ 1378c2ecf20Sopenharmony_ci#define SMU74_MAX_LEVELS_LINK SMU__NUM_PCIE_DPM_LEVELS /* PCIe speed and number of lanes */ 1388c2ecf20Sopenharmony_ci#define SMU74_MAX_LEVELS_UVD 8 /* VCLK/DCLK levels for UVD */ 1398c2ecf20Sopenharmony_ci#define SMU74_MAX_LEVELS_VCE 8 /* ECLK levels for VCE */ 1408c2ecf20Sopenharmony_ci#define SMU74_MAX_LEVELS_ACP 8 /* ACLK levels for ACP */ 1418c2ecf20Sopenharmony_ci#define SMU74_MAX_LEVELS_SAMU 8 /* SAMCLK levels for SAMU */ 1428c2ecf20Sopenharmony_ci#define SMU74_MAX_ENTRIES_SMIO 32 /* Number of entries in SMIO table */ 1438c2ecf20Sopenharmony_ci 1448c2ecf20Sopenharmony_ci#define DPM_NO_LIMIT 0 1458c2ecf20Sopenharmony_ci#define DPM_NO_UP 1 1468c2ecf20Sopenharmony_ci#define DPM_GO_DOWN 2 1478c2ecf20Sopenharmony_ci#define DPM_GO_UP 3 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_ci#define SMU7_FIRST_DPM_GRAPHICS_LEVEL 0 1508c2ecf20Sopenharmony_ci#define SMU7_FIRST_DPM_MEMORY_LEVEL 0 1518c2ecf20Sopenharmony_ci 1528c2ecf20Sopenharmony_ci#define GPIO_CLAMP_MODE_VRHOT 1 1538c2ecf20Sopenharmony_ci#define GPIO_CLAMP_MODE_THERM 2 1548c2ecf20Sopenharmony_ci#define GPIO_CLAMP_MODE_DC 4 1558c2ecf20Sopenharmony_ci 1568c2ecf20Sopenharmony_ci#define SCRATCH_B_TARG_PCIE_INDEX_SHIFT 0 1578c2ecf20Sopenharmony_ci#define SCRATCH_B_TARG_PCIE_INDEX_MASK (0x7<<SCRATCH_B_TARG_PCIE_INDEX_SHIFT) 1588c2ecf20Sopenharmony_ci#define SCRATCH_B_CURR_PCIE_INDEX_SHIFT 3 1598c2ecf20Sopenharmony_ci#define SCRATCH_B_CURR_PCIE_INDEX_MASK (0x7<<SCRATCH_B_CURR_PCIE_INDEX_SHIFT) 1608c2ecf20Sopenharmony_ci#define SCRATCH_B_TARG_UVD_INDEX_SHIFT 6 1618c2ecf20Sopenharmony_ci#define SCRATCH_B_TARG_UVD_INDEX_MASK (0x7<<SCRATCH_B_TARG_UVD_INDEX_SHIFT) 1628c2ecf20Sopenharmony_ci#define SCRATCH_B_CURR_UVD_INDEX_SHIFT 9 1638c2ecf20Sopenharmony_ci#define SCRATCH_B_CURR_UVD_INDEX_MASK (0x7<<SCRATCH_B_CURR_UVD_INDEX_SHIFT) 1648c2ecf20Sopenharmony_ci#define SCRATCH_B_TARG_VCE_INDEX_SHIFT 12 1658c2ecf20Sopenharmony_ci#define SCRATCH_B_TARG_VCE_INDEX_MASK (0x7<<SCRATCH_B_TARG_VCE_INDEX_SHIFT) 1668c2ecf20Sopenharmony_ci#define SCRATCH_B_CURR_VCE_INDEX_SHIFT 15 1678c2ecf20Sopenharmony_ci#define SCRATCH_B_CURR_VCE_INDEX_MASK (0x7<<SCRATCH_B_CURR_VCE_INDEX_SHIFT) 1688c2ecf20Sopenharmony_ci#define SCRATCH_B_TARG_ACP_INDEX_SHIFT 18 1698c2ecf20Sopenharmony_ci#define SCRATCH_B_TARG_ACP_INDEX_MASK (0x7<<SCRATCH_B_TARG_ACP_INDEX_SHIFT) 1708c2ecf20Sopenharmony_ci#define SCRATCH_B_CURR_ACP_INDEX_SHIFT 21 1718c2ecf20Sopenharmony_ci#define SCRATCH_B_CURR_ACP_INDEX_MASK (0x7<<SCRATCH_B_CURR_ACP_INDEX_SHIFT) 1728c2ecf20Sopenharmony_ci#define SCRATCH_B_TARG_SAMU_INDEX_SHIFT 24 1738c2ecf20Sopenharmony_ci#define SCRATCH_B_TARG_SAMU_INDEX_MASK (0x7<<SCRATCH_B_TARG_SAMU_INDEX_SHIFT) 1748c2ecf20Sopenharmony_ci#define SCRATCH_B_CURR_SAMU_INDEX_SHIFT 27 1758c2ecf20Sopenharmony_ci#define SCRATCH_B_CURR_SAMU_INDEX_MASK (0x7<<SCRATCH_B_CURR_SAMU_INDEX_SHIFT) 1768c2ecf20Sopenharmony_ci 1778c2ecf20Sopenharmony_ci/* Virtualization Defines */ 1788c2ecf20Sopenharmony_ci#define CG_XDMA_MASK 0x1 1798c2ecf20Sopenharmony_ci#define CG_XDMA_SHIFT 0 1808c2ecf20Sopenharmony_ci#define CG_UVD_MASK 0x2 1818c2ecf20Sopenharmony_ci#define CG_UVD_SHIFT 1 1828c2ecf20Sopenharmony_ci#define CG_VCE_MASK 0x4 1838c2ecf20Sopenharmony_ci#define CG_VCE_SHIFT 2 1848c2ecf20Sopenharmony_ci#define CG_SAMU_MASK 0x8 1858c2ecf20Sopenharmony_ci#define CG_SAMU_SHIFT 3 1868c2ecf20Sopenharmony_ci#define CG_GFX_MASK 0x10 1878c2ecf20Sopenharmony_ci#define CG_GFX_SHIFT 4 1888c2ecf20Sopenharmony_ci#define CG_SDMA_MASK 0x20 1898c2ecf20Sopenharmony_ci#define CG_SDMA_SHIFT 5 1908c2ecf20Sopenharmony_ci#define CG_HDP_MASK 0x40 1918c2ecf20Sopenharmony_ci#define CG_HDP_SHIFT 6 1928c2ecf20Sopenharmony_ci#define CG_MC_MASK 0x80 1938c2ecf20Sopenharmony_ci#define CG_MC_SHIFT 7 1948c2ecf20Sopenharmony_ci#define CG_DRM_MASK 0x100 1958c2ecf20Sopenharmony_ci#define CG_DRM_SHIFT 8 1968c2ecf20Sopenharmony_ci#define CG_ROM_MASK 0x200 1978c2ecf20Sopenharmony_ci#define CG_ROM_SHIFT 9 1988c2ecf20Sopenharmony_ci#define CG_BIF_MASK 0x400 1998c2ecf20Sopenharmony_ci#define CG_BIF_SHIFT 10 2008c2ecf20Sopenharmony_ci 2018c2ecf20Sopenharmony_ci 2028c2ecf20Sopenharmony_ci#define SMU74_DTE_ITERATIONS 5 2038c2ecf20Sopenharmony_ci#define SMU74_DTE_SOURCES 3 2048c2ecf20Sopenharmony_ci#define SMU74_DTE_SINKS 1 2058c2ecf20Sopenharmony_ci#define SMU74_NUM_CPU_TES 0 2068c2ecf20Sopenharmony_ci#define SMU74_NUM_GPU_TES 1 2078c2ecf20Sopenharmony_ci#define SMU74_NUM_NON_TES 2 2088c2ecf20Sopenharmony_ci#define SMU74_DTE_FAN_SCALAR_MIN 0x100 2098c2ecf20Sopenharmony_ci#define SMU74_DTE_FAN_SCALAR_MAX 0x166 2108c2ecf20Sopenharmony_ci#define SMU74_DTE_FAN_TEMP_MAX 93 2118c2ecf20Sopenharmony_ci#define SMU74_DTE_FAN_TEMP_MIN 83 2128c2ecf20Sopenharmony_ci 2138c2ecf20Sopenharmony_ci 2148c2ecf20Sopenharmony_ci#if defined SMU__FUSION_ONLY 2158c2ecf20Sopenharmony_ci#define SMU7_DTE_ITERATIONS 5 2168c2ecf20Sopenharmony_ci#define SMU7_DTE_SOURCES 5 2178c2ecf20Sopenharmony_ci#define SMU7_DTE_SINKS 3 2188c2ecf20Sopenharmony_ci#define SMU7_NUM_CPU_TES 2 2198c2ecf20Sopenharmony_ci#define SMU7_NUM_GPU_TES 1 2208c2ecf20Sopenharmony_ci#define SMU7_NUM_NON_TES 2 2218c2ecf20Sopenharmony_ci#endif 2228c2ecf20Sopenharmony_ci 2238c2ecf20Sopenharmony_cistruct SMU7_HystController_Data { 2248c2ecf20Sopenharmony_ci uint8_t waterfall_up; 2258c2ecf20Sopenharmony_ci uint8_t waterfall_down; 2268c2ecf20Sopenharmony_ci uint8_t waterfall_limit; 2278c2ecf20Sopenharmony_ci uint8_t spare; 2288c2ecf20Sopenharmony_ci uint16_t release_cnt; 2298c2ecf20Sopenharmony_ci uint16_t release_limit; 2308c2ecf20Sopenharmony_ci}; 2318c2ecf20Sopenharmony_ci 2328c2ecf20Sopenharmony_citypedef struct SMU7_HystController_Data SMU7_HystController_Data; 2338c2ecf20Sopenharmony_ci 2348c2ecf20Sopenharmony_cistruct SMU74_PIDController { 2358c2ecf20Sopenharmony_ci uint32_t Ki; 2368c2ecf20Sopenharmony_ci int32_t LFWindupUpperLim; 2378c2ecf20Sopenharmony_ci int32_t LFWindupLowerLim; 2388c2ecf20Sopenharmony_ci uint32_t StatePrecision; 2398c2ecf20Sopenharmony_ci uint32_t LfPrecision; 2408c2ecf20Sopenharmony_ci uint32_t LfOffset; 2418c2ecf20Sopenharmony_ci uint32_t MaxState; 2428c2ecf20Sopenharmony_ci uint32_t MaxLfFraction; 2438c2ecf20Sopenharmony_ci uint32_t StateShift; 2448c2ecf20Sopenharmony_ci}; 2458c2ecf20Sopenharmony_ci 2468c2ecf20Sopenharmony_citypedef struct SMU74_PIDController SMU74_PIDController; 2478c2ecf20Sopenharmony_ci 2488c2ecf20Sopenharmony_cistruct SMU7_LocalDpmScoreboard { 2498c2ecf20Sopenharmony_ci uint32_t PercentageBusy; 2508c2ecf20Sopenharmony_ci 2518c2ecf20Sopenharmony_ci int32_t PIDError; 2528c2ecf20Sopenharmony_ci int32_t PIDIntegral; 2538c2ecf20Sopenharmony_ci int32_t PIDOutput; 2548c2ecf20Sopenharmony_ci 2558c2ecf20Sopenharmony_ci uint32_t SigmaDeltaAccum; 2568c2ecf20Sopenharmony_ci uint32_t SigmaDeltaOutput; 2578c2ecf20Sopenharmony_ci uint32_t SigmaDeltaLevel; 2588c2ecf20Sopenharmony_ci 2598c2ecf20Sopenharmony_ci uint32_t UtilizationSetpoint; 2608c2ecf20Sopenharmony_ci 2618c2ecf20Sopenharmony_ci uint8_t TdpClampMode; 2628c2ecf20Sopenharmony_ci uint8_t TdcClampMode; 2638c2ecf20Sopenharmony_ci uint8_t ThermClampMode; 2648c2ecf20Sopenharmony_ci uint8_t VoltageBusy; 2658c2ecf20Sopenharmony_ci 2668c2ecf20Sopenharmony_ci int8_t CurrLevel; 2678c2ecf20Sopenharmony_ci int8_t TargLevel; 2688c2ecf20Sopenharmony_ci uint8_t LevelChangeInProgress; 2698c2ecf20Sopenharmony_ci uint8_t UpHyst; 2708c2ecf20Sopenharmony_ci 2718c2ecf20Sopenharmony_ci uint8_t DownHyst; 2728c2ecf20Sopenharmony_ci uint8_t VoltageDownHyst; 2738c2ecf20Sopenharmony_ci uint8_t DpmEnable; 2748c2ecf20Sopenharmony_ci uint8_t DpmRunning; 2758c2ecf20Sopenharmony_ci 2768c2ecf20Sopenharmony_ci uint8_t DpmForce; 2778c2ecf20Sopenharmony_ci uint8_t DpmForceLevel; 2788c2ecf20Sopenharmony_ci uint8_t DisplayWatermark; 2798c2ecf20Sopenharmony_ci uint8_t McArbIndex; 2808c2ecf20Sopenharmony_ci 2818c2ecf20Sopenharmony_ci uint32_t MinimumPerfSclk; 2828c2ecf20Sopenharmony_ci 2838c2ecf20Sopenharmony_ci uint8_t AcpiReq; 2848c2ecf20Sopenharmony_ci uint8_t AcpiAck; 2858c2ecf20Sopenharmony_ci uint8_t GfxClkSlow; 2868c2ecf20Sopenharmony_ci uint8_t GpioClampMode; 2878c2ecf20Sopenharmony_ci 2888c2ecf20Sopenharmony_ci uint8_t spare2; 2898c2ecf20Sopenharmony_ci uint8_t EnabledLevelsChange; 2908c2ecf20Sopenharmony_ci uint8_t DteClampMode; 2918c2ecf20Sopenharmony_ci uint8_t FpsClampMode; 2928c2ecf20Sopenharmony_ci 2938c2ecf20Sopenharmony_ci uint16_t LevelResidencyCounters[SMU74_MAX_LEVELS_GRAPHICS]; 2948c2ecf20Sopenharmony_ci uint16_t LevelSwitchCounters[SMU74_MAX_LEVELS_GRAPHICS]; 2958c2ecf20Sopenharmony_ci 2968c2ecf20Sopenharmony_ci void (*TargetStateCalculator)(uint8_t); 2978c2ecf20Sopenharmony_ci void (*SavedTargetStateCalculator)(uint8_t); 2988c2ecf20Sopenharmony_ci 2998c2ecf20Sopenharmony_ci uint16_t AutoDpmInterval; 3008c2ecf20Sopenharmony_ci uint16_t AutoDpmRange; 3018c2ecf20Sopenharmony_ci 3028c2ecf20Sopenharmony_ci uint8_t FpsEnabled; 3038c2ecf20Sopenharmony_ci uint8_t MaxPerfLevel; 3048c2ecf20Sopenharmony_ci uint8_t AllowLowClkInterruptToHost; 3058c2ecf20Sopenharmony_ci uint8_t FpsRunning; 3068c2ecf20Sopenharmony_ci 3078c2ecf20Sopenharmony_ci uint32_t MaxAllowedFrequency; 3088c2ecf20Sopenharmony_ci 3098c2ecf20Sopenharmony_ci uint32_t FilteredSclkFrequency; 3108c2ecf20Sopenharmony_ci uint32_t LastSclkFrequency; 3118c2ecf20Sopenharmony_ci uint32_t FilteredSclkFrequencyCnt; 3128c2ecf20Sopenharmony_ci 3138c2ecf20Sopenharmony_ci uint8_t MinPerfLevel; 3148c2ecf20Sopenharmony_ci uint8_t padding[3]; 3158c2ecf20Sopenharmony_ci 3168c2ecf20Sopenharmony_ci uint16_t FpsAlpha; 3178c2ecf20Sopenharmony_ci uint16_t DeltaTime; 3188c2ecf20Sopenharmony_ci uint32_t CurrentFps; 3198c2ecf20Sopenharmony_ci uint32_t FilteredFps; 3208c2ecf20Sopenharmony_ci uint32_t FrameCount; 3218c2ecf20Sopenharmony_ci uint32_t FrameCountLast; 3228c2ecf20Sopenharmony_ci uint16_t FpsTargetScalar; 3238c2ecf20Sopenharmony_ci uint16_t FpsWaterfallLimitScalar; 3248c2ecf20Sopenharmony_ci uint16_t FpsAlphaScalar; 3258c2ecf20Sopenharmony_ci uint16_t spare8; 3268c2ecf20Sopenharmony_ci SMU7_HystController_Data HystControllerData; 3278c2ecf20Sopenharmony_ci}; 3288c2ecf20Sopenharmony_ci 3298c2ecf20Sopenharmony_citypedef struct SMU7_LocalDpmScoreboard SMU7_LocalDpmScoreboard; 3308c2ecf20Sopenharmony_ci 3318c2ecf20Sopenharmony_ci#define SMU7_MAX_VOLTAGE_CLIENTS 12 3328c2ecf20Sopenharmony_ci 3338c2ecf20Sopenharmony_citypedef uint8_t (*VoltageChangeHandler_t)(uint16_t, uint8_t); 3348c2ecf20Sopenharmony_ci 3358c2ecf20Sopenharmony_ci#define VDDC_MASK 0x00007FFF 3368c2ecf20Sopenharmony_ci#define VDDC_SHIFT 0 3378c2ecf20Sopenharmony_ci#define VDDCI_MASK 0x3FFF8000 3388c2ecf20Sopenharmony_ci#define VDDCI_SHIFT 15 3398c2ecf20Sopenharmony_ci#define PHASES_MASK 0xC0000000 3408c2ecf20Sopenharmony_ci#define PHASES_SHIFT 30 3418c2ecf20Sopenharmony_ci 3428c2ecf20Sopenharmony_citypedef uint32_t SMU_VoltageLevel; 3438c2ecf20Sopenharmony_ci 3448c2ecf20Sopenharmony_cistruct SMU7_VoltageScoreboard { 3458c2ecf20Sopenharmony_ci 3468c2ecf20Sopenharmony_ci SMU_VoltageLevel TargetVoltage; 3478c2ecf20Sopenharmony_ci uint16_t MaxVid; 3488c2ecf20Sopenharmony_ci uint8_t HighestVidOffset; 3498c2ecf20Sopenharmony_ci uint8_t CurrentVidOffset; 3508c2ecf20Sopenharmony_ci 3518c2ecf20Sopenharmony_ci uint16_t CurrentVddc; 3528c2ecf20Sopenharmony_ci uint16_t CurrentVddci; 3538c2ecf20Sopenharmony_ci 3548c2ecf20Sopenharmony_ci 3558c2ecf20Sopenharmony_ci uint8_t ControllerBusy; 3568c2ecf20Sopenharmony_ci uint8_t CurrentVid; 3578c2ecf20Sopenharmony_ci uint8_t CurrentVddciVid; 3588c2ecf20Sopenharmony_ci uint8_t padding; 3598c2ecf20Sopenharmony_ci 3608c2ecf20Sopenharmony_ci SMU_VoltageLevel RequestedVoltage[SMU7_MAX_VOLTAGE_CLIENTS]; 3618c2ecf20Sopenharmony_ci SMU_VoltageLevel TargetVoltageState; 3628c2ecf20Sopenharmony_ci uint8_t EnabledRequest[SMU7_MAX_VOLTAGE_CLIENTS]; 3638c2ecf20Sopenharmony_ci 3648c2ecf20Sopenharmony_ci uint8_t padding2; 3658c2ecf20Sopenharmony_ci uint8_t padding3; 3668c2ecf20Sopenharmony_ci uint8_t ControllerEnable; 3678c2ecf20Sopenharmony_ci uint8_t ControllerRunning; 3688c2ecf20Sopenharmony_ci uint16_t CurrentStdVoltageHiSidd; 3698c2ecf20Sopenharmony_ci uint16_t CurrentStdVoltageLoSidd; 3708c2ecf20Sopenharmony_ci uint8_t OverrideVoltage; 3718c2ecf20Sopenharmony_ci uint8_t padding4; 3728c2ecf20Sopenharmony_ci uint8_t padding5; 3738c2ecf20Sopenharmony_ci uint8_t CurrentPhases; 3748c2ecf20Sopenharmony_ci 3758c2ecf20Sopenharmony_ci VoltageChangeHandler_t ChangeVddc; 3768c2ecf20Sopenharmony_ci 3778c2ecf20Sopenharmony_ci VoltageChangeHandler_t ChangeVddci; 3788c2ecf20Sopenharmony_ci VoltageChangeHandler_t ChangePhase; 3798c2ecf20Sopenharmony_ci VoltageChangeHandler_t ChangeMvdd; 3808c2ecf20Sopenharmony_ci 3818c2ecf20Sopenharmony_ci VoltageChangeHandler_t functionLinks[6]; 3828c2ecf20Sopenharmony_ci 3838c2ecf20Sopenharmony_ci uint16_t *VddcFollower1; 3848c2ecf20Sopenharmony_ci 3858c2ecf20Sopenharmony_ci int16_t Driver_OD_RequestedVidOffset1; 3868c2ecf20Sopenharmony_ci int16_t Driver_OD_RequestedVidOffset2; 3878c2ecf20Sopenharmony_ci}; 3888c2ecf20Sopenharmony_ci 3898c2ecf20Sopenharmony_citypedef struct SMU7_VoltageScoreboard SMU7_VoltageScoreboard; 3908c2ecf20Sopenharmony_ci 3918c2ecf20Sopenharmony_ci#define SMU7_MAX_PCIE_LINK_SPEEDS 3 /* 0:Gen1 1:Gen2 2:Gen3 */ 3928c2ecf20Sopenharmony_ci 3938c2ecf20Sopenharmony_cistruct SMU7_PCIeLinkSpeedScoreboard { 3948c2ecf20Sopenharmony_ci uint8_t DpmEnable; 3958c2ecf20Sopenharmony_ci uint8_t DpmRunning; 3968c2ecf20Sopenharmony_ci uint8_t DpmForce; 3978c2ecf20Sopenharmony_ci uint8_t DpmForceLevel; 3988c2ecf20Sopenharmony_ci 3998c2ecf20Sopenharmony_ci uint8_t CurrentLinkSpeed; 4008c2ecf20Sopenharmony_ci uint8_t EnabledLevelsChange; 4018c2ecf20Sopenharmony_ci uint16_t AutoDpmInterval; 4028c2ecf20Sopenharmony_ci 4038c2ecf20Sopenharmony_ci uint16_t AutoDpmRange; 4048c2ecf20Sopenharmony_ci uint16_t AutoDpmCount; 4058c2ecf20Sopenharmony_ci 4068c2ecf20Sopenharmony_ci uint8_t DpmMode; 4078c2ecf20Sopenharmony_ci uint8_t AcpiReq; 4088c2ecf20Sopenharmony_ci uint8_t AcpiAck; 4098c2ecf20Sopenharmony_ci uint8_t CurrentLinkLevel; 4108c2ecf20Sopenharmony_ci 4118c2ecf20Sopenharmony_ci}; 4128c2ecf20Sopenharmony_ci 4138c2ecf20Sopenharmony_citypedef struct SMU7_PCIeLinkSpeedScoreboard SMU7_PCIeLinkSpeedScoreboard; 4148c2ecf20Sopenharmony_ci 4158c2ecf20Sopenharmony_ci#define SMU7_LKGE_LUT_NUM_OF_TEMP_ENTRIES 16 4168c2ecf20Sopenharmony_ci#define SMU7_LKGE_LUT_NUM_OF_VOLT_ENTRIES 16 4178c2ecf20Sopenharmony_ci 4188c2ecf20Sopenharmony_ci#define SMU7_SCALE_I 7 4198c2ecf20Sopenharmony_ci#define SMU7_SCALE_R 12 4208c2ecf20Sopenharmony_ci 4218c2ecf20Sopenharmony_cistruct SMU7_PowerScoreboard { 4228c2ecf20Sopenharmony_ci PowerCalculatorData_t VddcPowerData[SID_OPTION_COUNT]; 4238c2ecf20Sopenharmony_ci 4248c2ecf20Sopenharmony_ci uint32_t TotalGpuPower; 4258c2ecf20Sopenharmony_ci uint32_t TdcCurrent; 4268c2ecf20Sopenharmony_ci 4278c2ecf20Sopenharmony_ci uint16_t VddciTotalPower; 4288c2ecf20Sopenharmony_ci uint16_t sparesasfsdfd; 4298c2ecf20Sopenharmony_ci uint16_t Vddr1Power; 4308c2ecf20Sopenharmony_ci uint16_t RocPower; 4318c2ecf20Sopenharmony_ci 4328c2ecf20Sopenharmony_ci uint16_t CalcMeasPowerBlend; 4338c2ecf20Sopenharmony_ci uint8_t SidOptionPower; 4348c2ecf20Sopenharmony_ci uint8_t SidOptionCurrent; 4358c2ecf20Sopenharmony_ci 4368c2ecf20Sopenharmony_ci uint32_t WinTime; 4378c2ecf20Sopenharmony_ci 4388c2ecf20Sopenharmony_ci uint16_t Telemetry_1_slope; 4398c2ecf20Sopenharmony_ci uint16_t Telemetry_2_slope; 4408c2ecf20Sopenharmony_ci int32_t Telemetry_1_offset; 4418c2ecf20Sopenharmony_ci int32_t Telemetry_2_offset; 4428c2ecf20Sopenharmony_ci 4438c2ecf20Sopenharmony_ci uint32_t VddcCurrentTelemetry; 4448c2ecf20Sopenharmony_ci uint32_t VddGfxCurrentTelemetry; 4458c2ecf20Sopenharmony_ci uint32_t VddcPowerTelemetry; 4468c2ecf20Sopenharmony_ci uint32_t VddGfxPowerTelemetry; 4478c2ecf20Sopenharmony_ci uint32_t VddciPowerTelemetry; 4488c2ecf20Sopenharmony_ci 4498c2ecf20Sopenharmony_ci uint32_t VddcPower; 4508c2ecf20Sopenharmony_ci uint32_t VddGfxPower; 4518c2ecf20Sopenharmony_ci uint32_t VddciPower; 4528c2ecf20Sopenharmony_ci 4538c2ecf20Sopenharmony_ci uint32_t TelemetryCurrent[2]; 4548c2ecf20Sopenharmony_ci uint32_t TelemetryVoltage[2]; 4558c2ecf20Sopenharmony_ci uint32_t TelemetryPower[2]; 4568c2ecf20Sopenharmony_ci}; 4578c2ecf20Sopenharmony_ci 4588c2ecf20Sopenharmony_citypedef struct SMU7_PowerScoreboard SMU7_PowerScoreboard; 4598c2ecf20Sopenharmony_ci 4608c2ecf20Sopenharmony_cistruct SMU7_ThermalScoreboard { 4618c2ecf20Sopenharmony_ci int16_t GpuLimit; 4628c2ecf20Sopenharmony_ci int16_t GpuHyst; 4638c2ecf20Sopenharmony_ci uint16_t CurrGnbTemp; 4648c2ecf20Sopenharmony_ci uint16_t FilteredGnbTemp; 4658c2ecf20Sopenharmony_ci 4668c2ecf20Sopenharmony_ci uint8_t ControllerEnable; 4678c2ecf20Sopenharmony_ci uint8_t ControllerRunning; 4688c2ecf20Sopenharmony_ci uint8_t AutoTmonCalInterval; 4698c2ecf20Sopenharmony_ci uint8_t AutoTmonCalEnable; 4708c2ecf20Sopenharmony_ci 4718c2ecf20Sopenharmony_ci uint8_t ThermalDpmEnabled; 4728c2ecf20Sopenharmony_ci uint8_t SclkEnabledMask; 4738c2ecf20Sopenharmony_ci uint8_t spare[2]; 4748c2ecf20Sopenharmony_ci int32_t temperature_gradient; 4758c2ecf20Sopenharmony_ci 4768c2ecf20Sopenharmony_ci SMU7_HystController_Data HystControllerData; 4778c2ecf20Sopenharmony_ci int32_t WeightedSensorTemperature; 4788c2ecf20Sopenharmony_ci uint16_t TemperatureLimit[SMU74_MAX_LEVELS_GRAPHICS]; 4798c2ecf20Sopenharmony_ci uint32_t Alpha; 4808c2ecf20Sopenharmony_ci}; 4818c2ecf20Sopenharmony_ci 4828c2ecf20Sopenharmony_citypedef struct SMU7_ThermalScoreboard SMU7_ThermalScoreboard; 4838c2ecf20Sopenharmony_ci 4848c2ecf20Sopenharmony_ci#define SMU7_SCLK_DPM_CONFIG_MASK 0x01 4858c2ecf20Sopenharmony_ci#define SMU7_VOLTAGE_CONTROLLER_CONFIG_MASK 0x02 4868c2ecf20Sopenharmony_ci#define SMU7_THERMAL_CONTROLLER_CONFIG_MASK 0x04 4878c2ecf20Sopenharmony_ci#define SMU7_MCLK_DPM_CONFIG_MASK 0x08 4888c2ecf20Sopenharmony_ci#define SMU7_UVD_DPM_CONFIG_MASK 0x10 4898c2ecf20Sopenharmony_ci#define SMU7_VCE_DPM_CONFIG_MASK 0x20 4908c2ecf20Sopenharmony_ci#define SMU7_ACP_DPM_CONFIG_MASK 0x40 4918c2ecf20Sopenharmony_ci#define SMU7_SAMU_DPM_CONFIG_MASK 0x80 4928c2ecf20Sopenharmony_ci#define SMU7_PCIEGEN_DPM_CONFIG_MASK 0x100 4938c2ecf20Sopenharmony_ci 4948c2ecf20Sopenharmony_ci#define SMU7_ACP_MCLK_HANDSHAKE_DISABLE 0x00000001 4958c2ecf20Sopenharmony_ci#define SMU7_ACP_SCLK_HANDSHAKE_DISABLE 0x00000002 4968c2ecf20Sopenharmony_ci#define SMU7_UVD_MCLK_HANDSHAKE_DISABLE 0x00000100 4978c2ecf20Sopenharmony_ci#define SMU7_UVD_SCLK_HANDSHAKE_DISABLE 0x00000200 4988c2ecf20Sopenharmony_ci#define SMU7_VCE_MCLK_HANDSHAKE_DISABLE 0x00010000 4998c2ecf20Sopenharmony_ci#define SMU7_VCE_SCLK_HANDSHAKE_DISABLE 0x00020000 5008c2ecf20Sopenharmony_ci 5018c2ecf20Sopenharmony_ci/* All 'soft registers' should be uint32_t. */ 5028c2ecf20Sopenharmony_cistruct SMU74_SoftRegisters { 5038c2ecf20Sopenharmony_ci uint32_t RefClockFrequency; 5048c2ecf20Sopenharmony_ci uint32_t PmTimerPeriod; 5058c2ecf20Sopenharmony_ci uint32_t FeatureEnables; 5068c2ecf20Sopenharmony_ci 5078c2ecf20Sopenharmony_ci uint32_t PreVBlankGap; 5088c2ecf20Sopenharmony_ci uint32_t VBlankTimeout; 5098c2ecf20Sopenharmony_ci uint32_t TrainTimeGap; 5108c2ecf20Sopenharmony_ci 5118c2ecf20Sopenharmony_ci uint32_t MvddSwitchTime; 5128c2ecf20Sopenharmony_ci uint32_t LongestAcpiTrainTime; 5138c2ecf20Sopenharmony_ci uint32_t AcpiDelay; 5148c2ecf20Sopenharmony_ci uint32_t G5TrainTime; 5158c2ecf20Sopenharmony_ci uint32_t DelayMpllPwron; 5168c2ecf20Sopenharmony_ci uint32_t VoltageChangeTimeout; 5178c2ecf20Sopenharmony_ci 5188c2ecf20Sopenharmony_ci uint32_t HandshakeDisables; 5198c2ecf20Sopenharmony_ci 5208c2ecf20Sopenharmony_ci uint8_t DisplayPhy1Config; 5218c2ecf20Sopenharmony_ci uint8_t DisplayPhy2Config; 5228c2ecf20Sopenharmony_ci uint8_t DisplayPhy3Config; 5238c2ecf20Sopenharmony_ci uint8_t DisplayPhy4Config; 5248c2ecf20Sopenharmony_ci 5258c2ecf20Sopenharmony_ci uint8_t DisplayPhy5Config; 5268c2ecf20Sopenharmony_ci uint8_t DisplayPhy6Config; 5278c2ecf20Sopenharmony_ci uint8_t DisplayPhy7Config; 5288c2ecf20Sopenharmony_ci uint8_t DisplayPhy8Config; 5298c2ecf20Sopenharmony_ci 5308c2ecf20Sopenharmony_ci uint32_t AverageGraphicsActivity; 5318c2ecf20Sopenharmony_ci uint32_t AverageMemoryActivity; 5328c2ecf20Sopenharmony_ci uint32_t AverageGioActivity; 5338c2ecf20Sopenharmony_ci 5348c2ecf20Sopenharmony_ci uint8_t SClkDpmEnabledLevels; 5358c2ecf20Sopenharmony_ci uint8_t MClkDpmEnabledLevels; 5368c2ecf20Sopenharmony_ci uint8_t LClkDpmEnabledLevels; 5378c2ecf20Sopenharmony_ci uint8_t PCIeDpmEnabledLevels; 5388c2ecf20Sopenharmony_ci 5398c2ecf20Sopenharmony_ci uint8_t UVDDpmEnabledLevels; 5408c2ecf20Sopenharmony_ci uint8_t SAMUDpmEnabledLevels; 5418c2ecf20Sopenharmony_ci uint8_t ACPDpmEnabledLevels; 5428c2ecf20Sopenharmony_ci uint8_t VCEDpmEnabledLevels; 5438c2ecf20Sopenharmony_ci 5448c2ecf20Sopenharmony_ci uint32_t DRAM_LOG_ADDR_H; 5458c2ecf20Sopenharmony_ci uint32_t DRAM_LOG_ADDR_L; 5468c2ecf20Sopenharmony_ci uint32_t DRAM_LOG_PHY_ADDR_H; 5478c2ecf20Sopenharmony_ci uint32_t DRAM_LOG_PHY_ADDR_L; 5488c2ecf20Sopenharmony_ci uint32_t DRAM_LOG_BUFF_SIZE; 5498c2ecf20Sopenharmony_ci uint32_t UlvEnterCount; 5508c2ecf20Sopenharmony_ci uint32_t UlvTime; 5518c2ecf20Sopenharmony_ci uint32_t UcodeLoadStatus; 5528c2ecf20Sopenharmony_ci uint32_t AllowMvddSwitch; 5538c2ecf20Sopenharmony_ci uint8_t Activity_Weight; 5548c2ecf20Sopenharmony_ci uint8_t Reserved8[3]; 5558c2ecf20Sopenharmony_ci}; 5568c2ecf20Sopenharmony_ci 5578c2ecf20Sopenharmony_citypedef struct SMU74_SoftRegisters SMU74_SoftRegisters; 5588c2ecf20Sopenharmony_ci 5598c2ecf20Sopenharmony_cistruct SMU74_Firmware_Header { 5608c2ecf20Sopenharmony_ci uint32_t Digest[5]; 5618c2ecf20Sopenharmony_ci uint32_t Version; 5628c2ecf20Sopenharmony_ci uint32_t HeaderSize; 5638c2ecf20Sopenharmony_ci uint32_t Flags; 5648c2ecf20Sopenharmony_ci uint32_t EntryPoint; 5658c2ecf20Sopenharmony_ci uint32_t CodeSize; 5668c2ecf20Sopenharmony_ci uint32_t ImageSize; 5678c2ecf20Sopenharmony_ci 5688c2ecf20Sopenharmony_ci uint32_t Rtos; 5698c2ecf20Sopenharmony_ci uint32_t SoftRegisters; 5708c2ecf20Sopenharmony_ci uint32_t DpmTable; 5718c2ecf20Sopenharmony_ci uint32_t FanTable; 5728c2ecf20Sopenharmony_ci uint32_t CacConfigTable; 5738c2ecf20Sopenharmony_ci uint32_t CacStatusTable; 5748c2ecf20Sopenharmony_ci 5758c2ecf20Sopenharmony_ci uint32_t mcRegisterTable; 5768c2ecf20Sopenharmony_ci 5778c2ecf20Sopenharmony_ci uint32_t mcArbDramTimingTable; 5788c2ecf20Sopenharmony_ci 5798c2ecf20Sopenharmony_ci uint32_t PmFuseTable; 5808c2ecf20Sopenharmony_ci uint32_t Globals; 5818c2ecf20Sopenharmony_ci uint32_t ClockStretcherTable; 5828c2ecf20Sopenharmony_ci uint32_t VftTable; 5838c2ecf20Sopenharmony_ci uint32_t Reserved1; 5848c2ecf20Sopenharmony_ci uint32_t AvfsTable; 5858c2ecf20Sopenharmony_ci uint32_t AvfsCksOffGbvTable; 5868c2ecf20Sopenharmony_ci uint32_t AvfsMeanNSigma; 5878c2ecf20Sopenharmony_ci uint32_t AvfsSclkOffsetTable; 5888c2ecf20Sopenharmony_ci uint32_t Reserved[16]; 5898c2ecf20Sopenharmony_ci uint32_t Signature; 5908c2ecf20Sopenharmony_ci}; 5918c2ecf20Sopenharmony_ci 5928c2ecf20Sopenharmony_citypedef struct SMU74_Firmware_Header SMU74_Firmware_Header; 5938c2ecf20Sopenharmony_ci 5948c2ecf20Sopenharmony_ci#define SMU7_FIRMWARE_HEADER_LOCATION 0x20000 5958c2ecf20Sopenharmony_ci 5968c2ecf20Sopenharmony_cienum DisplayConfig { 5978c2ecf20Sopenharmony_ci PowerDown = 1, 5988c2ecf20Sopenharmony_ci DP54x4, 5998c2ecf20Sopenharmony_ci DP54x2, 6008c2ecf20Sopenharmony_ci DP54x1, 6018c2ecf20Sopenharmony_ci DP27x4, 6028c2ecf20Sopenharmony_ci DP27x2, 6038c2ecf20Sopenharmony_ci DP27x1, 6048c2ecf20Sopenharmony_ci HDMI297, 6058c2ecf20Sopenharmony_ci HDMI162, 6068c2ecf20Sopenharmony_ci LVDS, 6078c2ecf20Sopenharmony_ci DP324x4, 6088c2ecf20Sopenharmony_ci DP324x2, 6098c2ecf20Sopenharmony_ci DP324x1 6108c2ecf20Sopenharmony_ci}; 6118c2ecf20Sopenharmony_ci 6128c2ecf20Sopenharmony_ci 6138c2ecf20Sopenharmony_ci#define MC_BLOCK_COUNT 1 6148c2ecf20Sopenharmony_ci#define CPL_BLOCK_COUNT 5 6158c2ecf20Sopenharmony_ci#define SE_BLOCK_COUNT 15 6168c2ecf20Sopenharmony_ci#define GC_BLOCK_COUNT 24 6178c2ecf20Sopenharmony_ci 6188c2ecf20Sopenharmony_cistruct SMU7_Local_Cac { 6198c2ecf20Sopenharmony_ci uint8_t BlockId; 6208c2ecf20Sopenharmony_ci uint8_t SignalId; 6218c2ecf20Sopenharmony_ci uint8_t Threshold; 6228c2ecf20Sopenharmony_ci uint8_t Padding; 6238c2ecf20Sopenharmony_ci}; 6248c2ecf20Sopenharmony_ci 6258c2ecf20Sopenharmony_citypedef struct SMU7_Local_Cac SMU7_Local_Cac; 6268c2ecf20Sopenharmony_ci 6278c2ecf20Sopenharmony_cistruct SMU7_Local_Cac_Table { 6288c2ecf20Sopenharmony_ci 6298c2ecf20Sopenharmony_ci SMU7_Local_Cac CplLocalCac[CPL_BLOCK_COUNT]; 6308c2ecf20Sopenharmony_ci SMU7_Local_Cac McLocalCac[MC_BLOCK_COUNT]; 6318c2ecf20Sopenharmony_ci SMU7_Local_Cac SeLocalCac[SE_BLOCK_COUNT]; 6328c2ecf20Sopenharmony_ci SMU7_Local_Cac GcLocalCac[GC_BLOCK_COUNT]; 6338c2ecf20Sopenharmony_ci}; 6348c2ecf20Sopenharmony_ci 6358c2ecf20Sopenharmony_citypedef struct SMU7_Local_Cac_Table SMU7_Local_Cac_Table; 6368c2ecf20Sopenharmony_ci 6378c2ecf20Sopenharmony_ci#pragma pack(pop) 6388c2ecf20Sopenharmony_ci 6398c2ecf20Sopenharmony_ci/* Description of Clock Gating bitmask for Tonga: 6408c2ecf20Sopenharmony_ci * System Clock Gating 6418c2ecf20Sopenharmony_ci */ 6428c2ecf20Sopenharmony_ci#define CG_SYS_BITMASK_FIRST_BIT 0 /* First bit of Sys CG bitmask */ 6438c2ecf20Sopenharmony_ci#define CG_SYS_BITMASK_LAST_BIT 9 /* Last bit of Sys CG bitmask */ 6448c2ecf20Sopenharmony_ci#define CG_SYS_BIF_MGLS_SHIFT 0 6458c2ecf20Sopenharmony_ci#define CG_SYS_ROM_SHIFT 1 6468c2ecf20Sopenharmony_ci#define CG_SYS_MC_MGCG_SHIFT 2 6478c2ecf20Sopenharmony_ci#define CG_SYS_MC_MGLS_SHIFT 3 6488c2ecf20Sopenharmony_ci#define CG_SYS_SDMA_MGCG_SHIFT 4 6498c2ecf20Sopenharmony_ci#define CG_SYS_SDMA_MGLS_SHIFT 5 6508c2ecf20Sopenharmony_ci#define CG_SYS_DRM_MGCG_SHIFT 6 6518c2ecf20Sopenharmony_ci#define CG_SYS_HDP_MGCG_SHIFT 7 6528c2ecf20Sopenharmony_ci#define CG_SYS_HDP_MGLS_SHIFT 8 6538c2ecf20Sopenharmony_ci#define CG_SYS_DRM_MGLS_SHIFT 9 6548c2ecf20Sopenharmony_ci#define CG_SYS_BIF_MGCG_SHIFT 10 6558c2ecf20Sopenharmony_ci 6568c2ecf20Sopenharmony_ci#define CG_SYS_BIF_MGLS_MASK 0x1 6578c2ecf20Sopenharmony_ci#define CG_SYS_ROM_MASK 0x2 6588c2ecf20Sopenharmony_ci#define CG_SYS_MC_MGCG_MASK 0x4 6598c2ecf20Sopenharmony_ci#define CG_SYS_MC_MGLS_MASK 0x8 6608c2ecf20Sopenharmony_ci#define CG_SYS_SDMA_MGCG_MASK 0x10 6618c2ecf20Sopenharmony_ci#define CG_SYS_SDMA_MGLS_MASK 0x20 6628c2ecf20Sopenharmony_ci#define CG_SYS_DRM_MGCG_MASK 0x40 6638c2ecf20Sopenharmony_ci#define CG_SYS_HDP_MGCG_MASK 0x80 6648c2ecf20Sopenharmony_ci#define CG_SYS_HDP_MGLS_MASK 0x100 6658c2ecf20Sopenharmony_ci#define CG_SYS_DRM_MGLS_MASK 0x200 6668c2ecf20Sopenharmony_ci#define CG_SYS_BIF_MGCG_MASK 0x400 6678c2ecf20Sopenharmony_ci 6688c2ecf20Sopenharmony_ci/* Graphics Clock Gating */ 6698c2ecf20Sopenharmony_ci#define CG_GFX_BITMASK_FIRST_BIT 16 /* First bit of Gfx CG bitmask */ 6708c2ecf20Sopenharmony_ci#define CG_GFX_BITMASK_LAST_BIT 24 /* Last bit of Gfx CG bitmask */ 6718c2ecf20Sopenharmony_ci 6728c2ecf20Sopenharmony_ci#define CG_GFX_CGCG_SHIFT 16 6738c2ecf20Sopenharmony_ci#define CG_GFX_CGLS_SHIFT 17 6748c2ecf20Sopenharmony_ci#define CG_CPF_MGCG_SHIFT 18 6758c2ecf20Sopenharmony_ci#define CG_RLC_MGCG_SHIFT 19 6768c2ecf20Sopenharmony_ci#define CG_GFX_OTHERS_MGCG_SHIFT 20 6778c2ecf20Sopenharmony_ci#define CG_GFX_3DCG_SHIFT 21 6788c2ecf20Sopenharmony_ci#define CG_GFX_3DLS_SHIFT 22 6798c2ecf20Sopenharmony_ci#define CG_GFX_RLC_LS_SHIFT 23 6808c2ecf20Sopenharmony_ci#define CG_GFX_CP_LS_SHIFT 24 6818c2ecf20Sopenharmony_ci 6828c2ecf20Sopenharmony_ci#define CG_GFX_CGCG_MASK 0x00010000 6838c2ecf20Sopenharmony_ci#define CG_GFX_CGLS_MASK 0x00020000 6848c2ecf20Sopenharmony_ci#define CG_CPF_MGCG_MASK 0x00040000 6858c2ecf20Sopenharmony_ci#define CG_RLC_MGCG_MASK 0x00080000 6868c2ecf20Sopenharmony_ci#define CG_GFX_OTHERS_MGCG_MASK 0x00100000 6878c2ecf20Sopenharmony_ci#define CG_GFX_3DCG_MASK 0x00200000 6888c2ecf20Sopenharmony_ci#define CG_GFX_3DLS_MASK 0x00400000 6898c2ecf20Sopenharmony_ci#define CG_GFX_RLC_LS_MASK 0x00800000 6908c2ecf20Sopenharmony_ci#define CG_GFX_CP_LS_MASK 0x01000000 6918c2ecf20Sopenharmony_ci 6928c2ecf20Sopenharmony_ci 6938c2ecf20Sopenharmony_ci/* Voltage Regulator Configuration 6948c2ecf20Sopenharmony_ciVR Config info is contained in dpmTable.VRConfig */ 6958c2ecf20Sopenharmony_ci 6968c2ecf20Sopenharmony_ci#define VRCONF_VDDC_MASK 0x000000FF 6978c2ecf20Sopenharmony_ci#define VRCONF_VDDC_SHIFT 0 6988c2ecf20Sopenharmony_ci#define VRCONF_VDDGFX_MASK 0x0000FF00 6998c2ecf20Sopenharmony_ci#define VRCONF_VDDGFX_SHIFT 8 7008c2ecf20Sopenharmony_ci#define VRCONF_VDDCI_MASK 0x00FF0000 7018c2ecf20Sopenharmony_ci#define VRCONF_VDDCI_SHIFT 16 7028c2ecf20Sopenharmony_ci#define VRCONF_MVDD_MASK 0xFF000000 7038c2ecf20Sopenharmony_ci#define VRCONF_MVDD_SHIFT 24 7048c2ecf20Sopenharmony_ci 7058c2ecf20Sopenharmony_ci#define VR_MERGED_WITH_VDDC 0 7068c2ecf20Sopenharmony_ci#define VR_SVI2_PLANE_1 1 7078c2ecf20Sopenharmony_ci#define VR_SVI2_PLANE_2 2 7088c2ecf20Sopenharmony_ci#define VR_SMIO_PATTERN_1 3 7098c2ecf20Sopenharmony_ci#define VR_SMIO_PATTERN_2 4 7108c2ecf20Sopenharmony_ci#define VR_STATIC_VOLTAGE 5 7118c2ecf20Sopenharmony_ci 7128c2ecf20Sopenharmony_ci/* Clock Stretcher Configuration */ 7138c2ecf20Sopenharmony_ci 7148c2ecf20Sopenharmony_ci#define CLOCK_STRETCHER_MAX_ENTRIES 0x4 7158c2ecf20Sopenharmony_ci#define CKS_LOOKUPTable_MAX_ENTRIES 0x4 7168c2ecf20Sopenharmony_ci 7178c2ecf20Sopenharmony_ci/* The 'settings' field is subdivided in the following way: */ 7188c2ecf20Sopenharmony_ci#define CLOCK_STRETCHER_SETTING_DDT_MASK 0x01 7198c2ecf20Sopenharmony_ci#define CLOCK_STRETCHER_SETTING_DDT_SHIFT 0x0 7208c2ecf20Sopenharmony_ci#define CLOCK_STRETCHER_SETTING_STRETCH_AMOUNT_MASK 0x1E 7218c2ecf20Sopenharmony_ci#define CLOCK_STRETCHER_SETTING_STRETCH_AMOUNT_SHIFT 0x1 7228c2ecf20Sopenharmony_ci#define CLOCK_STRETCHER_SETTING_ENABLE_MASK 0x80 7238c2ecf20Sopenharmony_ci#define CLOCK_STRETCHER_SETTING_ENABLE_SHIFT 0x7 7248c2ecf20Sopenharmony_ci 7258c2ecf20Sopenharmony_cistruct SMU_ClockStretcherDataTableEntry { 7268c2ecf20Sopenharmony_ci uint8_t minVID; 7278c2ecf20Sopenharmony_ci uint8_t maxVID; 7288c2ecf20Sopenharmony_ci uint16_t setting; 7298c2ecf20Sopenharmony_ci}; 7308c2ecf20Sopenharmony_citypedef struct SMU_ClockStretcherDataTableEntry SMU_ClockStretcherDataTableEntry; 7318c2ecf20Sopenharmony_ci 7328c2ecf20Sopenharmony_cistruct SMU_ClockStretcherDataTable { 7338c2ecf20Sopenharmony_ci SMU_ClockStretcherDataTableEntry ClockStretcherDataTableEntry[CLOCK_STRETCHER_MAX_ENTRIES]; 7348c2ecf20Sopenharmony_ci}; 7358c2ecf20Sopenharmony_citypedef struct SMU_ClockStretcherDataTable SMU_ClockStretcherDataTable; 7368c2ecf20Sopenharmony_ci 7378c2ecf20Sopenharmony_cistruct SMU_CKS_LOOKUPTableEntry { 7388c2ecf20Sopenharmony_ci uint16_t minFreq; 7398c2ecf20Sopenharmony_ci uint16_t maxFreq; 7408c2ecf20Sopenharmony_ci 7418c2ecf20Sopenharmony_ci uint8_t setting; 7428c2ecf20Sopenharmony_ci uint8_t padding[3]; 7438c2ecf20Sopenharmony_ci}; 7448c2ecf20Sopenharmony_citypedef struct SMU_CKS_LOOKUPTableEntry SMU_CKS_LOOKUPTableEntry; 7458c2ecf20Sopenharmony_ci 7468c2ecf20Sopenharmony_cistruct SMU_CKS_LOOKUPTable { 7478c2ecf20Sopenharmony_ci SMU_CKS_LOOKUPTableEntry CKS_LOOKUPTableEntry[CKS_LOOKUPTable_MAX_ENTRIES]; 7488c2ecf20Sopenharmony_ci}; 7498c2ecf20Sopenharmony_citypedef struct SMU_CKS_LOOKUPTable SMU_CKS_LOOKUPTable; 7508c2ecf20Sopenharmony_ci 7518c2ecf20Sopenharmony_cistruct AgmAvfsData_t { 7528c2ecf20Sopenharmony_ci uint16_t avgPsmCount[28]; 7538c2ecf20Sopenharmony_ci uint16_t minPsmCount[28]; 7548c2ecf20Sopenharmony_ci}; 7558c2ecf20Sopenharmony_ci 7568c2ecf20Sopenharmony_citypedef struct AgmAvfsData_t AgmAvfsData_t; 7578c2ecf20Sopenharmony_ci 7588c2ecf20Sopenharmony_cienum VFT_COLUMNS { 7598c2ecf20Sopenharmony_ci SCLK0, 7608c2ecf20Sopenharmony_ci SCLK1, 7618c2ecf20Sopenharmony_ci SCLK2, 7628c2ecf20Sopenharmony_ci SCLK3, 7638c2ecf20Sopenharmony_ci SCLK4, 7648c2ecf20Sopenharmony_ci SCLK5, 7658c2ecf20Sopenharmony_ci SCLK6, 7668c2ecf20Sopenharmony_ci SCLK7, 7678c2ecf20Sopenharmony_ci 7688c2ecf20Sopenharmony_ci NUM_VFT_COLUMNS 7698c2ecf20Sopenharmony_ci}; 7708c2ecf20Sopenharmony_ci 7718c2ecf20Sopenharmony_ci#define VFT_TABLE_DEFINED 7728c2ecf20Sopenharmony_ci 7738c2ecf20Sopenharmony_ci#define TEMP_RANGE_MAXSTEPS 12 7748c2ecf20Sopenharmony_ci 7758c2ecf20Sopenharmony_cistruct VFT_CELL_t { 7768c2ecf20Sopenharmony_ci uint16_t Voltage; 7778c2ecf20Sopenharmony_ci}; 7788c2ecf20Sopenharmony_ci 7798c2ecf20Sopenharmony_citypedef struct VFT_CELL_t VFT_CELL_t; 7808c2ecf20Sopenharmony_ci 7818c2ecf20Sopenharmony_cistruct VFT_TABLE_t { 7828c2ecf20Sopenharmony_ci VFT_CELL_t Cell[TEMP_RANGE_MAXSTEPS][NUM_VFT_COLUMNS]; 7838c2ecf20Sopenharmony_ci uint16_t AvfsGbv[NUM_VFT_COLUMNS]; 7848c2ecf20Sopenharmony_ci uint16_t BtcGbv[NUM_VFT_COLUMNS]; 7858c2ecf20Sopenharmony_ci uint16_t Temperature[TEMP_RANGE_MAXSTEPS]; 7868c2ecf20Sopenharmony_ci 7878c2ecf20Sopenharmony_ci uint8_t NumTemperatureSteps; 7888c2ecf20Sopenharmony_ci uint8_t padding[3]; 7898c2ecf20Sopenharmony_ci}; 7908c2ecf20Sopenharmony_ci 7918c2ecf20Sopenharmony_citypedef struct VFT_TABLE_t VFT_TABLE_t; 7928c2ecf20Sopenharmony_ci 7938c2ecf20Sopenharmony_ci 7948c2ecf20Sopenharmony_ci/* Total margin, root mean square of Fmax + DC + Platform */ 7958c2ecf20Sopenharmony_cistruct AVFS_Margin_t { 7968c2ecf20Sopenharmony_ci VFT_CELL_t Cell[NUM_VFT_COLUMNS]; 7978c2ecf20Sopenharmony_ci}; 7988c2ecf20Sopenharmony_citypedef struct AVFS_Margin_t AVFS_Margin_t; 7998c2ecf20Sopenharmony_ci 8008c2ecf20Sopenharmony_ci#define BTCGB_VDROOP_TABLE_MAX_ENTRIES 2 8018c2ecf20Sopenharmony_ci#define AVFSGB_VDROOP_TABLE_MAX_ENTRIES 2 8028c2ecf20Sopenharmony_ci 8038c2ecf20Sopenharmony_cistruct GB_VDROOP_TABLE_t { 8048c2ecf20Sopenharmony_ci int32_t a0; 8058c2ecf20Sopenharmony_ci int32_t a1; 8068c2ecf20Sopenharmony_ci int32_t a2; 8078c2ecf20Sopenharmony_ci uint32_t spare; 8088c2ecf20Sopenharmony_ci}; 8098c2ecf20Sopenharmony_citypedef struct GB_VDROOP_TABLE_t GB_VDROOP_TABLE_t; 8108c2ecf20Sopenharmony_ci 8118c2ecf20Sopenharmony_cistruct AVFS_CksOff_Gbv_t { 8128c2ecf20Sopenharmony_ci VFT_CELL_t Cell[NUM_VFT_COLUMNS]; 8138c2ecf20Sopenharmony_ci}; 8148c2ecf20Sopenharmony_citypedef struct AVFS_CksOff_Gbv_t AVFS_CksOff_Gbv_t; 8158c2ecf20Sopenharmony_ci 8168c2ecf20Sopenharmony_cistruct AVFS_meanNsigma_t { 8178c2ecf20Sopenharmony_ci uint32_t Aconstant[3]; 8188c2ecf20Sopenharmony_ci uint16_t DC_tol_sigma; 8198c2ecf20Sopenharmony_ci uint16_t Platform_mean; 8208c2ecf20Sopenharmony_ci uint16_t Platform_sigma; 8218c2ecf20Sopenharmony_ci uint16_t PSM_Age_CompFactor; 8228c2ecf20Sopenharmony_ci uint8_t Static_Voltage_Offset[NUM_VFT_COLUMNS]; 8238c2ecf20Sopenharmony_ci}; 8248c2ecf20Sopenharmony_citypedef struct AVFS_meanNsigma_t AVFS_meanNsigma_t; 8258c2ecf20Sopenharmony_ci 8268c2ecf20Sopenharmony_cistruct AVFS_Sclk_Offset_t { 8278c2ecf20Sopenharmony_ci uint16_t Sclk_Offset[8]; 8288c2ecf20Sopenharmony_ci}; 8298c2ecf20Sopenharmony_citypedef struct AVFS_Sclk_Offset_t AVFS_Sclk_Offset_t; 8308c2ecf20Sopenharmony_ci 8318c2ecf20Sopenharmony_ci#endif 8328c2ecf20Sopenharmony_ci 8338c2ecf20Sopenharmony_ci 834