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 260b2daf09SJammy Zhou #define AMD_MAX_USEC_TIMEOUT 100000 /* 100 ms */ 270b2daf09SJammy Zhou 280b2daf09SJammy Zhou /* 290b2daf09SJammy Zhou * Supported GPU families (aligned with amdgpu_drm.h) 300b2daf09SJammy Zhou */ 310b2daf09SJammy Zhou #define AMD_FAMILY_UNKNOWN 0 320b2daf09SJammy Zhou #define AMD_FAMILY_CI 120 /* Bonaire, Hawaii */ 330b2daf09SJammy Zhou #define AMD_FAMILY_KV 125 /* Kaveri, Kabini, Mullins */ 340b2daf09SJammy Zhou #define AMD_FAMILY_VI 130 /* Iceland, Tonga */ 350b2daf09SJammy Zhou #define AMD_FAMILY_CZ 135 /* Carrizo */ 360b2daf09SJammy Zhou 372f7d10b3SJammy Zhou /* 382f7d10b3SJammy Zhou * Supported ASIC types 392f7d10b3SJammy Zhou */ 402f7d10b3SJammy Zhou enum amd_asic_type { 412f7d10b3SJammy Zhou CHIP_BONAIRE = 0, 422f7d10b3SJammy Zhou CHIP_KAVERI, 432f7d10b3SJammy Zhou CHIP_KABINI, 442f7d10b3SJammy Zhou CHIP_HAWAII, 452f7d10b3SJammy Zhou CHIP_MULLINS, 462f7d10b3SJammy Zhou CHIP_TOPAZ, 472f7d10b3SJammy Zhou CHIP_TONGA, 4848299f95SDavid Zhang CHIP_FIJI, 492f7d10b3SJammy Zhou CHIP_CARRIZO, 50139f4917SSamuel Li CHIP_STONEY, 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, 715fc3aeebSyanyang1 AMD_IP_BLOCK_TYPE_DCE, 725fc3aeebSyanyang1 AMD_IP_BLOCK_TYPE_GFX, 735fc3aeebSyanyang1 AMD_IP_BLOCK_TYPE_SDMA, 745fc3aeebSyanyang1 AMD_IP_BLOCK_TYPE_UVD, 755fc3aeebSyanyang1 AMD_IP_BLOCK_TYPE_VCE, 76a8fe58ceSMaruthi Bayyavarapu AMD_IP_BLOCK_TYPE_ACP, 775fc3aeebSyanyang1 }; 785fc3aeebSyanyang1 795fc3aeebSyanyang1 enum amd_clockgating_state { 805fc3aeebSyanyang1 AMD_CG_STATE_GATE = 0, 815fc3aeebSyanyang1 AMD_CG_STATE_UNGATE, 825fc3aeebSyanyang1 }; 835fc3aeebSyanyang1 845fc3aeebSyanyang1 enum amd_powergating_state { 855fc3aeebSyanyang1 AMD_PG_STATE_GATE = 0, 865fc3aeebSyanyang1 AMD_PG_STATE_UNGATE, 875fc3aeebSyanyang1 }; 885fc3aeebSyanyang1 89e3b04bc7SAlex Deucher /* CG flags */ 90e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_GFX_MGCG (1 << 0) 91e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_GFX_MGLS (1 << 1) 92e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_GFX_CGCG (1 << 2) 93e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_GFX_CGLS (1 << 3) 94e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_GFX_CGTS (1 << 4) 95e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_GFX_CGTS_LS (1 << 5) 96e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_GFX_CP_LS (1 << 6) 97e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_GFX_RLC_LS (1 << 7) 98e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_MC_LS (1 << 8) 99e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_MC_MGCG (1 << 9) 100e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_SDMA_LS (1 << 10) 101e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_SDMA_MGCG (1 << 11) 102e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_BIF_LS (1 << 12) 103e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_UVD_MGCG (1 << 13) 104e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_VCE_MGCG (1 << 14) 105e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_HDP_LS (1 << 15) 106e3b04bc7SAlex Deucher #define AMD_CG_SUPPORT_HDP_MGCG (1 << 16) 1074fae91c5SAlex Deucher #define AMD_CG_SUPPORT_ROM_MGCG (1 << 17) 108e3b04bc7SAlex Deucher 109e3b04bc7SAlex Deucher /* PG flags */ 110e3b04bc7SAlex Deucher #define AMD_PG_SUPPORT_GFX_PG (1 << 0) 111e3b04bc7SAlex Deucher #define AMD_PG_SUPPORT_GFX_SMG (1 << 1) 112e3b04bc7SAlex Deucher #define AMD_PG_SUPPORT_GFX_DMG (1 << 2) 113e3b04bc7SAlex Deucher #define AMD_PG_SUPPORT_UVD (1 << 3) 114e3b04bc7SAlex Deucher #define AMD_PG_SUPPORT_VCE (1 << 4) 115e3b04bc7SAlex Deucher #define AMD_PG_SUPPORT_CP (1 << 5) 116e3b04bc7SAlex Deucher #define AMD_PG_SUPPORT_GDS (1 << 6) 117e3b04bc7SAlex Deucher #define AMD_PG_SUPPORT_RLC_SMU_HS (1 << 7) 118e3b04bc7SAlex Deucher #define AMD_PG_SUPPORT_SDMA (1 << 8) 119e3b04bc7SAlex Deucher #define AMD_PG_SUPPORT_ACP (1 << 9) 120e3b04bc7SAlex Deucher #define AMD_PG_SUPPORT_SAMU (1 << 10) 121e3b04bc7SAlex Deucher 1223a2c788dSRex Zhu enum amd_pm_state_type { 1233a2c788dSRex Zhu /* not used for dpm */ 1243a2c788dSRex Zhu POWER_STATE_TYPE_DEFAULT, 1253a2c788dSRex Zhu POWER_STATE_TYPE_POWERSAVE, 1263a2c788dSRex Zhu /* user selectable states */ 1273a2c788dSRex Zhu POWER_STATE_TYPE_BATTERY, 1283a2c788dSRex Zhu POWER_STATE_TYPE_BALANCED, 1293a2c788dSRex Zhu POWER_STATE_TYPE_PERFORMANCE, 1303a2c788dSRex Zhu /* internal states */ 1313a2c788dSRex Zhu POWER_STATE_TYPE_INTERNAL_UVD, 1323a2c788dSRex Zhu POWER_STATE_TYPE_INTERNAL_UVD_SD, 1333a2c788dSRex Zhu POWER_STATE_TYPE_INTERNAL_UVD_HD, 1343a2c788dSRex Zhu POWER_STATE_TYPE_INTERNAL_UVD_HD2, 1353a2c788dSRex Zhu POWER_STATE_TYPE_INTERNAL_UVD_MVC, 1363a2c788dSRex Zhu POWER_STATE_TYPE_INTERNAL_BOOT, 1373a2c788dSRex Zhu POWER_STATE_TYPE_INTERNAL_THERMAL, 1383a2c788dSRex Zhu POWER_STATE_TYPE_INTERNAL_ACPI, 1393a2c788dSRex Zhu POWER_STATE_TYPE_INTERNAL_ULV, 1403a2c788dSRex Zhu POWER_STATE_TYPE_INTERNAL_3DPERF, 1413a2c788dSRex Zhu }; 1423a2c788dSRex Zhu 1435fc3aeebSyanyang1 struct amd_ip_funcs { 1445fc3aeebSyanyang1 /* sets up early driver state (pre sw_init), does not configure hw - Optional */ 1455fc3aeebSyanyang1 int (*early_init)(void *handle); 1465fc3aeebSyanyang1 /* sets up late driver/hw state (post hw_init) - Optional */ 1475fc3aeebSyanyang1 int (*late_init)(void *handle); 1485fc3aeebSyanyang1 /* sets up driver state, does not configure hw */ 1495fc3aeebSyanyang1 int (*sw_init)(void *handle); 1505fc3aeebSyanyang1 /* tears down driver state, does not configure hw */ 1515fc3aeebSyanyang1 int (*sw_fini)(void *handle); 1525fc3aeebSyanyang1 /* sets up the hw state */ 1535fc3aeebSyanyang1 int (*hw_init)(void *handle); 1545fc3aeebSyanyang1 /* tears down the hw state */ 1555fc3aeebSyanyang1 int (*hw_fini)(void *handle); 1565fc3aeebSyanyang1 /* handles IP specific hw/sw changes for suspend */ 1575fc3aeebSyanyang1 int (*suspend)(void *handle); 1585fc3aeebSyanyang1 /* handles IP specific hw/sw changes for resume */ 1595fc3aeebSyanyang1 int (*resume)(void *handle); 1605fc3aeebSyanyang1 /* returns current IP block idle status */ 1615fc3aeebSyanyang1 bool (*is_idle)(void *handle); 1625fc3aeebSyanyang1 /* poll for idle */ 1635fc3aeebSyanyang1 int (*wait_for_idle)(void *handle); 1645fc3aeebSyanyang1 /* soft reset the IP block */ 1655fc3aeebSyanyang1 int (*soft_reset)(void *handle); 1665fc3aeebSyanyang1 /* dump the IP block status registers */ 1675fc3aeebSyanyang1 void (*print_status)(void *handle); 1685fc3aeebSyanyang1 /* enable/disable cg for the IP block */ 1695fc3aeebSyanyang1 int (*set_clockgating_state)(void *handle, 1705fc3aeebSyanyang1 enum amd_clockgating_state state); 1715fc3aeebSyanyang1 /* enable/disable pg for the IP block */ 1725fc3aeebSyanyang1 int (*set_powergating_state)(void *handle, 1735fc3aeebSyanyang1 enum amd_powergating_state state); 1745fc3aeebSyanyang1 }; 1755fc3aeebSyanyang1 1765fc3aeebSyanyang1 #endif /* __AMD_SHARED_H__ */ 177