1c59a5c48SFrançois Tigeot /* 2c59a5c48SFrançois Tigeot * Copyright 2015 Advanced Micro Devices, Inc. 3c59a5c48SFrançois Tigeot * 4c59a5c48SFrançois Tigeot * Permission is hereby granted, free of charge, to any person obtaining a 5c59a5c48SFrançois Tigeot * copy of this software and associated documentation files (the "Software"), 6c59a5c48SFrançois Tigeot * to deal in the Software without restriction, including without limitation 7c59a5c48SFrançois Tigeot * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8c59a5c48SFrançois Tigeot * and/or sell copies of the Software, and to permit persons to whom the 9c59a5c48SFrançois Tigeot * Software is furnished to do so, subject to the following conditions: 10c59a5c48SFrançois Tigeot * 11c59a5c48SFrançois Tigeot * The above copyright notice and this permission notice shall be included in 12c59a5c48SFrançois Tigeot * all copies or substantial portions of the Software. 13c59a5c48SFrançois Tigeot * 14c59a5c48SFrançois Tigeot * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15c59a5c48SFrançois Tigeot * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16c59a5c48SFrançois Tigeot * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17c59a5c48SFrançois Tigeot * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18c59a5c48SFrançois Tigeot * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19c59a5c48SFrançois Tigeot * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20c59a5c48SFrançois Tigeot * OTHER DEALINGS IN THE SOFTWARE. 21c59a5c48SFrançois Tigeot */ 22c59a5c48SFrançois Tigeot 23c59a5c48SFrançois Tigeot #ifndef __AMD_SHARED_H__ 24c59a5c48SFrançois Tigeot #define __AMD_SHARED_H__ 25c59a5c48SFrançois Tigeot 26c59a5c48SFrançois Tigeot #define AMD_MAX_USEC_TIMEOUT 100000 /* 100 ms */ 27c59a5c48SFrançois Tigeot 28c59a5c48SFrançois Tigeot /* 29c59a5c48SFrançois Tigeot * Supported GPU families (aligned with amdgpu_drm.h) 30c59a5c48SFrançois Tigeot */ 31c59a5c48SFrançois Tigeot #define AMD_FAMILY_UNKNOWN 0 32c59a5c48SFrançois Tigeot #define AMD_FAMILY_CI 120 /* Bonaire, Hawaii */ 33c59a5c48SFrançois Tigeot #define AMD_FAMILY_KV 125 /* Kaveri, Kabini, Mullins */ 34c59a5c48SFrançois Tigeot #define AMD_FAMILY_VI 130 /* Iceland, Tonga */ 35c59a5c48SFrançois Tigeot #define AMD_FAMILY_CZ 135 /* Carrizo */ 36c59a5c48SFrançois Tigeot 37c59a5c48SFrançois Tigeot /* 38c59a5c48SFrançois Tigeot * Supported ASIC types 39c59a5c48SFrançois Tigeot */ 40c59a5c48SFrançois Tigeot enum amd_asic_type { 41c59a5c48SFrançois Tigeot CHIP_BONAIRE = 0, 42c59a5c48SFrançois Tigeot CHIP_KAVERI, 43c59a5c48SFrançois Tigeot CHIP_KABINI, 44c59a5c48SFrançois Tigeot CHIP_HAWAII, 45c59a5c48SFrançois Tigeot CHIP_MULLINS, 46c59a5c48SFrançois Tigeot CHIP_TOPAZ, 47c59a5c48SFrançois Tigeot CHIP_TONGA, 48c59a5c48SFrançois Tigeot CHIP_FIJI, 49c59a5c48SFrançois Tigeot CHIP_CARRIZO, 50c59a5c48SFrançois Tigeot CHIP_STONEY, 51*d78d3a22SFrançois Tigeot CHIP_POLARIS10, 52*d78d3a22SFrançois Tigeot CHIP_POLARIS11, 53c59a5c48SFrançois Tigeot CHIP_LAST, 54c59a5c48SFrançois Tigeot }; 55c59a5c48SFrançois Tigeot 56c59a5c48SFrançois Tigeot /* 57c59a5c48SFrançois Tigeot * Chip flags 58c59a5c48SFrançois Tigeot */ 59c59a5c48SFrançois Tigeot enum amd_chip_flags { 60c59a5c48SFrançois Tigeot AMD_ASIC_MASK = 0x0000ffffUL, 61c59a5c48SFrançois Tigeot AMD_FLAGS_MASK = 0xffff0000UL, 62c59a5c48SFrançois Tigeot AMD_IS_MOBILITY = 0x00010000UL, 63c59a5c48SFrançois Tigeot AMD_IS_APU = 0x00020000UL, 64c59a5c48SFrançois Tigeot AMD_IS_PX = 0x00040000UL, 65c59a5c48SFrançois Tigeot AMD_EXP_HW_SUPPORT = 0x00080000UL, 66c59a5c48SFrançois Tigeot }; 67c59a5c48SFrançois Tigeot 68c59a5c48SFrançois Tigeot enum amd_ip_block_type { 69c59a5c48SFrançois Tigeot AMD_IP_BLOCK_TYPE_COMMON, 70c59a5c48SFrançois Tigeot AMD_IP_BLOCK_TYPE_GMC, 71c59a5c48SFrançois Tigeot AMD_IP_BLOCK_TYPE_IH, 72c59a5c48SFrançois Tigeot AMD_IP_BLOCK_TYPE_SMC, 73c59a5c48SFrançois Tigeot AMD_IP_BLOCK_TYPE_DCE, 74c59a5c48SFrançois Tigeot AMD_IP_BLOCK_TYPE_GFX, 75c59a5c48SFrançois Tigeot AMD_IP_BLOCK_TYPE_SDMA, 76c59a5c48SFrançois Tigeot AMD_IP_BLOCK_TYPE_UVD, 77c59a5c48SFrançois Tigeot AMD_IP_BLOCK_TYPE_VCE, 78*d78d3a22SFrançois Tigeot AMD_IP_BLOCK_TYPE_ACP, 79c59a5c48SFrançois Tigeot }; 80c59a5c48SFrançois Tigeot 81c59a5c48SFrançois Tigeot enum amd_clockgating_state { 82c59a5c48SFrançois Tigeot AMD_CG_STATE_GATE = 0, 83c59a5c48SFrançois Tigeot AMD_CG_STATE_UNGATE, 84c59a5c48SFrançois Tigeot }; 85c59a5c48SFrançois Tigeot 86c59a5c48SFrançois Tigeot enum amd_powergating_state { 87c59a5c48SFrançois Tigeot AMD_PG_STATE_GATE = 0, 88c59a5c48SFrançois Tigeot AMD_PG_STATE_UNGATE, 89c59a5c48SFrançois Tigeot }; 90c59a5c48SFrançois Tigeot 91*d78d3a22SFrançois Tigeot /* CG flags */ 92*d78d3a22SFrançois Tigeot #define AMD_CG_SUPPORT_GFX_MGCG (1 << 0) 93*d78d3a22SFrançois Tigeot #define AMD_CG_SUPPORT_GFX_MGLS (1 << 1) 94*d78d3a22SFrançois Tigeot #define AMD_CG_SUPPORT_GFX_CGCG (1 << 2) 95*d78d3a22SFrançois Tigeot #define AMD_CG_SUPPORT_GFX_CGLS (1 << 3) 96*d78d3a22SFrançois Tigeot #define AMD_CG_SUPPORT_GFX_CGTS (1 << 4) 97*d78d3a22SFrançois Tigeot #define AMD_CG_SUPPORT_GFX_CGTS_LS (1 << 5) 98*d78d3a22SFrançois Tigeot #define AMD_CG_SUPPORT_GFX_CP_LS (1 << 6) 99*d78d3a22SFrançois Tigeot #define AMD_CG_SUPPORT_GFX_RLC_LS (1 << 7) 100*d78d3a22SFrançois Tigeot #define AMD_CG_SUPPORT_MC_LS (1 << 8) 101*d78d3a22SFrançois Tigeot #define AMD_CG_SUPPORT_MC_MGCG (1 << 9) 102*d78d3a22SFrançois Tigeot #define AMD_CG_SUPPORT_SDMA_LS (1 << 10) 103*d78d3a22SFrançois Tigeot #define AMD_CG_SUPPORT_SDMA_MGCG (1 << 11) 104*d78d3a22SFrançois Tigeot #define AMD_CG_SUPPORT_BIF_LS (1 << 12) 105*d78d3a22SFrançois Tigeot #define AMD_CG_SUPPORT_UVD_MGCG (1 << 13) 106*d78d3a22SFrançois Tigeot #define AMD_CG_SUPPORT_VCE_MGCG (1 << 14) 107*d78d3a22SFrançois Tigeot #define AMD_CG_SUPPORT_HDP_LS (1 << 15) 108*d78d3a22SFrançois Tigeot #define AMD_CG_SUPPORT_HDP_MGCG (1 << 16) 109*d78d3a22SFrançois Tigeot #define AMD_CG_SUPPORT_ROM_MGCG (1 << 17) 110*d78d3a22SFrançois Tigeot 111*d78d3a22SFrançois Tigeot /* PG flags */ 112*d78d3a22SFrançois Tigeot #define AMD_PG_SUPPORT_GFX_PG (1 << 0) 113*d78d3a22SFrançois Tigeot #define AMD_PG_SUPPORT_GFX_SMG (1 << 1) 114*d78d3a22SFrançois Tigeot #define AMD_PG_SUPPORT_GFX_DMG (1 << 2) 115*d78d3a22SFrançois Tigeot #define AMD_PG_SUPPORT_UVD (1 << 3) 116*d78d3a22SFrançois Tigeot #define AMD_PG_SUPPORT_VCE (1 << 4) 117*d78d3a22SFrançois Tigeot #define AMD_PG_SUPPORT_CP (1 << 5) 118*d78d3a22SFrançois Tigeot #define AMD_PG_SUPPORT_GDS (1 << 6) 119*d78d3a22SFrançois Tigeot #define AMD_PG_SUPPORT_RLC_SMU_HS (1 << 7) 120*d78d3a22SFrançois Tigeot #define AMD_PG_SUPPORT_SDMA (1 << 8) 121*d78d3a22SFrançois Tigeot #define AMD_PG_SUPPORT_ACP (1 << 9) 122*d78d3a22SFrançois Tigeot #define AMD_PG_SUPPORT_SAMU (1 << 10) 123*d78d3a22SFrançois Tigeot 124*d78d3a22SFrançois Tigeot enum amd_pm_state_type { 125*d78d3a22SFrançois Tigeot /* not used for dpm */ 126*d78d3a22SFrançois Tigeot POWER_STATE_TYPE_DEFAULT, 127*d78d3a22SFrançois Tigeot POWER_STATE_TYPE_POWERSAVE, 128*d78d3a22SFrançois Tigeot /* user selectable states */ 129*d78d3a22SFrançois Tigeot POWER_STATE_TYPE_BATTERY, 130*d78d3a22SFrançois Tigeot POWER_STATE_TYPE_BALANCED, 131*d78d3a22SFrançois Tigeot POWER_STATE_TYPE_PERFORMANCE, 132*d78d3a22SFrançois Tigeot /* internal states */ 133*d78d3a22SFrançois Tigeot POWER_STATE_TYPE_INTERNAL_UVD, 134*d78d3a22SFrançois Tigeot POWER_STATE_TYPE_INTERNAL_UVD_SD, 135*d78d3a22SFrançois Tigeot POWER_STATE_TYPE_INTERNAL_UVD_HD, 136*d78d3a22SFrançois Tigeot POWER_STATE_TYPE_INTERNAL_UVD_HD2, 137*d78d3a22SFrançois Tigeot POWER_STATE_TYPE_INTERNAL_UVD_MVC, 138*d78d3a22SFrançois Tigeot POWER_STATE_TYPE_INTERNAL_BOOT, 139*d78d3a22SFrançois Tigeot POWER_STATE_TYPE_INTERNAL_THERMAL, 140*d78d3a22SFrançois Tigeot POWER_STATE_TYPE_INTERNAL_ACPI, 141*d78d3a22SFrançois Tigeot POWER_STATE_TYPE_INTERNAL_ULV, 142*d78d3a22SFrançois Tigeot POWER_STATE_TYPE_INTERNAL_3DPERF, 143*d78d3a22SFrançois Tigeot }; 144*d78d3a22SFrançois Tigeot 145c59a5c48SFrançois Tigeot struct amd_ip_funcs { 146*d78d3a22SFrançois Tigeot /* Name of IP block */ 147*d78d3a22SFrançois Tigeot char *name; 148c59a5c48SFrançois Tigeot /* sets up early driver state (pre sw_init), does not configure hw - Optional */ 149c59a5c48SFrançois Tigeot int (*early_init)(void *handle); 150c59a5c48SFrançois Tigeot /* sets up late driver/hw state (post hw_init) - Optional */ 151c59a5c48SFrançois Tigeot int (*late_init)(void *handle); 152c59a5c48SFrançois Tigeot /* sets up driver state, does not configure hw */ 153c59a5c48SFrançois Tigeot int (*sw_init)(void *handle); 154c59a5c48SFrançois Tigeot /* tears down driver state, does not configure hw */ 155c59a5c48SFrançois Tigeot int (*sw_fini)(void *handle); 156c59a5c48SFrançois Tigeot /* sets up the hw state */ 157c59a5c48SFrançois Tigeot int (*hw_init)(void *handle); 158c59a5c48SFrançois Tigeot /* tears down the hw state */ 159c59a5c48SFrançois Tigeot int (*hw_fini)(void *handle); 160*d78d3a22SFrançois Tigeot void (*late_fini)(void *handle); 161c59a5c48SFrançois Tigeot /* handles IP specific hw/sw changes for suspend */ 162c59a5c48SFrançois Tigeot int (*suspend)(void *handle); 163c59a5c48SFrançois Tigeot /* handles IP specific hw/sw changes for resume */ 164c59a5c48SFrançois Tigeot int (*resume)(void *handle); 165c59a5c48SFrançois Tigeot /* returns current IP block idle status */ 166c59a5c48SFrançois Tigeot bool (*is_idle)(void *handle); 167c59a5c48SFrançois Tigeot /* poll for idle */ 168c59a5c48SFrançois Tigeot int (*wait_for_idle)(void *handle); 169c59a5c48SFrançois Tigeot /* soft reset the IP block */ 170c59a5c48SFrançois Tigeot int (*soft_reset)(void *handle); 171c59a5c48SFrançois Tigeot /* enable/disable cg for the IP block */ 172c59a5c48SFrançois Tigeot int (*set_clockgating_state)(void *handle, 173c59a5c48SFrançois Tigeot enum amd_clockgating_state state); 174c59a5c48SFrançois Tigeot /* enable/disable pg for the IP block */ 175c59a5c48SFrançois Tigeot int (*set_powergating_state)(void *handle, 176c59a5c48SFrançois Tigeot enum amd_powergating_state state); 177c59a5c48SFrançois Tigeot }; 178c59a5c48SFrançois Tigeot 179c59a5c48SFrançois Tigeot #endif /* __AMD_SHARED_H__ */ 180