xref: /dragonfly/sys/dev/crypto/hifn/hifn7751reg.h (revision 36a3d1d6)
1 /* $FreeBSD: src/sys/dev/hifn/hifn7751reg.h,v 1.1.2.1 2002/11/21 23:37:11 sam Exp $ */
2 /* $DragonFly: src/sys/dev/crypto/hifn/hifn7751reg.h,v 1.3 2007/12/04 09:11:12 hasso Exp $ */
3 /*	$OpenBSD: hifn7751reg.h,v 1.35 2002/04/08 17:49:42 jason Exp $	*/
4 
5 /*-
6  * Invertex AEON / Hifn 7751 driver
7  * Copyright (c) 1999 Invertex Inc. All rights reserved.
8  * Copyright (c) 1999 Theo de Raadt
9  * Copyright (c) 2000-2001 Network Security Technologies, Inc.
10  *			http://www.netsec.net
11  *
12  * Please send any comments, feedback, bug-fixes, or feature requests to
13  * software@invertex.com.
14  *
15  * Redistribution and use in source and binary forms, with or without
16  * modification, are permitted provided that the following conditions
17  * are met:
18  *
19  * 1. Redistributions of source code must retain the above copyright
20  *    notice, this list of conditions and the following disclaimer.
21  * 2. Redistributions in binary form must reproduce the above copyright
22  *    notice, this list of conditions and the following disclaimer in the
23  *    documentation and/or other materials provided with the distribution.
24  * 3. The name of the author may not be used to endorse or promote products
25  *    derived from this software without specific prior written permission.
26  *
27  *
28  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
29  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
30  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
31  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
32  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
33  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
37  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38  *
39  * Effort sponsored in part by the Defense Advanced Research Projects
40  * Agency (DARPA) and Air Force Research Laboratory, Air Force
41  * Materiel Command, USAF, under agreement number F30602-01-2-0537.
42  *
43  */
44 #ifndef __HIFN_H__
45 #define	__HIFN_H__
46 
47 #include <sys/endian.h>
48 
49 /*
50  * Some PCI configuration space offset defines.  The names were made
51  * identical to the names used by the Linux kernel.
52  */
53 #ifdef notyet
54 #define	HIFN_BAR0		(PCIR_MAPS+0x0)	/* PUC register map */
55 #define	HIFN_BAR1		(PCIR_MAPS+0x4)	/* DMA register map */
56 #else
57 #define	HIFN_BAR0		PCIR_BAR(0)	/* PUC register map */
58 #define	HIFN_BAR1		PCIR_BAR(1)	/* DMA register map */
59 #endif
60 #define	HIFN_TRDY_TIMEOUT	0x40
61 #define	HIFN_RETRY_TIMEOUT	0x41
62 
63 /*
64  * PCI vendor and device identifiers
65  * (the names are preserved from their OpenBSD source).
66  */
67 #define	PCI_VENDOR_HIFN		0x13a3		/* Hifn */
68 #define	PCI_PRODUCT_HIFN_7751	0x0005		/* 7751 */
69 #define	PCI_PRODUCT_HIFN_6500	0x0006		/* 6500 */
70 #define	PCI_PRODUCT_HIFN_7811	0x0007		/* 7811 */
71 #define	PCI_PRODUCT_HIFN_7951	0x0012		/* 7951 */
72 #define	PCI_PRODUCT_HIFN_7955	0x0020		/* 7954/7955 */
73 #define	PCI_PRODUCT_HIFN_7956	0x001d		/* 7956 */
74 
75 #define	PCI_VENDOR_INVERTEX	0x14e1		/* Invertex */
76 #define	PCI_PRODUCT_INVERTEX_AEON 0x0005	/* AEON */
77 
78 #define	PCI_VENDOR_NETSEC	0x1660		/* NetSec */
79 #define	PCI_PRODUCT_NETSEC_7751	0x7751		/* 7751 */
80 
81 /*
82  * The values below should multiple of 4 -- and be large enough to handle
83  * any command the driver implements.
84  *
85  * MAX_COMMAND = base command + mac command + encrypt command +
86  *			mac-key + rc4-key
87  * MAX_RESULT  = base result + mac result + mac + encrypt result
88  *
89  *
90  */
91 #define	HIFN_MAX_COMMAND	(8 + 8 + 8 + 64 + 260)
92 #define	HIFN_MAX_RESULT		(8 + 4 + 20 + 4)
93 
94 /*
95  * hifn_desc_t
96  *
97  * Holds an individual descriptor for any of the rings.
98  */
99 typedef struct hifn_desc {
100 	volatile u_int32_t l;		/* length and status bits */
101 	volatile u_int32_t p;
102 } hifn_desc_t;
103 
104 /*
105  * Masks for the "length" field of struct hifn_desc.
106  */
107 #define	HIFN_D_LENGTH		0x0000ffff	/* length bit mask */
108 #define	HIFN_D_MASKDONEIRQ	0x02000000	/* mask the done interrupt */
109 #define	HIFN_D_DESTOVER		0x04000000	/* destination overflow */
110 #define	HIFN_D_OVER		0x08000000	/* overflow */
111 #define	HIFN_D_LAST		0x20000000	/* last descriptor in chain */
112 #define	HIFN_D_JUMP		0x40000000	/* jump descriptor */
113 #define	HIFN_D_VALID		0x80000000	/* valid bit */
114 
115 
116 /*
117  * Processing Unit Registers (offset from BASEREG0)
118  */
119 #define	HIFN_0_PUDATA		0x00	/* Processing Unit Data */
120 #define	HIFN_0_PUCTRL		0x04	/* Processing Unit Control */
121 #define	HIFN_0_PUISR		0x08	/* Processing Unit Interrupt Status */
122 #define	HIFN_0_PUCNFG		0x0c	/* Processing Unit Configuration */
123 #define	HIFN_0_PUIER		0x10	/* Processing Unit Interrupt Enable */
124 #define	HIFN_0_PUSTAT		0x14	/* Processing Unit Status/Chip ID */
125 #define	HIFN_0_FIFOSTAT		0x18	/* FIFO Status */
126 #define	HIFN_0_FIFOCNFG		0x1c	/* FIFO Configuration */
127 #define	HIFN_0_PUCTRL2		0x28	/* Processing Unit Control (2nd map) */
128 #define	HIFN_0_SPACESIZE	0x20	/* Register space size */
129 
130 /* Processing Unit Control Register (HIFN_0_PUCTRL) */
131 #define	HIFN_PUCTRL_CLRSRCFIFO	0x0010	/* clear source fifo */
132 #define	HIFN_PUCTRL_STOP	0x0008	/* stop pu */
133 #define	HIFN_PUCTRL_LOCKRAM	0x0004	/* lock ram */
134 #define	HIFN_PUCTRL_DMAENA	0x0002	/* enable dma */
135 #define	HIFN_PUCTRL_RESET	0x0001	/* Reset processing unit */
136 
137 /* Processing Unit Interrupt Status Register (HIFN_0_PUISR) */
138 #define	HIFN_PUISR_CMDINVAL	0x8000	/* Invalid command interrupt */
139 #define	HIFN_PUISR_DATAERR	0x4000	/* Data error interrupt */
140 #define	HIFN_PUISR_SRCFIFO	0x2000	/* Source FIFO ready interrupt */
141 #define	HIFN_PUISR_DSTFIFO	0x1000	/* Destination FIFO ready interrupt */
142 #define	HIFN_PUISR_DSTOVER	0x0200	/* Destination overrun interrupt */
143 #define	HIFN_PUISR_SRCCMD	0x0080	/* Source command interrupt */
144 #define	HIFN_PUISR_SRCCTX	0x0040	/* Source context interrupt */
145 #define	HIFN_PUISR_SRCDATA	0x0020	/* Source data interrupt */
146 #define	HIFN_PUISR_DSTDATA	0x0010	/* Destination data interrupt */
147 #define	HIFN_PUISR_DSTRESULT	0x0004	/* Destination result interrupt */
148 
149 /* Processing Unit Configuration Register (HIFN_0_PUCNFG) */
150 #define	HIFN_PUCNFG_DRAMMASK	0xe000	/* DRAM size mask */
151 #define	HIFN_PUCNFG_DSZ_256K	0x0000	/* 256k dram */
152 #define	HIFN_PUCNFG_DSZ_512K	0x2000	/* 512k dram */
153 #define	HIFN_PUCNFG_DSZ_1M	0x4000	/* 1m dram */
154 #define	HIFN_PUCNFG_DSZ_2M	0x6000	/* 2m dram */
155 #define	HIFN_PUCNFG_DSZ_4M	0x8000	/* 4m dram */
156 #define	HIFN_PUCNFG_DSZ_8M	0xa000	/* 8m dram */
157 #define	HIFN_PUNCFG_DSZ_16M	0xc000	/* 16m dram */
158 #define	HIFN_PUCNFG_DSZ_32M	0xe000	/* 32m dram */
159 #define	HIFN_PUCNFG_DRAMREFRESH	0x1800	/* DRAM refresh rate mask */
160 #define	HIFN_PUCNFG_DRFR_512	0x0000	/* 512 divisor of ECLK */
161 #define	HIFN_PUCNFG_DRFR_256	0x0800	/* 256 divisor of ECLK */
162 #define	HIFN_PUCNFG_DRFR_128	0x1000	/* 128 divisor of ECLK */
163 #define	HIFN_PUCNFG_TCALLPHASES	0x0200	/* your guess is as good as mine... */
164 #define	HIFN_PUCNFG_TCDRVTOTEM	0x0100	/* your guess is as good as mine... */
165 #define	HIFN_PUCNFG_BIGENDIAN	0x0080	/* DMA big endian mode */
166 #define	HIFN_PUCNFG_BUS32	0x0040	/* Bus width 32bits */
167 #define	HIFN_PUCNFG_BUS16	0x0000	/* Bus width 16 bits */
168 #define	HIFN_PUCNFG_CHIPID	0x0020	/* Allow chipid from PUSTAT */
169 #define	HIFN_PUCNFG_DRAM	0x0010	/* Context RAM is DRAM */
170 #define	HIFN_PUCNFG_SRAM	0x0000	/* Context RAM is SRAM */
171 #define	HIFN_PUCNFG_COMPSING	0x0004	/* Enable single compression context */
172 #define	HIFN_PUCNFG_ENCCNFG	0x0002	/* Encryption configuration */
173 
174 /* Processing Unit Interrupt Enable Register (HIFN_0_PUIER) */
175 #define	HIFN_PUIER_CMDINVAL	0x8000	/* Invalid command interrupt */
176 #define	HIFN_PUIER_DATAERR	0x4000	/* Data error interrupt */
177 #define	HIFN_PUIER_SRCFIFO	0x2000	/* Source FIFO ready interrupt */
178 #define	HIFN_PUIER_DSTFIFO	0x1000	/* Destination FIFO ready interrupt */
179 #define	HIFN_PUIER_DSTOVER	0x0200	/* Destination overrun interrupt */
180 #define	HIFN_PUIER_SRCCMD	0x0080	/* Source command interrupt */
181 #define	HIFN_PUIER_SRCCTX	0x0040	/* Source context interrupt */
182 #define	HIFN_PUIER_SRCDATA	0x0020	/* Source data interrupt */
183 #define	HIFN_PUIER_DSTDATA	0x0010	/* Destination data interrupt */
184 #define	HIFN_PUIER_DSTRESULT	0x0004	/* Destination result interrupt */
185 
186 /* Processing Unit Status Register/Chip ID (HIFN_0_PUSTAT) */
187 #define	HIFN_PUSTAT_CMDINVAL	0x8000	/* Invalid command interrupt */
188 #define	HIFN_PUSTAT_DATAERR	0x4000	/* Data error interrupt */
189 #define	HIFN_PUSTAT_SRCFIFO	0x2000	/* Source FIFO ready interrupt */
190 #define	HIFN_PUSTAT_DSTFIFO	0x1000	/* Destination FIFO ready interrupt */
191 #define	HIFN_PUSTAT_DSTOVER	0x0200	/* Destination overrun interrupt */
192 #define	HIFN_PUSTAT_SRCCMD	0x0080	/* Source command interrupt */
193 #define	HIFN_PUSTAT_SRCCTX	0x0040	/* Source context interrupt */
194 #define	HIFN_PUSTAT_SRCDATA	0x0020	/* Source data interrupt */
195 #define	HIFN_PUSTAT_DSTDATA	0x0010	/* Destination data interrupt */
196 #define	HIFN_PUSTAT_DSTRESULT	0x0004	/* Destination result interrupt */
197 #define	HIFN_PUSTAT_CHIPREV	0x00ff	/* Chip revision mask */
198 #define	HIFN_PUSTAT_CHIPENA	0xff00	/* Chip enabled mask */
199 #define	HIFN_PUSTAT_ENA_2	0x1100	/* Level 2 enabled */
200 #define	HIFN_PUSTAT_ENA_1	0x1000	/* Level 1 enabled */
201 #define	HIFN_PUSTAT_ENA_0	0x3000	/* Level 0 enabled */
202 #define	HIFN_PUSTAT_REV_2	0x0020	/* 7751 PT6/2 */
203 #define	HIFN_PUSTAT_REV_3	0x0030	/* 7751 PT6/3 */
204 
205 /* FIFO Status Register (HIFN_0_FIFOSTAT) */
206 #define	HIFN_FIFOSTAT_SRC	0x7f00	/* Source FIFO available */
207 #define	HIFN_FIFOSTAT_DST	0x007f	/* Destination FIFO available */
208 
209 /* FIFO Configuration Register (HIFN_0_FIFOCNFG) */
210 #define	HIFN_FIFOCNFG_THRESHOLD	0x0400	/* must be written as 1 */
211 
212 /*
213  * DMA Interface Registers (offset from BASEREG1)
214  */
215 #define	HIFN_1_DMA_CRAR		0x0c	/* DMA Command Ring Address */
216 #define	HIFN_1_DMA_SRAR		0x1c	/* DMA Source Ring Address */
217 #define	HIFN_1_DMA_RRAR		0x2c	/* DMA Result Ring Address */
218 #define	HIFN_1_DMA_DRAR		0x3c	/* DMA Destination Ring Address */
219 #define	HIFN_1_DMA_CSR		0x40	/* DMA Status and Control */
220 #define	HIFN_1_DMA_IER		0x44	/* DMA Interrupt Enable */
221 #define	HIFN_1_DMA_CNFG		0x48	/* DMA Configuration */
222 #define	HIFN_1_PLL		0x4c	/* 7955/7956: PLL config */
223 #define	HIFN_1_7811_RNGENA	0x60	/* 7811: rng enable */
224 #define	HIFN_1_7811_RNGCFG	0x64	/* 7811: rng config */
225 #define	HIFN_1_7811_RNGDAT	0x68	/* 7811: rng data */
226 #define	HIFN_1_7811_RNGSTS	0x6c	/* 7811: rng status */
227 #define	HIFN_1_DMA_CNFG2	0x6c	/* 7955/7956: dma config #2 */
228 #define	HIFN_1_7811_MIPSRST	0x94	/* 7811: MIPS reset */
229 #define	HIFN_1_REVID		0x98	/* Revision ID */
230 
231 #define	HIFN_1_PUB_RESET	0x204	/* Public/RNG Reset */
232 #define	HIFN_1_PUB_BASE		0x300	/* Public Base Address */
233 #define	HIFN_1_PUB_OPLEN	0x304	/* Public Operand Length */
234 #define	HIFN_1_PUB_OP		0x308	/* Public Operand */
235 #define	HIFN_1_PUB_STATUS	0x30c	/* Public Status */
236 #define	HIFN_1_PUB_IEN		0x310	/* Public Interrupt nable */
237 #define	HIFN_1_RNG_CONFIG	0x314	/* RNG config */
238 #define	HIFN_1_RNG_DATA		0x318	/* RNG data */
239 #define	HIFN_1_PUB_MEM		0x400	/* start of Public key memory */
240 #define	HIFN_1_PUB_MEMEND	0xbff	/* end of Public key memory */
241 
242 /* DMA Status and Control Register (HIFN_1_DMA_CSR) */
243 #define	HIFN_DMACSR_D_CTRLMASK	0xc0000000	/* Destinition Ring Control */
244 #define	HIFN_DMACSR_D_CTRL_NOP	0x00000000	/* Dest. Control: no-op */
245 #define	HIFN_DMACSR_D_CTRL_DIS	0x40000000	/* Dest. Control: disable */
246 #define	HIFN_DMACSR_D_CTRL_ENA	0x80000000	/* Dest. Control: enable */
247 #define	HIFN_DMACSR_D_ABORT	0x20000000	/* Destinition Ring PCIAbort */
248 #define	HIFN_DMACSR_D_DONE	0x10000000	/* Destinition Ring Done */
249 #define	HIFN_DMACSR_D_LAST	0x08000000	/* Destinition Ring Last */
250 #define	HIFN_DMACSR_D_WAIT	0x04000000	/* Destinition Ring Waiting */
251 #define	HIFN_DMACSR_D_OVER	0x02000000	/* Destinition Ring Overflow */
252 #define	HIFN_DMACSR_R_CTRL	0x00c00000	/* Result Ring Control */
253 #define	HIFN_DMACSR_R_CTRL_NOP	0x00000000	/* Result Control: no-op */
254 #define	HIFN_DMACSR_R_CTRL_DIS	0x00400000	/* Result Control: disable */
255 #define	HIFN_DMACSR_R_CTRL_ENA	0x00800000	/* Result Control: enable */
256 #define	HIFN_DMACSR_R_ABORT	0x00200000	/* Result Ring PCI Abort */
257 #define	HIFN_DMACSR_R_DONE	0x00100000	/* Result Ring Done */
258 #define	HIFN_DMACSR_R_LAST	0x00080000	/* Result Ring Last */
259 #define	HIFN_DMACSR_R_WAIT	0x00040000	/* Result Ring Waiting */
260 #define	HIFN_DMACSR_R_OVER	0x00020000	/* Result Ring Overflow */
261 #define	HIFN_DMACSR_S_CTRL	0x0000c000	/* Source Ring Control */
262 #define	HIFN_DMACSR_S_CTRL_NOP	0x00000000	/* Source Control: no-op */
263 #define	HIFN_DMACSR_S_CTRL_DIS	0x00004000	/* Source Control: disable */
264 #define	HIFN_DMACSR_S_CTRL_ENA	0x00008000	/* Source Control: enable */
265 #define	HIFN_DMACSR_S_ABORT	0x00002000	/* Source Ring PCI Abort */
266 #define	HIFN_DMACSR_S_DONE	0x00001000	/* Source Ring Done */
267 #define	HIFN_DMACSR_S_LAST	0x00000800	/* Source Ring Last */
268 #define	HIFN_DMACSR_S_WAIT	0x00000400	/* Source Ring Waiting */
269 #define	HIFN_DMACSR_ILLW	0x00000200	/* Illegal write (7811 only) */
270 #define	HIFN_DMACSR_ILLR	0x00000100	/* Illegal read (7811 only) */
271 #define	HIFN_DMACSR_C_CTRL	0x000000c0	/* Command Ring Control */
272 #define	HIFN_DMACSR_C_CTRL_NOP	0x00000000	/* Command Control: no-op */
273 #define	HIFN_DMACSR_C_CTRL_DIS	0x00000040	/* Command Control: disable */
274 #define	HIFN_DMACSR_C_CTRL_ENA	0x00000080	/* Command Control: enable */
275 #define	HIFN_DMACSR_C_ABORT	0x00000020	/* Command Ring PCI Abort */
276 #define	HIFN_DMACSR_C_DONE	0x00000010	/* Command Ring Done */
277 #define	HIFN_DMACSR_C_LAST	0x00000008	/* Command Ring Last */
278 #define	HIFN_DMACSR_C_WAIT	0x00000004	/* Command Ring Waiting */
279 #define	HIFN_DMACSR_PUBDONE	0x00000002	/* Public op done (7951 only) */
280 #define	HIFN_DMACSR_ENGINE	0x00000001	/* Command Ring Engine IRQ */
281 
282 /* DMA Interrupt Enable Register (HIFN_1_DMA_IER) */
283 #define	HIFN_DMAIER_D_ABORT	0x20000000	/* Destination Ring PCIAbort */
284 #define	HIFN_DMAIER_D_DONE	0x10000000	/* Destination Ring Done */
285 #define	HIFN_DMAIER_D_LAST	0x08000000	/* Destination Ring Last */
286 #define	HIFN_DMAIER_D_WAIT	0x04000000	/* Destination Ring Waiting */
287 #define	HIFN_DMAIER_D_OVER	0x02000000	/* Destination Ring Overflow */
288 #define	HIFN_DMAIER_R_ABORT	0x00200000	/* Result Ring PCI Abort */
289 #define	HIFN_DMAIER_R_DONE	0x00100000	/* Result Ring Done */
290 #define	HIFN_DMAIER_R_LAST	0x00080000	/* Result Ring Last */
291 #define	HIFN_DMAIER_R_WAIT	0x00040000	/* Result Ring Waiting */
292 #define	HIFN_DMAIER_R_OVER	0x00020000	/* Result Ring Overflow */
293 #define	HIFN_DMAIER_S_ABORT	0x00002000	/* Source Ring PCI Abort */
294 #define	HIFN_DMAIER_S_DONE	0x00001000	/* Source Ring Done */
295 #define	HIFN_DMAIER_S_LAST	0x00000800	/* Source Ring Last */
296 #define	HIFN_DMAIER_S_WAIT	0x00000400	/* Source Ring Waiting */
297 #define	HIFN_DMAIER_ILLW	0x00000200	/* Illegal write (7811 only) */
298 #define	HIFN_DMAIER_ILLR	0x00000100	/* Illegal read (7811 only) */
299 #define	HIFN_DMAIER_C_ABORT	0x00000020	/* Command Ring PCI Abort */
300 #define	HIFN_DMAIER_C_DONE	0x00000010	/* Command Ring Done */
301 #define	HIFN_DMAIER_C_LAST	0x00000008	/* Command Ring Last */
302 #define	HIFN_DMAIER_C_WAIT	0x00000004	/* Command Ring Waiting */
303 #define	HIFN_DMAIER_PUBDONE	0x00000002	/* public op done (7951 only) */
304 #define	HIFN_DMAIER_ENGINE	0x00000001	/* Engine IRQ */
305 
306 /* DMA Configuration Register (HIFN_1_DMA_CNFG) */
307 #define	HIFN_DMACNFG_BIGENDIAN	0x10000000	/* big endian mode */
308 #define	HIFN_DMACNFG_POLLFREQ	0x00ff0000	/* Poll frequency mask */
309 #define	HIFN_DMACNFG_UNLOCK	0x00000800
310 #define	HIFN_DMACNFG_POLLINVAL	0x00000700	/* Invalid Poll Scalar */
311 #define	HIFN_DMACNFG_LAST	0x00000010	/* Host control LAST bit */
312 #define	HIFN_DMACNFG_MODE	0x00000004	/* DMA mode */
313 #define	HIFN_DMACNFG_DMARESET	0x00000002	/* DMA Reset # */
314 #define	HIFN_DMACNFG_MSTRESET	0x00000001	/* Master Reset # */
315 
316 /* DMA Configuration Register (HIFN_1_DMA_CNFG2) */
317 #define	HIFN_DMACNFG2_PKSWAP32	(1 << 19)	/* swap the OPLEN/OP reg */
318 #define	HIFN_DMACNFG2_PKSWAP8	(1 << 18)	/* swap the bits of OPLEN/OP */
319 #define	HIFN_DMACNFG2_BAR0_SWAP32 (1<<17)	/* swap the bytes of BAR0 */
320 #define	HIFN_DMACNFG2_BAR1_SWAP8 (1<<16)	/* swap the bits  of BAR0 */
321 #define	HIFN_DMACNFG2_INIT_WRITE_BURST_SHIFT 12
322 #define	HIFN_DMACNFG2_INIT_READ_BURST_SHIFT 8
323 #define	HIFN_DMACNFG2_TGT_WRITE_BURST_SHIFT 4
324 #define	HIFN_DMACNFG2_TGT_READ_BURST_SHIFT  0
325 
326 /* 7811 RNG Enable Register (HIFN_1_7811_RNGENA) */
327 #define	HIFN_7811_RNGENA_ENA	0x00000001	/* enable RNG */
328 
329 /* 7811 RNG Config Register (HIFN_1_7811_RNGCFG) */
330 #define	HIFN_7811_RNGCFG_PRE1	0x00000f00	/* first prescalar */
331 #define	HIFN_7811_RNGCFG_OPRE	0x00000080	/* output prescalar */
332 #define	HIFN_7811_RNGCFG_DEFL	0x00000f80	/* 2 words/ 1/100 sec */
333 
334 /* 7811 RNG Status Register (HIFN_1_7811_RNGSTS) */
335 #define	HIFN_7811_RNGSTS_RDY	0x00004000	/* two numbers in FIFO */
336 #define	HIFN_7811_RNGSTS_UFL	0x00001000	/* rng underflow */
337 
338 /* 7811 MIPS Reset Register (HIFN_1_7811_MIPSRST) */
339 #define	HIFN_MIPSRST_BAR2SIZE	0xffff0000	/* sdram size */
340 #define	HIFN_MIPSRST_GPRAMINIT	0x00008000	/* gpram can be accessed */
341 #define	HIFN_MIPSRST_CRAMINIT	0x00004000	/* ctxram can be accessed */
342 #define	HIFN_MIPSRST_LED2	0x00000400	/* external LED2 */
343 #define	HIFN_MIPSRST_LED1	0x00000200	/* external LED1 */
344 #define	HIFN_MIPSRST_LED0	0x00000100	/* external LED0 */
345 #define	HIFN_MIPSRST_MIPSDIS	0x00000004	/* disable MIPS */
346 #define	HIFN_MIPSRST_MIPSRST	0x00000002	/* warm reset MIPS */
347 #define	HIFN_MIPSRST_MIPSCOLD	0x00000001	/* cold reset MIPS */
348 
349 /* Public key reset register (HIFN_1_PUB_RESET) */
350 #define	HIFN_PUBRST_RESET	0x00000001	/* reset public/rng unit */
351 
352 /* Public operation register (HIFN_1_PUB_OP) */
353 #define	HIFN_PUBOP_AOFFSET	0x0000003e	/* A offset */
354 #define	HIFN_PUBOP_BOFFSET	0x00000fc0	/* B offset */
355 #define	HIFN_PUBOP_MOFFSET	0x0003f000	/* M offset */
356 #define	HIFN_PUBOP_OP_MASK	0x003c0000	/* Opcode: */
357 #define	HIFN_PUBOP_OP_NOP	0x00000000	/*  NOP */
358 #define	HIFN_PUBOP_OP_ADD	0x00040000	/*  ADD */
359 #define	HIFN_PUBOP_OP_ADDC	0x00080000	/*  ADD w/carry */
360 #define	HIFN_PUBOP_OP_SUB	0x000c0000	/*  SUB */
361 #define	HIFN_PUBOP_OP_SUBC	0x00100000	/*  SUB w/carry */
362 #define	HIFN_PUBOP_OP_MODADD	0x00140000	/*  Modular ADD */
363 #define	HIFN_PUBOP_OP_MODSUB	0x00180000	/*  Modular SUB */
364 #define	HIFN_PUBOP_OP_INCA	0x001c0000	/*  INC A */
365 #define	HIFN_PUBOP_OP_DECA	0x00200000	/*  DEC A */
366 #define	HIFN_PUBOP_OP_MULT	0x00240000	/*  MULT */
367 #define	HIFN_PUBOP_OP_MODMULT	0x00280000	/*  Modular MULT */
368 #define	HIFN_PUBOP_OP_MODRED	0x002c0000	/*  Modular Red */
369 #define	HIFN_PUBOP_OP_MODEXP	0x00300000	/*  Modular Exp */
370 
371 /* Public operand length register (HIFN_1_PUB_OPLEN) */
372 #define	HIFN_PUBOPLEN_MODLEN	0x0000007f
373 #define	HIFN_PUBOPLEN_EXPLEN	0x0003ff80
374 #define	HIFN_PUBOPLEN_REDLEN	0x003c0000
375 
376 /* Public status register (HIFN_1_PUB_STATUS) */
377 #define	HIFN_PUBSTS_DONE	0x00000001	/* operation done */
378 #define	HIFN_PUBSTS_CARRY	0x00000002	/* carry */
379 
380 /* Public interrupt enable register (HIFN_1_PUB_IEN) */
381 #define	HIFN_PUBIEN_DONE	0x00000001	/* operation done interrupt */
382 
383 /* Random number generator config register (HIFN_1_RNG_CONFIG) */
384 #define	HIFN_RNGCFG_ENA		0x00000001	/* enable rng */
385 
386 /*
387  * Register offsets in register set 1
388  */
389 
390 #define	HIFN_UNLOCK_SECRET1	0xf4
391 #define	HIFN_UNLOCK_SECRET2	0xfc
392 
393 /*
394  * PLL config register
395  *
396  * This register is present only on 7954/7955/7956 parts. It must be
397  * programmed according to the bus interface method used by the h/w.
398  * Note that the parts require a stable clock.  Since the PCI clock
399  * may vary the reference clock must usually be used.  To avoid
400  * overclocking the core logic, setup must be done carefully, refer
401  * to the driver for details.  The exact multiplier required varies
402  * by part and system configuration; refer to the Hifn documentation.
403  */
404 #define	HIFN_PLL_REF_SEL	0x00000001	/* REF/HBI clk selection */
405 #define	HIFN_PLL_BP		0x00000002	/* bypass (used during setup) */
406 /* bit 2 reserved */
407 #define	HIFN_PLL_PK_CLK_SEL	0x00000008	/* public key clk select */
408 #define	HIFN_PLL_PE_CLK_SEL	0x00000010	/* packet engine clk select */
409 /* bits 5-9 reserved */
410 #define	HIFN_PLL_MBSET		0x00000400	/* must be set to 1 */
411 #define	HIFN_PLL_ND		0x00003800	/* Fpll_ref multiplier select */
412 #define	HIFN_PLL_ND_SHIFT	11
413 #define	HIFN_PLL_ND_2		0x00000000	/* 2x */
414 #define	HIFN_PLL_ND_4		0x00000800	/* 4x */
415 #define	HIFN_PLL_ND_6		0x00001000	/* 6x */
416 #define	HIFN_PLL_ND_8		0x00001800	/* 8x */
417 #define	HIFN_PLL_ND_10		0x00002000	/* 10x */
418 #define	HIFN_PLL_ND_12		0x00002800	/* 12x */
419 /* bits 14-15 reserved */
420 #define	HIFN_PLL_IS		0x00010000	/* charge pump current select */
421 /* bits 17-31 reserved */
422 
423 /*
424  * Board configuration specifies only these bits.
425  */
426 #define        HIFN_PLL_CONFIG         (HIFN_PLL_IS|HIFN_PLL_ND|HIFN_PLL_REF_SEL)
427 
428 /*********************************************************************
429  * Structs for board commands
430  *
431  *********************************************************************/
432 
433 /*
434  * Structure to help build up the command data structure.
435  */
436 typedef struct hifn_base_command {
437 	volatile u_int16_t masks;
438 	volatile u_int16_t session_num;
439 	volatile u_int16_t total_source_count;
440 	volatile u_int16_t total_dest_count;
441 } hifn_base_command_t;
442 
443 #define	HIFN_BASE_CMD_COMP		0x0100	/* enable compression engine */
444 #define	HIFN_BASE_CMD_PAD		0x0200	/* enable padding engine */
445 #define	HIFN_BASE_CMD_MAC		0x0400
446 #define	HIFN_BASE_CMD_CRYPT		0x0800
447 #define	HIFN_BASE_CMD_DECODE		0x2000
448 #define	HIFN_BASE_CMD_SRCLEN_M		0xc000
449 #define	HIFN_BASE_CMD_SRCLEN_S		14
450 #define	HIFN_BASE_CMD_DSTLEN_M		0x3000
451 #define	HIFN_BASE_CMD_DSTLEN_S		12
452 #define	HIFN_BASE_CMD_LENMASK_HI	0x30000
453 #define	HIFN_BASE_CMD_LENMASK_LO	0x0ffff
454 
455 /*
456  * Structure to help build up the command data structure.
457  */
458 typedef struct hifn_crypt_command {
459 	volatile u_int16_t masks;
460 	volatile u_int16_t header_skip;
461 	volatile u_int16_t source_count;
462 	volatile u_int16_t reserved;
463 } hifn_crypt_command_t;
464 
465 #define	HIFN_CRYPT_CMD_ALG_MASK		0x0003		/* algorithm: */
466 #define	HIFN_CRYPT_CMD_ALG_DES		0x0000		/*   DES */
467 #define	HIFN_CRYPT_CMD_ALG_3DES		0x0001		/*   3DES */
468 #define	HIFN_CRYPT_CMD_ALG_RC4		0x0002		/*   RC4 */
469 #define	HIFN_CRYPT_CMD_ALG_AES		0x0003		/*   AES */
470 #define	HIFN_CRYPT_CMD_MODE_MASK	0x0018		/* Encrypt/DES mode: */
471 #define	HIFN_CRYPT_CMD_MODE_ECB		0x0000		/*   ECB */
472 #define	HIFN_CRYPT_CMD_MODE_CBC		0x0008		/*   CBC */
473 #define	HIFN_CRYPT_CMD_MODE_CFB		0x0010		/*   CFB */
474 #define	HIFN_CRYPT_CMD_MODE_OFB		0x0018		/*   OFB */
475 #define	HIFN_CRYPT_CMD_CLR_CTX		0x0040		/* clear context */
476 #define	HIFN_CRYPT_CMD_NEW_KEY		0x0800		/* expect new key */
477 #define	HIFN_CRYPT_CMD_NEW_IV		0x1000		/* expect new iv */
478 
479 #define	HIFN_CRYPT_CMD_SRCLEN_M		0xc000
480 #define	HIFN_CRYPT_CMD_SRCLEN_S		14
481 
482 #define	HIFN_CRYPT_CMD_KSZ_MASK		0x0600		/* AES key size: */
483 #define	HIFN_CRYPT_CMD_KSZ_128		0x0000		/*  128 bit */
484 #define	HIFN_CRYPT_CMD_KSZ_192		0x0200		/*  192 bit */
485 #define	HIFN_CRYPT_CMD_KSZ_256		0x0400		/*  256 bit */
486 
487 /*
488  * Structure to help build up the command data structure.
489  */
490 typedef struct hifn_mac_command {
491 	volatile u_int16_t masks;
492 	volatile u_int16_t header_skip;
493 	volatile u_int16_t source_count;
494 	volatile u_int16_t reserved;
495 } hifn_mac_command_t;
496 
497 #define	HIFN_MAC_CMD_ALG_MASK		0x0001
498 #define	HIFN_MAC_CMD_ALG_SHA1		0x0000
499 #define	HIFN_MAC_CMD_ALG_MD5		0x0001
500 #define	HIFN_MAC_CMD_MODE_MASK		0x000c
501 #define	HIFN_MAC_CMD_MODE_HMAC		0x0000
502 #define	HIFN_MAC_CMD_MODE_SSL_MAC	0x0004
503 #define	HIFN_MAC_CMD_MODE_HASH		0x0008
504 #define	HIFN_MAC_CMD_MODE_FULL		0x0004
505 #define	HIFN_MAC_CMD_TRUNC		0x0010
506 #define	HIFN_MAC_CMD_RESULT		0x0020
507 #define	HIFN_MAC_CMD_APPEND		0x0040
508 #define	HIFN_MAC_CMD_SRCLEN_M		0xc000
509 #define	HIFN_MAC_CMD_SRCLEN_S		14
510 
511 /*
512  * MAC POS IPsec initiates authentication after encryption on encodes
513  * and before decryption on decodes.
514  */
515 #define	HIFN_MAC_CMD_POS_IPSEC		0x0200
516 #define	HIFN_MAC_CMD_NEW_KEY		0x0800
517 
518 struct hifn_comp_command {
519 	volatile u_int16_t masks;
520 	volatile u_int16_t header_skip;
521 	volatile u_int16_t source_count;
522 	volatile u_int16_t reserved;
523 };
524 
525 #define	HIFN_COMP_CMD_SRCLEN_M		0xc000
526 #define	HIFN_COMP_CMD_SRCLEN_S		14
527 #define	HIFN_COMP_CMD_ONE		0x0100	/* must be one */
528 #define	HIFN_COMP_CMD_CLEARHIST		0x0010	/* clear history */
529 #define	HIFN_COMP_CMD_UPDATEHIST	0x0008	/* update history */
530 #define	HIFN_COMP_CMD_LZS_STRIP0	0x0004	/* LZS: strip zero */
531 #define	HIFN_COMP_CMD_MPPC_RESTART	0x0004	/* MPPC: restart */
532 #define	HIFN_COMP_CMD_ALG_MASK		0x0001	/* compression mode: */
533 #define	HIFN_COMP_CMD_ALG_MPPC		0x0001	/*   MPPC */
534 #define	HIFN_COMP_CMD_ALG_LZS		0x0000	/*   LZS */
535 
536 struct hifn_base_result {
537 	volatile u_int16_t flags;
538 	volatile u_int16_t session;
539 	volatile u_int16_t src_cnt;		/* 15:0 of source count */
540 	volatile u_int16_t dst_cnt;		/* 15:0 of dest count */
541 };
542 
543 #define	HIFN_BASE_RES_DSTOVERRUN	0x0200	/* destination overrun */
544 #define	HIFN_BASE_RES_SRCLEN_M		0xc000	/* 17:16 of source count */
545 #define	HIFN_BASE_RES_SRCLEN_S		14
546 #define	HIFN_BASE_RES_DSTLEN_M		0x3000	/* 17:16 of dest count */
547 #define	HIFN_BASE_RES_DSTLEN_S		12
548 
549 struct hifn_comp_result {
550 	volatile u_int16_t flags;
551 	volatile u_int16_t crc;
552 };
553 
554 #define	HIFN_COMP_RES_LCB_M		0xff00	/* longitudinal check byte */
555 #define	HIFN_COMP_RES_LCB_S		8
556 #define	HIFN_COMP_RES_RESTART		0x0004	/* MPPC: restart */
557 #define	HIFN_COMP_RES_ENDMARKER		0x0002	/* LZS: end marker seen */
558 #define	HIFN_COMP_RES_SRC_NOTZERO	0x0001	/* source expired */
559 
560 struct hifn_mac_result {
561 	volatile u_int16_t flags;
562 	volatile u_int16_t reserved;
563 	/* followed by 0, 6, 8, or 10 u_int16_t's of the MAC, then crypt */
564 };
565 
566 #define	HIFN_MAC_RES_MISCOMPARE		0x0002	/* compare failed */
567 #define	HIFN_MAC_RES_SRC_NOTZERO	0x0001	/* source expired */
568 
569 struct hifn_crypt_result {
570 	volatile u_int16_t flags;
571 	volatile u_int16_t reserved;
572 };
573 
574 #define	HIFN_CRYPT_RES_SRC_NOTZERO	0x0001	/* source expired */
575 
576 /*
577  * The poll frequency and poll scalar defines are unshifted values used
578  * to set fields in the DMA Configuration Register.
579  */
580 #ifndef HIFN_POLL_FREQUENCY
581 #define	HIFN_POLL_FREQUENCY	0x1
582 #endif
583 
584 #ifndef HIFN_POLL_SCALAR
585 #define	HIFN_POLL_SCALAR	0x0
586 #endif
587 
588 #define	HIFN_MAX_SEGLEN 	0xffff		/* maximum dma segment len */
589 #define	HIFN_MAX_DMALEN		0x3ffff		/* maximum dma length */
590 #endif /* __HIFN_H__ */
591