xref: /openbmc/linux/drivers/net/ipa/gsi_reg.h (revision 910499e1)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 
3 /* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
4  * Copyright (C) 2018-2021 Linaro Ltd.
5  */
6 #ifndef _GSI_REG_H_
7 #define _GSI_REG_H_
8 
9 /* === Only "gsi.c" should include this file === */
10 
11 #include <linux/bits.h>
12 
13 /**
14  * DOC: GSI Registers
15  *
16  * GSI registers are located within the "gsi" address space defined by Device
17  * Tree.  The offset of each register within that space is specified by
18  * symbols defined below.  The GSI address space is mapped to virtual memory
19  * space in gsi_init().  All GSI registers are 32 bits wide.
20  *
21  * Each register type is duplicated for a number of instances of something.
22  * For example, each GSI channel has its own set of registers defining its
23  * configuration.  The offset to a channel's set of registers is computed
24  * based on a "base" offset plus an additional "stride" amount computed
25  * from the channel's ID.  For such registers, the offset is computed by a
26  * function-like macro that takes a parameter used in the computation.
27  *
28  * The offset of a register dependent on execution environment is computed
29  * by a macro that is supplied a parameter "ee".  The "ee" value is a member
30  * of the gsi_ee_id enumerated type.
31  *
32  * The offset of a channel register is computed by a macro that is supplied a
33  * parameter "ch".  The "ch" value is a channel id whose maximum value is 30
34  * (though the actual limit is hardware-dependent).
35  *
36  * The offset of an event register is computed by a macro that is supplied a
37  * parameter "ev".  The "ev" value is an event id whose maximum value is 15
38  * (though the actual limit is hardware-dependent).
39  */
40 
41 /* GSI EE registers as a group are shifted downward by a fixed constant amount
42  * for IPA versions 4.5 and beyond.  This applies to all GSI registers we use
43  * *except* the ones that disable inter-EE interrupts for channels and event
44  * channels.
45  *
46  * The "raw" (not adjusted) GSI register range is mapped, and a pointer to
47  * the mapped range is held in gsi->virt_raw.  The inter-EE interrupt
48  * registers are accessed using that pointer.
49  *
50  * Most registers are accessed using gsi->virt, which is a copy of the "raw"
51  * pointer, adjusted downward by the fixed amount.
52  */
53 #define GSI_EE_REG_ADJUST			0x0000d000	/* IPA v4.5+ */
54 
55 /* The two inter-EE IRQ register offsets are relative to gsi->virt_raw */
56 #define GSI_INTER_EE_SRC_CH_IRQ_OFFSET \
57 			GSI_INTER_EE_N_SRC_CH_IRQ_OFFSET(GSI_EE_AP)
58 #define GSI_INTER_EE_N_SRC_CH_IRQ_OFFSET(ee) \
59 			(0x0000c018 + 0x1000 * (ee))
60 
61 #define GSI_INTER_EE_SRC_EV_CH_IRQ_OFFSET \
62 			GSI_INTER_EE_N_SRC_EV_CH_IRQ_OFFSET(GSI_EE_AP)
63 #define GSI_INTER_EE_N_SRC_EV_CH_IRQ_OFFSET(ee) \
64 			(0x0000c01c + 0x1000 * (ee))
65 
66 /* All other register offsets are relative to gsi->virt */
67 #define GSI_CH_C_CNTXT_0_OFFSET(ch) \
68 		GSI_EE_N_CH_C_CNTXT_0_OFFSET((ch), GSI_EE_AP)
69 #define GSI_EE_N_CH_C_CNTXT_0_OFFSET(ch, ee) \
70 		(0x0001c000 + 0x4000 * (ee) + 0x80 * (ch))
71 #define CHTYPE_PROTOCOL_FMASK		GENMASK(2, 0)
72 #define CHTYPE_DIR_FMASK		GENMASK(3, 3)
73 #define EE_FMASK			GENMASK(7, 4)
74 #define CHID_FMASK			GENMASK(12, 8)
75 /* The next field is present for IPA v4.5 and above */
76 #define CHTYPE_PROTOCOL_MSB_FMASK	GENMASK(13, 13)
77 #define ERINDEX_FMASK			GENMASK(18, 14)
78 #define CHSTATE_FMASK			GENMASK(23, 20)
79 #define ELEMENT_SIZE_FMASK		GENMASK(31, 24)
80 
81 /** enum gsi_channel_type - CHTYPE_PROTOCOL field values in CH_C_CNTXT_0 */
82 enum gsi_channel_type {
83 	GSI_CHANNEL_TYPE_MHI			= 0x0,
84 	GSI_CHANNEL_TYPE_XHCI			= 0x1,
85 	GSI_CHANNEL_TYPE_GPI			= 0x2,
86 	GSI_CHANNEL_TYPE_XDCI			= 0x3,
87 };
88 
89 #define GSI_CH_C_CNTXT_1_OFFSET(ch) \
90 		GSI_EE_N_CH_C_CNTXT_1_OFFSET((ch), GSI_EE_AP)
91 #define GSI_EE_N_CH_C_CNTXT_1_OFFSET(ch, ee) \
92 		(0x0001c004 + 0x4000 * (ee) + 0x80 * (ch))
93 #define R_LENGTH_FMASK			GENMASK(15, 0)
94 
95 #define GSI_CH_C_CNTXT_2_OFFSET(ch) \
96 		GSI_EE_N_CH_C_CNTXT_2_OFFSET((ch), GSI_EE_AP)
97 #define GSI_EE_N_CH_C_CNTXT_2_OFFSET(ch, ee) \
98 		(0x0001c008 + 0x4000 * (ee) + 0x80 * (ch))
99 
100 #define GSI_CH_C_CNTXT_3_OFFSET(ch) \
101 		GSI_EE_N_CH_C_CNTXT_3_OFFSET((ch), GSI_EE_AP)
102 #define GSI_EE_N_CH_C_CNTXT_3_OFFSET(ch, ee) \
103 		(0x0001c00c + 0x4000 * (ee) + 0x80 * (ch))
104 
105 #define GSI_CH_C_QOS_OFFSET(ch) \
106 		GSI_EE_N_CH_C_QOS_OFFSET((ch), GSI_EE_AP)
107 #define GSI_EE_N_CH_C_QOS_OFFSET(ch, ee) \
108 		(0x0001c05c + 0x4000 * (ee) + 0x80 * (ch))
109 #define WRR_WEIGHT_FMASK		GENMASK(3, 0)
110 #define MAX_PREFETCH_FMASK		GENMASK(8, 8)
111 #define USE_DB_ENG_FMASK		GENMASK(9, 9)
112 /* The next field is only present for IPA v4.0, v4.1, and v4.2 */
113 #define USE_ESCAPE_BUF_ONLY_FMASK	GENMASK(10, 10)
114 /* The next two fields are present for IPA v4.5 and above */
115 #define PREFETCH_MODE_FMASK		GENMASK(13, 10)
116 #define EMPTY_LVL_THRSHOLD_FMASK	GENMASK(23, 16)
117 /** enum gsi_prefetch_mode - PREFETCH_MODE field in CH_C_QOS */
118 enum gsi_prefetch_mode {
119 	GSI_USE_PREFETCH_BUFS			= 0x0,
120 	GSI_ESCAPE_BUF_ONLY			= 0x1,
121 	GSI_SMART_PREFETCH			= 0x2,
122 	GSI_FREE_PREFETCH			= 0x3,
123 };
124 
125 #define GSI_CH_C_SCRATCH_0_OFFSET(ch) \
126 		GSI_EE_N_CH_C_SCRATCH_0_OFFSET((ch), GSI_EE_AP)
127 #define GSI_EE_N_CH_C_SCRATCH_0_OFFSET(ch, ee) \
128 		(0x0001c060 + 0x4000 * (ee) + 0x80 * (ch))
129 
130 #define GSI_CH_C_SCRATCH_1_OFFSET(ch) \
131 		GSI_EE_N_CH_C_SCRATCH_1_OFFSET((ch), GSI_EE_AP)
132 #define GSI_EE_N_CH_C_SCRATCH_1_OFFSET(ch, ee) \
133 		(0x0001c064 + 0x4000 * (ee) + 0x80 * (ch))
134 
135 #define GSI_CH_C_SCRATCH_2_OFFSET(ch) \
136 		GSI_EE_N_CH_C_SCRATCH_2_OFFSET((ch), GSI_EE_AP)
137 #define GSI_EE_N_CH_C_SCRATCH_2_OFFSET(ch, ee) \
138 		(0x0001c068 + 0x4000 * (ee) + 0x80 * (ch))
139 
140 #define GSI_CH_C_SCRATCH_3_OFFSET(ch) \
141 		GSI_EE_N_CH_C_SCRATCH_3_OFFSET((ch), GSI_EE_AP)
142 #define GSI_EE_N_CH_C_SCRATCH_3_OFFSET(ch, ee) \
143 		(0x0001c06c + 0x4000 * (ee) + 0x80 * (ch))
144 
145 #define GSI_EV_CH_E_CNTXT_0_OFFSET(ev) \
146 		GSI_EE_N_EV_CH_E_CNTXT_0_OFFSET((ev), GSI_EE_AP)
147 #define GSI_EE_N_EV_CH_E_CNTXT_0_OFFSET(ev, ee) \
148 		(0x0001d000 + 0x4000 * (ee) + 0x80 * (ev))
149 #define EV_CHTYPE_FMASK			GENMASK(3, 0)
150 #define EV_EE_FMASK			GENMASK(7, 4)
151 #define EV_EVCHID_FMASK			GENMASK(15, 8)
152 #define EV_INTYPE_FMASK			GENMASK(16, 16)
153 #define EV_CHSTATE_FMASK		GENMASK(23, 20)
154 #define EV_ELEMENT_SIZE_FMASK		GENMASK(31, 24)
155 /* enum gsi_channel_type defines EV_CHTYPE field values in EV_CH_E_CNTXT_0 */
156 
157 #define GSI_EV_CH_E_CNTXT_1_OFFSET(ev) \
158 		GSI_EE_N_EV_CH_E_CNTXT_1_OFFSET((ev), GSI_EE_AP)
159 #define GSI_EE_N_EV_CH_E_CNTXT_1_OFFSET(ev, ee) \
160 		(0x0001d004 + 0x4000 * (ee) + 0x80 * (ev))
161 #define EV_R_LENGTH_FMASK		GENMASK(15, 0)
162 
163 #define GSI_EV_CH_E_CNTXT_2_OFFSET(ev) \
164 		GSI_EE_N_EV_CH_E_CNTXT_2_OFFSET((ev), GSI_EE_AP)
165 #define GSI_EE_N_EV_CH_E_CNTXT_2_OFFSET(ev, ee) \
166 		(0x0001d008 + 0x4000 * (ee) + 0x80 * (ev))
167 
168 #define GSI_EV_CH_E_CNTXT_3_OFFSET(ev) \
169 		GSI_EE_N_EV_CH_E_CNTXT_3_OFFSET((ev), GSI_EE_AP)
170 #define GSI_EE_N_EV_CH_E_CNTXT_3_OFFSET(ev, ee) \
171 		(0x0001d00c + 0x4000 * (ee) + 0x80 * (ev))
172 
173 #define GSI_EV_CH_E_CNTXT_4_OFFSET(ev) \
174 		GSI_EE_N_EV_CH_E_CNTXT_4_OFFSET((ev), GSI_EE_AP)
175 #define GSI_EE_N_EV_CH_E_CNTXT_4_OFFSET(ev, ee) \
176 		(0x0001d010 + 0x4000 * (ee) + 0x80 * (ev))
177 
178 #define GSI_EV_CH_E_CNTXT_8_OFFSET(ev) \
179 		GSI_EE_N_EV_CH_E_CNTXT_8_OFFSET((ev), GSI_EE_AP)
180 #define GSI_EE_N_EV_CH_E_CNTXT_8_OFFSET(ev, ee) \
181 		(0x0001d020 + 0x4000 * (ee) + 0x80 * (ev))
182 #define MODT_FMASK			GENMASK(15, 0)
183 #define MODC_FMASK			GENMASK(23, 16)
184 #define MOD_CNT_FMASK			GENMASK(31, 24)
185 
186 #define GSI_EV_CH_E_CNTXT_9_OFFSET(ev) \
187 		GSI_EE_N_EV_CH_E_CNTXT_9_OFFSET((ev), GSI_EE_AP)
188 #define GSI_EE_N_EV_CH_E_CNTXT_9_OFFSET(ev, ee) \
189 		(0x0001d024 + 0x4000 * (ee) + 0x80 * (ev))
190 
191 #define GSI_EV_CH_E_CNTXT_10_OFFSET(ev) \
192 		GSI_EE_N_EV_CH_E_CNTXT_10_OFFSET((ev), GSI_EE_AP)
193 #define GSI_EE_N_EV_CH_E_CNTXT_10_OFFSET(ev, ee) \
194 		(0x0001d028 + 0x4000 * (ee) + 0x80 * (ev))
195 
196 #define GSI_EV_CH_E_CNTXT_11_OFFSET(ev) \
197 		GSI_EE_N_EV_CH_E_CNTXT_11_OFFSET((ev), GSI_EE_AP)
198 #define GSI_EE_N_EV_CH_E_CNTXT_11_OFFSET(ev, ee) \
199 		(0x0001d02c + 0x4000 * (ee) + 0x80 * (ev))
200 
201 #define GSI_EV_CH_E_CNTXT_12_OFFSET(ev) \
202 		GSI_EE_N_EV_CH_E_CNTXT_12_OFFSET((ev), GSI_EE_AP)
203 #define GSI_EE_N_EV_CH_E_CNTXT_12_OFFSET(ev, ee) \
204 		(0x0001d030 + 0x4000 * (ee) + 0x80 * (ev))
205 
206 #define GSI_EV_CH_E_CNTXT_13_OFFSET(ev) \
207 		GSI_EE_N_EV_CH_E_CNTXT_13_OFFSET((ev), GSI_EE_AP)
208 #define GSI_EE_N_EV_CH_E_CNTXT_13_OFFSET(ev, ee) \
209 		(0x0001d034 + 0x4000 * (ee) + 0x80 * (ev))
210 
211 #define GSI_EV_CH_E_SCRATCH_0_OFFSET(ev) \
212 		GSI_EE_N_EV_CH_E_SCRATCH_0_OFFSET((ev), GSI_EE_AP)
213 #define GSI_EE_N_EV_CH_E_SCRATCH_0_OFFSET(ev, ee) \
214 		(0x0001d048 + 0x4000 * (ee) + 0x80 * (ev))
215 
216 #define GSI_EV_CH_E_SCRATCH_1_OFFSET(ev) \
217 		GSI_EE_N_EV_CH_E_SCRATCH_1_OFFSET((ev), GSI_EE_AP)
218 #define GSI_EE_N_EV_CH_E_SCRATCH_1_OFFSET(ev, ee) \
219 		(0x0001d04c + 0x4000 * (ee) + 0x80 * (ev))
220 
221 #define GSI_CH_C_DOORBELL_0_OFFSET(ch) \
222 		GSI_EE_N_CH_C_DOORBELL_0_OFFSET((ch), GSI_EE_AP)
223 #define GSI_EE_N_CH_C_DOORBELL_0_OFFSET(ch, ee) \
224 			(0x0001e000 + 0x4000 * (ee) + 0x08 * (ch))
225 
226 #define GSI_EV_CH_E_DOORBELL_0_OFFSET(ev) \
227 			GSI_EE_N_EV_CH_E_DOORBELL_0_OFFSET((ev), GSI_EE_AP)
228 #define GSI_EE_N_EV_CH_E_DOORBELL_0_OFFSET(ev, ee) \
229 			(0x0001e100 + 0x4000 * (ee) + 0x08 * (ev))
230 
231 #define GSI_GSI_STATUS_OFFSET \
232 			GSI_EE_N_GSI_STATUS_OFFSET(GSI_EE_AP)
233 #define GSI_EE_N_GSI_STATUS_OFFSET(ee) \
234 			(0x0001f000 + 0x4000 * (ee))
235 #define ENABLED_FMASK			GENMASK(0, 0)
236 
237 #define GSI_CH_CMD_OFFSET \
238 			GSI_EE_N_CH_CMD_OFFSET(GSI_EE_AP)
239 #define GSI_EE_N_CH_CMD_OFFSET(ee) \
240 			(0x0001f008 + 0x4000 * (ee))
241 #define CH_CHID_FMASK			GENMASK(7, 0)
242 #define CH_OPCODE_FMASK			GENMASK(31, 24)
243 
244 /** enum gsi_ch_cmd_opcode - CH_OPCODE field values in CH_CMD */
245 enum gsi_ch_cmd_opcode {
246 	GSI_CH_ALLOCATE				= 0x0,
247 	GSI_CH_START				= 0x1,
248 	GSI_CH_STOP				= 0x2,
249 	GSI_CH_RESET				= 0x9,
250 	GSI_CH_DE_ALLOC				= 0xa,
251 };
252 
253 #define GSI_EV_CH_CMD_OFFSET \
254 			GSI_EE_N_EV_CH_CMD_OFFSET(GSI_EE_AP)
255 #define GSI_EE_N_EV_CH_CMD_OFFSET(ee) \
256 			(0x0001f010 + 0x4000 * (ee))
257 #define EV_CHID_FMASK			GENMASK(7, 0)
258 #define EV_OPCODE_FMASK			GENMASK(31, 24)
259 
260 /** enum gsi_evt_cmd_opcode - EV_OPCODE field values in EV_CH_CMD */
261 enum gsi_evt_cmd_opcode {
262 	GSI_EVT_ALLOCATE			= 0x0,
263 	GSI_EVT_RESET				= 0x9,
264 	GSI_EVT_DE_ALLOC			= 0xa,
265 };
266 
267 #define GSI_GENERIC_CMD_OFFSET \
268 			GSI_EE_N_GENERIC_CMD_OFFSET(GSI_EE_AP)
269 #define GSI_EE_N_GENERIC_CMD_OFFSET(ee) \
270 			(0x0001f018 + 0x4000 * (ee))
271 #define GENERIC_OPCODE_FMASK		GENMASK(4, 0)
272 #define GENERIC_CHID_FMASK		GENMASK(9, 5)
273 #define GENERIC_EE_FMASK		GENMASK(13, 10)
274 
275 /** enum gsi_generic_cmd_opcode - GENERIC_OPCODE field values in GENERIC_CMD */
276 enum gsi_generic_cmd_opcode {
277 	GSI_GENERIC_HALT_CHANNEL		= 0x1,
278 	GSI_GENERIC_ALLOCATE_CHANNEL		= 0x2,
279 };
280 
281 #define GSI_GSI_HW_PARAM_2_OFFSET \
282 			GSI_EE_N_GSI_HW_PARAM_2_OFFSET(GSI_EE_AP)
283 #define GSI_EE_N_GSI_HW_PARAM_2_OFFSET(ee) \
284 			(0x0001f040 + 0x4000 * (ee))
285 #define IRAM_SIZE_FMASK			GENMASK(2, 0)
286 #define NUM_CH_PER_EE_FMASK		GENMASK(7, 3)
287 #define NUM_EV_PER_EE_FMASK		GENMASK(12, 8)
288 #define GSI_CH_PEND_TRANSLATE_FMASK	GENMASK(13, 13)
289 #define GSI_CH_FULL_LOGIC_FMASK		GENMASK(14, 14)
290 /* Fields below are present for IPA v4.0 and above */
291 #define GSI_USE_SDMA_FMASK		GENMASK(15, 15)
292 #define GSI_SDMA_N_INT_FMASK		GENMASK(18, 16)
293 #define GSI_SDMA_MAX_BURST_FMASK	GENMASK(26, 19)
294 #define GSI_SDMA_N_IOVEC_FMASK		GENMASK(29, 27)
295 /* Fields below are present for IPA v4.2 and above */
296 #define GSI_USE_RD_WR_ENG_FMASK		GENMASK(30, 30)
297 #define GSI_USE_INTER_EE_FMASK		GENMASK(31, 31)
298 
299 /** enum gsi_iram_size - IRAM_SIZE field values in HW_PARAM_2 */
300 enum gsi_iram_size {
301 	IRAM_SIZE_ONE_KB			= 0x0,
302 	IRAM_SIZE_TWO_KB			= 0x1,
303 /* The next two values are available for IPA v4.0 and above */
304 	IRAM_SIZE_TWO_N_HALF_KB			= 0x2,
305 	IRAM_SIZE_THREE_KB			= 0x3,
306 	/* The next two values are available for IPA v4.5 and above */
307 	IRAM_SIZE_THREE_N_HALF_KB		= 0x4,
308 	IRAM_SIZE_FOUR_KB			= 0x5,
309 };
310 
311 /* IRQ condition for each type is cleared by writing type-specific register */
312 #define GSI_CNTXT_TYPE_IRQ_OFFSET \
313 			GSI_EE_N_CNTXT_TYPE_IRQ_OFFSET(GSI_EE_AP)
314 #define GSI_EE_N_CNTXT_TYPE_IRQ_OFFSET(ee) \
315 			(0x0001f080 + 0x4000 * (ee))
316 #define GSI_CNTXT_TYPE_IRQ_MSK_OFFSET \
317 			GSI_EE_N_CNTXT_TYPE_IRQ_MSK_OFFSET(GSI_EE_AP)
318 #define GSI_EE_N_CNTXT_TYPE_IRQ_MSK_OFFSET(ee) \
319 			(0x0001f088 + 0x4000 * (ee))
320 
321 /* Values here are bit positions in the TYPE_IRQ and TYPE_IRQ_MSK registers */
322 enum gsi_irq_type_id {
323 	GSI_CH_CTRL		= 0x0,	/* channel allocation, etc.  */
324 	GSI_EV_CTRL		= 0x1,	/* event ring allocation, etc. */
325 	GSI_GLOB_EE		= 0x2,	/* global/general event */
326 	GSI_IEOB		= 0x3,	/* TRE completion */
327 	GSI_INTER_EE_CH_CTRL	= 0x4,	/* remote-issued stop/reset (unused) */
328 	GSI_INTER_EE_EV_CTRL	= 0x5,	/* remote-issued event reset (unused) */
329 	GSI_GENERAL		= 0x6,	/* general-purpose event */
330 };
331 
332 #define GSI_CNTXT_SRC_CH_IRQ_OFFSET \
333 			GSI_EE_N_CNTXT_SRC_CH_IRQ_OFFSET(GSI_EE_AP)
334 #define GSI_EE_N_CNTXT_SRC_CH_IRQ_OFFSET(ee) \
335 			(0x0001f090 + 0x4000 * (ee))
336 
337 #define GSI_CNTXT_SRC_EV_CH_IRQ_OFFSET \
338 			GSI_EE_N_CNTXT_SRC_EV_CH_IRQ_OFFSET(GSI_EE_AP)
339 #define GSI_EE_N_CNTXT_SRC_EV_CH_IRQ_OFFSET(ee) \
340 			(0x0001f094 + 0x4000 * (ee))
341 
342 #define GSI_CNTXT_SRC_CH_IRQ_MSK_OFFSET \
343 			GSI_EE_N_CNTXT_SRC_CH_IRQ_MSK_OFFSET(GSI_EE_AP)
344 #define GSI_EE_N_CNTXT_SRC_CH_IRQ_MSK_OFFSET(ee) \
345 			(0x0001f098 + 0x4000 * (ee))
346 
347 #define GSI_CNTXT_SRC_EV_CH_IRQ_MSK_OFFSET \
348 			GSI_EE_N_CNTXT_SRC_EV_CH_IRQ_MSK_OFFSET(GSI_EE_AP)
349 #define GSI_EE_N_CNTXT_SRC_EV_CH_IRQ_MSK_OFFSET(ee) \
350 			(0x0001f09c + 0x4000 * (ee))
351 
352 #define GSI_CNTXT_SRC_CH_IRQ_CLR_OFFSET \
353 			GSI_EE_N_CNTXT_SRC_CH_IRQ_CLR_OFFSET(GSI_EE_AP)
354 #define GSI_EE_N_CNTXT_SRC_CH_IRQ_CLR_OFFSET(ee) \
355 			(0x0001f0a0 + 0x4000 * (ee))
356 
357 #define GSI_CNTXT_SRC_EV_CH_IRQ_CLR_OFFSET \
358 			GSI_EE_N_CNTXT_SRC_EV_CH_IRQ_CLR_OFFSET(GSI_EE_AP)
359 #define GSI_EE_N_CNTXT_SRC_EV_CH_IRQ_CLR_OFFSET(ee) \
360 			(0x0001f0a4 + 0x4000 * (ee))
361 
362 #define GSI_CNTXT_SRC_IEOB_IRQ_OFFSET \
363 			GSI_EE_N_CNTXT_SRC_IEOB_IRQ_OFFSET(GSI_EE_AP)
364 #define GSI_EE_N_CNTXT_SRC_IEOB_IRQ_OFFSET(ee) \
365 			(0x0001f0b0 + 0x4000 * (ee))
366 
367 #define GSI_CNTXT_SRC_IEOB_IRQ_MSK_OFFSET \
368 			GSI_EE_N_CNTXT_SRC_IEOB_IRQ_MSK_OFFSET(GSI_EE_AP)
369 #define GSI_EE_N_CNTXT_SRC_IEOB_IRQ_MSK_OFFSET(ee) \
370 			(0x0001f0b8 + 0x4000 * (ee))
371 
372 #define GSI_CNTXT_SRC_IEOB_IRQ_CLR_OFFSET \
373 			GSI_EE_N_CNTXT_SRC_IEOB_IRQ_CLR_OFFSET(GSI_EE_AP)
374 #define GSI_EE_N_CNTXT_SRC_IEOB_IRQ_CLR_OFFSET(ee) \
375 			(0x0001f0c0 + 0x4000 * (ee))
376 
377 #define GSI_CNTXT_GLOB_IRQ_STTS_OFFSET \
378 			GSI_EE_N_CNTXT_GLOB_IRQ_STTS_OFFSET(GSI_EE_AP)
379 #define GSI_EE_N_CNTXT_GLOB_IRQ_STTS_OFFSET(ee) \
380 			(0x0001f100 + 0x4000 * (ee))
381 #define GSI_CNTXT_GLOB_IRQ_EN_OFFSET \
382 			GSI_EE_N_CNTXT_GLOB_IRQ_EN_OFFSET(GSI_EE_AP)
383 #define GSI_EE_N_CNTXT_GLOB_IRQ_EN_OFFSET(ee) \
384 			(0x0001f108 + 0x4000 * (ee))
385 #define GSI_CNTXT_GLOB_IRQ_CLR_OFFSET \
386 			GSI_EE_N_CNTXT_GLOB_IRQ_CLR_OFFSET(GSI_EE_AP)
387 #define GSI_EE_N_CNTXT_GLOB_IRQ_CLR_OFFSET(ee) \
388 			(0x0001f110 + 0x4000 * (ee))
389 /* Values here are bit positions in the GLOB_IRQ_* registers */
390 enum gsi_global_irq_id {
391 	ERROR_INT				= 0x0,
392 	GP_INT1					= 0x1,
393 	GP_INT2					= 0x2,
394 	GP_INT3					= 0x3,
395 };
396 
397 #define GSI_CNTXT_GSI_IRQ_STTS_OFFSET \
398 			GSI_EE_N_CNTXT_GSI_IRQ_STTS_OFFSET(GSI_EE_AP)
399 #define GSI_EE_N_CNTXT_GSI_IRQ_STTS_OFFSET(ee) \
400 			(0x0001f118 + 0x4000 * (ee))
401 #define GSI_CNTXT_GSI_IRQ_EN_OFFSET \
402 			GSI_EE_N_CNTXT_GSI_IRQ_EN_OFFSET(GSI_EE_AP)
403 #define GSI_EE_N_CNTXT_GSI_IRQ_EN_OFFSET(ee) \
404 			(0x0001f120 + 0x4000 * (ee))
405 #define GSI_CNTXT_GSI_IRQ_CLR_OFFSET \
406 			GSI_EE_N_CNTXT_GSI_IRQ_CLR_OFFSET(GSI_EE_AP)
407 #define GSI_EE_N_CNTXT_GSI_IRQ_CLR_OFFSET(ee) \
408 			(0x0001f128 + 0x4000 * (ee))
409 /* Values here are bit positions in the (general) GSI_IRQ_* registers */
410 enum gsi_general_id {
411 	BREAK_POINT				= 0x0,
412 	BUS_ERROR				= 0x1,
413 	CMD_FIFO_OVRFLOW			= 0x2,
414 	MCS_STACK_OVRFLOW			= 0x3,
415 };
416 
417 #define GSI_CNTXT_INTSET_OFFSET \
418 			GSI_EE_N_CNTXT_INTSET_OFFSET(GSI_EE_AP)
419 #define GSI_EE_N_CNTXT_INTSET_OFFSET(ee) \
420 			(0x0001f180 + 0x4000 * (ee))
421 #define INTYPE_FMASK			GENMASK(0, 0)
422 
423 #define GSI_ERROR_LOG_OFFSET \
424 			GSI_EE_N_ERROR_LOG_OFFSET(GSI_EE_AP)
425 #define GSI_EE_N_ERROR_LOG_OFFSET(ee) \
426 			(0x0001f200 + 0x4000 * (ee))
427 #define ERR_ARG3_FMASK			GENMASK(3, 0)
428 #define ERR_ARG2_FMASK			GENMASK(7, 4)
429 #define ERR_ARG1_FMASK			GENMASK(11, 8)
430 #define ERR_CODE_FMASK			GENMASK(15, 12)
431 #define ERR_VIRT_IDX_FMASK		GENMASK(23, 19)
432 #define ERR_TYPE_FMASK			GENMASK(27, 24)
433 #define ERR_EE_FMASK			GENMASK(31, 28)
434 
435 /** enum gsi_err_code - ERR_CODE field values in EE_ERR_LOG */
436 enum gsi_err_code {
437 	GSI_INVALID_TRE				= 0x1,
438 	GSI_OUT_OF_BUFFERS			= 0x2,
439 	GSI_OUT_OF_RESOURCES			= 0x3,
440 	GSI_UNSUPPORTED_INTER_EE_OP		= 0x4,
441 	GSI_EVT_RING_EMPTY			= 0x5,
442 	GSI_NON_ALLOCATED_EVT_ACCESS		= 0x6,
443 	/* 7 is not assigned */
444 	GSI_HWO_1				= 0x8,
445 };
446 
447 /** enum gsi_err_type - ERR_TYPE field values in EE_ERR_LOG */
448 enum gsi_err_type {
449 	GSI_ERR_TYPE_GLOB			= 0x1,
450 	GSI_ERR_TYPE_CHAN			= 0x2,
451 	GSI_ERR_TYPE_EVT			= 0x3,
452 };
453 
454 #define GSI_ERROR_LOG_CLR_OFFSET \
455 			GSI_EE_N_ERROR_LOG_CLR_OFFSET(GSI_EE_AP)
456 #define GSI_EE_N_ERROR_LOG_CLR_OFFSET(ee) \
457 			(0x0001f210 + 0x4000 * (ee))
458 
459 #define GSI_CNTXT_SCRATCH_0_OFFSET \
460 			GSI_EE_N_CNTXT_SCRATCH_0_OFFSET(GSI_EE_AP)
461 #define GSI_EE_N_CNTXT_SCRATCH_0_OFFSET(ee) \
462 			(0x0001f400 + 0x4000 * (ee))
463 #define INTER_EE_RESULT_FMASK		GENMASK(2, 0)
464 #define GENERIC_EE_RESULT_FMASK		GENMASK(7, 5)
465 
466 /** enum gsi_generic_ee_result - GENERIC_EE_RESULT field values in SCRATCH_0 */
467 enum gsi_generic_ee_result {
468 	GENERIC_EE_SUCCESS			= 0x1,
469 	GENERIC_EE_CHANNEL_NOT_RUNNING		= 0x2,
470 	GENERIC_EE_INCORRECT_DIRECTION		= 0x3,
471 	GENERIC_EE_INCORRECT_CHANNEL_TYPE	= 0x4,
472 	GENERIC_EE_INCORRECT_CHANNEL		= 0x5,
473 	GENERIC_EE_RETRY			= 0x6,
474 	GENERIC_EE_NO_RESOURCES			= 0x7,
475 };
476 
477 #define USB_MAX_PACKET_FMASK		GENMASK(15, 15)	/* 0: HS; 1: SS */
478 #define MHI_BASE_CHANNEL_FMASK		GENMASK(31, 24)
479 
480 #endif	/* _GSI_REG_H_ */
481