15fc3aeebSyanyang1 /* 25fc3aeebSyanyang1 * Copyright 2015 Advanced Micro Devices, Inc. 35fc3aeebSyanyang1 * 45fc3aeebSyanyang1 * Permission is hereby granted, free of charge, to any person obtaining a 55fc3aeebSyanyang1 * copy of this software and associated documentation files (the "Software"), 65fc3aeebSyanyang1 * to deal in the Software without restriction, including without limitation 75fc3aeebSyanyang1 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 85fc3aeebSyanyang1 * and/or sell copies of the Software, and to permit persons to whom the 95fc3aeebSyanyang1 * Software is furnished to do so, subject to the following conditions: 105fc3aeebSyanyang1 * 115fc3aeebSyanyang1 * The above copyright notice and this permission notice shall be included in 125fc3aeebSyanyang1 * all copies or substantial portions of the Software. 135fc3aeebSyanyang1 * 145fc3aeebSyanyang1 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 155fc3aeebSyanyang1 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 165fc3aeebSyanyang1 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 175fc3aeebSyanyang1 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 185fc3aeebSyanyang1 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 195fc3aeebSyanyang1 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 205fc3aeebSyanyang1 * OTHER DEALINGS IN THE SOFTWARE. 215fc3aeebSyanyang1 */ 225fc3aeebSyanyang1 235fc3aeebSyanyang1 #ifndef __AMD_SHARED_H__ 245fc3aeebSyanyang1 #define __AMD_SHARED_H__ 255fc3aeebSyanyang1 26f674bd28SAkshu Agrawal #include <drm/amd_asic_type.h> 270b2daf09SJammy Zhou 28cfa289fdSRex Zhu 29617a64dcSEvan Quan #define AMD_MAX_USEC_TIMEOUT 1000000 /* 1000 ms */ 302f7d10b3SJammy Zhou 312f7d10b3SJammy Zhou /* 322f7d10b3SJammy Zhou * Chip flags 332f7d10b3SJammy Zhou */ 342f7d10b3SJammy Zhou enum amd_chip_flags { 352f7d10b3SJammy Zhou AMD_ASIC_MASK = 0x0000ffffUL, 362f7d10b3SJammy Zhou AMD_FLAGS_MASK = 0xffff0000UL, 372f7d10b3SJammy Zhou AMD_IS_MOBILITY = 0x00010000UL, 382f7d10b3SJammy Zhou AMD_IS_APU = 0x00020000UL, 392f7d10b3SJammy Zhou AMD_IS_PX = 0x00040000UL, 402f7d10b3SJammy Zhou AMD_EXP_HW_SUPPORT = 0x00080000UL, 412f7d10b3SJammy Zhou }; 422f7d10b3SJammy Zhou 435fc3aeebSyanyang1 enum amd_ip_block_type { 445fc3aeebSyanyang1 AMD_IP_BLOCK_TYPE_COMMON, 455fc3aeebSyanyang1 AMD_IP_BLOCK_TYPE_GMC, 465fc3aeebSyanyang1 AMD_IP_BLOCK_TYPE_IH, 475fc3aeebSyanyang1 AMD_IP_BLOCK_TYPE_SMC, 480e5ca0d1SHuang Rui AMD_IP_BLOCK_TYPE_PSP, 495fc3aeebSyanyang1 AMD_IP_BLOCK_TYPE_DCE, 505fc3aeebSyanyang1 AMD_IP_BLOCK_TYPE_GFX, 515fc3aeebSyanyang1 AMD_IP_BLOCK_TYPE_SDMA, 525fc3aeebSyanyang1 AMD_IP_BLOCK_TYPE_UVD, 535fc3aeebSyanyang1 AMD_IP_BLOCK_TYPE_VCE, 54a8fe58ceSMaruthi Bayyavarapu AMD_IP_BLOCK_TYPE_ACP, 55886f82aaSJack Xiao AMD_IP_BLOCK_TYPE_VCN, 568d1b04a6SLeo Liu AMD_IP_BLOCK_TYPE_MES, 578d1b04a6SLeo Liu AMD_IP_BLOCK_TYPE_JPEG 585fc3aeebSyanyang1 }; 595fc3aeebSyanyang1 605fc3aeebSyanyang1 enum amd_clockgating_state { 615fc3aeebSyanyang1 AMD_CG_STATE_GATE = 0, 625fc3aeebSyanyang1 AMD_CG_STATE_UNGATE, 635fc3aeebSyanyang1 }; 645fc3aeebSyanyang1 65e5d03ac2SRex Zhu 665fc3aeebSyanyang1 enum amd_powergating_state { 675fc3aeebSyanyang1 AMD_PG_STATE_GATE = 0, 685fc3aeebSyanyang1 AMD_PG_STATE_UNGATE, 695fc3aeebSyanyang1 }; 705fc3aeebSyanyang1 71cfa289fdSRex Zhu 72e3b04bc7SAlex Deucher /* CG flags */ 73e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_GFX_MGCG (1 << 0) 74e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_GFX_MGLS (1 << 1) 75e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_GFX_CGCG (1 << 2) 76e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_GFX_CGLS (1 << 3) 77e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_GFX_CGTS (1 << 4) 78e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_GFX_CGTS_LS (1 << 5) 79e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_GFX_CP_LS (1 << 6) 80e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_GFX_RLC_LS (1 << 7) 81e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_MC_LS (1 << 8) 82e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_MC_MGCG (1 << 9) 83e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_SDMA_LS (1 << 10) 84e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_SDMA_MGCG (1 << 11) 85e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_BIF_LS (1 << 12) 86e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_UVD_MGCG (1 << 13) 87e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_VCE_MGCG (1 << 14) 88e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_HDP_LS (1 << 15) 89e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_HDP_MGCG (1 << 16) 904fae91c5SAlex Deucher #define AMD_CG_SUPPORT_ROM_MGCG (1 << 17) 91398d82ccSRex Zhu #define AMD_CG_SUPPORT_DRM_LS (1 << 18) 92398d82ccSRex Zhu #define AMD_CG_SUPPORT_BIF_MGCG (1 << 19) 93398d82ccSRex Zhu #define AMD_CG_SUPPORT_GFX_3D_CGCG (1 << 20) 94398d82ccSRex Zhu #define AMD_CG_SUPPORT_GFX_3D_CGLS (1 << 21) 95e929c98dSHuang Rui #define AMD_CG_SUPPORT_DRM_MGCG (1 << 22) 96c773a632SHuang Rui #define AMD_CG_SUPPORT_DF_MGCG (1 << 23) 978dbb8cdfSRex Zhu #define AMD_CG_SUPPORT_VCN_MGCG (1 << 24) 98714ff852SHawking Zhang #define AMD_CG_SUPPORT_HDP_DS (1 << 25) 99714ff852SHawking Zhang #define AMD_CG_SUPPORT_HDP_SD (1 << 26) 1009faa494eSHawking Zhang #define AMD_CG_SUPPORT_IH_CG (1 << 27) 101367adb2aSJack Xiao #define AMD_CG_SUPPORT_ATHUB_LS (1 << 28) 102367adb2aSJack Xiao #define AMD_CG_SUPPORT_ATHUB_MGCG (1 << 29) 10318e6d414SLeo Liu #define AMD_CG_SUPPORT_JPEG_MGCG (1 << 30) 104e3b04bc7SAlex Deucher /* PG flags */ 105e3b04bc7SAlex Deucher #define AMD_PG_SUPPORT_GFX_PG (1 << 0) 106e3b04bc7SAlex Deucher #define AMD_PG_SUPPORT_GFX_SMG (1 << 1) 107e3b04bc7SAlex Deucher #define AMD_PG_SUPPORT_GFX_DMG (1 << 2) 108e3b04bc7SAlex Deucher #define AMD_PG_SUPPORT_UVD (1 << 3) 109e3b04bc7SAlex Deucher #define AMD_PG_SUPPORT_VCE (1 << 4) 110e3b04bc7SAlex Deucher #define AMD_PG_SUPPORT_CP (1 << 5) 111e3b04bc7SAlex Deucher #define AMD_PG_SUPPORT_GDS (1 << 6) 112e3b04bc7SAlex Deucher #define AMD_PG_SUPPORT_RLC_SMU_HS (1 << 7) 113e3b04bc7SAlex Deucher #define AMD_PG_SUPPORT_SDMA (1 << 8) 114e3b04bc7SAlex Deucher #define AMD_PG_SUPPORT_ACP (1 << 9) 115e3b04bc7SAlex Deucher #define AMD_PG_SUPPORT_SAMU (1 << 10) 1166b0432b7SAlex Deucher #define AMD_PG_SUPPORT_GFX_QUICK_MG (1 << 11) 1176b0432b7SAlex Deucher #define AMD_PG_SUPPORT_GFX_PIPELINE (1 << 12) 118f8386b35SHawking Zhang #define AMD_PG_SUPPORT_MMHUB (1 << 13) 1198dbb8cdfSRex Zhu #define AMD_PG_SUPPORT_VCN (1 << 14) 120f28ff062SJames Zhu #define AMD_PG_SUPPORT_VCN_DPG (1 << 15) 121a201b6acSHuang Rui #define AMD_PG_SUPPORT_ATHUB (1 << 16) 12218e6d414SLeo Liu #define AMD_PG_SUPPORT_JPEG (1 << 17) 123e3b04bc7SAlex Deucher 124fa7bd27dSHuang Rui enum PP_FEATURE_MASK { 125fa7bd27dSHuang Rui PP_SCLK_DPM_MASK = 0x1, 126fa7bd27dSHuang Rui PP_MCLK_DPM_MASK = 0x2, 127fa7bd27dSHuang Rui PP_PCIE_DPM_MASK = 0x4, 128fa7bd27dSHuang Rui PP_SCLK_DEEP_SLEEP_MASK = 0x8, 129fa7bd27dSHuang Rui PP_POWER_CONTAINMENT_MASK = 0x10, 130fa7bd27dSHuang Rui PP_UVD_HANDSHAKE_MASK = 0x20, 131fa7bd27dSHuang Rui PP_SMC_VOLTAGE_CONTROL_MASK = 0x40, 132fa7bd27dSHuang Rui PP_VBI_TIME_SUPPORT_MASK = 0x80, 133fa7bd27dSHuang Rui PP_ULV_MASK = 0x100, 134fa7bd27dSHuang Rui PP_ENABLE_GFX_CG_THRU_SMU = 0x200, 135fa7bd27dSHuang Rui PP_CLOCK_STRETCH_MASK = 0x400, 136fa7bd27dSHuang Rui PP_OD_FUZZY_FAN_CONTROL_MASK = 0x800, 137fa7bd27dSHuang Rui PP_SOCCLK_DPM_MASK = 0x1000, 138fa7bd27dSHuang Rui PP_DCEFCLK_DPM_MASK = 0x2000, 139fa7bd27dSHuang Rui PP_OVERDRIVE_MASK = 0x4000, 1406f92ad2aSHuang Rui PP_GFXOFF_MASK = 0x8000, 141fa7bd27dSHuang Rui PP_ACG_MASK = 0x10000, 14222994e16Srex zhu PP_STUTTER_MODE = 0x20000, 143a4ead3e5SAlex Deucher PP_AVFS_MASK = 0x40000, 144fa7bd27dSHuang Rui }; 145fa7bd27dSHuang Rui 1467875a226SAlex Deucher enum DC_FEATURE_MASK { 1477875a226SAlex Deucher DC_FBC_MASK = 0x1, 148d99f38aeSAlex Deucher DC_MULTI_MON_PP_MCLK_SWITCH_MASK = 0x2, 149eaf56410SLeo Li DC_DISABLE_FRACTIONAL_PWM_MASK = 0x4, 150397a9bc5SRoman Li DC_PSR_MASK = 0x8, 1517875a226SAlex Deucher }; 1527875a226SAlex Deucher 1538a791dabSHarry Wentland enum DC_DEBUG_MASK { 1548a791dabSHarry Wentland DC_DISABLE_PIPE_SPLIT = 0x1, 1558a791dabSHarry Wentland DC_DISABLE_STUTTER = 0x2, 1568a791dabSHarry Wentland DC_DISABLE_DSC = 0x4, 1578a791dabSHarry Wentland DC_DISABLE_CLOCK_GATING = 0x8 1588a791dabSHarry Wentland }; 1598a791dabSHarry Wentland 16049d27e91SChengming Gui enum amd_dpm_forced_level; 16143911fb6SDarren Powell /** 16243911fb6SDarren Powell * struct amd_ip_funcs - general hooks for managing amdgpu IP Blocks 16343911fb6SDarren Powell */ 1645fc3aeebSyanyang1 struct amd_ip_funcs { 16543911fb6SDarren Powell /** @name: Name of IP block */ 16688a907d6STom St Denis char *name; 16743911fb6SDarren Powell /** 16843911fb6SDarren Powell * @early_init: 16943911fb6SDarren Powell * 17043911fb6SDarren Powell * sets up early driver state (pre sw_init), 17143911fb6SDarren Powell * does not configure hw - Optional 17243911fb6SDarren Powell */ 1735fc3aeebSyanyang1 int (*early_init)(void *handle); 17443911fb6SDarren Powell /** @late_init: sets up late driver/hw state (post hw_init) - Optional */ 1755fc3aeebSyanyang1 int (*late_init)(void *handle); 17643911fb6SDarren Powell /** @sw_init: sets up driver state, does not configure hw */ 1775fc3aeebSyanyang1 int (*sw_init)(void *handle); 17843911fb6SDarren Powell /** @sw_fini: tears down driver state, does not configure hw */ 1795fc3aeebSyanyang1 int (*sw_fini)(void *handle); 18043911fb6SDarren Powell /** @hw_init: sets up the hw state */ 1815fc3aeebSyanyang1 int (*hw_init)(void *handle); 18243911fb6SDarren Powell /** @hw_fini: tears down the hw state */ 1835fc3aeebSyanyang1 int (*hw_fini)(void *handle); 18443911fb6SDarren Powell /** @late_fini: final cleanup */ 185212cb3b6SMonk Liu void (*late_fini)(void *handle); 18643911fb6SDarren Powell /** @suspend: handles IP specific hw/sw changes for suspend */ 1875fc3aeebSyanyang1 int (*suspend)(void *handle); 18843911fb6SDarren Powell /** @resume: handles IP specific hw/sw changes for resume */ 1895fc3aeebSyanyang1 int (*resume)(void *handle); 19043911fb6SDarren Powell /** @is_idle: returns current IP block idle status */ 1915fc3aeebSyanyang1 bool (*is_idle)(void *handle); 19243911fb6SDarren Powell /** @wait_for_idle: poll for idle */ 1935fc3aeebSyanyang1 int (*wait_for_idle)(void *handle); 19443911fb6SDarren Powell /** @check_soft_reset: check soft reset the IP block */ 195da146d3bSAlex Deucher bool (*check_soft_reset)(void *handle); 19643911fb6SDarren Powell /** @pre_soft_reset: pre soft reset the IP block */ 197d31a501eSChunming Zhou int (*pre_soft_reset)(void *handle); 19843911fb6SDarren Powell /** @soft_reset: soft reset the IP block */ 1995fc3aeebSyanyang1 int (*soft_reset)(void *handle); 20043911fb6SDarren Powell /** @post_soft_reset: post soft reset the IP block */ 20135d782feSChunming Zhou int (*post_soft_reset)(void *handle); 20243911fb6SDarren Powell /** @set_clockgating_state: enable/disable cg for the IP block */ 2035fc3aeebSyanyang1 int (*set_clockgating_state)(void *handle, 2045fc3aeebSyanyang1 enum amd_clockgating_state state); 20543911fb6SDarren Powell /** @set_powergating_state: enable/disable pg for the IP block */ 2065fc3aeebSyanyang1 int (*set_powergating_state)(void *handle, 2075fc3aeebSyanyang1 enum amd_powergating_state state); 20843911fb6SDarren Powell /** @get_clockgating_state: get current clockgating status */ 2096cb2d4e4SHuang Rui void (*get_clockgating_state)(void *handle, u32 *flags); 21049d27e91SChengming Gui /** @enable_umd_pstate: enable UMD powerstate */ 21149d27e91SChengming Gui int (*enable_umd_pstate)(void *handle, enum amd_dpm_forced_level *level); 2125fc3aeebSyanyang1 }; 2135fc3aeebSyanyang1 214f93f0c3aSRex Zhu 2155fc3aeebSyanyang1 #endif /* __AMD_SHARED_H__ */ 216