xref: /freebsd/sys/dev/safexcel/safexcel_reg.h (revision d0b2dbfa0ecf2bbc9709efc5e20baf8e4b44bbbf)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 2020 Rubicon Communications, LLC (Netgate)
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  */
26 
27 #ifndef _SAFEXCEL_REGS_H_
28 #define	_SAFEXCEL_REGS_H_
29 
30 #define	SAFEXCEL_HIA_VERSION_LE			0x35ca
31 #define	SAFEXCEL_HIA_VERSION_BE			0xca35
32 #define	EIP201_VERSION_LE			0x36c9
33 #define	SAFEXCEL_REG_LO16(_reg)			((_reg) & 0xffff)
34 #define	SAFEXCEL_REG_HI16(_reg)			(((_reg) >> 16) & 0xffff)
35 
36 /* HIA, Command Descriptor Ring Manager */
37 #define	CDR_BASE_ADDR_LO(x)			(0x0 + ((x) << 12))
38 #define	CDR_BASE_ADDR_HI(x)			(0x4 + ((x) << 12))
39 #define	CDR_DATA_BASE_ADDR_LO(x)		(0x8 + ((x) << 12))
40 #define	CDR_DATA_BASE_ADDR_HI(x)		(0xC + ((x) << 12))
41 #define	CDR_ACD_BASE_ADDR_LO(x)			(0x10 + ((x) << 12))
42 #define	CDR_ACD_BASE_ADDR_HI(x)			(0x14 + ((x) << 12))
43 #define	CDR_RING_SIZE(x)			(0x18 + ((x) << 12))
44 #define	CDR_DESC_SIZE(x)			(0x1C + ((x) << 12))
45 #define	CDR_CFG(x)				(0x20 + ((x) << 12))
46 #define	CDR_DMA_CFG(x)				(0x24 + ((x) << 12))
47 #define	CDR_THR(x)				(0x28 + ((x) << 12))
48 #define	CDR_PREP_COUNT(x)			(0x2C + ((x) << 12))
49 #define	CDR_PROC_COUNT(x)			(0x30 + ((x) << 12))
50 #define	CDR_PREP_PNTR(x)			(0x34 + ((x) << 12))
51 #define	CDR_PROC_PNTR(x)			(0x38 + ((x) << 12))
52 #define	CDR_STAT(x)				(0x3C + ((x) << 12))
53 
54 /* HIA, Result Descriptor Ring Manager */
55 #define	RDR_BASE_ADDR_LO(x)			(0x800 + ((x) << 12))
56 #define	RDR_BASE_ADDR_HI(x)			(0x804 + ((x) << 12))
57 #define	RDR_DATA_BASE_ADDR_LO(x)		(0x808 + ((x) << 12))
58 #define	RDR_DATA_BASE_ADDR_HI(x)		(0x80C + ((x) << 12))
59 #define	RDR_ACD_BASE_ADDR_LO(x)			(0x810 + ((x) << 12))
60 #define	RDR_ACD_BASE_ADDR_HI(x)			(0x814 + ((x) << 12))
61 #define	RDR_RING_SIZE(x)			(0x818 + ((x) << 12))
62 #define	RDR_DESC_SIZE(x)			(0x81C + ((x) << 12))
63 #define	RDR_CFG(x)				(0x820 + ((x) << 12))
64 #define	RDR_DMA_CFG(x)				(0x824 + ((x) << 12))
65 #define	RDR_THR(x)				(0x828 + ((x) << 12))
66 #define	RDR_PREP_COUNT(x)			(0x82C + ((x) << 12))
67 #define	RDR_PROC_COUNT(x)			(0x830 + ((x) << 12))
68 #define	RDR_PREP_PNTR(x)			(0x834 + ((x) << 12))
69 #define	RDR_PROC_PNTR(x)			(0x838 + ((x) << 12))
70 #define	RDR_STAT(x)				(0x83C + ((x) << 12))
71 
72 /* HIA, Ring AIC */
73 #define	AIC_POL_CTRL(x)				(0xE000 - ((x) << 12))
74 #define	AIC_TYPE_CTRL(x)			(0xE004 - ((x) << 12))
75 #define	AIC_ENABLE_CTRL(x)			(0xE008 - ((x) << 12))
76 #define	AIC_RAW_STAL(x)				(0xE00C - ((x) << 12))
77 #define	AIC_ENABLE_SET(x)			(0xE00C - ((x) << 12))
78 #define	AIC_ENABLED_STAT(x)			(0xE010 - ((x) << 12))
79 #define	AIC_ACK(x)				(0xE010 - ((x) << 12))
80 #define	AIC_ENABLE_CLR(x)			(0xE014 - ((x) << 12))
81 #define	AIC_OPTIONS(x)				(0xE018 - ((x) << 12))
82 #define	AIC_VERSION(x)				(0xE01C - ((x) << 12))
83 
84 /* HIA, Global AIC */
85 #define	AIC_G_POL_CTRL				0xF800
86 #define	AIC_G_TYPE_CTRL				0xF804
87 #define	AIC_G_ENABLE_CTRL			0xF808
88 #define	AIC_G_RAW_STAT				0xF80C
89 #define	AIC_G_ENABLE_SET			0xF80C
90 #define	AIC_G_ENABLED_STAT			0xF810
91 #define	AIC_G_ACK				0xF810
92 #define	AIC_G_ENABLE_CLR			0xF814
93 #define	AIC_G_OPTIONS				0xF818
94 #define	AIC_G_VERSION				0xF81C
95 
96 /* HIA, Data Fetch Engine */
97 #define	DFE_CFG					0xF000
98 #define	DFE_PRIO_0				0xF010
99 #define	DFE_PRIO_1				0xF014
100 #define	DFE_PRIO_2				0xF018
101 #define	DFE_PRIO_3				0xF01C
102 
103 /* HIA, Data Fetch Engine access monitoring for CDR */
104 #define	DFE_RING_REGION_LO(x)			(0xF080 + ((x) << 3))
105 #define	DFE_RING_REGION_HI(x)			(0xF084 + ((x) << 3))
106 
107 /* HIA, Data Fetch Engine thread control and status for thread */
108 #define	DFE_THR_CTRL				0xF200
109 #define	DFE_THR_STAT				0xF204
110 #define	DFE_THR_DESC_CTRL			0xF208
111 #define	DFE_THR_DESC_DPTR_LO			0xF210
112 #define	DFE_THR_DESC_DPTR_HI			0xF214
113 #define	DFE_THR_DESC_ACDPTR_LO			0xF218
114 #define	DFE_THR_DESC_ACDPTR_HI			0xF21C
115 
116 /* HIA, Data Store Engine */
117 #define	DSE_CFG					0xF400
118 #define	DSE_PRIO_0				0xF410
119 #define	DSE_PRIO_1				0xF414
120 #define	DSE_PRIO_2				0xF418
121 #define	DSE_PRIO_3				0xF41C
122 
123 /* HIA, Data Store Engine access monitoring for RDR */
124 #define	DSE_RING_REGION_LO(x)			(0xF480 + ((x) << 3))
125 #define	DSE_RING_REGION_HI(x)			(0xF484 + ((x) << 3))
126 
127 /* HIA, Data Store Engine thread control and status for thread */
128 #define	DSE_THR_CTRL				0xF600
129 #define	DSE_THR_STAT				0xF604
130 #define	DSE_THR_DESC_CTRL			0xF608
131 #define	DSE_THR_DESC_DPTR_LO			0xF610
132 #define	DSE_THR_DESC_DPTR_HI			0xF614
133 #define	DSE_THR_DESC_S_DPTR_LO			0xF618
134 #define	DSE_THR_DESC_S_DPTR_HI			0xF61C
135 #define	DSE_THR_ERROR_STAT			0xF620
136 
137 /* HIA Global */
138 #define	HIA_MST_CTRL				0xFFF4
139 #define	HIA_OPTIONS				0xFFF8
140 #define	HIA_VERSION				0xFFFC
141 
142 /* Processing Engine Input Side, Processing Engine */
143 #define	PE_IN_DBUF_THRESH			0x10000
144 #define	PE_IN_TBUF_THRESH			0x10100
145 
146 /* Packet Engine Configuration / Status Registers */
147 #define	PE_TOKEN_CTRL_STAT			0x11000
148 #define	PE_FUNCTION_EN				0x11004
149 #define	PE_CONTEXT_CTRL				0x11008
150 #define	PE_INTERRUPT_CTRL_STAT			0x11010
151 #define	PE_CONTEXT_STAT				0x1100C
152 #define	PE_OUT_TRANS_CTRL_STAT			0x11018
153 #define	PE_OUT_BUF_CTRL				0x1101C
154 
155 /* Packet Engine AIC */
156 #define	PE_EIP96_AIC_POL_CTRL			0x113C0
157 #define	PE_EIP96_AIC_TYPE_CTRL			0x113C4
158 #define	PE_EIP96_AIC_ENABLE_CTRL		0x113C8
159 #define	PE_EIP96_AIC_RAW_STAT			0x113CC
160 #define	PE_EIP96_AIC_ENABLE_SET			0x113CC
161 #define	PE_EIP96_AIC_ENABLED_STAT		0x113D0
162 #define	PE_EIP96_AIC_ACK			0x113D0
163 #define	PE_EIP96_AIC_ENABLE_CLR			0x113D4
164 #define	PE_EIP96_AIC_OPTIONS			0x113D8
165 #define	PE_EIP96_AIC_VERSION			0x113DC
166 
167 /* Packet Engine Options & Version Registers */
168 #define	PE_EIP96_OPTIONS			0x113F8
169 #define	PE_EIP96_VERSION			0x113FC
170 
171 #define	SAFEXCEL_OPT
172 
173 /* Processing Engine Output Side */
174 #define	PE_OUT_DBUF_THRESH			0x11C00
175 #define	PE_OUT_TBUF_THRESH			0x11D00
176 
177 /* Processing Engine Local AIC */
178 #define	PE_AIC_POL_CTRL				0x11F00
179 #define	PE_AIC_TYPE_CTRL			0x11F04
180 #define	PE_AIC_ENABLE_CTRL			0x11F08
181 #define	PE_AIC_RAW_STAT				0x11F0C
182 #define	PE_AIC_ENABLE_SET			0x11F0C
183 #define	PE_AIC_ENABLED_STAT			0x11F10
184 #define	PE_AIC_ENABLE_CLR			0x11F14
185 #define	PE_AIC_OPTIONS				0x11F18
186 #define	PE_AIC_VERSION				0x11F1C
187 
188 /* Processing Engine General Configuration and Version */
189 #define	PE_IN_FLIGHT				0x11FF0
190 #define	PE_OPTIONS				0x11FF8
191 #define	PE_VERSION				0x11FFC
192 
193 /* EIP-97 - Global */
194 #define	EIP97_CLOCK_STATE			0x1FFE4
195 #define	EIP97_FORCE_CLOCK_ON			0x1FFE8
196 #define	EIP97_FORCE_CLOCK_OFF			0x1FFEC
197 #define	EIP97_MST_CTRL				0x1FFF4
198 #define	EIP97_OPTIONS				0x1FFF8
199 #define	EIP97_VERSION				0x1FFFC
200 
201 /* Register base offsets */
202 #define	SAFEXCEL_HIA_AIC(_sc)			((_sc)->sc_offsets.hia_aic)
203 #define	SAFEXCEL_HIA_AIC_G(_sc)			((_sc)->sc_offsets.hia_aic_g)
204 #define	SAFEXCEL_HIA_AIC_R(_sc)			((_sc)->sc_offsets.hia_aic_r)
205 #define	SAFEXCEL_HIA_AIC_xDR(_sc)		((_sc)->sc_offsets.hia_aic_xdr)
206 #define	SAFEXCEL_HIA_DFE(_sc)			((_sc)->sc_offsets.hia_dfe)
207 #define	SAFEXCEL_HIA_DFE_THR(_sc)		((_sc)->sc_offsets.hia_dfe_thr)
208 #define	SAFEXCEL_HIA_DSE(_sc)			((_sc)->sc_offsets.hia_dse)
209 #define	SAFEXCEL_HIA_DSE_THR(_sc)		((_sc)->sc_offsets.hia_dse_thr)
210 #define	SAFEXCEL_HIA_GEN_CFG(_sc)		((_sc)->sc_offsets.hia_gen_cfg)
211 #define	SAFEXCEL_PE(_sc)			((_sc)->sc_offsets.pe)
212 
213 /* EIP197 base offsets */
214 #define	SAFEXCEL_EIP197_HIA_AIC_BASE		0x90000
215 #define	SAFEXCEL_EIP197_HIA_AIC_G_BASE		0x90000
216 #define	SAFEXCEL_EIP197_HIA_AIC_R_BASE		0x90800
217 #define	SAFEXCEL_EIP197_HIA_AIC_xDR_BASE	0x80000
218 #define	SAFEXCEL_EIP197_HIA_DFE_BASE		0x8c000
219 #define	SAFEXCEL_EIP197_HIA_DFE_THR_BASE	0x8c040
220 #define	SAFEXCEL_EIP197_HIA_DSE_BASE		0x8d000
221 #define	SAFEXCEL_EIP197_HIA_DSE_THR_BASE	0x8d040
222 #define	SAFEXCEL_EIP197_HIA_GEN_CFG_BASE	0xf0000
223 #define	SAFEXCEL_EIP197_PE_BASE			0xa0000
224 
225 /* EIP97 base offsets */
226 #define	SAFEXCEL_EIP97_HIA_AIC_BASE		0x0
227 #define	SAFEXCEL_EIP97_HIA_AIC_G_BASE		0x0
228 #define	SAFEXCEL_EIP97_HIA_AIC_R_BASE		0x0
229 #define	SAFEXCEL_EIP97_HIA_AIC_xDR_BASE		0x0
230 #define	SAFEXCEL_EIP97_HIA_DFE_BASE		0xf000
231 #define	SAFEXCEL_EIP97_HIA_DFE_THR_BASE		0xf200
232 #define	SAFEXCEL_EIP97_HIA_DSE_BASE		0xf400
233 #define	SAFEXCEL_EIP97_HIA_DSE_THR_BASE		0xf600
234 #define	SAFEXCEL_EIP97_HIA_GEN_CFG_BASE		0x10000
235 #define	SAFEXCEL_EIP97_PE_BASE			0x10000
236 
237 /* CDR/RDR register offsets */
238 #define	SAFEXCEL_HIA_xDR_OFF(priv, r)		(SAFEXCEL_HIA_AIC_xDR(priv) + (r) * 0x1000)
239 #define	SAFEXCEL_HIA_CDR(priv, r)		(SAFEXCEL_HIA_xDR_OFF(priv, r))
240 #define	SAFEXCEL_HIA_RDR(priv, r)		(SAFEXCEL_HIA_xDR_OFF(priv, r) + 0x800)
241 #define	SAFEXCEL_HIA_xDR_RING_BASE_ADDR_LO	0x0000
242 #define	SAFEXCEL_HIA_xDR_RING_BASE_ADDR_HI	0x0004
243 #define	SAFEXCEL_HIA_xDR_RING_SIZE		0x0018
244 #define	SAFEXCEL_HIA_xDR_DESC_SIZE		0x001c
245 #define	SAFEXCEL_HIA_xDR_CFG			0x0020
246 #define	SAFEXCEL_HIA_xDR_DMA_CFG		0x0024
247 #define	SAFEXCEL_HIA_xDR_THRESH			0x0028
248 #define	SAFEXCEL_HIA_xDR_PREP_COUNT		0x002c
249 #define	SAFEXCEL_HIA_xDR_PROC_COUNT		0x0030
250 #define	SAFEXCEL_HIA_xDR_PREP_PNTR		0x0034
251 #define	SAFEXCEL_HIA_xDR_PROC_PNTR		0x0038
252 #define	SAFEXCEL_HIA_xDR_STAT			0x003c
253 
254 /* register offsets */
255 #define	SAFEXCEL_HIA_DFE_CFG(n)			(0x000 + (128 * (n)))
256 #define	SAFEXCEL_HIA_DFE_THR_CTRL(n)		(0x000 + (128 * (n)))
257 #define	SAFEXCEL_HIA_DFE_THR_STAT(n)		(0x004 + (128 * (n)))
258 #define	SAFEXCEL_HIA_DSE_CFG(n)			(0x000 + (128 * (n)))
259 #define	SAFEXCEL_HIA_DSE_THR_CTRL(n)		(0x000 + (128 * (n)))
260 #define	SAFEXCEL_HIA_DSE_THR_STAT(n)		(0x004 + (128 * (n)))
261 #define	SAFEXCEL_HIA_RA_PE_CTRL(n)		(0x010 + (8 * (n)))
262 #define	SAFEXCEL_HIA_RA_PE_STAT			0x0014
263 #define	SAFEXCEL_HIA_AIC_R_OFF(r)		((r) * 0x1000)
264 #define	SAFEXCEL_HIA_AIC_R_ENABLE_CTRL(r)	(0xe008 - SAFEXCEL_HIA_AIC_R_OFF(r))
265 #define	SAFEXCEL_HIA_AIC_R_ENABLED_STAT(r)	(0xe010 - SAFEXCEL_HIA_AIC_R_OFF(r))
266 #define	SAFEXCEL_HIA_AIC_R_ACK(r)		(0xe010 - SAFEXCEL_HIA_AIC_R_OFF(r))
267 #define	SAFEXCEL_HIA_AIC_R_ENABLE_CLR(r)	(0xe014 - SAFEXCEL_HIA_AIC_R_OFF(r))
268 #define	SAFEXCEL_HIA_AIC_R_VERSION(r)		(0xe01c - SAFEXCEL_HIA_AIC_R_OFF(r))
269 #define	SAFEXCEL_HIA_AIC_G_ENABLE_CTRL		0xf808
270 #define	SAFEXCEL_HIA_AIC_G_ENABLED_STAT		0xf810
271 #define	SAFEXCEL_HIA_AIC_G_ACK			0xf810
272 #define	SAFEXCEL_HIA_MST_CTRL			0xfff4
273 #define	SAFEXCEL_HIA_OPTIONS			0xfff8
274 #define	SAFEXCEL_HIA_VERSION			0xfffc
275 #define	SAFEXCEL_PE_IN_DBUF_THRES(n)		(0x0000 + (0x2000 * (n)))
276 #define	SAFEXCEL_PE_IN_TBUF_THRES(n)		(0x0100 + (0x2000 * (n)))
277 #define	SAFEXCEL_PE_ICE_SCRATCH_RAM(x, n)	((0x800 + (x) * 4) + 0x2000 * (n))
278 #define	SAFEXCEL_PE_ICE_PUE_CTRL(n)		(0xc80 + (0x2000 * (n)))
279 #define	SAFEXCEL_PE_ICE_SCRATCH_CTRL		0x0d04
280 #define	SAFEXCEL_PE_ICE_FPP_CTRL(n)		(0xd80 + (0x2000 * (n)))
281 #define	SAFEXCEL_PE_ICE_RAM_CTRL(n)		(0xff0 + (0x2000 * (n)))
282 #define	SAFEXCEL_PE_EIP96_FUNCTION_EN(n)	(0x1004 + (0x2000 * (n)))
283 #define	SAFEXCEL_PE_EIP96_CONTEXT_CTRL(n)	(0x1008 + (0x2000 * (n)))
284 #define	SAFEXCEL_PE_EIP96_CONTEXT_STAT(n)	(0x100c + (0x2000 * (n)))
285 #define	SAFEXCEL_PE_EIP96_FUNCTION2_EN(n)	(0x1030 + (0x2000 * (n)))
286 #define	SAFEXCEL_PE_OUT_DBUF_THRES(n)		(0x1c00 + (0x2000 * (n)))
287 #define	SAFEXCEL_PE_OUT_TBUF_THRES(n)		(0x1d00 + (0x2000 * (n)))
288 
289 /* EIP-197 Classification Engine */
290 
291 /* Classification regs */
292 #define	SAFEXCEL_CS_RAM_CTRL			0xf7ff0
293 
294 /* SAFEXCEL_HIA_xDR_DESC_SIZE */
295 #define	SAFEXCEL_xDR_DESC_MODE_64BIT		(1U << 31)
296 #define	SAFEXCEL_CDR_DESC_MODE_ADCP		(1 << 30)
297 #define	SAFEXCEL_xDR_DESC_xD_OFFSET		16
298 
299 /* SAFEXCEL_DIA_xDR_CFG */
300 #define	SAFEXCEL_xDR_xD_FETCH_THRESH		16
301 
302 /* SAFEXCEL_HIA_xDR_DMA_CFG */
303 #define	SAFEXCEL_HIA_xDR_WR_RES_BUF		(1 << 22)
304 #define	SAFEXCEL_HIA_xDR_WR_CTRL_BUF		(1 << 23)
305 #define	SAFEXCEL_HIA_xDR_WR_OWN_BUF		(1 << 24)
306 #define	SAFEXCEL_HIA_xDR_CFG_xD_PROT(n)		(((n) & 0xf) << 4)
307 #define	SAFEXCEL_HIA_xDR_CFG_DATA_PROT(n)	(((n) & 0xf) << 12)
308 #define	SAFEXCEL_HIA_xDR_CFG_ACD_PROT(n)	(((n) & 0xf) << 20)
309 #define	SAFEXCEL_HIA_xDR_CFG_WR_CACHE(n)	(((n) & 0x7) << 25)
310 #define	SAFEXCEL_HIA_xDR_CFG_RD_CACHE(n)	(((n) & 0x7) << 29)
311 
312 /* SAFEXCEL_HIA_CDR_THRESH */
313 #define	SAFEXCEL_HIA_CDR_THRESH_PROC_PKT(n)	((n) & 0xffff)
314 #define	SAFEXCEL_HIA_CDR_THRESH_PROC_MODE	(1 << 22)
315 #define	SAFEXCEL_HIA_CDR_THRESH_PKT_MODE	(1 << 23)
316 						/* x256 clk cycles */
317 #define	SAFEXCEL_HIA_CDR_THRESH_TIMEOUT(n)	(((n) & 0xff) << 24)
318 
319 /* SAFEXCEL_HIA_RDR_THRESH */
320 #define	SAFEXCEL_HIA_RDR_THRESH_PROC_PKT(n)	((n) & 0xffff)
321 #define	SAFEXCEL_HIA_RDR_THRESH_PKT_MODE	(1 << 23)
322 						/* x256 clk cycles */
323 #define	SAFEXCEL_HIA_RDR_THRESH_TIMEOUT(n)	(((n) & 0xff) << 24)
324 
325 /* SAFEXCEL_HIA_xDR_PREP_COUNT */
326 #define	SAFEXCEL_xDR_PREP_CLR_COUNT		(1U << 31)
327 #define	SAFEXCEL_xDR_PREP_xD_COUNT_INCR_OFFSET	2
328 #define	SAFEXCEL_xDR_PREP_RD_COUNT_INCR_MASK	0x3fff
329 
330 /* SAFEXCEL_HIA_xDR_PROC_COUNT */
331 #define	SAFEXCEL_xDR_PROC_xD_PKT_OFFSET		24
332 #define	SAFEXCEL_xDR_PROC_xD_PKT_MASK		0x7f
333 #define	SAFEXCEL_xDR_PROC_xD_COUNT(n)		((n) << 2)
334 #define	SAFEXCEL_xDR_PROC_xD_PKT(n)		\
335     (((n) & SAFEXCEL_xDR_PROC_xD_PKT_MASK) << SAFEXCEL_xDR_PROC_xD_PKT_OFFSET)
336 #define	SAFEXCEL_xDR_PROC_CLR_COUNT		(1U << 31)
337 
338 /* SAFEXCEL_HIA_xDR_STAT */
339 #define	SAFEXCEL_xDR_DMA_ERR			(1 << 0)
340 #define	SAFEXCEL_xDR_PREP_CMD_THRES		(1 << 1)
341 #define	SAFEXCEL_xDR_ERR			(1 << 2)
342 #define	SAFEXCEL_xDR_THRESH			(1 << 4)
343 #define	SAFEXCEL_xDR_TIMEOUT			(1 << 5)
344 #define	SAFEXCEL_CDR_INTR_MASK			0x3f
345 #define	SAFEXCEL_RDR_INTR_MASK			0xff
346 
347 #define	SAFEXCEL_HIA_RA_PE_CTRL_RESET		(1U << 31)
348 #define	SAFEXCEL_HIA_RA_PE_CTRL_EN		(1 << 30)
349 
350 /* Register offsets */
351 
352 /* SAFEXCEL_HIA_DSE_THR_STAT */
353 #define	SAFEXCEL_DSE_THR_RDR_ID_MASK		0xf000
354 
355 /* SAFEXCEL_HIA_OPTIONS */
356 #define	SAFEXCEL_OPT_ADDR_64			(1U << 31)
357 #define	SAFEXCEL_OPT_TGT_ALIGN_OFFSET		28
358 #define	SAFEXCEL_OPT_TGT_ALIGN_MASK		0x70000000
359 #define	SAFEXCEL_xDR_HDW_OFFSET			25
360 #define	SAFEXCEL_xDR_HDW_MASK			0x6000000
361 #define	SAFEXCEL_N_RINGS_MASK			0xf
362 #define	SAFEXCEL_N_PES_OFFSET			4
363 #define	SAFEXCEL_N_PES_MASK			0x1f0
364 #define	EIP97_N_PES_MASK			0x70
365 
366 /* SAFEXCEL_HIA_AIC_R_ENABLE_CTRL */
367 #define	SAFEXCEL_CDR_IRQ(n)			(1 << ((n) * 2))
368 #define	SAFEXCEL_RDR_IRQ(n)			(1 << ((n) * 2 + 1))
369 
370 /* SAFEXCEL_HIA_DFE/DSE_CFG */
371 #define	SAFEXCEL_HIA_DxE_CFG_MIN_DATA_SIZE(n)	((n) << 0)
372 #define	SAFEXCEL_HIA_DxE_CFG_DATA_CACHE_CTRL(n)	(((n) & 0x7) << 4)
373 #define	SAFEXCEL_HIA_DxE_CFG_MAX_DATA_SIZE(n)	((n) << 8)
374 #define	SAFEXCEL_HIA_DSE_CFG_ALLWAYS_BUFFERABLE	0xc000
375 #define	SAFEXCEL_HIA_DxE_CFG_MIN_CTRL_SIZE(n)	((n) << 16)
376 #define	SAFEXCEL_HIA_DxE_CFG_CTRL_CACHE_CTRL(n)	(((n) & 0x7) << 20)
377 #define	SAFEXCEL_HIA_DxE_CFG_MAX_CTRL_SIZE(n)	((n) << 24)
378 #define	SAFEXCEL_HIA_DFE_CFG_DIS_DEBUG		0xe0000000
379 #define	SAFEXCEL_HIA_DSE_CFG_EN_SINGLE_WR	(1 << 29)
380 #define	SAFEXCEL_HIA_DSE_CFG_DIS_DEBUG		0xc0000000
381 
382 /* SAFEXCEL_HIA_DFE/DSE_THR_CTRL */
383 #define	SAFEXCEL_DxE_THR_CTRL_EN		(1 << 30)
384 #define	SAFEXCEL_DxE_THR_CTRL_RESET_PE		(1U << 31)
385 
386 /* SAFEXCEL_HIA_AIC_G_ENABLED_STAT */
387 #define	SAFEXCEL_G_IRQ_DFE(n)			(1 << ((n) << 1))
388 #define	SAFEXCEL_G_IRQ_DSE(n)			(1 << (((n) << 1) + 1))
389 #define	SAFEXCEL_G_IRQ_RING			(1 << 16)
390 #define	SAFEXCEL_G_IRQ_PE(n)			(1 << ((n) + 20))
391 
392 /* SAFEXCEL_HIA_MST_CTRL */
393 #define	RD_CACHE_3BITS				0x5U
394 #define	WR_CACHE_3BITS				0x3U
395 #define	RD_CACHE_4BITS				(RD_CACHE_3BITS << 1 | (1 << 0))
396 #define	WR_CACHE_4BITS				(WR_CACHE_3BITS << 1 | (1 << 0))
397 #define	SAFEXCEL_MST_CTRL_RD_CACHE(n)		(((n) & 0xf) << 0)
398 #define	SAFEXCEL_MST_CTRL_WD_CACHE(n)		(((n) & 0xf) << 4)
399 #define	MST_CTRL_SUPPORT_PROT(n)		(((n) & 0xf) << 12)
400 #define	SAFEXCEL_MST_CTRL_BYTE_SWAP		(1 << 24)
401 #define	SAFEXCEL_MST_CTRL_NO_BYTE_SWAP		(1 << 25)
402 
403 /* SAFEXCEL_PE_IN_DBUF/TBUF_THRES */
404 #define	SAFEXCEL_PE_IN_xBUF_THRES_MIN(n)	((n) << 8)
405 #define	SAFEXCEL_PE_IN_xBUF_THRES_MAX(n)	((n) << 12)
406 
407 /* SAFEXCEL_PE_OUT_DBUF_THRES */
408 #define	SAFEXCEL_PE_OUT_DBUF_THRES_MIN(n)	((n) << 0)
409 #define	SAFEXCEL_PE_OUT_DBUF_THRES_MAX(n)	((n) << 4)
410 
411 /* SAFEXCEL_HIA_AIC_G_ACK */
412 #define	SAFEXCEL_AIC_G_ACK_ALL_MASK		0xffffffff
413 #define	SAFEXCEL_AIC_G_ACK_HIA_MASK		0x7ff00000
414 
415 /* SAFEXCEL_HIA_AIC_R_ENABLE_CLR */
416 #define	SAFEXCEL_HIA_AIC_R_ENABLE_CLR_ALL_MASK	0xffffffff
417 
418 /* SAFEXCEL_PE_EIP96_CONTEXT_CTRL */
419 #define	SAFEXCEL_CONTEXT_SIZE(n)		(n)
420 #define	SAFEXCEL_ADDRESS_MODE			(1 << 8)
421 #define	SAFEXCEL_CONTROL_MODE			(1 << 9)
422 
423 /* SAFEXCEL_PE_EIP96_FUNCTION_EN */
424 #define	SAFEXCEL_FUNCTION_RSVD			((1U << 6) | (1U << 15) | (1U << 20) | (1U << 23))
425 #define	SAFEXCEL_PROTOCOL_HASH_ONLY		(1U << 0)
426 #define	SAFEXCEL_PROTOCOL_ENCRYPT_ONLY		(1U << 1)
427 #define	SAFEXCEL_PROTOCOL_HASH_ENCRYPT		(1U << 2)
428 #define	SAFEXCEL_PROTOCOL_HASH_DECRYPT		(1U << 3)
429 #define	SAFEXCEL_PROTOCOL_ENCRYPT_HASH		(1U << 4)
430 #define	SAFEXCEL_PROTOCOL_DECRYPT_HASH		(1U << 5)
431 #define	SAFEXCEL_ALG_ARC4			(1U << 7)
432 #define	SAFEXCEL_ALG_AES_ECB			(1U << 8)
433 #define	SAFEXCEL_ALG_AES_CBC			(1U << 9)
434 #define	SAFEXCEL_ALG_AES_CTR_ICM		(1U << 10)
435 #define	SAFEXCEL_ALG_AES_OFB			(1U << 11)
436 #define	SAFEXCEL_ALG_AES_CFB			(1U << 12)
437 #define	SAFEXCEL_ALG_DES_ECB			(1U << 13)
438 #define	SAFEXCEL_ALG_DES_CBC			(1U << 14)
439 #define	SAFEXCEL_ALG_DES_OFB			(1U << 16)
440 #define	SAFEXCEL_ALG_DES_CFB			(1U << 17)
441 #define	SAFEXCEL_ALG_3DES_ECB			(1U << 18)
442 #define	SAFEXCEL_ALG_3DES_CBC			(1U << 19)
443 #define	SAFEXCEL_ALG_3DES_OFB			(1U << 21)
444 #define	SAFEXCEL_ALG_3DES_CFB			(1U << 22)
445 #define	SAFEXCEL_ALG_MD5			(1U << 24)
446 #define	SAFEXCEL_ALG_HMAC_MD5			(1U << 25)
447 #define	SAFEXCEL_ALG_SHA1			(1U << 26)
448 #define	SAFEXCEL_ALG_HMAC_SHA1			(1U << 27)
449 #define	SAFEXCEL_ALG_SHA2			(1U << 28)
450 #define	SAFEXCEL_ALG_HMAC_SHA2			(1U << 29)
451 #define	SAFEXCEL_ALG_AES_XCBC_MAC		(1U << 30)
452 #define	SAFEXCEL_ALG_GCM_HASH			(1U << 31)
453 
454 #endif /* _SAFEXCEL_REGS_H_ */
455