1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 #define NOFN_BAR0_REGS 0x10
35 #define NOFN_BAR1 0x14
36 #define NOFN_BAR2 0x18
37 #define NOFN_BAR3_PK 0x1c
38
39 #define NOFN_MIPS_PCI_BASE_0 0x0000
40 #define NOFN_MIPS_PCI_WIN_SZ_0 0x0008
41 #define NOFN_PCI_XLAT_0 0x0010
42 #define NOFN_MIPS_PCI_BASE_1 0x0018
43 #define NOFN_MIPS_PCI_WIN_SZ_1 0x0020
44 #define NOFN_PCI_XLAT_1 0x0028
45 #define NOFN_MIPS_SDRAM_BASE 0x0030
46 #define NOFN_MIPS_SDRAM_SZ 0x0038
47 #define NOFN_PCI_BARM0_SHADOW 0x0040
48 #define NOFN_PCI_BARM1_SHADOW 0x0050
49 #define NOFN_PCI_BARM_SZ 0x0060
50 #define NOFN_XPARNT_MEM_EN 0x0068
51 #define NOFN_PCI_BARR_SHADOW 0x0070
52 #define NOFN_MIPS_REG_BASE 0x0078
53 #define NOFN_MAX_FREE_IDX 0x0080
54 #define NOFN_TRAP_IN_Q 0x0090
55 #define NOFN_OUT_CMPLT 0x00a0
56 #define NOFN_TRAP_OUT_Q 0x00a8
57 #define NOFN_CHOKE_CORE_IN_Q 0x00b0
58 #define NOFN_DONE_BITMAP 0x00b8
59 #define NOFN_HEAD_DESC_PTR 0x00c0
60 #define NOFN_TAIL_DESC_PTR 0x00c8
61 #define NOFN_RSLT_POST_ADR 0x00d0
62 #define NOFN_SM_CTX_BASE 0x00d8
63 #define NOFN_DESC_BASE 0x00e8
64 #define NOFN_LG_CTX_BASE 0x00e0
65 #define NOFN_SESSION_NUM_MASK 0x00f0
66 #define NOFN_HOST_MBOX_0 0x00f8
67 #define NOFN_REVID 0x0098
68 #define NOFN_HOST_SIGNAL 0x0100
69 #define NOFN_MIPS_MBOX_0 0x0108
70 #define NOFN_MIPS_SIGNAL 0x0110
71 #define NOFN_SPINLOCK_0 0x0118
72 #define NOFN_SPINLOCK_1 0x0120
73 #define NOFN_PCI_INT 0x0130
74 #define NOFN_PCI_INT_STAT 0x0138
75 #define NOFN_PCI_INT_MASK 0x0140
76 #define NOFN_MIPS_INT 0x0148
77 #define NOFN_MIPS_INT_STAT 0x0150
78 #define NOFN_SDRAM_CFG 0x0168
79 #define NOFN_ENDIAN_CFG 0x0170
80 #define NOFN_EPT 0x0178
81 #define NOFN_MIPS_RST 0x0180
82 #define NOFN_EEPROM_DATA_0 0x0188
83 #define NOFN_EEPROM_DATA_1 0x0190
84 #define NOFN_EEPROM_DATA_2 0x0198
85 #define NOFN_EEPROM_DATA_3 0x01a0
86 #define NOFN_CHIP_CFG 0x01d8
87 #define NOFN_SCRATCH_0 0x01e0
88 #define NOFN_SCRATCH_1 0x01e8
89 #define NOFN_SCRATCH_2 0x01f0
90 #define NOFN_SCRATCH_3 0x01f8
91 #define NOFN_CMD_RING_CTL 0x0200
92 #define NOFN_CMD_RING_BASE 0x0208
93 #define NOFN_CMD_RING_LEN 0x0210
94 #define NOFN_CMD_RING_HEAD 0x0218
95 #define NOFN_CMD_RING_TAIL 0x0220
96 #define NOFN_DST_RING_CTL 0x0230
97 #define NOFN_DST_RING_BASE 0x0238
98 #define NOFN_DST_RING_LEN 0x0240
99 #define NOFN_DST_RING_HEAD 0x0248
100 #define NOFN_DST_RING_TAIL 0x0250
101 #define NOFN_RSLT_RING_CTL 0x0258
102 #define NOFN_RSLT_RING_BASE 0x0260
103 #define NOFN_RSLT_RING_LEN 0x0268
104 #define NOFN_RSLT_RING_HEAD 0x0270
105 #define NOFN_RSLT_RING_TAIL 0x0278
106 #define NOFN_SRC_RING_CTL 0x0288
107 #define NOFN_SRC_RING_BASE 0x0290
108 #define NOFN_SRC_RING_LEN 0x0298
109 #define NOFN_SRC_RING_HEAD 0x02a0
110 #define NOFN_SRC_RING_TAIL 0x02a8
111 #define NOFN_FREE_RING_CTL 0x02b8
112 #define NOFN_FREE_RING_BASE 0x02c0
113 #define NOFN_FREE_RING_LEN 0x02c8
114 #define NOFN_FREE_RING_HEAD 0x02d0
115 #define NOFN_FREE_RING_TAIL 0x02d8
116 #define NOFN_ECC_TEST 0x02e0
117 #define NOFN_ECC_SNGL_ADR 0x02e8
118 #define NOFN_ECC_SNGL_ECC 0x02f0
119 #define NOFN_ECC_SNGL_CNT 0x02f8
120 #define NOFN_ECC_MULTI_ADR 0x0300
121 #define NOFN_ECC_MULTI_ECC 0x0308
122 #define NOFN_ECC_MULTI_DATAL 0x0310
123 #define NOFN_ECC_MULTI_DATAH 0x0318
124 #define NOFN_MIPS_ERR_ADR 0x0320
125 #define NOFN_MIPS_ERR_DATA 0x0328
126 #define NOFN_MIPS_ERR_PAR 0x0330
127 #define NOFN_MIPS_PAR_TEST 0x0338
128 #define NOFN_MIPS_MBOX_1 0x0340
129 #define NOFN_MIPS_MBOX_2 0x0348
130 #define NOFN_MIPS_MBOX_3 0x0350
131 #define NOFN_HOST_MBOX_1 0x0358
132 #define NOFN_HOST_MBOX_2 0x0360
133 #define NOFN_HOST_MBOX_3 0x0368
134 #define NOFN_MIPS_INT_0_MASK 0x0400
135 #define NOFN_MIPS_INT_1_MASK 0x0408
136 #define NOFN_MIPS_INT_2_MASK 0x0410
137 #define NOFN_MIPS_PCI_RD_ERRADR 0x0418
138 #define NOFN_MIPS_PCI_WR_ERRADR 0x0420
139 #define NOFN_MIPS_EP0_LMT 0x0428
140 #define NOFN_PCI_INIT_ERR_ADR 0x0430
141 #define NOFN_ECC_SNGL_DATAL 0x0438
142 #define NOFN_ECC_SNGL_DATAH 0x0440
143 #define NOFN_GPDMA_DATA_0 0x0480
144 #define NOFN_GPDMA_DATA_1 0x0488
145 #define NOFN_GPDMA_DATA_2 0x0490
146 #define NOFN_GPDMA_DATA_3 0x0498
147 #define NOFN_GPDMA_DATA_4 0x04a0
148 #define NOFN_GPDMA_DATA_5 0x04a8
149 #define NOFN_GPDMA_DATA_6 0x04b0
150 #define NOFN_GPDMA_DATA_7 0x04b8
151 #define NOFN_GPDMA_DATA_8 0x04c0
152 #define NOFN_GPDMA_DATA_9 0x04c8
153 #define NOFN_GPDMA_DATA_10 0x04d0
154 #define NOFN_GPDMA_DATA_11 0x04d8
155 #define NOFN_GPDMA_DATA_12 0x04e0
156 #define NOFN_GPDMA_DATA_13 0x04e8
157 #define NOFN_GPDMA_DATA_14 0x04f0
158 #define NOFN_GPDMA_DATA_15 0x04f8
159 #define NOFN_GPDMA_CTL 0x0500
160 #define NOFN_GPDMA_ADR 0x0508
161 #define NOFN_MIPS_PK_BASE 0x0510
162 #define NOFN_PCI_BAR3_SHADOW 0x0518
163 #define NOFN_AES_ROUNDS 0x0520
164 #define NOFN_MIPS_INIT 0x0530
165 #define NOFN_MIPS_INIT_CTL 0x0528
166 #define NOFN_UART_TX 0x0538
167 #define NOFN_UART_RX 0x0540
168 #define NOFN_UART_CLK_LOW 0x0548
169 #define NOFN_UART_CLK_HIGH 0x0550
170 #define NOFN_UART_STAT 0x0558
171 #define NOFN_MIPS_FLASH_BASE 0x0560
172 #define NOFN_MIPS_FLASH_SZ 0x0568
173 #define NOFN_MIPS_FLASH_XLATE 0x0570
174 #define NOFN_MIPS_SRAM_BASE 0x0578
175 #define NOFN_MIPS_SRAM_SZ 0x0580
176 #define NOFN_MIPS_SRAM_XLATE 0x0588
177 #define NOFN_MIPS_MEM_LOCK 0x0590
178 #define NOFN_MIPS_SDRAM2_BASE 0x0598
179 #define NOFN_MIPS_SDRAM2_SZ 0x05a0
180 #define NOFN_MIPS_EPO2_LMT 0x05a8
181
182 #define REVID_7851_1 0x00140000
183 #define REVID_7851_2 0x00140001
184 #define REVID_7814_7854_1 0x00140002
185 #define REVID_8154_1 0x00180000
186 #define REVID_8065_1 0x00160000
187 #define REVID_8165_1 0x00170000
188
189 #define PCIINTMASK_PK 0x80000000
190 #define PCIINTMASK_RNGRDY 0x40000000
191 #define PCIINTMASK_MIPSINT 0x00080000
192 #define PCIINTMASK_ERR_OUT 0x00010000
193 #define PCIINTMASK_ERR_FREE 0x00008000
194 #define PCIINTMASK_ERR_DEST 0x00004000
195 #define PCIINTMASK_ERR_RES 0x00002000
196 #define PCIINTMASK_ERR_RESP 0x00001000
197 #define PCIINTMASK_DESCOVF 0x00000800
198 #define PCIINTMASK_RESDONE 0x00000400
199 #define PCIINTMASK_DESTINV 0x00000200
200 #define PCIINTMASK_POOLINV 0x00000100
201 #define PCIINTMASK_ERR_CMD 0x00000080
202 #define PCIINTMASK_ERR_SRC 0x00000040
203 #define PCIINTMASK_ERR_IN 0x00000020
204 #define PCIINTMASK_ERR_MULTI 0x00000010
205 #define PCIINTMASK_MIPSPAR 0x00000004
206 #define PCIINTMASK_MIPSPCI 0x00000002
207 #define PCIINTMASK_FREE_E 0x00000001
208
209 #define PCIINTSTAT_PK 0x80000000
210 #define PCIINTSTAT_RNGRDY 0x40000000
211 #define PCIINTSTAT_MIPSINT 0x00080000
212 #define PCIINTSTAT_ERR_OUT 0x00010000
213 #define PCIINTSTAT_ERR_FREE 0x00008000
214 #define PCIINTSTAT_ERR_DEST 0x00004000
215 #define PCIINTSTAT_ERR_RES 0x00002000
216 #define PCIINTSTAT_ERR_RESP 0x00001000
217 #define PCIINTSTAT_DESCOVF 0x00000800
218 #define PCIINTSTAT_RESDONE 0x00000400
219 #define PCIINTSTAT_DESTINV 0x00000200
220 #define PCIINTSTAT_POOLINV 0x00000100
221 #define PCIINTSTAT_ERR_CMD 0x00000080
222 #define PCIINTSTAT_ERR_SRC 0x00000040
223 #define PCIINTSTAT_ERR_IN 0x00000020
224 #define PCIINTSTAT_ERR_MULTI 0x00000010
225 #define PCIINTSTAT_MIPSPAR 0x00000004
226 #define PCIINTSTAT_MIPSPCI 0x00000002
227 #define PCIINTSTAT_FREE_E 0x00000001
228
229 #define NOFN_PK_WIN_0 0x0000
230 #define NOFN_PK_WIN_1 0x2000
231 #define NOFN_PK_WIN_2 0x4000
232 #define NOFN_PK_WIN_3 0x6000
233
234 #define NOFN_PK_REGADDR(win,r,i) \
235 ((win) | (((r) & 0xf) << 7) | (((i) & 0x1f) << 2))
236
237 #define NOFN_PK_LENADDR(r) (0x1000 + ((r) << 2))
238 #define NOFN_PK_LENMASK 0x000007ff
239
240 #define NOFN_PK_RNGFIFO_BEGIN 0x1080
241 #define NOFN_PK_RNGFIFO_END 0x10bc
242 #define NOFN_PK_INSTR_BEGIN 0x1100
243 #define NOFN_PK_INSTR_END 0x12fc
244
245 #define NOFN_PK_CR 0x1fd4
246 #define NOFN_PK_SR 0x1fd8
247 #define NOFN_PK_IER 0x1fdc
248 #define NOFN_PK_RNC 0x1fe0
249 #define NOFN_PK_CFG1 0x1fe4
250 #define NOFN_PK_CFG2 0x1fe8
251 #define NOFN_PK_CHIPID 0x1fec
252 #define NOFN_PK_SCR 0x1ff0
253
254 #define PK_CR_OFFSET_M 0x000001fc
255 #define PK_CR_OFFSET_S 2
256
257 #define PK_SR_DONE 0x00008000
258 #define PK_SR_RRDY 0x00004000
259 #define PK_SR_UFLOW 0x00001000
260 #define PK_SR_CARRY 0x00000008
261
262 #define PK_IER_DONE 0x00008000
263 #define PK_IER_RRDY 0x00004000
264
265 #define PK_RNC_FST_SCALER 0x00000f00
266 #define PK_RNC_OUT_SCALER 0x00000080
267
268 #define PK_CFG1_RESET 0x00000001
269
270 #define PK_CFG2_ALU_ENA 0x00000002
271 #define PK_CFG2_RNG_ENA 0x00000001
272
273
274 union nofn_pk_reg {
275 u_int8_t b[128];
276 u_int32_t w[32];
277 };
278
279 #define PK_OP_DONE 0x80000000
280 #define PK_OPCODE_MASK 0x7c000000
281 #define PK_OPCODE_MODEXP 0x00000000
282 #define PK_OPCODE_MODMUL 0x04000000
283 #define PK_OPCODE_MODRED 0x08000000
284 #define PK_OPCODE_MODADD 0x0c000000
285 #define PK_OPCODE_MODSUB 0x10000000
286 #define PK_OPCODE_ADD 0x14000000
287 #define PK_OPCODE_SUB 0x18000000
288 #define PK_OPCODE_ADDC 0x1c000000
289 #define PK_OPCODE_SUBC 0x20000000
290 #define PK_OPCODE_MULT 0x24000000
291 #define PK_OPCODE_SR 0x28000000
292 #define PK_OPCODE_SL 0x2c000000
293 #define PK_OPCODE_INC 0x30000000
294 #define PK_OPCODE_DEC 0x34000000
295 #define PK_OPCODE_TAG 0x38000000
296 #define PK_OPCODE_BRANCH 0x3c000000
297 #define PK_OPCODE_CALL 0x40000000
298 #define PK_OPCODE_RETURN 0x44000000
299
300 #define PK_OP_RD_SHIFT 21
301 #define PK_OP_RA_SHIFT 16
302 #define PK_OP_RB_SHIFT 11
303 #define PK_OP_RM_SHIFT 6
304 #define PK_OP_R_MASK 0x1f
305 #define PK_OP_LEN_MASK 0xffff
306
307 #define NOFN_PK_INSTR(done,op,rd,ra,rb,rm) \
308 ((done) | (op) | \
309 (((rd) & PK_OP_R_MASK) << PK_OP_RD_SHIFT) | \
310 (((ra) & PK_OP_R_MASK) << PK_OP_RA_SHIFT) | \
311 (((rb) & PK_OP_R_MASK) << PK_OP_RB_SHIFT) | \
312 (((rm) & PK_OP_R_MASK) << PK_OP_RM_SHIFT))
313
314
315 #define NOFN_PK_INSTR2(done,op,rd,ra,len) \
316 ((done) | (op) | \
317 (((rd) & PK_OP_R_MASK) << PK_OP_RD_SHIFT) | \
318 (((ra) & PK_OP_R_MASK) << PK_OP_RA_SHIFT) | \
319 ((len) & PK_OP_LEN_MASK))