1 /*
2  * Copyright (c) 2011 Intel Corporation. All Rights Reserved.
3  * Copyright (c) Imagination Technologies Limited, UK
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sub license, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice (including the
14  * next paragraph) shall be included in all copies or substantial portions
15  * of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
20  * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
21  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24  */
25 
26 #ifndef _REGCONV_H_topaz_db_regs_h
27 #define _REGCONV_H_topaz_db_regs_h
28 
29 #ifdef __cplusplus
30 #include "img_types.h"
31 #include "systemc_utils.h"
32 #endif
33 
34 
35 /* Register CR_DB_ALPHA_BETA_OFFSET */
36 #define TOPAZ_DB_CR_DB_ALPHA_BETA_OFFSET 0x0004
37 #define MASK_TOPAZ_DB_CR_H264_ALPHA_OFFSET 0x0000001F
38 #define SHIFT_TOPAZ_DB_CR_H264_ALPHA_OFFSET 0
39 #define REGNUM_TOPAZ_DB_CR_H264_ALPHA_OFFSET 0x0004
40 #define SIGNED_TOPAZ_DB_CR_H264_ALPHA_OFFSET 0
41 
42 #define MASK_TOPAZ_DB_CR_H264_BETA_OFFSET 0x000003E0
43 #define SHIFT_TOPAZ_DB_CR_H264_BETA_OFFSET 5
44 #define REGNUM_TOPAZ_DB_CR_H264_BETA_OFFSET 0x0004
45 #define SIGNED_TOPAZ_DB_CR_H264_BETA_OFFSET 0
46 
47 /* Register CR_DB_BUF_STATE */
48 #define TOPAZ_DB_CR_DB_BUF_STATE    0x0008
49 #define MASK_TOPAZ_DB_CR_BUSY       0x08000000
50 #define SHIFT_TOPAZ_DB_CR_BUSY      27
51 #define REGNUM_TOPAZ_DB_CR_BUSY     0x0008
52 #define SIGNED_TOPAZ_DB_CR_BUSY     0
53 
54 /* Register CR_DB_CMD_FIFO_SIG */
55 #define TOPAZ_DB_CR_DB_CMD_FIFO_SIG 0x000C
56 #define MASK_TOPAZ_DB_CR_CMD_IN_SIGNATURE 0xFFFFFFFF
57 #define SHIFT_TOPAZ_DB_CR_CMD_IN_SIGNATURE 0
58 #define REGNUM_TOPAZ_DB_CR_CMD_IN_SIGNATURE 0x000C
59 #define SIGNED_TOPAZ_DB_CR_CMD_IN_SIGNATURE 0
60 
61 /* Register CR_DB_INPUT_SIG */
62 #define TOPAZ_DB_CR_DB_INPUT_SIG    0x0010
63 #define MASK_TOPAZ_DB_CR_DATA_IN_SIGNATURE 0xFFFFFFFF
64 #define SHIFT_TOPAZ_DB_CR_DATA_IN_SIGNATURE 0
65 #define REGNUM_TOPAZ_DB_CR_DATA_IN_SIGNATURE 0x0010
66 #define SIGNED_TOPAZ_DB_CR_DATA_IN_SIGNATURE 0
67 
68 /* Register CR_DB_OUTPUT_SIG */
69 #define TOPAZ_DB_CR_DB_OUTPUT_SIG   0x0014
70 #define MASK_TOPAZ_DB_CR_DATA_OUT_SIGNATURE 0xFFFFFFFF
71 #define SHIFT_TOPAZ_DB_CR_DATA_OUT_SIGNATURE 0
72 #define REGNUM_TOPAZ_DB_CR_DATA_OUT_SIGNATURE 0x0014
73 #define SIGNED_TOPAZ_DB_CR_DATA_OUT_SIGNATURE 0
74 
75 /* Register CR_DB_DIAG */
76 #define TOPAZ_DB_CR_DB_DIAG         0x0018
77 #define MASK_TOPAZ_DB_CR_DIAG       0xFFFFFFFF
78 #define SHIFT_TOPAZ_DB_CR_DIAG      0
79 #define REGNUM_TOPAZ_DB_CR_DIAG     0x0018
80 #define SIGNED_TOPAZ_DB_CR_DIAG     0
81 
82 /* Register CR_DB_SIG_ADDR */
83 #define TOPAZ_DB_CR_DB_SIG_ADDR     0x001C
84 #define MASK_TOPAZ_DB_CR_ADDR_OUT_SIGNATURE 0xFFFFFFFF
85 #define SHIFT_TOPAZ_DB_CR_ADDR_OUT_SIGNATURE 0
86 #define REGNUM_TOPAZ_DB_CR_ADDR_OUT_SIGNATURE 0x001C
87 #define SIGNED_TOPAZ_DB_CR_ADDR_OUT_SIGNATURE 0
88 
89 /* Register CR_DB_START */
90 #define TOPAZ_DB_CR_DB_START        0x0020
91 #define MASK_TOPAZ_DB_CR_START      0x00000001
92 #define SHIFT_TOPAZ_DB_CR_START     0
93 #define REGNUM_TOPAZ_DB_CR_START    0x0020
94 #define SIGNED_TOPAZ_DB_CR_START    0
95 
96 #define MASK_TOPAZ_DB_CR_FLUSH      0x00000002
97 #define SHIFT_TOPAZ_DB_CR_FLUSH     1
98 #define REGNUM_TOPAZ_DB_CR_FLUSH    0x0020
99 #define SIGNED_TOPAZ_DB_CR_FLUSH    0
100 
101 /* Register CR_DB_RESET */
102 #define TOPAZ_DB_CR_DB_RESET        0x0024
103 #define MASK_TOPAZ_DB_CR_RESET      0x00000001
104 #define SHIFT_TOPAZ_DB_CR_RESET     0
105 #define REGNUM_TOPAZ_DB_CR_RESET    0x0024
106 #define SIGNED_TOPAZ_DB_CR_RESET    0
107 
108 /* Register CR_DB_DISABLE_DEBLOCK_IDC */
109 #define TOPAZ_DB_CR_DB_DISABLE_DEBLOCK_IDC 0x002C
110 #define MASK_TOPAZ_DB_CR_DISABLE_DEBLOCK_IDC 0x00000003
111 #define SHIFT_TOPAZ_DB_CR_DISABLE_DEBLOCK_IDC 0
112 #define REGNUM_TOPAZ_DB_CR_DISABLE_DEBLOCK_IDC 0x002C
113 #define SIGNED_TOPAZ_DB_CR_DISABLE_DEBLOCK_IDC 0
114 
115 #define MASK_TOPAZ_DB_CR_DISABLE_FILTER_SLICETOP 0x00000004
116 #define SHIFT_TOPAZ_DB_CR_DISABLE_FILTER_SLICETOP 2
117 #define REGNUM_TOPAZ_DB_CR_DISABLE_FILTER_SLICETOP 0x002C
118 #define SIGNED_TOPAZ_DB_CR_DISABLE_FILTER_SLICETOP 0
119 
120 /* Register CR_DB_STATUS */
121 #define TOPAZ_DB_CR_DB_STATUS       0x0030
122 #define MASK_TOPAZ_DB_CR_V_PLANE_DONE 0x00000001
123 #define SHIFT_TOPAZ_DB_CR_V_PLANE_DONE 0
124 #define REGNUM_TOPAZ_DB_CR_V_PLANE_DONE 0x0030
125 #define SIGNED_TOPAZ_DB_CR_V_PLANE_DONE 0
126 
127 #define MASK_TOPAZ_DB_CR_U_PLANE_DONE 0x00000002
128 #define SHIFT_TOPAZ_DB_CR_U_PLANE_DONE 1
129 #define REGNUM_TOPAZ_DB_CR_U_PLANE_DONE 0x0030
130 #define SIGNED_TOPAZ_DB_CR_U_PLANE_DONE 0
131 
132 #define MASK_TOPAZ_DB_CR_Y_PLANE_DONE 0x00000004
133 #define SHIFT_TOPAZ_DB_CR_Y_PLANE_DONE 2
134 #define REGNUM_TOPAZ_DB_CR_Y_PLANE_DONE 0x0030
135 #define SIGNED_TOPAZ_DB_CR_Y_PLANE_DONE 0
136 
137 #define MASK_TOPAZ_DB_CR_MODULE_BUSY 0x00000008
138 #define SHIFT_TOPAZ_DB_CR_MODULE_BUSY 3
139 #define REGNUM_TOPAZ_DB_CR_MODULE_BUSY 0x0030
140 #define SIGNED_TOPAZ_DB_CR_MODULE_BUSY 0
141 
142 /* Register CR_DB_PERFORMANCE_0 */
143 #define TOPAZ_DB_CR_DB_PERFORMANCE_0 0x0034
144 #define MASK_TOPAZ_DB_CR_WORST_MB_CYCLES 0x0000FFFF
145 #define SHIFT_TOPAZ_DB_CR_WORST_MB_CYCLES 0
146 #define REGNUM_TOPAZ_DB_CR_WORST_MB_CYCLES 0x0034
147 #define SIGNED_TOPAZ_DB_CR_WORST_MB_CYCLES 0
148 
149 #define MASK_TOPAZ_DB_CR_WORST_MB_TYPE 0x00030000
150 #define SHIFT_TOPAZ_DB_CR_WORST_MB_TYPE 16
151 #define REGNUM_TOPAZ_DB_CR_WORST_MB_TYPE 0x0034
152 #define SIGNED_TOPAZ_DB_CR_WORST_MB_TYPE 0
153 
154 /* Register CR_DB_PERFORMANCE_1 */
155 #define TOPAZ_DB_CR_DB_PERFORMANCE_1 0x0038
156 #define MASK_TOPAZ_DB_CR_WORST_MB_NUMBER 0x003FFFFF
157 #define SHIFT_TOPAZ_DB_CR_WORST_MB_NUMBER 0
158 #define REGNUM_TOPAZ_DB_CR_WORST_MB_NUMBER 0x0038
159 #define SIGNED_TOPAZ_DB_CR_WORST_MB_NUMBER 0
160 
161 /* Register CR_DB_PERFORMANCE_RESET */
162 #define TOPAZ_DB_CR_DB_PERFORMANCE_RESET 0x003C
163 #define MASK_TOPAZ_DB_CR_WORST_MB_RESET 0x00000001
164 #define SHIFT_TOPAZ_DB_CR_WORST_MB_RESET 0
165 #define REGNUM_TOPAZ_DB_CR_WORST_MB_RESET 0x003C
166 #define SIGNED_TOPAZ_DB_CR_WORST_MB_RESET 0
167 
168 #define MASK_TOPAZ_DB_CR_DISABLE_COUNTERS 0x00000002
169 #define SHIFT_TOPAZ_DB_CR_DISABLE_COUNTERS 1
170 #define REGNUM_TOPAZ_DB_CR_DISABLE_COUNTERS 0x003C
171 #define SIGNED_TOPAZ_DB_CR_DISABLE_COUNTERS 0
172 
173 /*
174 	Byte range covering the group TOPAZHP_DB file
175 */
176 
177 #define TOPAZ_DB_TOPAZHP_DB_REGISTERS_START		0x00000004
178 #define TOPAZ_DB_TOPAZHP_DB_REGISTERS_END  		0x0000003F
179 
180 /*
181 	Byte range covering the whole register file
182 */
183 
184 #define TOPAZ_DB_REGISTERS_START		0x00000004
185 #define TOPAZ_DB_REGISTERS_END  		0x0000003F
186 #define TOPAZ_DB_REG_DEFAULT_TABLE struct {\
187 			IMG_UINT16 uRegOffset;\
188 			IMG_UINT32 uRegDefault;\
189 			IMG_UINT32 uRegMask;\
190 			bool bReadonly;\
191 			const char* pszName;\
192 		} TOPAZ_DB_Defaults[] = {\
193 	{0x0004, 0x00000000, 0x000003FF, 0, "CR_DB_ALPHA_BETA_OFFSET" } ,\
194 	{0x0008, 0x00000000, 0x08000000, 1, "CR_DB_BUF_STATE" } ,\
195 	{0x000C, 0x00000000, 0xFFFFFFFF, 1, "CR_DB_CMD_FIFO_SIG" } ,\
196 	{0x0010, 0x00000000, 0xFFFFFFFF, 1, "CR_DB_INPUT_SIG" } ,\
197 	{0x0014, 0x00000000, 0xFFFFFFFF, 1, "CR_DB_OUTPUT_SIG" } ,\
198 	{0x0018, 0x11000000, 0xFFFFFFFF, 1, "CR_DB_DIAG" } ,\
199 	{0x001C, 0x00000000, 0xFFFFFFFF, 1, "CR_DB_SIG_ADDR" } ,\
200 	{0x0020, 0x00000000, 0x00000003, 0, "CR_DB_START" } ,\
201 	{0x0024, 0x00000000, 0x00000001, 0, "CR_DB_RESET" } ,\
202 	{0x002C, 0x00000000, 0x00000007, 0, "CR_DB_DISABLE_DEBLOCK_IDC" } ,\
203 	{0x0030, 0x00000000, 0x0000000F, 1, "CR_DB_STATUS" } ,\
204 	{0x0034, 0x00000000, 0x0003FFFF, 1, "CR_DB_PERFORMANCE_0" } ,\
205 	{0x0038, 0x00000000, 0x003FFFFF, 1, "CR_DB_PERFORMANCE_1" } ,\
206 	{0x003C, 0x00000000, 0x00000003, 0, "CR_DB_PERFORMANCE_RESET" } ,\
207 { 0 }}
208 
209 #define TOPAZ_DB_REGS_INIT(uBase) \
210 	{ \
211 		int n;\
212 		TOPAZ_DB_REG_DEFAULT_TABLE;\
213 		for (n = 0; n < sizeof(TOPAZ_DB_Defaults)/ sizeof(TOPAZ_DB_Defaults[0] ) -1; n++)\
214 		{\
215 			RegWriteNoTrap(TOPAZ_DB_Defaults[n].uRegOffset + uBase, TOPAZ_DB_Defaults[n].uRegDefault); \
216 		}\
217 	}
218 #endif
219