RK3368 GPU: Rogue N Init.
[firefly-linux-kernel-4.4.55.git] / drivers / staging / imgtec / rogue / rgx_common.h
1 /*************************************************************************/ /*!
2 @File
3 @Title          RGX Common Types and Defines Header
4 @Copyright      Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description    Common types and definitions for RGX software
6 @License        Dual MIT/GPLv2
7
8 The contents of this file are subject to the MIT license as set out below.
9
10 Permission is hereby granted, free of charge, to any person obtaining a copy
11 of this software and associated documentation files (the "Software"), to deal
12 in the Software without restriction, including without limitation the rights
13 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 copies of the Software, and to permit persons to whom the Software is
15 furnished to do so, subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19
20 Alternatively, the contents of this file may be used under the terms of
21 the GNU General Public License Version 2 ("GPL") in which case the provisions
22 of GPL are applicable instead of those above.
23
24 If you wish to allow use of your version of this file only under the terms of
25 GPL, and not to allow others to use your version of this file under the terms
26 of the MIT license, indicate your decision by deleting the provisions above
27 and replace them with the notice and other provisions required by GPL as set
28 out in the file called "GPL-COPYING" included in this distribution. If you do
29 not delete the provisions above, a recipient may use your version of this file
30 under the terms of either the MIT license or GPL.
31
32 This License is also included in this distribution in the file called
33 "MIT-COPYING".
34
35 EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
36 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
37 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
38 PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
39 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
40 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
41 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
42 */ /**************************************************************************/
43 #ifndef RGX_COMMON_H_
44 #define RGX_COMMON_H_
45
46 #if defined (__cplusplus)
47 extern "C" {
48 #endif
49
50 #include "img_defs.h"
51
52 /* Included to get the BVNC_KM_N defined and other feature defs */
53 #include "km/rgxdefs_km.h"
54
55 /*! This macro represents a mask of LSBs that must be zero on data structure
56  * sizes and offsets to ensure they are 8-byte granular on types shared between
57  * the FW and host driver */
58 #define RGX_FW_ALIGNMENT_LSB (7)
59
60 /*! Macro to test structure size alignment */
61 #define RGX_FW_STRUCT_SIZE_ASSERT(_a)   \
62         static_assert((sizeof(_a) & RGX_FW_ALIGNMENT_LSB) == 0, \
63                                   "Size of " #_a " is not properly aligned")
64
65 /*! Macro to test structure member alignment */
66 #define RGX_FW_STRUCT_OFFSET_ASSERT(_a, _b)     \
67         static_assert((offsetof(_a, _b) & RGX_FW_ALIGNMENT_LSB) == 0,   \
68                                   "Offset of " #_a "." #_b " is not properly aligned")
69
70
71 /* The following enum assumes only one of RGX_FEATURE_TLA or RGX_FEATURE_FASTRENDER_DM feature
72  * is present. In case this is no more true, fail build to fix code */
73 #if defined (RGX_FEATURE_TLA) && defined (RGX_FEATURE_FASTRENDER_DM)
74 #error "Both RGX_FEATURE_TLA and RGX_FEATURE_FASTRENDER_DM defined. Fix code to handle this!"
75 #endif
76
77 /*! The master definition for data masters known to the firmware of RGX.
78  * When a new DM is added to this enum, relevant entry should be added to
79  * RGX_HWPERF_DM enum list.
80  * The DM in a V1 HWPerf packet uses this definition. */
81 typedef enum _RGXFWIF_DM_
82 {
83         RGXFWIF_DM_GP                   = 0,
84
85         /* Either TDM or 2D DM is present. The above build time error is present to verify this */
86         RGXFWIF_DM_2D                   = 1, /* when RGX_FEATURE_TLA defined */
87         RGXFWIF_DM_TDM                  = 1, /* when RGX_FEATURE_FASTRENDER_DM defined */
88
89         RGXFWIF_DM_TA                   = 2,
90         RGXFWIF_DM_3D                   = 3,
91         RGXFWIF_DM_CDM                  = 4,
92
93         /* present on Ray cores only */
94         RGXFWIF_DM_RTU                  = 5,
95         RGXFWIF_DM_SHG                  = 6,
96
97         RGXFWIF_DM_LAST,
98
99         RGXFWIF_DM_FORCE_I32  = 0x7fffffff   /*!< Force enum to be at least 32-bits wide */
100 } RGXFWIF_DM;
101
102 typedef enum _RGX_KICK_TYPE_DM_
103 {
104         RGX_KICK_TYPE_DM_GP                     = 1 << 0,
105         RGX_KICK_TYPE_DM_TDM_2D         = 1 << 1,
106         RGX_KICK_TYPE_DM_TA                     = 1 << 2,
107         RGX_KICK_TYPE_DM_3D                     = 1 << 3,
108         RGX_KICK_TYPE_DM_CDM            = 1 << 4,
109         RGX_KICK_TYPE_DM_RTU            = 1 << 5,
110         RGX_KICK_TYPE_DM_SHG            = 1 << 6,
111         RGX_KICK_TYPE_DM_TQ2D           = 1 << 7,
112         RGX_KICK_TYPE_DM_TQ3D           = 1 << 8,
113         RGX_KICK_TYPE_DM_LAST           = 1 << 9
114 } RGX_KICK_TYPE_DM;
115
116 /* Maximum number of DM in use: GP, 2D/TDM, TA, 3D, CDM, SHG, RTU */
117 #define RGXFWIF_DM_DEFAULT_MAX  (7)
118
119 #if !defined(__KERNEL__)
120 #if defined(RGX_FEATURE_RAY_TRACING)
121 #define RGXFWIF_DM_MAX_MTS 8
122 #else
123 #define RGXFWIF_DM_MAX_MTS 6
124 #endif
125
126 #if defined(RGX_FEATURE_RAY_TRACING)
127 /* Maximum number of DM in use: GP, 2D/TDM, TA, 3D, CDM, SHG, RTU */
128 #define RGXFWIF_DM_MAX                  (7)
129 #else
130 /* Maximum number of DM in use: GP, 2D/TDM, TA, 3D, CDM*/
131 #define RGXFWIF_DM_MAX                  (5)
132 #endif
133 #define RGXFWIF_HWDM_MAX                (RGXFWIF_DM_MAX)
134 #else
135         #define RGXFWIF_DM_MIN_MTS_CNT (6)
136         #define RGXFWIF_RAY_TRACING_DM_MTS_CNT (2)
137         #define RGXFWIF_DM_MIN_CNT                      (5)
138         #define RGXFWIF_RAY_TRACING_DM_CNT      (2)
139         #define RGXFWIF_DM_MAX  (RGXFWIF_DM_MIN_CNT + RGXFWIF_RAY_TRACING_DM_CNT)
140 #endif
141
142 /* Min/Max number of HW DMs (all but GP) */
143 #if defined(RGX_FEATURE_TLA)
144 #define RGXFWIF_HWDM_MIN                (1)
145 #else
146 #if defined(RGX_FEATURE_FASTRENDER_DM)
147 #define RGXFWIF_HWDM_MIN                (1)
148 #else
149 #define RGXFWIF_HWDM_MIN                (2)
150 #endif
151 #endif
152
153 /*!
154  ******************************************************************************
155  * RGXFW Compiler alignment definitions
156  *****************************************************************************/
157 #if defined(__GNUC__) || defined(HAS_GNUC_ATTRIBUTES)
158 #define RGXFW_ALIGN                     __attribute__ ((aligned (8)))
159 #elif defined(_MSC_VER)
160 #define RGXFW_ALIGN                     __declspec(align(8))
161 #pragma warning (disable : 4324)
162 #else
163 #error "Align MACROS need to be defined for this compiler"
164 #endif
165
166 /*!
167  ******************************************************************************
168  * Force 8-byte alignment for structures allocated uncached.
169  *****************************************************************************/
170 #define UNCACHED_ALIGN      RGXFW_ALIGN
171
172 #if defined (__cplusplus)
173 }
174 #endif
175
176 #endif /* RGX_COMMON_H_ */
177
178 /******************************************************************************
179  End of file
180 ******************************************************************************/
181