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 2670fd80d6SRex Zhu #define AMD_MAX_USEC_TIMEOUT 200000 /* 200 ms */ 270b2daf09SJammy Zhou 280b2daf09SJammy Zhou /* 292f7d10b3SJammy Zhou * Supported ASIC types 302f7d10b3SJammy Zhou */ 312f7d10b3SJammy Zhou enum amd_asic_type { 3226d721c5SKen Wang CHIP_TAHITI = 0, 3326d721c5SKen Wang CHIP_PITCAIRN, 3426d721c5SKen Wang CHIP_VERDE, 3526d721c5SKen Wang CHIP_OLAND, 3626d721c5SKen Wang CHIP_HAINAN, 3726d721c5SKen Wang CHIP_BONAIRE, 382f7d10b3SJammy Zhou CHIP_KAVERI, 392f7d10b3SJammy Zhou CHIP_KABINI, 402f7d10b3SJammy Zhou CHIP_HAWAII, 412f7d10b3SJammy Zhou CHIP_MULLINS, 422f7d10b3SJammy Zhou CHIP_TOPAZ, 432f7d10b3SJammy Zhou CHIP_TONGA, 4448299f95SDavid Zhang CHIP_FIJI, 452f7d10b3SJammy Zhou CHIP_CARRIZO, 46139f4917SSamuel Li CHIP_STONEY, 472cc0c0b5SFlora Cui CHIP_POLARIS10, 482cc0c0b5SFlora Cui CHIP_POLARIS11, 49c4642a47SJunwei Zhang CHIP_POLARIS12, 50d4196f01SKen Wang CHIP_VEGA10, 512f7d10b3SJammy Zhou CHIP_LAST, 522f7d10b3SJammy Zhou }; 532f7d10b3SJammy Zhou 542f7d10b3SJammy Zhou /* 552f7d10b3SJammy Zhou * Chip flags 562f7d10b3SJammy Zhou */ 572f7d10b3SJammy Zhou enum amd_chip_flags { 582f7d10b3SJammy Zhou AMD_ASIC_MASK = 0x0000ffffUL, 592f7d10b3SJammy Zhou AMD_FLAGS_MASK = 0xffff0000UL, 602f7d10b3SJammy Zhou AMD_IS_MOBILITY = 0x00010000UL, 612f7d10b3SJammy Zhou AMD_IS_APU = 0x00020000UL, 622f7d10b3SJammy Zhou AMD_IS_PX = 0x00040000UL, 632f7d10b3SJammy Zhou AMD_EXP_HW_SUPPORT = 0x00080000UL, 642f7d10b3SJammy Zhou }; 652f7d10b3SJammy Zhou 665fc3aeebSyanyang1 enum amd_ip_block_type { 675fc3aeebSyanyang1 AMD_IP_BLOCK_TYPE_COMMON, 685fc3aeebSyanyang1 AMD_IP_BLOCK_TYPE_GMC, 695fc3aeebSyanyang1 AMD_IP_BLOCK_TYPE_IH, 705fc3aeebSyanyang1 AMD_IP_BLOCK_TYPE_SMC, 710e5ca0d1SHuang Rui AMD_IP_BLOCK_TYPE_PSP, 725fc3aeebSyanyang1 AMD_IP_BLOCK_TYPE_DCE, 735fc3aeebSyanyang1 AMD_IP_BLOCK_TYPE_GFX, 745fc3aeebSyanyang1 AMD_IP_BLOCK_TYPE_SDMA, 755fc3aeebSyanyang1 AMD_IP_BLOCK_TYPE_UVD, 765fc3aeebSyanyang1 AMD_IP_BLOCK_TYPE_VCE, 77a8fe58ceSMaruthi Bayyavarapu AMD_IP_BLOCK_TYPE_ACP, 78e60f8db5SAlex Xie AMD_IP_BLOCK_TYPE_GFXHUB, 79e60f8db5SAlex Xie AMD_IP_BLOCK_TYPE_MMHUB 805fc3aeebSyanyang1 }; 815fc3aeebSyanyang1 825fc3aeebSyanyang1 enum amd_clockgating_state { 835fc3aeebSyanyang1 AMD_CG_STATE_GATE = 0, 845fc3aeebSyanyang1 AMD_CG_STATE_UNGATE, 855fc3aeebSyanyang1 }; 865fc3aeebSyanyang1 87e5d03ac2SRex Zhu enum amd_dpm_forced_level { 88e5d03ac2SRex Zhu AMD_DPM_FORCED_LEVEL_AUTO = 0x1, 89e5d03ac2SRex Zhu AMD_DPM_FORCED_LEVEL_MANUAL = 0x2, 90e5d03ac2SRex Zhu AMD_DPM_FORCED_LEVEL_LOW = 0x4, 91e5d03ac2SRex Zhu AMD_DPM_FORCED_LEVEL_HIGH = 0x8, 92570272d2SRex Zhu AMD_DPM_FORCED_LEVEL_PROFILE_STANDARD = 0x10, 93570272d2SRex Zhu AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK = 0x20, 94570272d2SRex Zhu AMD_DPM_FORCED_LEVEL_PROFILE_MIN_MCLK = 0x40, 95570272d2SRex Zhu AMD_DPM_FORCED_LEVEL_PROFILE_PEAK = 0x80, 96570272d2SRex Zhu AMD_DPM_FORCED_LEVEL_PROFILE_EXIT = 0x100, 97e5d03ac2SRex Zhu }; 98e5d03ac2SRex Zhu 995fc3aeebSyanyang1 enum amd_powergating_state { 1005fc3aeebSyanyang1 AMD_PG_STATE_GATE = 0, 1015fc3aeebSyanyang1 AMD_PG_STATE_UNGATE, 1025fc3aeebSyanyang1 }; 1035fc3aeebSyanyang1 1040d8de7caSRex Zhu struct amd_vce_state { 1050d8de7caSRex Zhu /* vce clocks */ 1060d8de7caSRex Zhu u32 evclk; 1070d8de7caSRex Zhu u32 ecclk; 1080d8de7caSRex Zhu /* gpu clocks */ 1090d8de7caSRex Zhu u32 sclk; 1100d8de7caSRex Zhu u32 mclk; 1110d8de7caSRex Zhu u8 clk_idx; 1120d8de7caSRex Zhu u8 pstate; 1130d8de7caSRex Zhu }; 1140d8de7caSRex Zhu 1150d8de7caSRex Zhu 1160d8de7caSRex Zhu #define AMD_MAX_VCE_LEVELS 6 1170d8de7caSRex Zhu 1180d8de7caSRex Zhu enum amd_vce_level { 1190d8de7caSRex Zhu AMD_VCE_LEVEL_AC_ALL = 0, /* AC, All cases */ 1200d8de7caSRex Zhu AMD_VCE_LEVEL_DC_EE = 1, /* DC, entropy encoding */ 1210d8de7caSRex Zhu AMD_VCE_LEVEL_DC_LL_LOW = 2, /* DC, low latency queue, res <= 720 */ 1220d8de7caSRex Zhu AMD_VCE_LEVEL_DC_LL_HIGH = 3, /* DC, low latency queue, 1080 >= res > 720 */ 1230d8de7caSRex Zhu AMD_VCE_LEVEL_DC_GP_LOW = 4, /* DC, general purpose queue, res <= 720 */ 1240d8de7caSRex Zhu AMD_VCE_LEVEL_DC_GP_HIGH = 5, /* DC, general purpose queue, 1080 >= res > 720 */ 1250d8de7caSRex Zhu }; 1260d8de7caSRex Zhu 12734bb2734SEric Huang enum amd_pp_profile_type { 12834bb2734SEric Huang AMD_PP_GFX_PROFILE, 12934bb2734SEric Huang AMD_PP_COMPUTE_PROFILE, 13034bb2734SEric Huang }; 13134bb2734SEric Huang 13234bb2734SEric Huang struct amd_pp_profile { 13334bb2734SEric Huang enum amd_pp_profile_type type; 13434bb2734SEric Huang uint32_t min_sclk; 13534bb2734SEric Huang uint32_t min_mclk; 13634bb2734SEric Huang uint16_t activity_threshold; 13734bb2734SEric Huang uint8_t up_hyst; 13834bb2734SEric Huang uint8_t down_hyst; 13934bb2734SEric Huang }; 14034bb2734SEric Huang 141e3b04bc7SAlex Deucher /* CG flags */ 142e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_GFX_MGCG (1 << 0) 143e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_GFX_MGLS (1 << 1) 144e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_GFX_CGCG (1 << 2) 145e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_GFX_CGLS (1 << 3) 146e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_GFX_CGTS (1 << 4) 147e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_GFX_CGTS_LS (1 << 5) 148e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_GFX_CP_LS (1 << 6) 149e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_GFX_RLC_LS (1 << 7) 150e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_MC_LS (1 << 8) 151e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_MC_MGCG (1 << 9) 152e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_SDMA_LS (1 << 10) 153e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_SDMA_MGCG (1 << 11) 154e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_BIF_LS (1 << 12) 155e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_UVD_MGCG (1 << 13) 156e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_VCE_MGCG (1 << 14) 157e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_HDP_LS (1 << 15) 158e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_HDP_MGCG (1 << 16) 1594fae91c5SAlex Deucher #define AMD_CG_SUPPORT_ROM_MGCG (1 << 17) 160398d82ccSRex Zhu #define AMD_CG_SUPPORT_DRM_LS (1 << 18) 161398d82ccSRex Zhu #define AMD_CG_SUPPORT_BIF_MGCG (1 << 19) 162398d82ccSRex Zhu #define AMD_CG_SUPPORT_GFX_3D_CGCG (1 << 20) 163398d82ccSRex Zhu #define AMD_CG_SUPPORT_GFX_3D_CGLS (1 << 21) 164e929c98dSHuang Rui #define AMD_CG_SUPPORT_DRM_MGCG (1 << 22) 165c773a632SHuang Rui #define AMD_CG_SUPPORT_DF_MGCG (1 << 23) 166e3b04bc7SAlex Deucher 167e3b04bc7SAlex Deucher /* PG flags */ 168e3b04bc7SAlex Deucher #define AMD_PG_SUPPORT_GFX_PG (1 << 0) 169e3b04bc7SAlex Deucher #define AMD_PG_SUPPORT_GFX_SMG (1 << 1) 170e3b04bc7SAlex Deucher #define AMD_PG_SUPPORT_GFX_DMG (1 << 2) 171e3b04bc7SAlex Deucher #define AMD_PG_SUPPORT_UVD (1 << 3) 172e3b04bc7SAlex Deucher #define AMD_PG_SUPPORT_VCE (1 << 4) 173e3b04bc7SAlex Deucher #define AMD_PG_SUPPORT_CP (1 << 5) 174e3b04bc7SAlex Deucher #define AMD_PG_SUPPORT_GDS (1 << 6) 175e3b04bc7SAlex Deucher #define AMD_PG_SUPPORT_RLC_SMU_HS (1 << 7) 176e3b04bc7SAlex Deucher #define AMD_PG_SUPPORT_SDMA (1 << 8) 177e3b04bc7SAlex Deucher #define AMD_PG_SUPPORT_ACP (1 << 9) 178e3b04bc7SAlex Deucher #define AMD_PG_SUPPORT_SAMU (1 << 10) 1796b0432b7SAlex Deucher #define AMD_PG_SUPPORT_GFX_QUICK_MG (1 << 11) 1806b0432b7SAlex Deucher #define AMD_PG_SUPPORT_GFX_PIPELINE (1 << 12) 181e3b04bc7SAlex Deucher 1823a2c788dSRex Zhu enum amd_pm_state_type { 1833a2c788dSRex Zhu /* not used for dpm */ 1843a2c788dSRex Zhu POWER_STATE_TYPE_DEFAULT, 1853a2c788dSRex Zhu POWER_STATE_TYPE_POWERSAVE, 1863a2c788dSRex Zhu /* user selectable states */ 1873a2c788dSRex Zhu POWER_STATE_TYPE_BATTERY, 1883a2c788dSRex Zhu POWER_STATE_TYPE_BALANCED, 1893a2c788dSRex Zhu POWER_STATE_TYPE_PERFORMANCE, 1903a2c788dSRex Zhu /* internal states */ 1913a2c788dSRex Zhu POWER_STATE_TYPE_INTERNAL_UVD, 1923a2c788dSRex Zhu POWER_STATE_TYPE_INTERNAL_UVD_SD, 1933a2c788dSRex Zhu POWER_STATE_TYPE_INTERNAL_UVD_HD, 1943a2c788dSRex Zhu POWER_STATE_TYPE_INTERNAL_UVD_HD2, 1953a2c788dSRex Zhu POWER_STATE_TYPE_INTERNAL_UVD_MVC, 1963a2c788dSRex Zhu POWER_STATE_TYPE_INTERNAL_BOOT, 1973a2c788dSRex Zhu POWER_STATE_TYPE_INTERNAL_THERMAL, 1983a2c788dSRex Zhu POWER_STATE_TYPE_INTERNAL_ACPI, 1993a2c788dSRex Zhu POWER_STATE_TYPE_INTERNAL_ULV, 2003a2c788dSRex Zhu POWER_STATE_TYPE_INTERNAL_3DPERF, 2013a2c788dSRex Zhu }; 2023a2c788dSRex Zhu 2035fc3aeebSyanyang1 struct amd_ip_funcs { 20488a907d6STom St Denis /* Name of IP block */ 20588a907d6STom St Denis char *name; 2065fc3aeebSyanyang1 /* sets up early driver state (pre sw_init), does not configure hw - Optional */ 2075fc3aeebSyanyang1 int (*early_init)(void *handle); 2085fc3aeebSyanyang1 /* sets up late driver/hw state (post hw_init) - Optional */ 2095fc3aeebSyanyang1 int (*late_init)(void *handle); 2105fc3aeebSyanyang1 /* sets up driver state, does not configure hw */ 2115fc3aeebSyanyang1 int (*sw_init)(void *handle); 2125fc3aeebSyanyang1 /* tears down driver state, does not configure hw */ 2135fc3aeebSyanyang1 int (*sw_fini)(void *handle); 2145fc3aeebSyanyang1 /* sets up the hw state */ 2155fc3aeebSyanyang1 int (*hw_init)(void *handle); 2165fc3aeebSyanyang1 /* tears down the hw state */ 2175fc3aeebSyanyang1 int (*hw_fini)(void *handle); 218212cb3b6SMonk Liu void (*late_fini)(void *handle); 2195fc3aeebSyanyang1 /* handles IP specific hw/sw changes for suspend */ 2205fc3aeebSyanyang1 int (*suspend)(void *handle); 2215fc3aeebSyanyang1 /* handles IP specific hw/sw changes for resume */ 2225fc3aeebSyanyang1 int (*resume)(void *handle); 2235fc3aeebSyanyang1 /* returns current IP block idle status */ 2245fc3aeebSyanyang1 bool (*is_idle)(void *handle); 2255fc3aeebSyanyang1 /* poll for idle */ 2265fc3aeebSyanyang1 int (*wait_for_idle)(void *handle); 22763fbf42fSChunming Zhou /* check soft reset the IP block */ 228da146d3bSAlex Deucher bool (*check_soft_reset)(void *handle); 229d31a501eSChunming Zhou /* pre soft reset the IP block */ 230d31a501eSChunming Zhou int (*pre_soft_reset)(void *handle); 2315fc3aeebSyanyang1 /* soft reset the IP block */ 2325fc3aeebSyanyang1 int (*soft_reset)(void *handle); 23335d782feSChunming Zhou /* post soft reset the IP block */ 23435d782feSChunming Zhou int (*post_soft_reset)(void *handle); 2355fc3aeebSyanyang1 /* enable/disable cg for the IP block */ 2365fc3aeebSyanyang1 int (*set_clockgating_state)(void *handle, 2375fc3aeebSyanyang1 enum amd_clockgating_state state); 2385fc3aeebSyanyang1 /* enable/disable pg for the IP block */ 2395fc3aeebSyanyang1 int (*set_powergating_state)(void *handle, 2405fc3aeebSyanyang1 enum amd_powergating_state state); 2416cb2d4e4SHuang Rui /* get current clockgating status */ 2426cb2d4e4SHuang Rui void (*get_clockgating_state)(void *handle, u32 *flags); 2435fc3aeebSyanyang1 }; 2445fc3aeebSyanyang1 2455fc3aeebSyanyang1 #endif /* __AMD_SHARED_H__ */ 246