18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright 2017 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 SMU72_H 258c2ecf20Sopenharmony_ci#define SMU72_H 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci#if !defined(SMC_MICROCODE) 288c2ecf20Sopenharmony_ci#pragma pack(push, 1) 298c2ecf20Sopenharmony_ci#endif 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci#define SMU__NUM_SCLK_DPM_STATE 8 328c2ecf20Sopenharmony_ci#define SMU__NUM_MCLK_DPM_LEVELS 4 338c2ecf20Sopenharmony_ci#define SMU__NUM_LCLK_DPM_LEVELS 8 348c2ecf20Sopenharmony_ci#define SMU__NUM_PCIE_DPM_LEVELS 8 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_cienum SID_OPTION { 378c2ecf20Sopenharmony_ci SID_OPTION_HI, 388c2ecf20Sopenharmony_ci SID_OPTION_LO, 398c2ecf20Sopenharmony_ci SID_OPTION_COUNT 408c2ecf20Sopenharmony_ci}; 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_cienum Poly3rdOrderCoeff { 438c2ecf20Sopenharmony_ci LEAKAGE_TEMPERATURE_SCALAR, 448c2ecf20Sopenharmony_ci LEAKAGE_VOLTAGE_SCALAR, 458c2ecf20Sopenharmony_ci DYNAMIC_VOLTAGE_SCALAR, 468c2ecf20Sopenharmony_ci POLY_3RD_ORDER_COUNT 478c2ecf20Sopenharmony_ci}; 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_cistruct SMU7_Poly3rdOrder_Data { 508c2ecf20Sopenharmony_ci int32_t a; 518c2ecf20Sopenharmony_ci int32_t b; 528c2ecf20Sopenharmony_ci int32_t c; 538c2ecf20Sopenharmony_ci int32_t d; 548c2ecf20Sopenharmony_ci uint8_t a_shift; 558c2ecf20Sopenharmony_ci uint8_t b_shift; 568c2ecf20Sopenharmony_ci uint8_t c_shift; 578c2ecf20Sopenharmony_ci uint8_t x_shift; 588c2ecf20Sopenharmony_ci}; 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_citypedef struct SMU7_Poly3rdOrder_Data SMU7_Poly3rdOrder_Data; 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_cistruct Power_Calculator_Data { 638c2ecf20Sopenharmony_ci uint16_t NoLoadVoltage; 648c2ecf20Sopenharmony_ci uint16_t LoadVoltage; 658c2ecf20Sopenharmony_ci uint16_t Resistance; 668c2ecf20Sopenharmony_ci uint16_t Temperature; 678c2ecf20Sopenharmony_ci uint16_t BaseLeakage; 688c2ecf20Sopenharmony_ci uint16_t LkgTempScalar; 698c2ecf20Sopenharmony_ci uint16_t LkgVoltScalar; 708c2ecf20Sopenharmony_ci uint16_t LkgAreaScalar; 718c2ecf20Sopenharmony_ci uint16_t LkgPower; 728c2ecf20Sopenharmony_ci uint16_t DynVoltScalar; 738c2ecf20Sopenharmony_ci uint32_t Cac; 748c2ecf20Sopenharmony_ci uint32_t DynPower; 758c2ecf20Sopenharmony_ci uint32_t TotalCurrent; 768c2ecf20Sopenharmony_ci uint32_t TotalPower; 778c2ecf20Sopenharmony_ci}; 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_citypedef struct Power_Calculator_Data PowerCalculatorData_t; 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_cistruct Gc_Cac_Weight_Data { 828c2ecf20Sopenharmony_ci uint8_t index; 838c2ecf20Sopenharmony_ci uint32_t value; 848c2ecf20Sopenharmony_ci}; 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_citypedef struct Gc_Cac_Weight_Data GcCacWeight_Data; 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_citypedef struct { 908c2ecf20Sopenharmony_ci uint32_t high; 918c2ecf20Sopenharmony_ci uint32_t low; 928c2ecf20Sopenharmony_ci} data_64_t; 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_citypedef struct { 958c2ecf20Sopenharmony_ci data_64_t high; 968c2ecf20Sopenharmony_ci data_64_t low; 978c2ecf20Sopenharmony_ci} data_128_t; 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_ci#define SMU7_CONTEXT_ID_SMC 1 1008c2ecf20Sopenharmony_ci#define SMU7_CONTEXT_ID_VBIOS 2 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ci#define SMU72_MAX_LEVELS_VDDC 16 1038c2ecf20Sopenharmony_ci#define SMU72_MAX_LEVELS_VDDGFX 16 1048c2ecf20Sopenharmony_ci#define SMU72_MAX_LEVELS_VDDCI 8 1058c2ecf20Sopenharmony_ci#define SMU72_MAX_LEVELS_MVDD 4 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_ci#define SMU_MAX_SMIO_LEVELS 4 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ci#define SMU72_MAX_LEVELS_GRAPHICS SMU__NUM_SCLK_DPM_STATE /* SCLK + SQ DPM + ULV */ 1108c2ecf20Sopenharmony_ci#define SMU72_MAX_LEVELS_MEMORY SMU__NUM_MCLK_DPM_LEVELS /* MCLK Levels DPM */ 1118c2ecf20Sopenharmony_ci#define SMU72_MAX_LEVELS_GIO SMU__NUM_LCLK_DPM_LEVELS /* LCLK Levels */ 1128c2ecf20Sopenharmony_ci#define SMU72_MAX_LEVELS_LINK SMU__NUM_PCIE_DPM_LEVELS /* PCIe speed and number of lanes. */ 1138c2ecf20Sopenharmony_ci#define SMU72_MAX_LEVELS_UVD 8 /* VCLK/DCLK levels for UVD. */ 1148c2ecf20Sopenharmony_ci#define SMU72_MAX_LEVELS_VCE 8 /* ECLK levels for VCE. */ 1158c2ecf20Sopenharmony_ci#define SMU72_MAX_LEVELS_ACP 8 /* ACLK levels for ACP. */ 1168c2ecf20Sopenharmony_ci#define SMU72_MAX_LEVELS_SAMU 8 /* SAMCLK levels for SAMU. */ 1178c2ecf20Sopenharmony_ci#define SMU72_MAX_ENTRIES_SMIO 32 /* Number of entries in SMIO table. */ 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_ci#define DPM_NO_LIMIT 0 1208c2ecf20Sopenharmony_ci#define DPM_NO_UP 1 1218c2ecf20Sopenharmony_ci#define DPM_GO_DOWN 2 1228c2ecf20Sopenharmony_ci#define DPM_GO_UP 3 1238c2ecf20Sopenharmony_ci 1248c2ecf20Sopenharmony_ci#define SMU7_FIRST_DPM_GRAPHICS_LEVEL 0 1258c2ecf20Sopenharmony_ci#define SMU7_FIRST_DPM_MEMORY_LEVEL 0 1268c2ecf20Sopenharmony_ci 1278c2ecf20Sopenharmony_ci#define GPIO_CLAMP_MODE_VRHOT 1 1288c2ecf20Sopenharmony_ci#define GPIO_CLAMP_MODE_THERM 2 1298c2ecf20Sopenharmony_ci#define GPIO_CLAMP_MODE_DC 4 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_ci#define SCRATCH_B_TARG_PCIE_INDEX_SHIFT 0 1328c2ecf20Sopenharmony_ci#define SCRATCH_B_TARG_PCIE_INDEX_MASK (0x7<<SCRATCH_B_TARG_PCIE_INDEX_SHIFT) 1338c2ecf20Sopenharmony_ci#define SCRATCH_B_CURR_PCIE_INDEX_SHIFT 3 1348c2ecf20Sopenharmony_ci#define SCRATCH_B_CURR_PCIE_INDEX_MASK (0x7<<SCRATCH_B_CURR_PCIE_INDEX_SHIFT) 1358c2ecf20Sopenharmony_ci#define SCRATCH_B_TARG_UVD_INDEX_SHIFT 6 1368c2ecf20Sopenharmony_ci#define SCRATCH_B_TARG_UVD_INDEX_MASK (0x7<<SCRATCH_B_TARG_UVD_INDEX_SHIFT) 1378c2ecf20Sopenharmony_ci#define SCRATCH_B_CURR_UVD_INDEX_SHIFT 9 1388c2ecf20Sopenharmony_ci#define SCRATCH_B_CURR_UVD_INDEX_MASK (0x7<<SCRATCH_B_CURR_UVD_INDEX_SHIFT) 1398c2ecf20Sopenharmony_ci#define SCRATCH_B_TARG_VCE_INDEX_SHIFT 12 1408c2ecf20Sopenharmony_ci#define SCRATCH_B_TARG_VCE_INDEX_MASK (0x7<<SCRATCH_B_TARG_VCE_INDEX_SHIFT) 1418c2ecf20Sopenharmony_ci#define SCRATCH_B_CURR_VCE_INDEX_SHIFT 15 1428c2ecf20Sopenharmony_ci#define SCRATCH_B_CURR_VCE_INDEX_MASK (0x7<<SCRATCH_B_CURR_VCE_INDEX_SHIFT) 1438c2ecf20Sopenharmony_ci#define SCRATCH_B_TARG_ACP_INDEX_SHIFT 18 1448c2ecf20Sopenharmony_ci#define SCRATCH_B_TARG_ACP_INDEX_MASK (0x7<<SCRATCH_B_TARG_ACP_INDEX_SHIFT) 1458c2ecf20Sopenharmony_ci#define SCRATCH_B_CURR_ACP_INDEX_SHIFT 21 1468c2ecf20Sopenharmony_ci#define SCRATCH_B_CURR_ACP_INDEX_MASK (0x7<<SCRATCH_B_CURR_ACP_INDEX_SHIFT) 1478c2ecf20Sopenharmony_ci#define SCRATCH_B_TARG_SAMU_INDEX_SHIFT 24 1488c2ecf20Sopenharmony_ci#define SCRATCH_B_TARG_SAMU_INDEX_MASK (0x7<<SCRATCH_B_TARG_SAMU_INDEX_SHIFT) 1498c2ecf20Sopenharmony_ci#define SCRATCH_B_CURR_SAMU_INDEX_SHIFT 27 1508c2ecf20Sopenharmony_ci#define SCRATCH_B_CURR_SAMU_INDEX_MASK (0x7<<SCRATCH_B_CURR_SAMU_INDEX_SHIFT) 1518c2ecf20Sopenharmony_ci 1528c2ecf20Sopenharmony_ci/* Virtualization Defines */ 1538c2ecf20Sopenharmony_ci#define CG_XDMA_MASK 0x1 1548c2ecf20Sopenharmony_ci#define CG_XDMA_SHIFT 0 1558c2ecf20Sopenharmony_ci#define CG_UVD_MASK 0x2 1568c2ecf20Sopenharmony_ci#define CG_UVD_SHIFT 1 1578c2ecf20Sopenharmony_ci#define CG_VCE_MASK 0x4 1588c2ecf20Sopenharmony_ci#define CG_VCE_SHIFT 2 1598c2ecf20Sopenharmony_ci#define CG_SAMU_MASK 0x8 1608c2ecf20Sopenharmony_ci#define CG_SAMU_SHIFT 3 1618c2ecf20Sopenharmony_ci#define CG_GFX_MASK 0x10 1628c2ecf20Sopenharmony_ci#define CG_GFX_SHIFT 4 1638c2ecf20Sopenharmony_ci#define CG_SDMA_MASK 0x20 1648c2ecf20Sopenharmony_ci#define CG_SDMA_SHIFT 5 1658c2ecf20Sopenharmony_ci#define CG_HDP_MASK 0x40 1668c2ecf20Sopenharmony_ci#define CG_HDP_SHIFT 6 1678c2ecf20Sopenharmony_ci#define CG_MC_MASK 0x80 1688c2ecf20Sopenharmony_ci#define CG_MC_SHIFT 7 1698c2ecf20Sopenharmony_ci#define CG_DRM_MASK 0x100 1708c2ecf20Sopenharmony_ci#define CG_DRM_SHIFT 8 1718c2ecf20Sopenharmony_ci#define CG_ROM_MASK 0x200 1728c2ecf20Sopenharmony_ci#define CG_ROM_SHIFT 9 1738c2ecf20Sopenharmony_ci#define CG_BIF_MASK 0x400 1748c2ecf20Sopenharmony_ci#define CG_BIF_SHIFT 10 1758c2ecf20Sopenharmony_ci 1768c2ecf20Sopenharmony_ci#define SMU72_DTE_ITERATIONS 5 1778c2ecf20Sopenharmony_ci#define SMU72_DTE_SOURCES 3 1788c2ecf20Sopenharmony_ci#define SMU72_DTE_SINKS 1 1798c2ecf20Sopenharmony_ci#define SMU72_NUM_CPU_TES 0 1808c2ecf20Sopenharmony_ci#define SMU72_NUM_GPU_TES 1 1818c2ecf20Sopenharmony_ci#define SMU72_NUM_NON_TES 2 1828c2ecf20Sopenharmony_ci#define SMU72_DTE_FAN_SCALAR_MIN 0x100 1838c2ecf20Sopenharmony_ci#define SMU72_DTE_FAN_SCALAR_MAX 0x166 1848c2ecf20Sopenharmony_ci#define SMU72_DTE_FAN_TEMP_MAX 93 1858c2ecf20Sopenharmony_ci#define SMU72_DTE_FAN_TEMP_MIN 83 1868c2ecf20Sopenharmony_ci 1878c2ecf20Sopenharmony_ci#if defined SMU__FUSION_ONLY 1888c2ecf20Sopenharmony_ci#define SMU7_DTE_ITERATIONS 5 1898c2ecf20Sopenharmony_ci#define SMU7_DTE_SOURCES 5 1908c2ecf20Sopenharmony_ci#define SMU7_DTE_SINKS 3 1918c2ecf20Sopenharmony_ci#define SMU7_NUM_CPU_TES 2 1928c2ecf20Sopenharmony_ci#define SMU7_NUM_GPU_TES 1 1938c2ecf20Sopenharmony_ci#define SMU7_NUM_NON_TES 2 1948c2ecf20Sopenharmony_ci#endif 1958c2ecf20Sopenharmony_ci 1968c2ecf20Sopenharmony_cistruct SMU7_HystController_Data { 1978c2ecf20Sopenharmony_ci uint8_t waterfall_up; 1988c2ecf20Sopenharmony_ci uint8_t waterfall_down; 1998c2ecf20Sopenharmony_ci uint8_t waterfall_limit; 2008c2ecf20Sopenharmony_ci uint8_t spare; 2018c2ecf20Sopenharmony_ci uint16_t release_cnt; 2028c2ecf20Sopenharmony_ci uint16_t release_limit; 2038c2ecf20Sopenharmony_ci}; 2048c2ecf20Sopenharmony_ci 2058c2ecf20Sopenharmony_citypedef struct SMU7_HystController_Data SMU7_HystController_Data; 2068c2ecf20Sopenharmony_ci 2078c2ecf20Sopenharmony_cistruct SMU72_PIDController { 2088c2ecf20Sopenharmony_ci uint32_t Ki; 2098c2ecf20Sopenharmony_ci int32_t LFWindupUpperLim; 2108c2ecf20Sopenharmony_ci int32_t LFWindupLowerLim; 2118c2ecf20Sopenharmony_ci uint32_t StatePrecision; 2128c2ecf20Sopenharmony_ci uint32_t LfPrecision; 2138c2ecf20Sopenharmony_ci uint32_t LfOffset; 2148c2ecf20Sopenharmony_ci uint32_t MaxState; 2158c2ecf20Sopenharmony_ci uint32_t MaxLfFraction; 2168c2ecf20Sopenharmony_ci uint32_t StateShift; 2178c2ecf20Sopenharmony_ci}; 2188c2ecf20Sopenharmony_ci 2198c2ecf20Sopenharmony_citypedef struct SMU72_PIDController SMU72_PIDController; 2208c2ecf20Sopenharmony_ci 2218c2ecf20Sopenharmony_cistruct SMU7_LocalDpmScoreboard { 2228c2ecf20Sopenharmony_ci uint32_t PercentageBusy; 2238c2ecf20Sopenharmony_ci 2248c2ecf20Sopenharmony_ci int32_t PIDError; 2258c2ecf20Sopenharmony_ci int32_t PIDIntegral; 2268c2ecf20Sopenharmony_ci int32_t PIDOutput; 2278c2ecf20Sopenharmony_ci 2288c2ecf20Sopenharmony_ci uint32_t SigmaDeltaAccum; 2298c2ecf20Sopenharmony_ci uint32_t SigmaDeltaOutput; 2308c2ecf20Sopenharmony_ci uint32_t SigmaDeltaLevel; 2318c2ecf20Sopenharmony_ci 2328c2ecf20Sopenharmony_ci uint32_t UtilizationSetpoint; 2338c2ecf20Sopenharmony_ci 2348c2ecf20Sopenharmony_ci uint8_t TdpClampMode; 2358c2ecf20Sopenharmony_ci uint8_t TdcClampMode; 2368c2ecf20Sopenharmony_ci uint8_t ThermClampMode; 2378c2ecf20Sopenharmony_ci uint8_t VoltageBusy; 2388c2ecf20Sopenharmony_ci 2398c2ecf20Sopenharmony_ci int8_t CurrLevel; 2408c2ecf20Sopenharmony_ci int8_t TargLevel; 2418c2ecf20Sopenharmony_ci uint8_t LevelChangeInProgress; 2428c2ecf20Sopenharmony_ci uint8_t UpHyst; 2438c2ecf20Sopenharmony_ci 2448c2ecf20Sopenharmony_ci uint8_t DownHyst; 2458c2ecf20Sopenharmony_ci uint8_t VoltageDownHyst; 2468c2ecf20Sopenharmony_ci uint8_t DpmEnable; 2478c2ecf20Sopenharmony_ci uint8_t DpmRunning; 2488c2ecf20Sopenharmony_ci 2498c2ecf20Sopenharmony_ci uint8_t DpmForce; 2508c2ecf20Sopenharmony_ci uint8_t DpmForceLevel; 2518c2ecf20Sopenharmony_ci uint8_t DisplayWatermark; 2528c2ecf20Sopenharmony_ci uint8_t McArbIndex; 2538c2ecf20Sopenharmony_ci 2548c2ecf20Sopenharmony_ci uint32_t MinimumPerfSclk; 2558c2ecf20Sopenharmony_ci 2568c2ecf20Sopenharmony_ci uint8_t AcpiReq; 2578c2ecf20Sopenharmony_ci uint8_t AcpiAck; 2588c2ecf20Sopenharmony_ci uint8_t GfxClkSlow; 2598c2ecf20Sopenharmony_ci uint8_t GpioClampMode; /* bit0 = VRHOT: bit1 = THERM: bit2 = DC */ 2608c2ecf20Sopenharmony_ci 2618c2ecf20Sopenharmony_ci uint8_t FpsFilterWeight; 2628c2ecf20Sopenharmony_ci uint8_t EnabledLevelsChange; 2638c2ecf20Sopenharmony_ci uint8_t DteClampMode; 2648c2ecf20Sopenharmony_ci uint8_t FpsClampMode; 2658c2ecf20Sopenharmony_ci 2668c2ecf20Sopenharmony_ci uint16_t LevelResidencyCounters[SMU72_MAX_LEVELS_GRAPHICS]; 2678c2ecf20Sopenharmony_ci uint16_t LevelSwitchCounters[SMU72_MAX_LEVELS_GRAPHICS]; 2688c2ecf20Sopenharmony_ci 2698c2ecf20Sopenharmony_ci void (*TargetStateCalculator)(uint8_t); 2708c2ecf20Sopenharmony_ci void (*SavedTargetStateCalculator)(uint8_t); 2718c2ecf20Sopenharmony_ci 2728c2ecf20Sopenharmony_ci uint16_t AutoDpmInterval; 2738c2ecf20Sopenharmony_ci uint16_t AutoDpmRange; 2748c2ecf20Sopenharmony_ci 2758c2ecf20Sopenharmony_ci uint8_t FpsEnabled; 2768c2ecf20Sopenharmony_ci uint8_t MaxPerfLevel; 2778c2ecf20Sopenharmony_ci uint8_t AllowLowClkInterruptToHost; 2788c2ecf20Sopenharmony_ci uint8_t FpsRunning; 2798c2ecf20Sopenharmony_ci 2808c2ecf20Sopenharmony_ci uint32_t MaxAllowedFrequency; 2818c2ecf20Sopenharmony_ci 2828c2ecf20Sopenharmony_ci uint32_t FilteredSclkFrequency; 2838c2ecf20Sopenharmony_ci uint32_t LastSclkFrequency; 2848c2ecf20Sopenharmony_ci uint32_t FilteredSclkFrequencyCnt; 2858c2ecf20Sopenharmony_ci}; 2868c2ecf20Sopenharmony_ci 2878c2ecf20Sopenharmony_citypedef struct SMU7_LocalDpmScoreboard SMU7_LocalDpmScoreboard; 2888c2ecf20Sopenharmony_ci 2898c2ecf20Sopenharmony_ci#define SMU7_MAX_VOLTAGE_CLIENTS 12 2908c2ecf20Sopenharmony_ci 2918c2ecf20Sopenharmony_citypedef uint8_t (*VoltageChangeHandler_t)(uint16_t, uint8_t); 2928c2ecf20Sopenharmony_ci 2938c2ecf20Sopenharmony_cistruct SMU_VoltageLevel { 2948c2ecf20Sopenharmony_ci uint8_t Vddc; 2958c2ecf20Sopenharmony_ci uint8_t Vddci; 2968c2ecf20Sopenharmony_ci uint8_t VddGfx; 2978c2ecf20Sopenharmony_ci uint8_t Phases; 2988c2ecf20Sopenharmony_ci}; 2998c2ecf20Sopenharmony_ci 3008c2ecf20Sopenharmony_citypedef struct SMU_VoltageLevel SMU_VoltageLevel; 3018c2ecf20Sopenharmony_ci 3028c2ecf20Sopenharmony_cistruct SMU7_VoltageScoreboard { 3038c2ecf20Sopenharmony_ci SMU_VoltageLevel CurrentVoltage; 3048c2ecf20Sopenharmony_ci SMU_VoltageLevel TargetVoltage; 3058c2ecf20Sopenharmony_ci uint16_t MaxVid; 3068c2ecf20Sopenharmony_ci uint8_t HighestVidOffset; 3078c2ecf20Sopenharmony_ci uint8_t CurrentVidOffset; 3088c2ecf20Sopenharmony_ci 3098c2ecf20Sopenharmony_ci uint8_t ControllerBusy; 3108c2ecf20Sopenharmony_ci uint8_t CurrentVid; 3118c2ecf20Sopenharmony_ci uint8_t CurrentVddciVid; 3128c2ecf20Sopenharmony_ci uint8_t VddGfxShutdown; /* 0 = normal mode, 1 = shut down */ 3138c2ecf20Sopenharmony_ci 3148c2ecf20Sopenharmony_ci SMU_VoltageLevel RequestedVoltage[SMU7_MAX_VOLTAGE_CLIENTS]; 3158c2ecf20Sopenharmony_ci uint8_t EnabledRequest[SMU7_MAX_VOLTAGE_CLIENTS]; 3168c2ecf20Sopenharmony_ci 3178c2ecf20Sopenharmony_ci uint8_t TargetIndex; 3188c2ecf20Sopenharmony_ci uint8_t Delay; 3198c2ecf20Sopenharmony_ci uint8_t ControllerEnable; 3208c2ecf20Sopenharmony_ci uint8_t ControllerRunning; 3218c2ecf20Sopenharmony_ci uint16_t CurrentStdVoltageHiSidd; 3228c2ecf20Sopenharmony_ci uint16_t CurrentStdVoltageLoSidd; 3238c2ecf20Sopenharmony_ci uint8_t OverrideVoltage; 3248c2ecf20Sopenharmony_ci uint8_t VddcUseUlvOffset; 3258c2ecf20Sopenharmony_ci uint8_t VddGfxUseUlvOffset; 3268c2ecf20Sopenharmony_ci uint8_t padding; 3278c2ecf20Sopenharmony_ci 3288c2ecf20Sopenharmony_ci VoltageChangeHandler_t ChangeVddc; 3298c2ecf20Sopenharmony_ci VoltageChangeHandler_t ChangeVddGfx; 3308c2ecf20Sopenharmony_ci VoltageChangeHandler_t ChangeVddci; 3318c2ecf20Sopenharmony_ci VoltageChangeHandler_t ChangePhase; 3328c2ecf20Sopenharmony_ci VoltageChangeHandler_t ChangeMvdd; 3338c2ecf20Sopenharmony_ci 3348c2ecf20Sopenharmony_ci VoltageChangeHandler_t functionLinks[6]; 3358c2ecf20Sopenharmony_ci 3368c2ecf20Sopenharmony_ci uint8_t *VddcFollower1; 3378c2ecf20Sopenharmony_ci uint8_t *VddcFollower2; 3388c2ecf20Sopenharmony_ci int16_t Driver_OD_RequestedVidOffset1; 3398c2ecf20Sopenharmony_ci int16_t Driver_OD_RequestedVidOffset2; 3408c2ecf20Sopenharmony_ci 3418c2ecf20Sopenharmony_ci}; 3428c2ecf20Sopenharmony_ci 3438c2ecf20Sopenharmony_citypedef struct SMU7_VoltageScoreboard SMU7_VoltageScoreboard; 3448c2ecf20Sopenharmony_ci 3458c2ecf20Sopenharmony_ci#define SMU7_MAX_PCIE_LINK_SPEEDS 3 /* 0:Gen1 1:Gen2 2:Gen3 */ 3468c2ecf20Sopenharmony_ci 3478c2ecf20Sopenharmony_cistruct SMU7_PCIeLinkSpeedScoreboard { 3488c2ecf20Sopenharmony_ci uint8_t DpmEnable; 3498c2ecf20Sopenharmony_ci uint8_t DpmRunning; 3508c2ecf20Sopenharmony_ci uint8_t DpmForce; 3518c2ecf20Sopenharmony_ci uint8_t DpmForceLevel; 3528c2ecf20Sopenharmony_ci 3538c2ecf20Sopenharmony_ci uint8_t CurrentLinkSpeed; 3548c2ecf20Sopenharmony_ci uint8_t EnabledLevelsChange; 3558c2ecf20Sopenharmony_ci uint16_t AutoDpmInterval; 3568c2ecf20Sopenharmony_ci 3578c2ecf20Sopenharmony_ci uint16_t AutoDpmRange; 3588c2ecf20Sopenharmony_ci uint16_t AutoDpmCount; 3598c2ecf20Sopenharmony_ci 3608c2ecf20Sopenharmony_ci uint8_t DpmMode; 3618c2ecf20Sopenharmony_ci uint8_t AcpiReq; 3628c2ecf20Sopenharmony_ci uint8_t AcpiAck; 3638c2ecf20Sopenharmony_ci uint8_t CurrentLinkLevel; 3648c2ecf20Sopenharmony_ci 3658c2ecf20Sopenharmony_ci}; 3668c2ecf20Sopenharmony_ci 3678c2ecf20Sopenharmony_citypedef struct SMU7_PCIeLinkSpeedScoreboard SMU7_PCIeLinkSpeedScoreboard; 3688c2ecf20Sopenharmony_ci 3698c2ecf20Sopenharmony_ci/* -------------------------------------------------------- CAC table ------------------------------------------------------ */ 3708c2ecf20Sopenharmony_ci#define SMU7_LKGE_LUT_NUM_OF_TEMP_ENTRIES 16 3718c2ecf20Sopenharmony_ci#define SMU7_LKGE_LUT_NUM_OF_VOLT_ENTRIES 16 3728c2ecf20Sopenharmony_ci#define SMU7_SCALE_I 7 3738c2ecf20Sopenharmony_ci#define SMU7_SCALE_R 12 3748c2ecf20Sopenharmony_ci 3758c2ecf20Sopenharmony_cistruct SMU7_PowerScoreboard { 3768c2ecf20Sopenharmony_ci PowerCalculatorData_t VddGfxPowerData[SID_OPTION_COUNT]; 3778c2ecf20Sopenharmony_ci PowerCalculatorData_t VddcPowerData[SID_OPTION_COUNT]; 3788c2ecf20Sopenharmony_ci 3798c2ecf20Sopenharmony_ci uint32_t TotalGpuPower; 3808c2ecf20Sopenharmony_ci uint32_t TdcCurrent; 3818c2ecf20Sopenharmony_ci 3828c2ecf20Sopenharmony_ci uint16_t VddciTotalPower; 3838c2ecf20Sopenharmony_ci uint16_t sparesasfsdfd; 3848c2ecf20Sopenharmony_ci uint16_t Vddr1Power; 3858c2ecf20Sopenharmony_ci uint16_t RocPower; 3868c2ecf20Sopenharmony_ci 3878c2ecf20Sopenharmony_ci uint16_t CalcMeasPowerBlend; 3888c2ecf20Sopenharmony_ci uint8_t SidOptionPower; 3898c2ecf20Sopenharmony_ci uint8_t SidOptionCurrent; 3908c2ecf20Sopenharmony_ci 3918c2ecf20Sopenharmony_ci uint32_t WinTime; 3928c2ecf20Sopenharmony_ci 3938c2ecf20Sopenharmony_ci uint16_t Telemetry_1_slope; 3948c2ecf20Sopenharmony_ci uint16_t Telemetry_2_slope; 3958c2ecf20Sopenharmony_ci int32_t Telemetry_1_offset; 3968c2ecf20Sopenharmony_ci int32_t Telemetry_2_offset; 3978c2ecf20Sopenharmony_ci 3988c2ecf20Sopenharmony_ci uint32_t VddcCurrentTelemetry; 3998c2ecf20Sopenharmony_ci uint32_t VddGfxCurrentTelemetry; 4008c2ecf20Sopenharmony_ci uint32_t VddcPowerTelemetry; 4018c2ecf20Sopenharmony_ci uint32_t VddGfxPowerTelemetry; 4028c2ecf20Sopenharmony_ci uint32_t VddciPowerTelemetry; 4038c2ecf20Sopenharmony_ci 4048c2ecf20Sopenharmony_ci uint32_t VddcPower; 4058c2ecf20Sopenharmony_ci uint32_t VddGfxPower; 4068c2ecf20Sopenharmony_ci uint32_t VddciPower; 4078c2ecf20Sopenharmony_ci 4088c2ecf20Sopenharmony_ci uint32_t TelemetryCurrent[2]; 4098c2ecf20Sopenharmony_ci uint32_t TelemetryVoltage[2]; 4108c2ecf20Sopenharmony_ci uint32_t TelemetryPower[2]; 4118c2ecf20Sopenharmony_ci}; 4128c2ecf20Sopenharmony_ci 4138c2ecf20Sopenharmony_citypedef struct SMU7_PowerScoreboard SMU7_PowerScoreboard; 4148c2ecf20Sopenharmony_ci 4158c2ecf20Sopenharmony_cistruct SMU7_ThermalScoreboard { 4168c2ecf20Sopenharmony_ci int16_t GpuLimit; 4178c2ecf20Sopenharmony_ci int16_t GpuHyst; 4188c2ecf20Sopenharmony_ci uint16_t CurrGnbTemp; 4198c2ecf20Sopenharmony_ci uint16_t FilteredGnbTemp; 4208c2ecf20Sopenharmony_ci 4218c2ecf20Sopenharmony_ci uint8_t ControllerEnable; 4228c2ecf20Sopenharmony_ci uint8_t ControllerRunning; 4238c2ecf20Sopenharmony_ci uint8_t AutoTmonCalInterval; 4248c2ecf20Sopenharmony_ci uint8_t AutoTmonCalEnable; 4258c2ecf20Sopenharmony_ci 4268c2ecf20Sopenharmony_ci uint8_t ThermalDpmEnabled; 4278c2ecf20Sopenharmony_ci uint8_t SclkEnabledMask; 4288c2ecf20Sopenharmony_ci uint8_t spare[2]; 4298c2ecf20Sopenharmony_ci int32_t temperature_gradient; 4308c2ecf20Sopenharmony_ci 4318c2ecf20Sopenharmony_ci SMU7_HystController_Data HystControllerData; 4328c2ecf20Sopenharmony_ci int32_t WeightedSensorTemperature; 4338c2ecf20Sopenharmony_ci uint16_t TemperatureLimit[SMU72_MAX_LEVELS_GRAPHICS]; 4348c2ecf20Sopenharmony_ci uint32_t Alpha; 4358c2ecf20Sopenharmony_ci}; 4368c2ecf20Sopenharmony_ci 4378c2ecf20Sopenharmony_citypedef struct SMU7_ThermalScoreboard SMU7_ThermalScoreboard; 4388c2ecf20Sopenharmony_ci 4398c2ecf20Sopenharmony_ci/* For FeatureEnables: */ 4408c2ecf20Sopenharmony_ci#define SMU7_SCLK_DPM_CONFIG_MASK 0x01 4418c2ecf20Sopenharmony_ci#define SMU7_VOLTAGE_CONTROLLER_CONFIG_MASK 0x02 4428c2ecf20Sopenharmony_ci#define SMU7_THERMAL_CONTROLLER_CONFIG_MASK 0x04 4438c2ecf20Sopenharmony_ci#define SMU7_MCLK_DPM_CONFIG_MASK 0x08 4448c2ecf20Sopenharmony_ci#define SMU7_UVD_DPM_CONFIG_MASK 0x10 4458c2ecf20Sopenharmony_ci#define SMU7_VCE_DPM_CONFIG_MASK 0x20 4468c2ecf20Sopenharmony_ci#define SMU7_ACP_DPM_CONFIG_MASK 0x40 4478c2ecf20Sopenharmony_ci#define SMU7_SAMU_DPM_CONFIG_MASK 0x80 4488c2ecf20Sopenharmony_ci#define SMU7_PCIEGEN_DPM_CONFIG_MASK 0x100 4498c2ecf20Sopenharmony_ci 4508c2ecf20Sopenharmony_ci#define SMU7_ACP_MCLK_HANDSHAKE_DISABLE 0x00000001 4518c2ecf20Sopenharmony_ci#define SMU7_ACP_SCLK_HANDSHAKE_DISABLE 0x00000002 4528c2ecf20Sopenharmony_ci#define SMU7_UVD_MCLK_HANDSHAKE_DISABLE 0x00000100 4538c2ecf20Sopenharmony_ci#define SMU7_UVD_SCLK_HANDSHAKE_DISABLE 0x00000200 4548c2ecf20Sopenharmony_ci#define SMU7_VCE_MCLK_HANDSHAKE_DISABLE 0x00010000 4558c2ecf20Sopenharmony_ci#define SMU7_VCE_SCLK_HANDSHAKE_DISABLE 0x00020000 4568c2ecf20Sopenharmony_ci 4578c2ecf20Sopenharmony_ci/* All 'soft registers' should be uint32_t. */ 4588c2ecf20Sopenharmony_cistruct SMU72_SoftRegisters { 4598c2ecf20Sopenharmony_ci uint32_t RefClockFrequency; 4608c2ecf20Sopenharmony_ci uint32_t PmTimerPeriod; 4618c2ecf20Sopenharmony_ci uint32_t FeatureEnables; 4628c2ecf20Sopenharmony_ci 4638c2ecf20Sopenharmony_ci uint32_t PreVBlankGap; 4648c2ecf20Sopenharmony_ci uint32_t VBlankTimeout; 4658c2ecf20Sopenharmony_ci uint32_t TrainTimeGap; 4668c2ecf20Sopenharmony_ci 4678c2ecf20Sopenharmony_ci uint32_t MvddSwitchTime; 4688c2ecf20Sopenharmony_ci uint32_t LongestAcpiTrainTime; 4698c2ecf20Sopenharmony_ci uint32_t AcpiDelay; 4708c2ecf20Sopenharmony_ci uint32_t G5TrainTime; 4718c2ecf20Sopenharmony_ci uint32_t DelayMpllPwron; 4728c2ecf20Sopenharmony_ci uint32_t VoltageChangeTimeout; 4738c2ecf20Sopenharmony_ci 4748c2ecf20Sopenharmony_ci uint32_t HandshakeDisables; 4758c2ecf20Sopenharmony_ci 4768c2ecf20Sopenharmony_ci uint8_t DisplayPhy1Config; 4778c2ecf20Sopenharmony_ci uint8_t DisplayPhy2Config; 4788c2ecf20Sopenharmony_ci uint8_t DisplayPhy3Config; 4798c2ecf20Sopenharmony_ci uint8_t DisplayPhy4Config; 4808c2ecf20Sopenharmony_ci 4818c2ecf20Sopenharmony_ci uint8_t DisplayPhy5Config; 4828c2ecf20Sopenharmony_ci uint8_t DisplayPhy6Config; 4838c2ecf20Sopenharmony_ci uint8_t DisplayPhy7Config; 4848c2ecf20Sopenharmony_ci uint8_t DisplayPhy8Config; 4858c2ecf20Sopenharmony_ci 4868c2ecf20Sopenharmony_ci uint32_t AverageGraphicsActivity; 4878c2ecf20Sopenharmony_ci uint32_t AverageMemoryActivity; 4888c2ecf20Sopenharmony_ci uint32_t AverageGioActivity; 4898c2ecf20Sopenharmony_ci 4908c2ecf20Sopenharmony_ci uint8_t SClkDpmEnabledLevels; 4918c2ecf20Sopenharmony_ci uint8_t MClkDpmEnabledLevels; 4928c2ecf20Sopenharmony_ci uint8_t LClkDpmEnabledLevels; 4938c2ecf20Sopenharmony_ci uint8_t PCIeDpmEnabledLevels; 4948c2ecf20Sopenharmony_ci 4958c2ecf20Sopenharmony_ci uint8_t UVDDpmEnabledLevels; 4968c2ecf20Sopenharmony_ci uint8_t SAMUDpmEnabledLevels; 4978c2ecf20Sopenharmony_ci uint8_t ACPDpmEnabledLevels; 4988c2ecf20Sopenharmony_ci uint8_t VCEDpmEnabledLevels; 4998c2ecf20Sopenharmony_ci 5008c2ecf20Sopenharmony_ci uint32_t DRAM_LOG_ADDR_H; 5018c2ecf20Sopenharmony_ci uint32_t DRAM_LOG_ADDR_L; 5028c2ecf20Sopenharmony_ci uint32_t DRAM_LOG_PHY_ADDR_H; 5038c2ecf20Sopenharmony_ci uint32_t DRAM_LOG_PHY_ADDR_L; 5048c2ecf20Sopenharmony_ci uint32_t DRAM_LOG_BUFF_SIZE; 5058c2ecf20Sopenharmony_ci uint32_t UlvEnterCount; 5068c2ecf20Sopenharmony_ci uint32_t UlvTime; 5078c2ecf20Sopenharmony_ci uint32_t UcodeLoadStatus; 5088c2ecf20Sopenharmony_ci uint32_t Reserved[2]; 5098c2ecf20Sopenharmony_ci 5108c2ecf20Sopenharmony_ci}; 5118c2ecf20Sopenharmony_ci 5128c2ecf20Sopenharmony_citypedef struct SMU72_SoftRegisters SMU72_SoftRegisters; 5138c2ecf20Sopenharmony_ci 5148c2ecf20Sopenharmony_cistruct SMU72_Firmware_Header { 5158c2ecf20Sopenharmony_ci uint32_t Digest[5]; 5168c2ecf20Sopenharmony_ci uint32_t Version; 5178c2ecf20Sopenharmony_ci uint32_t HeaderSize; 5188c2ecf20Sopenharmony_ci uint32_t Flags; 5198c2ecf20Sopenharmony_ci uint32_t EntryPoint; 5208c2ecf20Sopenharmony_ci uint32_t CodeSize; 5218c2ecf20Sopenharmony_ci uint32_t ImageSize; 5228c2ecf20Sopenharmony_ci 5238c2ecf20Sopenharmony_ci uint32_t Rtos; 5248c2ecf20Sopenharmony_ci uint32_t SoftRegisters; 5258c2ecf20Sopenharmony_ci uint32_t DpmTable; 5268c2ecf20Sopenharmony_ci uint32_t FanTable; 5278c2ecf20Sopenharmony_ci uint32_t CacConfigTable; 5288c2ecf20Sopenharmony_ci uint32_t CacStatusTable; 5298c2ecf20Sopenharmony_ci uint32_t mcRegisterTable; 5308c2ecf20Sopenharmony_ci uint32_t mcArbDramTimingTable; 5318c2ecf20Sopenharmony_ci uint32_t PmFuseTable; 5328c2ecf20Sopenharmony_ci uint32_t Globals; 5338c2ecf20Sopenharmony_ci uint32_t ClockStretcherTable; 5348c2ecf20Sopenharmony_ci uint32_t Reserved[41]; 5358c2ecf20Sopenharmony_ci uint32_t Signature; 5368c2ecf20Sopenharmony_ci}; 5378c2ecf20Sopenharmony_ci 5388c2ecf20Sopenharmony_citypedef struct SMU72_Firmware_Header SMU72_Firmware_Header; 5398c2ecf20Sopenharmony_ci 5408c2ecf20Sopenharmony_ci#define SMU72_FIRMWARE_HEADER_LOCATION 0x20000 5418c2ecf20Sopenharmony_ci 5428c2ecf20Sopenharmony_cienum DisplayConfig { 5438c2ecf20Sopenharmony_ci PowerDown = 1, 5448c2ecf20Sopenharmony_ci DP54x4, 5458c2ecf20Sopenharmony_ci DP54x2, 5468c2ecf20Sopenharmony_ci DP54x1, 5478c2ecf20Sopenharmony_ci DP27x4, 5488c2ecf20Sopenharmony_ci DP27x2, 5498c2ecf20Sopenharmony_ci DP27x1, 5508c2ecf20Sopenharmony_ci HDMI297, 5518c2ecf20Sopenharmony_ci HDMI162, 5528c2ecf20Sopenharmony_ci LVDS, 5538c2ecf20Sopenharmony_ci DP324x4, 5548c2ecf20Sopenharmony_ci DP324x2, 5558c2ecf20Sopenharmony_ci DP324x1 5568c2ecf20Sopenharmony_ci}; 5578c2ecf20Sopenharmony_ci 5588c2ecf20Sopenharmony_ci#define MC_BLOCK_COUNT 1 5598c2ecf20Sopenharmony_ci#define CPL_BLOCK_COUNT 5 5608c2ecf20Sopenharmony_ci#define SE_BLOCK_COUNT 15 5618c2ecf20Sopenharmony_ci#define GC_BLOCK_COUNT 24 5628c2ecf20Sopenharmony_ci 5638c2ecf20Sopenharmony_cistruct SMU7_Local_Cac { 5648c2ecf20Sopenharmony_ci uint8_t BlockId; 5658c2ecf20Sopenharmony_ci uint8_t SignalId; 5668c2ecf20Sopenharmony_ci uint8_t Threshold; 5678c2ecf20Sopenharmony_ci uint8_t Padding; 5688c2ecf20Sopenharmony_ci}; 5698c2ecf20Sopenharmony_ci 5708c2ecf20Sopenharmony_citypedef struct SMU7_Local_Cac SMU7_Local_Cac; 5718c2ecf20Sopenharmony_ci 5728c2ecf20Sopenharmony_cistruct SMU7_Local_Cac_Table { 5738c2ecf20Sopenharmony_ci SMU7_Local_Cac CplLocalCac[CPL_BLOCK_COUNT]; 5748c2ecf20Sopenharmony_ci SMU7_Local_Cac McLocalCac[MC_BLOCK_COUNT]; 5758c2ecf20Sopenharmony_ci SMU7_Local_Cac SeLocalCac[SE_BLOCK_COUNT]; 5768c2ecf20Sopenharmony_ci SMU7_Local_Cac GcLocalCac[GC_BLOCK_COUNT]; 5778c2ecf20Sopenharmony_ci}; 5788c2ecf20Sopenharmony_ci 5798c2ecf20Sopenharmony_citypedef struct SMU7_Local_Cac_Table SMU7_Local_Cac_Table; 5808c2ecf20Sopenharmony_ci 5818c2ecf20Sopenharmony_ci#if !defined(SMC_MICROCODE) 5828c2ecf20Sopenharmony_ci#pragma pack(pop) 5838c2ecf20Sopenharmony_ci#endif 5848c2ecf20Sopenharmony_ci 5858c2ecf20Sopenharmony_ci/* Description of Clock Gating bitmask for Tonga: */ 5868c2ecf20Sopenharmony_ci/* System Clock Gating */ 5878c2ecf20Sopenharmony_ci#define CG_SYS_BITMASK_FIRST_BIT 0 /* First bit of Sys CG bitmask */ 5888c2ecf20Sopenharmony_ci#define CG_SYS_BITMASK_LAST_BIT 9 /* Last bit of Sys CG bitmask */ 5898c2ecf20Sopenharmony_ci#define CG_SYS_BIF_MGLS_SHIFT 0 5908c2ecf20Sopenharmony_ci#define CG_SYS_ROM_SHIFT 1 5918c2ecf20Sopenharmony_ci#define CG_SYS_MC_MGCG_SHIFT 2 5928c2ecf20Sopenharmony_ci#define CG_SYS_MC_MGLS_SHIFT 3 5938c2ecf20Sopenharmony_ci#define CG_SYS_SDMA_MGCG_SHIFT 4 5948c2ecf20Sopenharmony_ci#define CG_SYS_SDMA_MGLS_SHIFT 5 5958c2ecf20Sopenharmony_ci#define CG_SYS_DRM_MGCG_SHIFT 6 5968c2ecf20Sopenharmony_ci#define CG_SYS_HDP_MGCG_SHIFT 7 5978c2ecf20Sopenharmony_ci#define CG_SYS_HDP_MGLS_SHIFT 8 5988c2ecf20Sopenharmony_ci#define CG_SYS_DRM_MGLS_SHIFT 9 5998c2ecf20Sopenharmony_ci 6008c2ecf20Sopenharmony_ci#define CG_SYS_BIF_MGLS_MASK 0x1 6018c2ecf20Sopenharmony_ci#define CG_SYS_ROM_MASK 0x2 6028c2ecf20Sopenharmony_ci#define CG_SYS_MC_MGCG_MASK 0x4 6038c2ecf20Sopenharmony_ci#define CG_SYS_MC_MGLS_MASK 0x8 6048c2ecf20Sopenharmony_ci#define CG_SYS_SDMA_MGCG_MASK 0x10 6058c2ecf20Sopenharmony_ci#define CG_SYS_SDMA_MGLS_MASK 0x20 6068c2ecf20Sopenharmony_ci#define CG_SYS_DRM_MGCG_MASK 0x40 6078c2ecf20Sopenharmony_ci#define CG_SYS_HDP_MGCG_MASK 0x80 6088c2ecf20Sopenharmony_ci#define CG_SYS_HDP_MGLS_MASK 0x100 6098c2ecf20Sopenharmony_ci#define CG_SYS_DRM_MGLS_MASK 0x200 6108c2ecf20Sopenharmony_ci 6118c2ecf20Sopenharmony_ci/* Graphics Clock Gating */ 6128c2ecf20Sopenharmony_ci#define CG_GFX_BITMASK_FIRST_BIT 16 /* First bit of Gfx CG bitmask */ 6138c2ecf20Sopenharmony_ci#define CG_GFX_BITMASK_LAST_BIT 20 /* Last bit of Gfx CG bitmask */ 6148c2ecf20Sopenharmony_ci#define CG_GFX_CGCG_SHIFT 16 6158c2ecf20Sopenharmony_ci#define CG_GFX_CGLS_SHIFT 17 6168c2ecf20Sopenharmony_ci#define CG_CPF_MGCG_SHIFT 18 6178c2ecf20Sopenharmony_ci#define CG_RLC_MGCG_SHIFT 19 6188c2ecf20Sopenharmony_ci#define CG_GFX_OTHERS_MGCG_SHIFT 20 6198c2ecf20Sopenharmony_ci 6208c2ecf20Sopenharmony_ci#define CG_GFX_CGCG_MASK 0x00010000 6218c2ecf20Sopenharmony_ci#define CG_GFX_CGLS_MASK 0x00020000 6228c2ecf20Sopenharmony_ci#define CG_CPF_MGCG_MASK 0x00040000 6238c2ecf20Sopenharmony_ci#define CG_RLC_MGCG_MASK 0x00080000 6248c2ecf20Sopenharmony_ci#define CG_GFX_OTHERS_MGCG_MASK 0x00100000 6258c2ecf20Sopenharmony_ci 6268c2ecf20Sopenharmony_ci/* Voltage Regulator Configuration */ 6278c2ecf20Sopenharmony_ci/* VR Config info is contained in dpmTable.VRConfig */ 6288c2ecf20Sopenharmony_ci 6298c2ecf20Sopenharmony_ci#define VRCONF_VDDC_MASK 0x000000FF 6308c2ecf20Sopenharmony_ci#define VRCONF_VDDC_SHIFT 0 6318c2ecf20Sopenharmony_ci#define VRCONF_VDDGFX_MASK 0x0000FF00 6328c2ecf20Sopenharmony_ci#define VRCONF_VDDGFX_SHIFT 8 6338c2ecf20Sopenharmony_ci#define VRCONF_VDDCI_MASK 0x00FF0000 6348c2ecf20Sopenharmony_ci#define VRCONF_VDDCI_SHIFT 16 6358c2ecf20Sopenharmony_ci#define VRCONF_MVDD_MASK 0xFF000000 6368c2ecf20Sopenharmony_ci#define VRCONF_MVDD_SHIFT 24 6378c2ecf20Sopenharmony_ci 6388c2ecf20Sopenharmony_ci#define VR_MERGED_WITH_VDDC 0 6398c2ecf20Sopenharmony_ci#define VR_SVI2_PLANE_1 1 6408c2ecf20Sopenharmony_ci#define VR_SVI2_PLANE_2 2 6418c2ecf20Sopenharmony_ci#define VR_SMIO_PATTERN_1 3 6428c2ecf20Sopenharmony_ci#define VR_SMIO_PATTERN_2 4 6438c2ecf20Sopenharmony_ci#define VR_STATIC_VOLTAGE 5 6448c2ecf20Sopenharmony_ci 6458c2ecf20Sopenharmony_ci/* Clock Stretcher Configuration */ 6468c2ecf20Sopenharmony_ci 6478c2ecf20Sopenharmony_ci#define CLOCK_STRETCHER_MAX_ENTRIES 0x4 6488c2ecf20Sopenharmony_ci#define CKS_LOOKUPTable_MAX_ENTRIES 0x4 6498c2ecf20Sopenharmony_ci 6508c2ecf20Sopenharmony_ci/* The 'settings' field is subdivided in the following way: */ 6518c2ecf20Sopenharmony_ci#define CLOCK_STRETCHER_SETTING_DDT_MASK 0x01 6528c2ecf20Sopenharmony_ci#define CLOCK_STRETCHER_SETTING_DDT_SHIFT 0x0 6538c2ecf20Sopenharmony_ci#define CLOCK_STRETCHER_SETTING_STRETCH_AMOUNT_MASK 0x1E 6548c2ecf20Sopenharmony_ci#define CLOCK_STRETCHER_SETTING_STRETCH_AMOUNT_SHIFT 0x1 6558c2ecf20Sopenharmony_ci#define CLOCK_STRETCHER_SETTING_ENABLE_MASK 0x80 6568c2ecf20Sopenharmony_ci#define CLOCK_STRETCHER_SETTING_ENABLE_SHIFT 0x7 6578c2ecf20Sopenharmony_ci 6588c2ecf20Sopenharmony_cistruct SMU_ClockStretcherDataTableEntry { 6598c2ecf20Sopenharmony_ci uint8_t minVID; 6608c2ecf20Sopenharmony_ci uint8_t maxVID; 6618c2ecf20Sopenharmony_ci 6628c2ecf20Sopenharmony_ci uint16_t setting; 6638c2ecf20Sopenharmony_ci}; 6648c2ecf20Sopenharmony_citypedef struct SMU_ClockStretcherDataTableEntry SMU_ClockStretcherDataTableEntry; 6658c2ecf20Sopenharmony_ci 6668c2ecf20Sopenharmony_cistruct SMU_ClockStretcherDataTable { 6678c2ecf20Sopenharmony_ci SMU_ClockStretcherDataTableEntry ClockStretcherDataTableEntry[CLOCK_STRETCHER_MAX_ENTRIES]; 6688c2ecf20Sopenharmony_ci}; 6698c2ecf20Sopenharmony_citypedef struct SMU_ClockStretcherDataTable SMU_ClockStretcherDataTable; 6708c2ecf20Sopenharmony_ci 6718c2ecf20Sopenharmony_cistruct SMU_CKS_LOOKUPTableEntry { 6728c2ecf20Sopenharmony_ci uint16_t minFreq; 6738c2ecf20Sopenharmony_ci uint16_t maxFreq; 6748c2ecf20Sopenharmony_ci 6758c2ecf20Sopenharmony_ci uint8_t setting; 6768c2ecf20Sopenharmony_ci uint8_t padding[3]; 6778c2ecf20Sopenharmony_ci}; 6788c2ecf20Sopenharmony_citypedef struct SMU_CKS_LOOKUPTableEntry SMU_CKS_LOOKUPTableEntry; 6798c2ecf20Sopenharmony_ci 6808c2ecf20Sopenharmony_cistruct SMU_CKS_LOOKUPTable { 6818c2ecf20Sopenharmony_ci SMU_CKS_LOOKUPTableEntry CKS_LOOKUPTableEntry[CKS_LOOKUPTable_MAX_ENTRIES]; 6828c2ecf20Sopenharmony_ci}; 6838c2ecf20Sopenharmony_citypedef struct SMU_CKS_LOOKUPTable SMU_CKS_LOOKUPTable; 6848c2ecf20Sopenharmony_ci 6858c2ecf20Sopenharmony_ci#endif 6868c2ecf20Sopenharmony_ci 6878c2ecf20Sopenharmony_ci 688