blob: a94420d680ec10a20004deeb6c89729723626682 [file] [log] [blame]
yanyang15fc3aee2015-05-22 14:39:35 -04001/*
2 * Copyright 2015 Advanced Micro Devices, Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 */
22
23#ifndef __AMD_SHARED_H__
24#define __AMD_SHARED_H__
25
Rex Zhu70fd80d2016-12-21 17:44:59 +080026#define AMD_MAX_USEC_TIMEOUT 200000 /* 200 ms */
Jammy Zhou0b2daf02015-07-21 17:41:48 +080027
28/*
Jammy Zhou2f7d10b2015-07-22 11:29:01 +080029 * Supported ASIC types
30 */
31enum amd_asic_type {
Ken Wang26d721c2016-01-21 17:00:06 +080032 CHIP_TAHITI = 0,
33 CHIP_PITCAIRN,
34 CHIP_VERDE,
35 CHIP_OLAND,
36 CHIP_HAINAN,
37 CHIP_BONAIRE,
Jammy Zhou2f7d10b2015-07-22 11:29:01 +080038 CHIP_KAVERI,
39 CHIP_KABINI,
40 CHIP_HAWAII,
41 CHIP_MULLINS,
42 CHIP_TOPAZ,
43 CHIP_TONGA,
David Zhang48299f92015-07-08 01:05:16 +080044 CHIP_FIJI,
Jammy Zhou2f7d10b2015-07-22 11:29:01 +080045 CHIP_CARRIZO,
Samuel Li139f4912015-10-08 14:50:27 -040046 CHIP_STONEY,
Flora Cui2cc0c0b2016-03-14 18:33:29 -040047 CHIP_POLARIS10,
48 CHIP_POLARIS11,
Junwei Zhangc4642a42016-12-14 15:32:28 -050049 CHIP_POLARIS12,
Ken Wangd4196f02016-03-09 09:28:32 +080050 CHIP_VEGA10,
Jammy Zhou2f7d10b2015-07-22 11:29:01 +080051 CHIP_LAST,
52};
53
54/*
55 * Chip flags
56 */
57enum amd_chip_flags {
58 AMD_ASIC_MASK = 0x0000ffffUL,
59 AMD_FLAGS_MASK = 0xffff0000UL,
60 AMD_IS_MOBILITY = 0x00010000UL,
61 AMD_IS_APU = 0x00020000UL,
62 AMD_IS_PX = 0x00040000UL,
63 AMD_EXP_HW_SUPPORT = 0x00080000UL,
64};
65
yanyang15fc3aee2015-05-22 14:39:35 -040066enum amd_ip_block_type {
67 AMD_IP_BLOCK_TYPE_COMMON,
68 AMD_IP_BLOCK_TYPE_GMC,
69 AMD_IP_BLOCK_TYPE_IH,
70 AMD_IP_BLOCK_TYPE_SMC,
71 AMD_IP_BLOCK_TYPE_DCE,
72 AMD_IP_BLOCK_TYPE_GFX,
73 AMD_IP_BLOCK_TYPE_SDMA,
74 AMD_IP_BLOCK_TYPE_UVD,
75 AMD_IP_BLOCK_TYPE_VCE,
Maruthi Bayyavarapua8fe58c2015-09-22 17:05:20 -040076 AMD_IP_BLOCK_TYPE_ACP,
Alex Xiee60f8db2017-03-09 11:36:26 -050077 AMD_IP_BLOCK_TYPE_GFXHUB,
78 AMD_IP_BLOCK_TYPE_MMHUB
yanyang15fc3aee2015-05-22 14:39:35 -040079};
80
81enum amd_clockgating_state {
82 AMD_CG_STATE_GATE = 0,
83 AMD_CG_STATE_UNGATE,
84};
85
Rex Zhue5d03ac2016-12-23 14:39:41 +080086enum amd_dpm_forced_level {
87 AMD_DPM_FORCED_LEVEL_AUTO = 0x1,
88 AMD_DPM_FORCED_LEVEL_MANUAL = 0x2,
89 AMD_DPM_FORCED_LEVEL_LOW = 0x4,
90 AMD_DPM_FORCED_LEVEL_HIGH = 0x8,
Rex Zhu570272d2017-01-06 13:32:49 +080091 AMD_DPM_FORCED_LEVEL_PROFILE_STANDARD = 0x10,
92 AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK = 0x20,
93 AMD_DPM_FORCED_LEVEL_PROFILE_MIN_MCLK = 0x40,
94 AMD_DPM_FORCED_LEVEL_PROFILE_PEAK = 0x80,
95 AMD_DPM_FORCED_LEVEL_PROFILE_EXIT = 0x100,
Rex Zhue5d03ac2016-12-23 14:39:41 +080096};
97
yanyang15fc3aee2015-05-22 14:39:35 -040098enum amd_powergating_state {
99 AMD_PG_STATE_GATE = 0,
100 AMD_PG_STATE_UNGATE,
101};
102
Rex Zhu0d8de7c2016-10-12 15:13:29 +0800103struct amd_vce_state {
104 /* vce clocks */
105 u32 evclk;
106 u32 ecclk;
107 /* gpu clocks */
108 u32 sclk;
109 u32 mclk;
110 u8 clk_idx;
111 u8 pstate;
112};
113
114
115#define AMD_MAX_VCE_LEVELS 6
116
117enum amd_vce_level {
118 AMD_VCE_LEVEL_AC_ALL = 0, /* AC, All cases */
119 AMD_VCE_LEVEL_DC_EE = 1, /* DC, entropy encoding */
120 AMD_VCE_LEVEL_DC_LL_LOW = 2, /* DC, low latency queue, res <= 720 */
121 AMD_VCE_LEVEL_DC_LL_HIGH = 3, /* DC, low latency queue, 1080 >= res > 720 */
122 AMD_VCE_LEVEL_DC_GP_LOW = 4, /* DC, general purpose queue, res <= 720 */
123 AMD_VCE_LEVEL_DC_GP_HIGH = 5, /* DC, general purpose queue, 1080 >= res > 720 */
124};
125
Eric Huang34bb2732016-09-12 16:17:44 -0400126enum amd_pp_profile_type {
127 AMD_PP_GFX_PROFILE,
128 AMD_PP_COMPUTE_PROFILE,
129};
130
131struct amd_pp_profile {
132 enum amd_pp_profile_type type;
133 uint32_t min_sclk;
134 uint32_t min_mclk;
135 uint16_t activity_threshold;
136 uint8_t up_hyst;
137 uint8_t down_hyst;
138};
139
Alex Deuchere3b04bc2016-02-05 10:56:22 -0500140/* CG flags */
141#define AMD_CG_SUPPORT_GFX_MGCG (1 << 0)
142#define AMD_CG_SUPPORT_GFX_MGLS (1 << 1)
143#define AMD_CG_SUPPORT_GFX_CGCG (1 << 2)
144#define AMD_CG_SUPPORT_GFX_CGLS (1 << 3)
145#define AMD_CG_SUPPORT_GFX_CGTS (1 << 4)
146#define AMD_CG_SUPPORT_GFX_CGTS_LS (1 << 5)
147#define AMD_CG_SUPPORT_GFX_CP_LS (1 << 6)
148#define AMD_CG_SUPPORT_GFX_RLC_LS (1 << 7)
149#define AMD_CG_SUPPORT_MC_LS (1 << 8)
150#define AMD_CG_SUPPORT_MC_MGCG (1 << 9)
151#define AMD_CG_SUPPORT_SDMA_LS (1 << 10)
152#define AMD_CG_SUPPORT_SDMA_MGCG (1 << 11)
153#define AMD_CG_SUPPORT_BIF_LS (1 << 12)
154#define AMD_CG_SUPPORT_UVD_MGCG (1 << 13)
155#define AMD_CG_SUPPORT_VCE_MGCG (1 << 14)
156#define AMD_CG_SUPPORT_HDP_LS (1 << 15)
157#define AMD_CG_SUPPORT_HDP_MGCG (1 << 16)
Alex Deucher4fae91c2016-04-08 00:52:24 -0400158#define AMD_CG_SUPPORT_ROM_MGCG (1 << 17)
Rex Zhu398d82c2016-12-09 13:27:27 +0800159#define AMD_CG_SUPPORT_DRM_LS (1 << 18)
160#define AMD_CG_SUPPORT_BIF_MGCG (1 << 19)
161#define AMD_CG_SUPPORT_GFX_3D_CGCG (1 << 20)
162#define AMD_CG_SUPPORT_GFX_3D_CGLS (1 << 21)
Huang Ruie929c982017-01-18 16:53:16 +0800163#define AMD_CG_SUPPORT_DRM_MGCG (1 << 22)
Huang Ruic773a632017-01-17 10:18:31 +0800164#define AMD_CG_SUPPORT_DF_MGCG (1 << 23)
Alex Deuchere3b04bc2016-02-05 10:56:22 -0500165
166/* PG flags */
167#define AMD_PG_SUPPORT_GFX_PG (1 << 0)
168#define AMD_PG_SUPPORT_GFX_SMG (1 << 1)
169#define AMD_PG_SUPPORT_GFX_DMG (1 << 2)
170#define AMD_PG_SUPPORT_UVD (1 << 3)
171#define AMD_PG_SUPPORT_VCE (1 << 4)
172#define AMD_PG_SUPPORT_CP (1 << 5)
173#define AMD_PG_SUPPORT_GDS (1 << 6)
174#define AMD_PG_SUPPORT_RLC_SMU_HS (1 << 7)
175#define AMD_PG_SUPPORT_SDMA (1 << 8)
176#define AMD_PG_SUPPORT_ACP (1 << 9)
177#define AMD_PG_SUPPORT_SAMU (1 << 10)
Alex Deucher6b0432b2016-05-04 10:06:21 -0400178#define AMD_PG_SUPPORT_GFX_QUICK_MG (1 << 11)
179#define AMD_PG_SUPPORT_GFX_PIPELINE (1 << 12)
Alex Deuchere3b04bc2016-02-05 10:56:22 -0500180
Rex Zhu3a2c7882015-08-25 15:57:43 +0800181enum amd_pm_state_type {
182 /* not used for dpm */
183 POWER_STATE_TYPE_DEFAULT,
184 POWER_STATE_TYPE_POWERSAVE,
185 /* user selectable states */
186 POWER_STATE_TYPE_BATTERY,
187 POWER_STATE_TYPE_BALANCED,
188 POWER_STATE_TYPE_PERFORMANCE,
189 /* internal states */
190 POWER_STATE_TYPE_INTERNAL_UVD,
191 POWER_STATE_TYPE_INTERNAL_UVD_SD,
192 POWER_STATE_TYPE_INTERNAL_UVD_HD,
193 POWER_STATE_TYPE_INTERNAL_UVD_HD2,
194 POWER_STATE_TYPE_INTERNAL_UVD_MVC,
195 POWER_STATE_TYPE_INTERNAL_BOOT,
196 POWER_STATE_TYPE_INTERNAL_THERMAL,
197 POWER_STATE_TYPE_INTERNAL_ACPI,
198 POWER_STATE_TYPE_INTERNAL_ULV,
199 POWER_STATE_TYPE_INTERNAL_3DPERF,
200};
201
yanyang15fc3aee2015-05-22 14:39:35 -0400202struct amd_ip_funcs {
Tom St Denis88a907d2016-05-04 14:28:35 -0400203 /* Name of IP block */
204 char *name;
yanyang15fc3aee2015-05-22 14:39:35 -0400205 /* sets up early driver state (pre sw_init), does not configure hw - Optional */
206 int (*early_init)(void *handle);
207 /* sets up late driver/hw state (post hw_init) - Optional */
208 int (*late_init)(void *handle);
209 /* sets up driver state, does not configure hw */
210 int (*sw_init)(void *handle);
211 /* tears down driver state, does not configure hw */
212 int (*sw_fini)(void *handle);
213 /* sets up the hw state */
214 int (*hw_init)(void *handle);
215 /* tears down the hw state */
216 int (*hw_fini)(void *handle);
Monk Liu212cb3b2016-05-19 14:35:17 +0800217 void (*late_fini)(void *handle);
yanyang15fc3aee2015-05-22 14:39:35 -0400218 /* handles IP specific hw/sw changes for suspend */
219 int (*suspend)(void *handle);
220 /* handles IP specific hw/sw changes for resume */
221 int (*resume)(void *handle);
222 /* returns current IP block idle status */
223 bool (*is_idle)(void *handle);
224 /* poll for idle */
225 int (*wait_for_idle)(void *handle);
Chunming Zhou63fbf422016-07-15 11:19:20 +0800226 /* check soft reset the IP block */
Alex Deucherda146d32016-10-13 16:07:03 -0400227 bool (*check_soft_reset)(void *handle);
Chunming Zhoud31a5012016-07-18 10:04:34 +0800228 /* pre soft reset the IP block */
229 int (*pre_soft_reset)(void *handle);
yanyang15fc3aee2015-05-22 14:39:35 -0400230 /* soft reset the IP block */
231 int (*soft_reset)(void *handle);
Chunming Zhou35d782f2016-07-15 15:57:13 +0800232 /* post soft reset the IP block */
233 int (*post_soft_reset)(void *handle);
yanyang15fc3aee2015-05-22 14:39:35 -0400234 /* enable/disable cg for the IP block */
235 int (*set_clockgating_state)(void *handle,
236 enum amd_clockgating_state state);
237 /* enable/disable pg for the IP block */
238 int (*set_powergating_state)(void *handle,
239 enum amd_powergating_state state);
Huang Rui6cb2d4e2017-01-05 18:44:41 +0800240 /* get current clockgating status */
241 void (*get_clockgating_state)(void *handle, u32 *flags);
yanyang15fc3aee2015-05-22 14:39:35 -0400242};
243
244#endif /* __AMD_SHARED_H__ */