blob: 717d6bea7b5219b3673b8a451b60bad71dbfeb9a [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,
yanyang15fc3aee2015-05-22 14:39:35 -040077};
78
79enum amd_clockgating_state {
80 AMD_CG_STATE_GATE = 0,
81 AMD_CG_STATE_UNGATE,
82};
83
Rex Zhue5d03ac2016-12-23 14:39:41 +080084enum amd_dpm_forced_level {
85 AMD_DPM_FORCED_LEVEL_AUTO = 0x1,
86 AMD_DPM_FORCED_LEVEL_MANUAL = 0x2,
87 AMD_DPM_FORCED_LEVEL_LOW = 0x4,
88 AMD_DPM_FORCED_LEVEL_HIGH = 0x8,
Rex Zhu570272d2017-01-06 13:32:49 +080089 AMD_DPM_FORCED_LEVEL_PROFILE_STANDARD = 0x10,
90 AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK = 0x20,
91 AMD_DPM_FORCED_LEVEL_PROFILE_MIN_MCLK = 0x40,
92 AMD_DPM_FORCED_LEVEL_PROFILE_PEAK = 0x80,
93 AMD_DPM_FORCED_LEVEL_PROFILE_EXIT = 0x100,
Rex Zhue5d03ac2016-12-23 14:39:41 +080094};
95
yanyang15fc3aee2015-05-22 14:39:35 -040096enum amd_powergating_state {
97 AMD_PG_STATE_GATE = 0,
98 AMD_PG_STATE_UNGATE,
99};
100
Rex Zhu0d8de7c2016-10-12 15:13:29 +0800101struct amd_vce_state {
102 /* vce clocks */
103 u32 evclk;
104 u32 ecclk;
105 /* gpu clocks */
106 u32 sclk;
107 u32 mclk;
108 u8 clk_idx;
109 u8 pstate;
110};
111
112
113#define AMD_MAX_VCE_LEVELS 6
114
115enum amd_vce_level {
116 AMD_VCE_LEVEL_AC_ALL = 0, /* AC, All cases */
117 AMD_VCE_LEVEL_DC_EE = 1, /* DC, entropy encoding */
118 AMD_VCE_LEVEL_DC_LL_LOW = 2, /* DC, low latency queue, res <= 720 */
119 AMD_VCE_LEVEL_DC_LL_HIGH = 3, /* DC, low latency queue, 1080 >= res > 720 */
120 AMD_VCE_LEVEL_DC_GP_LOW = 4, /* DC, general purpose queue, res <= 720 */
121 AMD_VCE_LEVEL_DC_GP_HIGH = 5, /* DC, general purpose queue, 1080 >= res > 720 */
122};
123
Eric Huang34bb2732016-09-12 16:17:44 -0400124enum amd_pp_profile_type {
125 AMD_PP_GFX_PROFILE,
126 AMD_PP_COMPUTE_PROFILE,
127};
128
129struct amd_pp_profile {
130 enum amd_pp_profile_type type;
131 uint32_t min_sclk;
132 uint32_t min_mclk;
133 uint16_t activity_threshold;
134 uint8_t up_hyst;
135 uint8_t down_hyst;
136};
137
Alex Deuchere3b04bc2016-02-05 10:56:22 -0500138/* CG flags */
139#define AMD_CG_SUPPORT_GFX_MGCG (1 << 0)
140#define AMD_CG_SUPPORT_GFX_MGLS (1 << 1)
141#define AMD_CG_SUPPORT_GFX_CGCG (1 << 2)
142#define AMD_CG_SUPPORT_GFX_CGLS (1 << 3)
143#define AMD_CG_SUPPORT_GFX_CGTS (1 << 4)
144#define AMD_CG_SUPPORT_GFX_CGTS_LS (1 << 5)
145#define AMD_CG_SUPPORT_GFX_CP_LS (1 << 6)
146#define AMD_CG_SUPPORT_GFX_RLC_LS (1 << 7)
147#define AMD_CG_SUPPORT_MC_LS (1 << 8)
148#define AMD_CG_SUPPORT_MC_MGCG (1 << 9)
149#define AMD_CG_SUPPORT_SDMA_LS (1 << 10)
150#define AMD_CG_SUPPORT_SDMA_MGCG (1 << 11)
151#define AMD_CG_SUPPORT_BIF_LS (1 << 12)
152#define AMD_CG_SUPPORT_UVD_MGCG (1 << 13)
153#define AMD_CG_SUPPORT_VCE_MGCG (1 << 14)
154#define AMD_CG_SUPPORT_HDP_LS (1 << 15)
155#define AMD_CG_SUPPORT_HDP_MGCG (1 << 16)
Alex Deucher4fae91c2016-04-08 00:52:24 -0400156#define AMD_CG_SUPPORT_ROM_MGCG (1 << 17)
Rex Zhu398d82c2016-12-09 13:27:27 +0800157#define AMD_CG_SUPPORT_DRM_LS (1 << 18)
158#define AMD_CG_SUPPORT_BIF_MGCG (1 << 19)
159#define AMD_CG_SUPPORT_GFX_3D_CGCG (1 << 20)
160#define AMD_CG_SUPPORT_GFX_3D_CGLS (1 << 21)
Huang Ruie929c982017-01-18 16:53:16 +0800161#define AMD_CG_SUPPORT_DRM_MGCG (1 << 22)
Huang Ruic773a632017-01-17 10:18:31 +0800162#define AMD_CG_SUPPORT_DF_MGCG (1 << 23)
Alex Deuchere3b04bc2016-02-05 10:56:22 -0500163
164/* PG flags */
165#define AMD_PG_SUPPORT_GFX_PG (1 << 0)
166#define AMD_PG_SUPPORT_GFX_SMG (1 << 1)
167#define AMD_PG_SUPPORT_GFX_DMG (1 << 2)
168#define AMD_PG_SUPPORT_UVD (1 << 3)
169#define AMD_PG_SUPPORT_VCE (1 << 4)
170#define AMD_PG_SUPPORT_CP (1 << 5)
171#define AMD_PG_SUPPORT_GDS (1 << 6)
172#define AMD_PG_SUPPORT_RLC_SMU_HS (1 << 7)
173#define AMD_PG_SUPPORT_SDMA (1 << 8)
174#define AMD_PG_SUPPORT_ACP (1 << 9)
175#define AMD_PG_SUPPORT_SAMU (1 << 10)
Alex Deucher6b0432b2016-05-04 10:06:21 -0400176#define AMD_PG_SUPPORT_GFX_QUICK_MG (1 << 11)
177#define AMD_PG_SUPPORT_GFX_PIPELINE (1 << 12)
Alex Deuchere3b04bc2016-02-05 10:56:22 -0500178
Rex Zhu3a2c7882015-08-25 15:57:43 +0800179enum amd_pm_state_type {
180 /* not used for dpm */
181 POWER_STATE_TYPE_DEFAULT,
182 POWER_STATE_TYPE_POWERSAVE,
183 /* user selectable states */
184 POWER_STATE_TYPE_BATTERY,
185 POWER_STATE_TYPE_BALANCED,
186 POWER_STATE_TYPE_PERFORMANCE,
187 /* internal states */
188 POWER_STATE_TYPE_INTERNAL_UVD,
189 POWER_STATE_TYPE_INTERNAL_UVD_SD,
190 POWER_STATE_TYPE_INTERNAL_UVD_HD,
191 POWER_STATE_TYPE_INTERNAL_UVD_HD2,
192 POWER_STATE_TYPE_INTERNAL_UVD_MVC,
193 POWER_STATE_TYPE_INTERNAL_BOOT,
194 POWER_STATE_TYPE_INTERNAL_THERMAL,
195 POWER_STATE_TYPE_INTERNAL_ACPI,
196 POWER_STATE_TYPE_INTERNAL_ULV,
197 POWER_STATE_TYPE_INTERNAL_3DPERF,
198};
199
yanyang15fc3aee2015-05-22 14:39:35 -0400200struct amd_ip_funcs {
Tom St Denis88a907d2016-05-04 14:28:35 -0400201 /* Name of IP block */
202 char *name;
yanyang15fc3aee2015-05-22 14:39:35 -0400203 /* sets up early driver state (pre sw_init), does not configure hw - Optional */
204 int (*early_init)(void *handle);
205 /* sets up late driver/hw state (post hw_init) - Optional */
206 int (*late_init)(void *handle);
207 /* sets up driver state, does not configure hw */
208 int (*sw_init)(void *handle);
209 /* tears down driver state, does not configure hw */
210 int (*sw_fini)(void *handle);
211 /* sets up the hw state */
212 int (*hw_init)(void *handle);
213 /* tears down the hw state */
214 int (*hw_fini)(void *handle);
Monk Liu212cb3b2016-05-19 14:35:17 +0800215 void (*late_fini)(void *handle);
yanyang15fc3aee2015-05-22 14:39:35 -0400216 /* handles IP specific hw/sw changes for suspend */
217 int (*suspend)(void *handle);
218 /* handles IP specific hw/sw changes for resume */
219 int (*resume)(void *handle);
220 /* returns current IP block idle status */
221 bool (*is_idle)(void *handle);
222 /* poll for idle */
223 int (*wait_for_idle)(void *handle);
Chunming Zhou63fbf422016-07-15 11:19:20 +0800224 /* check soft reset the IP block */
Alex Deucherda146d32016-10-13 16:07:03 -0400225 bool (*check_soft_reset)(void *handle);
Chunming Zhoud31a5012016-07-18 10:04:34 +0800226 /* pre soft reset the IP block */
227 int (*pre_soft_reset)(void *handle);
yanyang15fc3aee2015-05-22 14:39:35 -0400228 /* soft reset the IP block */
229 int (*soft_reset)(void *handle);
Chunming Zhou35d782f2016-07-15 15:57:13 +0800230 /* post soft reset the IP block */
231 int (*post_soft_reset)(void *handle);
yanyang15fc3aee2015-05-22 14:39:35 -0400232 /* enable/disable cg for the IP block */
233 int (*set_clockgating_state)(void *handle,
234 enum amd_clockgating_state state);
235 /* enable/disable pg for the IP block */
236 int (*set_powergating_state)(void *handle,
237 enum amd_powergating_state state);
Huang Rui6cb2d4e2017-01-05 18:44:41 +0800238 /* get current clockgating status */
239 void (*get_clockgating_state)(void *handle, u32 *flags);
yanyang15fc3aee2015-05-22 14:39:35 -0400240};
241
242#endif /* __AMD_SHARED_H__ */