drm/amdgpu: add some common definitions to amd_shared.h
[cascardo/linux.git] / drivers / gpu / drm / amd / include / amd_shared.h
1 /*
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
26 #define AMD_MAX_USEC_TIMEOUT            100000  /* 100 ms */
27
28 /*
29 * Supported GPU families (aligned with amdgpu_drm.h)
30 */
31 #define AMD_FAMILY_UNKNOWN              0
32 #define AMD_FAMILY_CI                   120 /* Bonaire, Hawaii */
33 #define AMD_FAMILY_KV                   125 /* Kaveri, Kabini, Mullins */
34 #define AMD_FAMILY_VI                   130 /* Iceland, Tonga */
35 #define AMD_FAMILY_CZ                   135 /* Carrizo */
36
37 enum amd_ip_block_type {
38         AMD_IP_BLOCK_TYPE_COMMON,
39         AMD_IP_BLOCK_TYPE_GMC,
40         AMD_IP_BLOCK_TYPE_IH,
41         AMD_IP_BLOCK_TYPE_SMC,
42         AMD_IP_BLOCK_TYPE_DCE,
43         AMD_IP_BLOCK_TYPE_GFX,
44         AMD_IP_BLOCK_TYPE_SDMA,
45         AMD_IP_BLOCK_TYPE_UVD,
46         AMD_IP_BLOCK_TYPE_VCE,
47 };
48
49 enum amd_clockgating_state {
50         AMD_CG_STATE_GATE = 0,
51         AMD_CG_STATE_UNGATE,
52 };
53
54 enum amd_powergating_state {
55         AMD_PG_STATE_GATE = 0,
56         AMD_PG_STATE_UNGATE,
57 };
58
59 struct amd_ip_funcs {
60         /* sets up early driver state (pre sw_init), does not configure hw - Optional */
61         int (*early_init)(void *handle);
62         /* sets up late driver/hw state (post hw_init) - Optional */
63         int (*late_init)(void *handle);
64         /* sets up driver state, does not configure hw */
65         int (*sw_init)(void *handle);
66         /* tears down driver state, does not configure hw */
67         int (*sw_fini)(void *handle);
68         /* sets up the hw state */
69         int (*hw_init)(void *handle);
70         /* tears down the hw state */
71         int (*hw_fini)(void *handle);
72         /* handles IP specific hw/sw changes for suspend */
73         int (*suspend)(void *handle);
74         /* handles IP specific hw/sw changes for resume */
75         int (*resume)(void *handle);
76         /* returns current IP block idle status */
77         bool (*is_idle)(void *handle);
78         /* poll for idle */
79         int (*wait_for_idle)(void *handle);
80         /* soft reset the IP block */
81         int (*soft_reset)(void *handle);
82         /* dump the IP block status registers */
83         void (*print_status)(void *handle);
84         /* enable/disable cg for the IP block */
85         int (*set_clockgating_state)(void *handle,
86                                      enum amd_clockgating_state state);
87         /* enable/disable pg for the IP block */
88         int (*set_powergating_state)(void *handle,
89                                      enum amd_powergating_state state);
90 };
91
92 #endif /* __AMD_SHARED_H__ */