18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright 2013 Advanced Micro Devices, Inc.
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
58c2ecf20Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
68c2ecf20Sopenharmony_ci * to deal in the Software without restriction, including without limitation
78c2ecf20Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
88c2ecf20Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
98c2ecf20Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
108c2ecf20Sopenharmony_ci *
118c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice shall be included in
128c2ecf20Sopenharmony_ci * all copies or substantial portions of the Software.
138c2ecf20Sopenharmony_ci *
148c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
158c2ecf20Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
168c2ecf20Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
178c2ecf20Sopenharmony_ci * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
188c2ecf20Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
198c2ecf20Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
208c2ecf20Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE.
218c2ecf20Sopenharmony_ci *
228c2ecf20Sopenharmony_ci */
238c2ecf20Sopenharmony_ci#ifndef PP_SISLANDS_SMC_H
248c2ecf20Sopenharmony_ci#define PP_SISLANDS_SMC_H
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci#include "ppsmc.h"
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci#pragma pack(push, 1)
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci#define SISLANDS_MAX_SMC_PERFORMANCE_LEVELS_PER_SWSTATE 16
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_cistruct PP_SIslands_Dpm2PerfLevel
338c2ecf20Sopenharmony_ci{
348c2ecf20Sopenharmony_ci    uint8_t MaxPS;
358c2ecf20Sopenharmony_ci    uint8_t TgtAct;
368c2ecf20Sopenharmony_ci    uint8_t MaxPS_StepInc;
378c2ecf20Sopenharmony_ci    uint8_t MaxPS_StepDec;
388c2ecf20Sopenharmony_ci    uint8_t PSSamplingTime;
398c2ecf20Sopenharmony_ci    uint8_t NearTDPDec;
408c2ecf20Sopenharmony_ci    uint8_t AboveSafeInc;
418c2ecf20Sopenharmony_ci    uint8_t BelowSafeInc;
428c2ecf20Sopenharmony_ci    uint8_t PSDeltaLimit;
438c2ecf20Sopenharmony_ci    uint8_t PSDeltaWin;
448c2ecf20Sopenharmony_ci    uint16_t PwrEfficiencyRatio;
458c2ecf20Sopenharmony_ci    uint8_t Reserved[4];
468c2ecf20Sopenharmony_ci};
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_citypedef struct PP_SIslands_Dpm2PerfLevel PP_SIslands_Dpm2PerfLevel;
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_cistruct PP_SIslands_DPM2Status
518c2ecf20Sopenharmony_ci{
528c2ecf20Sopenharmony_ci    uint32_t    dpm2Flags;
538c2ecf20Sopenharmony_ci    uint8_t     CurrPSkip;
548c2ecf20Sopenharmony_ci    uint8_t     CurrPSkipPowerShift;
558c2ecf20Sopenharmony_ci    uint8_t     CurrPSkipTDP;
568c2ecf20Sopenharmony_ci    uint8_t     CurrPSkipOCP;
578c2ecf20Sopenharmony_ci    uint8_t     MaxSPLLIndex;
588c2ecf20Sopenharmony_ci    uint8_t     MinSPLLIndex;
598c2ecf20Sopenharmony_ci    uint8_t     CurrSPLLIndex;
608c2ecf20Sopenharmony_ci    uint8_t     InfSweepMode;
618c2ecf20Sopenharmony_ci    uint8_t     InfSweepDir;
628c2ecf20Sopenharmony_ci    uint8_t     TDPexceeded;
638c2ecf20Sopenharmony_ci    uint8_t     reserved;
648c2ecf20Sopenharmony_ci    uint8_t     SwitchDownThreshold;
658c2ecf20Sopenharmony_ci    uint32_t    SwitchDownCounter;
668c2ecf20Sopenharmony_ci    uint32_t    SysScalingFactor;
678c2ecf20Sopenharmony_ci};
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_citypedef struct PP_SIslands_DPM2Status PP_SIslands_DPM2Status;
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_cistruct PP_SIslands_DPM2Parameters
728c2ecf20Sopenharmony_ci{
738c2ecf20Sopenharmony_ci    uint32_t    TDPLimit;
748c2ecf20Sopenharmony_ci    uint32_t    NearTDPLimit;
758c2ecf20Sopenharmony_ci    uint32_t    SafePowerLimit;
768c2ecf20Sopenharmony_ci    uint32_t    PowerBoostLimit;
778c2ecf20Sopenharmony_ci    uint32_t    MinLimitDelta;
788c2ecf20Sopenharmony_ci};
798c2ecf20Sopenharmony_citypedef struct PP_SIslands_DPM2Parameters PP_SIslands_DPM2Parameters;
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_cistruct PP_SIslands_PAPMStatus
828c2ecf20Sopenharmony_ci{
838c2ecf20Sopenharmony_ci    uint32_t    EstimatedDGPU_T;
848c2ecf20Sopenharmony_ci    uint32_t    EstimatedDGPU_P;
858c2ecf20Sopenharmony_ci    uint32_t    EstimatedAPU_T;
868c2ecf20Sopenharmony_ci    uint32_t    EstimatedAPU_P;
878c2ecf20Sopenharmony_ci    uint8_t     dGPU_T_Limit_Exceeded;
888c2ecf20Sopenharmony_ci    uint8_t     reserved[3];
898c2ecf20Sopenharmony_ci};
908c2ecf20Sopenharmony_citypedef struct PP_SIslands_PAPMStatus PP_SIslands_PAPMStatus;
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_cistruct PP_SIslands_PAPMParameters
938c2ecf20Sopenharmony_ci{
948c2ecf20Sopenharmony_ci    uint32_t    NearTDPLimitTherm;
958c2ecf20Sopenharmony_ci    uint32_t    NearTDPLimitPAPM;
968c2ecf20Sopenharmony_ci    uint32_t    PlatformPowerLimit;
978c2ecf20Sopenharmony_ci    uint32_t    dGPU_T_Limit;
988c2ecf20Sopenharmony_ci    uint32_t    dGPU_T_Warning;
998c2ecf20Sopenharmony_ci    uint32_t    dGPU_T_Hysteresis;
1008c2ecf20Sopenharmony_ci};
1018c2ecf20Sopenharmony_citypedef struct PP_SIslands_PAPMParameters PP_SIslands_PAPMParameters;
1028c2ecf20Sopenharmony_ci
1038c2ecf20Sopenharmony_cistruct SISLANDS_SMC_SCLK_VALUE
1048c2ecf20Sopenharmony_ci{
1058c2ecf20Sopenharmony_ci    uint32_t    vCG_SPLL_FUNC_CNTL;
1068c2ecf20Sopenharmony_ci    uint32_t    vCG_SPLL_FUNC_CNTL_2;
1078c2ecf20Sopenharmony_ci    uint32_t    vCG_SPLL_FUNC_CNTL_3;
1088c2ecf20Sopenharmony_ci    uint32_t    vCG_SPLL_FUNC_CNTL_4;
1098c2ecf20Sopenharmony_ci    uint32_t    vCG_SPLL_SPREAD_SPECTRUM;
1108c2ecf20Sopenharmony_ci    uint32_t    vCG_SPLL_SPREAD_SPECTRUM_2;
1118c2ecf20Sopenharmony_ci    uint32_t    sclk_value;
1128c2ecf20Sopenharmony_ci};
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_citypedef struct SISLANDS_SMC_SCLK_VALUE SISLANDS_SMC_SCLK_VALUE;
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_cistruct SISLANDS_SMC_MCLK_VALUE
1178c2ecf20Sopenharmony_ci{
1188c2ecf20Sopenharmony_ci    uint32_t    vMPLL_FUNC_CNTL;
1198c2ecf20Sopenharmony_ci    uint32_t    vMPLL_FUNC_CNTL_1;
1208c2ecf20Sopenharmony_ci    uint32_t    vMPLL_FUNC_CNTL_2;
1218c2ecf20Sopenharmony_ci    uint32_t    vMPLL_AD_FUNC_CNTL;
1228c2ecf20Sopenharmony_ci    uint32_t    vMPLL_DQ_FUNC_CNTL;
1238c2ecf20Sopenharmony_ci    uint32_t    vMCLK_PWRMGT_CNTL;
1248c2ecf20Sopenharmony_ci    uint32_t    vDLL_CNTL;
1258c2ecf20Sopenharmony_ci    uint32_t    vMPLL_SS;
1268c2ecf20Sopenharmony_ci    uint32_t    vMPLL_SS2;
1278c2ecf20Sopenharmony_ci    uint32_t    mclk_value;
1288c2ecf20Sopenharmony_ci};
1298c2ecf20Sopenharmony_ci
1308c2ecf20Sopenharmony_citypedef struct SISLANDS_SMC_MCLK_VALUE SISLANDS_SMC_MCLK_VALUE;
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_cistruct SISLANDS_SMC_VOLTAGE_VALUE
1338c2ecf20Sopenharmony_ci{
1348c2ecf20Sopenharmony_ci    uint16_t    value;
1358c2ecf20Sopenharmony_ci    uint8_t     index;
1368c2ecf20Sopenharmony_ci    uint8_t     phase_settings;
1378c2ecf20Sopenharmony_ci};
1388c2ecf20Sopenharmony_ci
1398c2ecf20Sopenharmony_citypedef struct SISLANDS_SMC_VOLTAGE_VALUE SISLANDS_SMC_VOLTAGE_VALUE;
1408c2ecf20Sopenharmony_ci
1418c2ecf20Sopenharmony_cistruct SISLANDS_SMC_HW_PERFORMANCE_LEVEL
1428c2ecf20Sopenharmony_ci{
1438c2ecf20Sopenharmony_ci    uint8_t                     ACIndex;
1448c2ecf20Sopenharmony_ci    uint8_t                     displayWatermark;
1458c2ecf20Sopenharmony_ci    uint8_t                     gen2PCIE;
1468c2ecf20Sopenharmony_ci    uint8_t                     UVDWatermark;
1478c2ecf20Sopenharmony_ci    uint8_t                     VCEWatermark;
1488c2ecf20Sopenharmony_ci    uint8_t                     strobeMode;
1498c2ecf20Sopenharmony_ci    uint8_t                     mcFlags;
1508c2ecf20Sopenharmony_ci    uint8_t                     padding;
1518c2ecf20Sopenharmony_ci    uint32_t                    aT;
1528c2ecf20Sopenharmony_ci    uint32_t                    bSP;
1538c2ecf20Sopenharmony_ci    SISLANDS_SMC_SCLK_VALUE     sclk;
1548c2ecf20Sopenharmony_ci    SISLANDS_SMC_MCLK_VALUE     mclk;
1558c2ecf20Sopenharmony_ci    SISLANDS_SMC_VOLTAGE_VALUE  vddc;
1568c2ecf20Sopenharmony_ci    SISLANDS_SMC_VOLTAGE_VALUE  mvdd;
1578c2ecf20Sopenharmony_ci    SISLANDS_SMC_VOLTAGE_VALUE  vddci;
1588c2ecf20Sopenharmony_ci    SISLANDS_SMC_VOLTAGE_VALUE  std_vddc;
1598c2ecf20Sopenharmony_ci    uint8_t                     hysteresisUp;
1608c2ecf20Sopenharmony_ci    uint8_t                     hysteresisDown;
1618c2ecf20Sopenharmony_ci    uint8_t                     stateFlags;
1628c2ecf20Sopenharmony_ci    uint8_t                     arbRefreshState;
1638c2ecf20Sopenharmony_ci    uint32_t                    SQPowerThrottle;
1648c2ecf20Sopenharmony_ci    uint32_t                    SQPowerThrottle_2;
1658c2ecf20Sopenharmony_ci    uint32_t                    MaxPoweredUpCU;
1668c2ecf20Sopenharmony_ci    SISLANDS_SMC_VOLTAGE_VALUE  high_temp_vddc;
1678c2ecf20Sopenharmony_ci    SISLANDS_SMC_VOLTAGE_VALUE  low_temp_vddc;
1688c2ecf20Sopenharmony_ci    uint32_t                    reserved[2];
1698c2ecf20Sopenharmony_ci    PP_SIslands_Dpm2PerfLevel   dpm2;
1708c2ecf20Sopenharmony_ci};
1718c2ecf20Sopenharmony_ci
1728c2ecf20Sopenharmony_ci#define SISLANDS_SMC_STROBE_RATIO    0x0F
1738c2ecf20Sopenharmony_ci#define SISLANDS_SMC_STROBE_ENABLE   0x10
1748c2ecf20Sopenharmony_ci
1758c2ecf20Sopenharmony_ci#define SISLANDS_SMC_MC_EDC_RD_FLAG  0x01
1768c2ecf20Sopenharmony_ci#define SISLANDS_SMC_MC_EDC_WR_FLAG  0x02
1778c2ecf20Sopenharmony_ci#define SISLANDS_SMC_MC_RTT_ENABLE   0x04
1788c2ecf20Sopenharmony_ci#define SISLANDS_SMC_MC_STUTTER_EN   0x08
1798c2ecf20Sopenharmony_ci#define SISLANDS_SMC_MC_PG_EN        0x10
1808c2ecf20Sopenharmony_ci
1818c2ecf20Sopenharmony_citypedef struct SISLANDS_SMC_HW_PERFORMANCE_LEVEL SISLANDS_SMC_HW_PERFORMANCE_LEVEL;
1828c2ecf20Sopenharmony_ci
1838c2ecf20Sopenharmony_cistruct SISLANDS_SMC_SWSTATE
1848c2ecf20Sopenharmony_ci{
1858c2ecf20Sopenharmony_ci    uint8_t                             flags;
1868c2ecf20Sopenharmony_ci    uint8_t                             levelCount;
1878c2ecf20Sopenharmony_ci    uint8_t                             padding2;
1888c2ecf20Sopenharmony_ci    uint8_t                             padding3;
1898c2ecf20Sopenharmony_ci    SISLANDS_SMC_HW_PERFORMANCE_LEVEL   levels[1];
1908c2ecf20Sopenharmony_ci};
1918c2ecf20Sopenharmony_ci
1928c2ecf20Sopenharmony_citypedef struct SISLANDS_SMC_SWSTATE SISLANDS_SMC_SWSTATE;
1938c2ecf20Sopenharmony_ci
1948c2ecf20Sopenharmony_ci#define SISLANDS_SMC_VOLTAGEMASK_VDDC  0
1958c2ecf20Sopenharmony_ci#define SISLANDS_SMC_VOLTAGEMASK_MVDD  1
1968c2ecf20Sopenharmony_ci#define SISLANDS_SMC_VOLTAGEMASK_VDDCI 2
1978c2ecf20Sopenharmony_ci#define SISLANDS_SMC_VOLTAGEMASK_VDDC_PHASE_SHEDDING 3
1988c2ecf20Sopenharmony_ci#define SISLANDS_SMC_VOLTAGEMASK_MAX   4
1998c2ecf20Sopenharmony_ci
2008c2ecf20Sopenharmony_cistruct SISLANDS_SMC_VOLTAGEMASKTABLE
2018c2ecf20Sopenharmony_ci{
2028c2ecf20Sopenharmony_ci    uint32_t lowMask[SISLANDS_SMC_VOLTAGEMASK_MAX];
2038c2ecf20Sopenharmony_ci};
2048c2ecf20Sopenharmony_ci
2058c2ecf20Sopenharmony_citypedef struct SISLANDS_SMC_VOLTAGEMASKTABLE SISLANDS_SMC_VOLTAGEMASKTABLE;
2068c2ecf20Sopenharmony_ci
2078c2ecf20Sopenharmony_ci#define SISLANDS_MAX_NO_VREG_STEPS 32
2088c2ecf20Sopenharmony_ci
2098c2ecf20Sopenharmony_cistruct SISLANDS_SMC_STATETABLE
2108c2ecf20Sopenharmony_ci{
2118c2ecf20Sopenharmony_ci    uint8_t                             thermalProtectType;
2128c2ecf20Sopenharmony_ci    uint8_t                             systemFlags;
2138c2ecf20Sopenharmony_ci    uint8_t                             maxVDDCIndexInPPTable;
2148c2ecf20Sopenharmony_ci    uint8_t                             extraFlags;
2158c2ecf20Sopenharmony_ci    uint32_t                            lowSMIO[SISLANDS_MAX_NO_VREG_STEPS];
2168c2ecf20Sopenharmony_ci    SISLANDS_SMC_VOLTAGEMASKTABLE       voltageMaskTable;
2178c2ecf20Sopenharmony_ci    SISLANDS_SMC_VOLTAGEMASKTABLE       phaseMaskTable;
2188c2ecf20Sopenharmony_ci    PP_SIslands_DPM2Parameters          dpm2Params;
2198c2ecf20Sopenharmony_ci    SISLANDS_SMC_SWSTATE                initialState;
2208c2ecf20Sopenharmony_ci    SISLANDS_SMC_SWSTATE                ACPIState;
2218c2ecf20Sopenharmony_ci    SISLANDS_SMC_SWSTATE                ULVState;
2228c2ecf20Sopenharmony_ci    SISLANDS_SMC_SWSTATE                driverState;
2238c2ecf20Sopenharmony_ci    SISLANDS_SMC_HW_PERFORMANCE_LEVEL   dpmLevels[SISLANDS_MAX_SMC_PERFORMANCE_LEVELS_PER_SWSTATE - 1];
2248c2ecf20Sopenharmony_ci};
2258c2ecf20Sopenharmony_ci
2268c2ecf20Sopenharmony_citypedef struct SISLANDS_SMC_STATETABLE SISLANDS_SMC_STATETABLE;
2278c2ecf20Sopenharmony_ci
2288c2ecf20Sopenharmony_ci#define SI_SMC_SOFT_REGISTER_mclk_chg_timeout         0x0
2298c2ecf20Sopenharmony_ci#define SI_SMC_SOFT_REGISTER_delay_vreg               0xC
2308c2ecf20Sopenharmony_ci#define SI_SMC_SOFT_REGISTER_delay_acpi               0x28
2318c2ecf20Sopenharmony_ci#define SI_SMC_SOFT_REGISTER_seq_index                0x5C
2328c2ecf20Sopenharmony_ci#define SI_SMC_SOFT_REGISTER_mvdd_chg_time            0x60
2338c2ecf20Sopenharmony_ci#define SI_SMC_SOFT_REGISTER_mclk_switch_lim          0x70
2348c2ecf20Sopenharmony_ci#define SI_SMC_SOFT_REGISTER_watermark_threshold      0x78
2358c2ecf20Sopenharmony_ci#define SI_SMC_SOFT_REGISTER_phase_shedding_delay     0x88
2368c2ecf20Sopenharmony_ci#define SI_SMC_SOFT_REGISTER_ulv_volt_change_delay    0x8C
2378c2ecf20Sopenharmony_ci#define SI_SMC_SOFT_REGISTER_mc_block_delay           0x98
2388c2ecf20Sopenharmony_ci#define SI_SMC_SOFT_REGISTER_ticks_per_us             0xA8
2398c2ecf20Sopenharmony_ci#define SI_SMC_SOFT_REGISTER_crtc_index               0xC4
2408c2ecf20Sopenharmony_ci#define SI_SMC_SOFT_REGISTER_mclk_change_block_cp_min 0xC8
2418c2ecf20Sopenharmony_ci#define SI_SMC_SOFT_REGISTER_mclk_change_block_cp_max 0xCC
2428c2ecf20Sopenharmony_ci#define SI_SMC_SOFT_REGISTER_non_ulv_pcie_link_width  0xF4
2438c2ecf20Sopenharmony_ci#define SI_SMC_SOFT_REGISTER_tdr_is_about_to_happen   0xFC
2448c2ecf20Sopenharmony_ci#define SI_SMC_SOFT_REGISTER_vr_hot_gpio              0x100
2458c2ecf20Sopenharmony_ci#define SI_SMC_SOFT_REGISTER_svi_rework_plat_type     0x118
2468c2ecf20Sopenharmony_ci#define SI_SMC_SOFT_REGISTER_svi_rework_gpio_id_svd   0x11c
2478c2ecf20Sopenharmony_ci#define SI_SMC_SOFT_REGISTER_svi_rework_gpio_id_svc   0x120
2488c2ecf20Sopenharmony_ci
2498c2ecf20Sopenharmony_cistruct PP_SIslands_FanTable
2508c2ecf20Sopenharmony_ci{
2518c2ecf20Sopenharmony_ci	uint8_t  fdo_mode;
2528c2ecf20Sopenharmony_ci	uint8_t  padding;
2538c2ecf20Sopenharmony_ci	int16_t  temp_min;
2548c2ecf20Sopenharmony_ci	int16_t  temp_med;
2558c2ecf20Sopenharmony_ci	int16_t  temp_max;
2568c2ecf20Sopenharmony_ci	int16_t  slope1;
2578c2ecf20Sopenharmony_ci	int16_t  slope2;
2588c2ecf20Sopenharmony_ci	int16_t  fdo_min;
2598c2ecf20Sopenharmony_ci	int16_t  hys_up;
2608c2ecf20Sopenharmony_ci	int16_t  hys_down;
2618c2ecf20Sopenharmony_ci	int16_t  hys_slope;
2628c2ecf20Sopenharmony_ci	int16_t  temp_resp_lim;
2638c2ecf20Sopenharmony_ci	int16_t  temp_curr;
2648c2ecf20Sopenharmony_ci	int16_t  slope_curr;
2658c2ecf20Sopenharmony_ci	int16_t  pwm_curr;
2668c2ecf20Sopenharmony_ci	uint32_t refresh_period;
2678c2ecf20Sopenharmony_ci	int16_t  fdo_max;
2688c2ecf20Sopenharmony_ci	uint8_t  temp_src;
2698c2ecf20Sopenharmony_ci	int8_t  padding2;
2708c2ecf20Sopenharmony_ci};
2718c2ecf20Sopenharmony_ci
2728c2ecf20Sopenharmony_citypedef struct PP_SIslands_FanTable PP_SIslands_FanTable;
2738c2ecf20Sopenharmony_ci
2748c2ecf20Sopenharmony_ci#define SMC_SISLANDS_LKGE_LUT_NUM_OF_TEMP_ENTRIES 16
2758c2ecf20Sopenharmony_ci#define SMC_SISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES 32
2768c2ecf20Sopenharmony_ci
2778c2ecf20Sopenharmony_ci#define SMC_SISLANDS_SCALE_I  7
2788c2ecf20Sopenharmony_ci#define SMC_SISLANDS_SCALE_R 12
2798c2ecf20Sopenharmony_ci
2808c2ecf20Sopenharmony_cistruct PP_SIslands_CacConfig
2818c2ecf20Sopenharmony_ci{
2828c2ecf20Sopenharmony_ci    uint16_t   cac_lkge_lut[SMC_SISLANDS_LKGE_LUT_NUM_OF_TEMP_ENTRIES][SMC_SISLANDS_LKGE_LUT_NUM_OF_VOLT_ENTRIES];
2838c2ecf20Sopenharmony_ci    uint32_t   lkge_lut_V0;
2848c2ecf20Sopenharmony_ci    uint32_t   lkge_lut_Vstep;
2858c2ecf20Sopenharmony_ci    uint32_t   WinTime;
2868c2ecf20Sopenharmony_ci    uint32_t   R_LL;
2878c2ecf20Sopenharmony_ci    uint32_t   calculation_repeats;
2888c2ecf20Sopenharmony_ci    uint32_t   l2numWin_TDP;
2898c2ecf20Sopenharmony_ci    uint32_t   dc_cac;
2908c2ecf20Sopenharmony_ci    uint8_t    lts_truncate_n;
2918c2ecf20Sopenharmony_ci    uint8_t    SHIFT_N;
2928c2ecf20Sopenharmony_ci    uint8_t    log2_PG_LKG_SCALE;
2938c2ecf20Sopenharmony_ci    uint8_t    cac_temp;
2948c2ecf20Sopenharmony_ci    uint32_t   lkge_lut_T0;
2958c2ecf20Sopenharmony_ci    uint32_t   lkge_lut_Tstep;
2968c2ecf20Sopenharmony_ci};
2978c2ecf20Sopenharmony_ci
2988c2ecf20Sopenharmony_citypedef struct PP_SIslands_CacConfig PP_SIslands_CacConfig;
2998c2ecf20Sopenharmony_ci
3008c2ecf20Sopenharmony_ci#define SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE 16
3018c2ecf20Sopenharmony_ci#define SMC_SISLANDS_MC_REGISTER_ARRAY_SET_COUNT 20
3028c2ecf20Sopenharmony_ci
3038c2ecf20Sopenharmony_cistruct SMC_SIslands_MCRegisterAddress
3048c2ecf20Sopenharmony_ci{
3058c2ecf20Sopenharmony_ci    uint16_t s0;
3068c2ecf20Sopenharmony_ci    uint16_t s1;
3078c2ecf20Sopenharmony_ci};
3088c2ecf20Sopenharmony_ci
3098c2ecf20Sopenharmony_citypedef struct SMC_SIslands_MCRegisterAddress SMC_SIslands_MCRegisterAddress;
3108c2ecf20Sopenharmony_ci
3118c2ecf20Sopenharmony_cistruct SMC_SIslands_MCRegisterSet
3128c2ecf20Sopenharmony_ci{
3138c2ecf20Sopenharmony_ci    uint32_t value[SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE];
3148c2ecf20Sopenharmony_ci};
3158c2ecf20Sopenharmony_ci
3168c2ecf20Sopenharmony_citypedef struct SMC_SIslands_MCRegisterSet SMC_SIslands_MCRegisterSet;
3178c2ecf20Sopenharmony_ci
3188c2ecf20Sopenharmony_cistruct SMC_SIslands_MCRegisters
3198c2ecf20Sopenharmony_ci{
3208c2ecf20Sopenharmony_ci    uint8_t                             last;
3218c2ecf20Sopenharmony_ci    uint8_t                             reserved[3];
3228c2ecf20Sopenharmony_ci    SMC_SIslands_MCRegisterAddress      address[SMC_SISLANDS_MC_REGISTER_ARRAY_SIZE];
3238c2ecf20Sopenharmony_ci    SMC_SIslands_MCRegisterSet          data[SMC_SISLANDS_MC_REGISTER_ARRAY_SET_COUNT];
3248c2ecf20Sopenharmony_ci};
3258c2ecf20Sopenharmony_ci
3268c2ecf20Sopenharmony_citypedef struct SMC_SIslands_MCRegisters SMC_SIslands_MCRegisters;
3278c2ecf20Sopenharmony_ci
3288c2ecf20Sopenharmony_cistruct SMC_SIslands_MCArbDramTimingRegisterSet
3298c2ecf20Sopenharmony_ci{
3308c2ecf20Sopenharmony_ci    uint32_t mc_arb_dram_timing;
3318c2ecf20Sopenharmony_ci    uint32_t mc_arb_dram_timing2;
3328c2ecf20Sopenharmony_ci    uint8_t  mc_arb_rfsh_rate;
3338c2ecf20Sopenharmony_ci    uint8_t  mc_arb_burst_time;
3348c2ecf20Sopenharmony_ci    uint8_t  padding[2];
3358c2ecf20Sopenharmony_ci};
3368c2ecf20Sopenharmony_ci
3378c2ecf20Sopenharmony_citypedef struct SMC_SIslands_MCArbDramTimingRegisterSet SMC_SIslands_MCArbDramTimingRegisterSet;
3388c2ecf20Sopenharmony_ci
3398c2ecf20Sopenharmony_cistruct SMC_SIslands_MCArbDramTimingRegisters
3408c2ecf20Sopenharmony_ci{
3418c2ecf20Sopenharmony_ci    uint8_t                                     arb_current;
3428c2ecf20Sopenharmony_ci    uint8_t                                     reserved[3];
3438c2ecf20Sopenharmony_ci    SMC_SIslands_MCArbDramTimingRegisterSet     data[16];
3448c2ecf20Sopenharmony_ci};
3458c2ecf20Sopenharmony_ci
3468c2ecf20Sopenharmony_citypedef struct SMC_SIslands_MCArbDramTimingRegisters SMC_SIslands_MCArbDramTimingRegisters;
3478c2ecf20Sopenharmony_ci
3488c2ecf20Sopenharmony_cistruct SMC_SISLANDS_SPLL_DIV_TABLE
3498c2ecf20Sopenharmony_ci{
3508c2ecf20Sopenharmony_ci    uint32_t    freq[256];
3518c2ecf20Sopenharmony_ci    uint32_t    ss[256];
3528c2ecf20Sopenharmony_ci};
3538c2ecf20Sopenharmony_ci
3548c2ecf20Sopenharmony_ci#define SMC_SISLANDS_SPLL_DIV_TABLE_FBDIV_MASK  0x01ffffff
3558c2ecf20Sopenharmony_ci#define SMC_SISLANDS_SPLL_DIV_TABLE_FBDIV_SHIFT 0
3568c2ecf20Sopenharmony_ci#define SMC_SISLANDS_SPLL_DIV_TABLE_PDIV_MASK   0xfe000000
3578c2ecf20Sopenharmony_ci#define SMC_SISLANDS_SPLL_DIV_TABLE_PDIV_SHIFT  25
3588c2ecf20Sopenharmony_ci#define SMC_SISLANDS_SPLL_DIV_TABLE_CLKV_MASK   0x000fffff
3598c2ecf20Sopenharmony_ci#define SMC_SISLANDS_SPLL_DIV_TABLE_CLKV_SHIFT  0
3608c2ecf20Sopenharmony_ci#define SMC_SISLANDS_SPLL_DIV_TABLE_CLKS_MASK   0xfff00000
3618c2ecf20Sopenharmony_ci#define SMC_SISLANDS_SPLL_DIV_TABLE_CLKS_SHIFT  20
3628c2ecf20Sopenharmony_ci
3638c2ecf20Sopenharmony_citypedef struct SMC_SISLANDS_SPLL_DIV_TABLE SMC_SISLANDS_SPLL_DIV_TABLE;
3648c2ecf20Sopenharmony_ci
3658c2ecf20Sopenharmony_ci#define SMC_SISLANDS_DTE_MAX_FILTER_STAGES 5
3668c2ecf20Sopenharmony_ci
3678c2ecf20Sopenharmony_ci#define SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE 16
3688c2ecf20Sopenharmony_ci
3698c2ecf20Sopenharmony_cistruct Smc_SIslands_DTE_Configuration
3708c2ecf20Sopenharmony_ci{
3718c2ecf20Sopenharmony_ci    uint32_t tau[SMC_SISLANDS_DTE_MAX_FILTER_STAGES];
3728c2ecf20Sopenharmony_ci    uint32_t R[SMC_SISLANDS_DTE_MAX_FILTER_STAGES];
3738c2ecf20Sopenharmony_ci    uint32_t K;
3748c2ecf20Sopenharmony_ci    uint32_t T0;
3758c2ecf20Sopenharmony_ci    uint32_t MaxT;
3768c2ecf20Sopenharmony_ci    uint8_t  WindowSize;
3778c2ecf20Sopenharmony_ci    uint8_t  Tdep_count;
3788c2ecf20Sopenharmony_ci    uint8_t  temp_select;
3798c2ecf20Sopenharmony_ci    uint8_t  DTE_mode;
3808c2ecf20Sopenharmony_ci    uint8_t  T_limits[SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE];
3818c2ecf20Sopenharmony_ci    uint32_t Tdep_tau[SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE];
3828c2ecf20Sopenharmony_ci    uint32_t Tdep_R[SMC_SISLANDS_DTE_MAX_TEMPERATURE_DEPENDENT_ARRAY_SIZE];
3838c2ecf20Sopenharmony_ci    uint32_t Tthreshold;
3848c2ecf20Sopenharmony_ci};
3858c2ecf20Sopenharmony_ci
3868c2ecf20Sopenharmony_citypedef struct Smc_SIslands_DTE_Configuration Smc_SIslands_DTE_Configuration;
3878c2ecf20Sopenharmony_ci
3888c2ecf20Sopenharmony_ci#define SMC_SISLANDS_DTE_STATUS_FLAG_DTE_ON 1
3898c2ecf20Sopenharmony_ci
3908c2ecf20Sopenharmony_ci#define SISLANDS_SMC_FIRMWARE_HEADER_LOCATION 0x10000
3918c2ecf20Sopenharmony_ci
3928c2ecf20Sopenharmony_ci#define SISLANDS_SMC_FIRMWARE_HEADER_version                   0x0
3938c2ecf20Sopenharmony_ci#define SISLANDS_SMC_FIRMWARE_HEADER_flags                     0x4
3948c2ecf20Sopenharmony_ci#define SISLANDS_SMC_FIRMWARE_HEADER_softRegisters             0xC
3958c2ecf20Sopenharmony_ci#define SISLANDS_SMC_FIRMWARE_HEADER_stateTable                0x10
3968c2ecf20Sopenharmony_ci#define SISLANDS_SMC_FIRMWARE_HEADER_fanTable                  0x14
3978c2ecf20Sopenharmony_ci#define SISLANDS_SMC_FIRMWARE_HEADER_CacConfigTable            0x18
3988c2ecf20Sopenharmony_ci#define SISLANDS_SMC_FIRMWARE_HEADER_mcRegisterTable           0x24
3998c2ecf20Sopenharmony_ci#define SISLANDS_SMC_FIRMWARE_HEADER_mcArbDramAutoRefreshTable 0x30
4008c2ecf20Sopenharmony_ci#define SISLANDS_SMC_FIRMWARE_HEADER_spllTable                 0x38
4018c2ecf20Sopenharmony_ci#define SISLANDS_SMC_FIRMWARE_HEADER_DteConfiguration          0x40
4028c2ecf20Sopenharmony_ci#define SISLANDS_SMC_FIRMWARE_HEADER_PAPMParameters            0x48
4038c2ecf20Sopenharmony_ci
4048c2ecf20Sopenharmony_ci#pragma pack(pop)
4058c2ecf20Sopenharmony_ci
4068c2ecf20Sopenharmony_ciint si_copy_bytes_to_smc(struct radeon_device *rdev,
4078c2ecf20Sopenharmony_ci			 u32 smc_start_address,
4088c2ecf20Sopenharmony_ci			 const u8 *src, u32 byte_count, u32 limit);
4098c2ecf20Sopenharmony_civoid si_start_smc(struct radeon_device *rdev);
4108c2ecf20Sopenharmony_civoid si_reset_smc(struct radeon_device *rdev);
4118c2ecf20Sopenharmony_ciint si_program_jump_on_start(struct radeon_device *rdev);
4128c2ecf20Sopenharmony_civoid si_stop_smc_clock(struct radeon_device *rdev);
4138c2ecf20Sopenharmony_civoid si_start_smc_clock(struct radeon_device *rdev);
4148c2ecf20Sopenharmony_cibool si_is_smc_running(struct radeon_device *rdev);
4158c2ecf20Sopenharmony_ciPPSMC_Result si_send_msg_to_smc(struct radeon_device *rdev, PPSMC_Msg msg);
4168c2ecf20Sopenharmony_ciPPSMC_Result si_wait_for_smc_inactive(struct radeon_device *rdev);
4178c2ecf20Sopenharmony_ciint si_load_smc_ucode(struct radeon_device *rdev, u32 limit);
4188c2ecf20Sopenharmony_ciint si_read_smc_sram_dword(struct radeon_device *rdev, u32 smc_address,
4198c2ecf20Sopenharmony_ci			   u32 *value, u32 limit);
4208c2ecf20Sopenharmony_ciint si_write_smc_sram_dword(struct radeon_device *rdev, u32 smc_address,
4218c2ecf20Sopenharmony_ci			    u32 value, u32 limit);
4228c2ecf20Sopenharmony_ci
4238c2ecf20Sopenharmony_ci#endif
4248c2ecf20Sopenharmony_ci
425