1 |
27 |
unneback |
//=============================================================================
|
2 |
|
|
//
|
3 |
|
|
// ether_test.h - Cyclone Diagnostics
|
4 |
|
|
//
|
5 |
|
|
//=============================================================================
|
6 |
|
|
//####ECOSGPLCOPYRIGHTBEGIN####
|
7 |
|
|
// -------------------------------------------
|
8 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
9 |
|
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
10 |
|
|
//
|
11 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
12 |
|
|
// the terms of the GNU General Public License as published by the Free
|
13 |
|
|
// Software Foundation; either version 2 or (at your option) any later version.
|
14 |
|
|
//
|
15 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
16 |
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
17 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
18 |
|
|
// for more details.
|
19 |
|
|
//
|
20 |
|
|
// You should have received a copy of the GNU General Public License along
|
21 |
|
|
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
22 |
|
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
23 |
|
|
//
|
24 |
|
|
// As a special exception, if other files instantiate templates or use macros
|
25 |
|
|
// or inline functions from this file, or you compile this file and link it
|
26 |
|
|
// with other works to produce a work based on this file, this file does not
|
27 |
|
|
// by itself cause the resulting work to be covered by the GNU General Public
|
28 |
|
|
// License. However the source code for this file must still be made available
|
29 |
|
|
// in accordance with section (3) of the GNU General Public License.
|
30 |
|
|
//
|
31 |
|
|
// This exception does not invalidate any other reasons why a work based on
|
32 |
|
|
// this file might be covered by the GNU General Public License.
|
33 |
|
|
//
|
34 |
|
|
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
|
35 |
|
|
// at http://sources.redhat.com/ecos/ecos-license/
|
36 |
|
|
// -------------------------------------------
|
37 |
|
|
//####ECOSGPLCOPYRIGHTEND####
|
38 |
|
|
//=============================================================================
|
39 |
|
|
//#####DESCRIPTIONBEGIN####
|
40 |
|
|
//
|
41 |
|
|
// Author(s): Scott Coulter, Jeff Frazier, Eric Breeden
|
42 |
|
|
// Contributors:
|
43 |
|
|
// Date: 2001-01-25
|
44 |
|
|
// Purpose:
|
45 |
|
|
// Description:
|
46 |
|
|
//
|
47 |
|
|
//####DESCRIPTIONEND####
|
48 |
|
|
//
|
49 |
|
|
//===========================================================================*/
|
50 |
|
|
|
51 |
|
|
|
52 |
|
|
#define ETHERMTU 1500
|
53 |
|
|
#define OK 0
|
54 |
|
|
#define ERROR -1
|
55 |
|
|
|
56 |
|
|
#ifndef TRUE
|
57 |
|
|
#define TRUE 1
|
58 |
|
|
#endif
|
59 |
|
|
|
60 |
|
|
#ifndef FALSE
|
61 |
|
|
#define FALSE 0
|
62 |
|
|
#endif
|
63 |
|
|
|
64 |
|
|
#ifndef NULL
|
65 |
|
|
#define NULL 0
|
66 |
|
|
#endif
|
67 |
|
|
|
68 |
|
|
/* Starting location for ether_test private malloc pool */
|
69 |
|
|
#define ETHER_MEM_POOL 0xa0400000 /* above top of diags. BE CAREFUL */
|
70 |
|
|
|
71 |
|
|
/* Length of interrupt time-out loops. */
|
72 |
|
|
#define MAX_DELAY 6000000
|
73 |
|
|
|
74 |
|
|
/* PCI Runtime Register offsets */
|
75 |
|
|
#define SCB_OFFSET 0
|
76 |
|
|
#define SCB_STAT_REG(n) ((UINT16 *)(n + 0x00))
|
77 |
|
|
#define SCB_CMD_REG(n) ((UINT16 *)(n + 0x02))
|
78 |
|
|
#define SCB_GENPTR_REG(n) ((UINT32 *)(n + 0x04))
|
79 |
|
|
#define PORT_REG(n) ((UINT32 *)(n + 0x08))
|
80 |
|
|
#define FLASH_CTL_REG(n) ((UINT16 *)(n + 0x0c))
|
81 |
|
|
#define EEPROM_CTL_REG(n) ((UINT16 *)(n + 0x0e))
|
82 |
|
|
#define MDI_CTL_REG(n) ((UINT32 *)(n + 0x10))
|
83 |
|
|
#define RXBC_REG(n) ((UINT32 *)(n + 0x14))
|
84 |
|
|
|
85 |
|
|
/* PORT* commands (lower 4 bits) */
|
86 |
|
|
#define PORT_RESET ((UINT32) 0x0)
|
87 |
|
|
#define PORT_SELF_TEST ((UINT32) 0x1)
|
88 |
|
|
#define PORT_DUMP ((UINT32) 0x3)
|
89 |
|
|
|
90 |
|
|
/* Individual Address offset into '557's serial eeprom */
|
91 |
|
|
#define IA_OFFSET 0
|
92 |
|
|
|
93 |
|
|
/* Command codes for the command fields of command descriptor blocks */
|
94 |
|
|
|
95 |
|
|
#define NOP 0
|
96 |
|
|
#define IA_SETUP 1
|
97 |
|
|
#define CONFIGURE 2
|
98 |
|
|
#define MC_SETUP 3
|
99 |
|
|
#define TRANSMIT 4
|
100 |
|
|
#define TDR 5
|
101 |
|
|
#define DUMP 6
|
102 |
|
|
#define DIAGNOSE 7
|
103 |
|
|
|
104 |
|
|
/* Commands for CUC in command word of SCB */
|
105 |
|
|
#define CU_NOP 0
|
106 |
|
|
#define CU_START 1
|
107 |
|
|
#define CU_RESUME 2
|
108 |
|
|
#define LOAD_DUMPCTR_ADDR 4 /* Load Dump Counters Address */
|
109 |
|
|
#define DUMP_STAT_COUNTERS 5 /* Dump Statistical Counters */
|
110 |
|
|
#define LOAD_CU_BASE 6 /* Load CU Base Register */
|
111 |
|
|
#define DUMP_RESET_COUNTERS 7 /* Dump and Reset Statistical
|
112 |
|
|
Counters */
|
113 |
|
|
/* Commands for RUC in command word of SCB */
|
114 |
|
|
#define RU_NOP 0
|
115 |
|
|
#define RU_START 1
|
116 |
|
|
#define RU_RESUME 2
|
117 |
|
|
#define RU_ABORT 4
|
118 |
|
|
#define LOAD_HDS 5 /* Load Header Data Size */
|
119 |
|
|
#define LOAD_RU_BASE 6 /* Load RU Base Register */
|
120 |
|
|
#define RBD_RESUME 7 /* Resume frame reception */
|
121 |
|
|
|
122 |
|
|
/* Misc. defines */
|
123 |
|
|
#define END_OF_LIST 1
|
124 |
|
|
#define BUSY 1
|
125 |
|
|
|
126 |
|
|
/* RU Status field */
|
127 |
|
|
#define RU_IDLE 0x0
|
128 |
|
|
#define RU_SUSPENDED 0x1
|
129 |
|
|
#define RU_NORESOURCE 0x2
|
130 |
|
|
#define RU_READY 0x4
|
131 |
|
|
#define RU_SUSP_NORBD 0x5
|
132 |
|
|
#define RU_NORSRC_NORBD 0x6
|
133 |
|
|
#define RU_READY_NORBD 0xc
|
134 |
|
|
|
135 |
|
|
/* Mask for interrupt status bits in SCB - six possible sources */
|
136 |
|
|
#define I557_INT 0xfc00
|
137 |
|
|
|
138 |
|
|
/* MDI definitions */
|
139 |
|
|
#define MDI_WRITE_OP 0x01
|
140 |
|
|
#define MDI_READ_OP 0x02
|
141 |
|
|
#define MDI_NOT_READY 0
|
142 |
|
|
#define MDI_POLLED 0
|
143 |
|
|
#define MDI_DEFAULT_PHY_ADDR 1 /* when only one PHY */
|
144 |
|
|
|
145 |
|
|
/* PHY device register addresses */
|
146 |
|
|
|
147 |
|
|
/* generic register addresses */
|
148 |
|
|
#define MDI_PHY_CTRL 0
|
149 |
|
|
#define MDI_PHY_STAT 1
|
150 |
|
|
#define MDI_PHY_ID_1 2
|
151 |
|
|
#define MDI_PHY_ID_2 3
|
152 |
|
|
#define MDI_PHY_AUTO_AD 4
|
153 |
|
|
#define MDI_PHY_AUTO_LNK 5
|
154 |
|
|
#define MDI_PHY_AUTO_EXP 6
|
155 |
|
|
|
156 |
|
|
#define I82555_PHY_ID 0x02a80150
|
157 |
|
|
#define ICS1890_PHY_ID 0x0015f420
|
158 |
|
|
#define DP83840_PHY_ID 0x20005c00
|
159 |
|
|
#define I82553_PHY_ID 0x02a80350
|
160 |
|
|
#define I82553_REVAB_PHY_ID 0x03e00000
|
161 |
|
|
|
162 |
|
|
/* I82555/558 Status and Control register */
|
163 |
|
|
#define I82555_STATCTRL_REG 0x10
|
164 |
|
|
#define I82555_100_MBPS (1 << 1)
|
165 |
|
|
#define I82555_10_MBPS (0 << 1)
|
166 |
|
|
|
167 |
|
|
#define REVISION_MASK 0xf
|
168 |
|
|
|
169 |
|
|
/* DP83840 specific register information */
|
170 |
|
|
#define DP83840_PCR_REG 0x17
|
171 |
|
|
#define PCR_TXREADY_SEL (1 << 10)
|
172 |
|
|
#define PCR_FCONNECT (1 << 5)
|
173 |
|
|
|
174 |
|
|
/* ICS1890 QuickPoll Detailed Status register */
|
175 |
|
|
#define ICS1890_QUICKPOLL_REG 0x11
|
176 |
|
|
#define QUICK_100_MBPS (1 << 15)
|
177 |
|
|
#define QUICK_10_MBPS (0 << 15)
|
178 |
|
|
#define QUICK_LINK_VALID (1 << 0)
|
179 |
|
|
#define QUICK_LINK_INVALID (0 << 0)
|
180 |
|
|
|
181 |
|
|
#define DP83840_PHY_ADDR_REG 0x19
|
182 |
|
|
#define PHY_ADDR_CON_STATUS (1 << 5)
|
183 |
|
|
#define PHY_ADDR_SPEED_10_MBPS (1 << 6)
|
184 |
|
|
#define PHY_ADDR_SPEED_100_MBPS (0 << 6)
|
185 |
|
|
|
186 |
|
|
#define DP83840_LOOPBACK_REG 0x18
|
187 |
|
|
#define TWISTER_LOOPBACK (0x1 << 8)
|
188 |
|
|
#define REMOTE_LOOPBACK (0x2 << 8)
|
189 |
|
|
#define CLEAR_LOOP_BITS ~(TWISTER_LOOPBACK | REMOTE_LOOPBACK)
|
190 |
|
|
|
191 |
|
|
/* 82553 specific register information */
|
192 |
|
|
#define I82553_PHY_EXT_REG0 0x10
|
193 |
|
|
#define EXT_REG0_100_MBPS (1 << 1)
|
194 |
|
|
#define GET_REV_CNTR(n) ((n & 0x00e0) >> 5)
|
195 |
|
|
#define I82553_PHY_EXT_REG1 0x14
|
196 |
|
|
|
197 |
|
|
/* MDI Control Register bits */
|
198 |
|
|
#define MDI_CTRL_COLL_TEST (1 << 7)
|
199 |
|
|
#define MDI_CTRL_FULL_DUPLEX (1 << 8)
|
200 |
|
|
#define MDI_CTRL_RESTART_AUTO (1 << 9)
|
201 |
|
|
#define MDI_CTRL_ISOLATE (1 << 10)
|
202 |
|
|
#define MDI_CTRL_POWER_DOWN (1 << 11)
|
203 |
|
|
#define MDI_CTRL_AUTO_ENAB (1 << 12)
|
204 |
|
|
#define MDI_CTRL_AUTO_DISAB (0 << 12)
|
205 |
|
|
#define MDI_CTRL_100_MBPS (1 << 13)
|
206 |
|
|
#define MDI_CTRL_10_MBPS (0 << 13)
|
207 |
|
|
#define MDI_CTRL_LOOPBACK (1 << 14)
|
208 |
|
|
#define MDI_CTRL_RESET (1 << 15)
|
209 |
|
|
|
210 |
|
|
/* MDI Status Register bits */
|
211 |
|
|
#define MDI_STAT_EXTENDED (1 << 0)
|
212 |
|
|
#define MDI_STAT_JABBER (1 << 1)
|
213 |
|
|
#define MDI_STAT_LINK (1 << 2)
|
214 |
|
|
#define MDI_STAT_AUTO_CAPABLE (1 << 3)
|
215 |
|
|
#define MDI_STAT_REMOTE_FLT (1 << 4)
|
216 |
|
|
#define MDI_STAT_AUTO_COMPLETE (1 << 5)
|
217 |
|
|
#define MDI_STAT_10BASET_HALF (1 << 11)
|
218 |
|
|
#define MDI_STAT_10BASET_FULL (1 << 12)
|
219 |
|
|
#define MDI_STAT_TX_HALF (1 << 13)
|
220 |
|
|
#define MDI_STAT_TX_FULL (1 << 14)
|
221 |
|
|
#define MDI_STAT_T4_CAPABLE (1 << 15)
|
222 |
|
|
|
223 |
|
|
/*
|
224 |
|
|
* Structure allignments. All addresses passed to the 557 must be
|
225 |
|
|
* even (bit 0 = 0), EXCEPT for addresses passed by the PORT*
|
226 |
|
|
* function (self-test address & dump address, which must be 16-byte aligned.
|
227 |
|
|
*/
|
228 |
|
|
|
229 |
|
|
#define SELF_TEST_ALIGN 16
|
230 |
|
|
#define DUMP_ALIGN 16
|
231 |
|
|
#define DEF_ALIGN 4
|
232 |
|
|
|
233 |
|
|
/*
|
234 |
|
|
* Bit definitions for the configure command. NOTE: Byte offsets are
|
235 |
|
|
* offsets from the start of the structure (8 and up) to correspond
|
236 |
|
|
* with the offsets in the PRO/100 PCI Adapter manual.
|
237 |
|
|
*/
|
238 |
|
|
|
239 |
|
|
/* Byte 0 */
|
240 |
|
|
#define BYTE_COUNT 0x16 /* use all 22 configure bytes */
|
241 |
|
|
#define CONFIG_BYTE_00 (BYTE_COUNT)
|
242 |
|
|
|
243 |
|
|
/* Byte 1 */
|
244 |
|
|
#define RX_FIFO_LIMIT 0x08
|
245 |
|
|
#define CONFIG_BYTE_01 (RX_FIFO_LIMIT)
|
246 |
|
|
|
247 |
|
|
/* Byte 2 */
|
248 |
|
|
#define ADAPT_IFS 0x00
|
249 |
|
|
#define CONFIG_BYTE_02 (ADAPT_IFS)
|
250 |
|
|
|
251 |
|
|
/* Byte 3 - must be 0x00 */
|
252 |
|
|
#define CONFIG_BYTE_03 (0x00)
|
253 |
|
|
|
254 |
|
|
/* Byte 4 */
|
255 |
|
|
#define RX_DMA_BCOUNT 0x00
|
256 |
|
|
#define CONFIG_BYTE_04 (RX_DMA_BCOUNT)
|
257 |
|
|
|
258 |
|
|
/* Byte 5 */
|
259 |
|
|
#define TX_DMA_BCOUNT 0x00
|
260 |
|
|
#define DMA_BCOUNT_ENAB 0x80
|
261 |
|
|
#define CONFIG_BYTE_05 (DMA_BCOUNT_ENAB | TX_DMA_BCOUNT)
|
262 |
|
|
|
263 |
|
|
/* Byte 6 */
|
264 |
|
|
#define NO_LATE_SCB 0x00
|
265 |
|
|
#define NO_TNO_INT 0x00 /* no interrupt on xmit failure */
|
266 |
|
|
#define INT_CU_IDLE 0x08 /* interrupt when CU goes idle */
|
267 |
|
|
#define NO_SV_BAD_FRAME 0x00 /* don't save bad frames */
|
268 |
|
|
#define DISCARD_RX_OVER 0x00 /* discard overrun frames */
|
269 |
|
|
#define BYTE6_REQUD 0x32 /* required "1" bits */
|
270 |
|
|
|
271 |
|
|
#define CONFIG_BYTE_06 (NO_LATE_SCB | NO_TNO_INT | INT_CU_IDLE |\
|
272 |
|
|
NO_SV_BAD_FRAME | DISCARD_RX_OVER | BYTE6_REQUD)
|
273 |
|
|
|
274 |
|
|
/* Byte 7 */
|
275 |
|
|
#define DISCARD_SHORT_RX 0x00 /* discard short rx frames */
|
276 |
|
|
#define ONE_URUN_RETRY 0x02 /* one underrun retry */
|
277 |
|
|
#define CONFIG_BYTE_07 (DISCARD_SHORT_RX | ONE_URUN_RETRY)
|
278 |
|
|
|
279 |
|
|
/* Byte 8 */
|
280 |
|
|
#define USE_503_MODE 0x00
|
281 |
|
|
#define USE_MII_MODE 0x01
|
282 |
|
|
#define CONFIG_BYTE_08 (USE_MII_MODE)
|
283 |
|
|
|
284 |
|
|
/* Byte 9 */
|
285 |
|
|
#define CONFIG_BYTE_09 (0x00)
|
286 |
|
|
|
287 |
|
|
/* Byte 10 */
|
288 |
|
|
#define INSERT_SRC_ADDR 0 /* Source address comes from IA of '557 */
|
289 |
|
|
#define PREAMBLE_LEN 0x20 /* 7 bytes */
|
290 |
|
|
#define NO_LOOP_BACK 0x00
|
291 |
|
|
#define INT_LOOP_BACK 0x40
|
292 |
|
|
#define EXT_LOOP_BACK 0xc0
|
293 |
|
|
#define BYTE10_REQUD 0x06 /* required "1" bits */
|
294 |
|
|
#define CONFIG_BYTE_10 (NO_LOOP_BACK | PREAMBLE_LEN | INSERT_SRC_ADDR | BYTE10_REQUD)
|
295 |
|
|
|
296 |
|
|
/* Byte 11 */
|
297 |
|
|
#define LIN_PRIORITY 0 /* normal CSMA/CD */
|
298 |
|
|
#define CONFIG_BYTE_11 (LIN_PRIORITY)
|
299 |
|
|
|
300 |
|
|
/* Byte 12 */
|
301 |
|
|
#define LIN_PRIORITY_MODE 0
|
302 |
|
|
#define IF_SPACING 96 /* inter-frame spacing */
|
303 |
|
|
#define CONFIG_BYTE_12 (IF_SPACING | LIN_PRIORITY_MODE)
|
304 |
|
|
|
305 |
|
|
/* Byte 13 */
|
306 |
|
|
#define CONFIG_BYTE_13 (0x00)
|
307 |
|
|
|
308 |
|
|
/* Byte 14 */
|
309 |
|
|
#define CONFIG_BYTE_14 (0xf2)
|
310 |
|
|
|
311 |
|
|
/* Byte 15 */
|
312 |
|
|
#define PROM_MODE 0 /* not promiscuous */
|
313 |
|
|
#define BROADCAST 0 /* disabled */
|
314 |
|
|
#define CRS 0x80 /* CDT = carrier */
|
315 |
|
|
#define BYTE15_REQUD 0x48 /* required "1" bits */
|
316 |
|
|
#define CONFIG_BYTE_15 (PROM_MODE | BROADCAST | CRS | BYTE15_REQUD)
|
317 |
|
|
|
318 |
|
|
/* Byte 16 */
|
319 |
|
|
#define CONFIG_BYTE_16 (0x00)
|
320 |
|
|
|
321 |
|
|
/* Byte 17 */
|
322 |
|
|
#define CONFIG_BYTE_17 (0x40)
|
323 |
|
|
|
324 |
|
|
/* Byte 18 */
|
325 |
|
|
#define STRIPPING_DISABLE 0x00
|
326 |
|
|
#define STRIPPING_ENABLE 0x01
|
327 |
|
|
#define PADDING_ENABLE 0x02
|
328 |
|
|
#define XFER_CRC 0x04 /* store CRC */
|
329 |
|
|
#define NO_XFER_CRC 0x00
|
330 |
|
|
#define BYTE18_REQUD 0xf0 /* required "1" bits */
|
331 |
|
|
#define CONFIG_BYTE_18 (NO_XFER_CRC | PADDING_ENABLE | STRIPPING_ENABLE | BYTE18_REQUD)
|
332 |
|
|
|
333 |
|
|
/* Byte 19 */
|
334 |
|
|
#define NO_FORCE_FDX 0x00
|
335 |
|
|
#define FORCE_FDX 0x40
|
336 |
|
|
#define FDX_PIN_ENAB 0x80
|
337 |
|
|
#define CONFIG_BYTE_19_10T FORCE_FDX
|
338 |
|
|
#define CONFIG_BYTE_19_100T NO_FORCE_FDX
|
339 |
|
|
|
340 |
|
|
/* Byte 20 */
|
341 |
|
|
#define NO_MULTI_IA 0x00
|
342 |
|
|
#define CONFIG_BYTE_20 (NO_MULTI_IA)
|
343 |
|
|
|
344 |
|
|
/* Byte 21 */
|
345 |
|
|
#define NO_MULTI_ALL 0x00
|
346 |
|
|
#define CONFIG_BYTE_21 (NO_MULTI_ALL)
|
347 |
|
|
|
348 |
|
|
#define SCB_S_CUMASK 0x00c0 /* state mask */
|
349 |
|
|
#define SCB_S_CUIDLE (0x00 << 6) /* CU is idle */
|
350 |
|
|
#define SCB_S_CUSUSP (0x01 << 6) /* CU is suspended */
|
351 |
|
|
#define SCB_S_CUACTIVE (0x02 << 6) /* CU is active */
|
352 |
|
|
#define SCB_S_CURSV1 (0x03 << 6) /* reserved */
|
353 |
|
|
|
354 |
|
|
/*
|
355 |
|
|
* 82557 structures. NOTE: the 557 is used in 32-bit linear addressing
|
356 |
|
|
* mode. See alignment restrictions above.
|
357 |
|
|
*/
|
358 |
|
|
|
359 |
|
|
/* Result of PORT* self-test command - MUST be 16 byte aligned! */
|
360 |
|
|
struct selfTest {
|
361 |
|
|
UINT32 romSig; /* signature of rom */
|
362 |
|
|
union { /* Flag bits - as UINT32 or field */
|
363 |
|
|
struct {
|
364 |
|
|
UINT32 rsrv1 : 2;
|
365 |
|
|
UINT32 romTest : 1;
|
366 |
|
|
UINT32 regTest : 1;
|
367 |
|
|
UINT32 rsrv2 : 1;
|
368 |
|
|
UINT32 diagnTest : 1;
|
369 |
|
|
UINT32 rsrv3 : 6;
|
370 |
|
|
UINT32 selfTest : 1;
|
371 |
|
|
UINT32 rsrv4 : 19;
|
372 |
|
|
} bits;
|
373 |
|
|
UINT32 word2;
|
374 |
|
|
} u;
|
375 |
|
|
};
|
376 |
|
|
|
377 |
|
|
/* MDI Control Register */
|
378 |
|
|
typedef union
|
379 |
|
|
{
|
380 |
|
|
struct
|
381 |
|
|
{
|
382 |
|
|
UINT32 data : 16; /* data to write or data read */
|
383 |
|
|
UINT32 regAdd : 5; /* PHY register address */
|
384 |
|
|
UINT32 phyAdd : 5; /* PHY address */
|
385 |
|
|
UINT32 op : 2; /* opcode, 1 for MDI write, 2 for MDI read */
|
386 |
|
|
UINT32 ready : 1; /* 1 = operation complete */
|
387 |
|
|
UINT32 intEnab : 1; /* 1 = interrupt at end of cycle */
|
388 |
|
|
UINT32 rsrv : 2; /* reserved */
|
389 |
|
|
} bits;
|
390 |
|
|
UINT32 word;
|
391 |
|
|
} MDI_CONTROL_U;
|
392 |
|
|
|
393 |
|
|
/* Command/Status Word of SCB */
|
394 |
|
|
typedef union
|
395 |
|
|
{
|
396 |
|
|
struct
|
397 |
|
|
{
|
398 |
|
|
UINT32 rsrv1 : 2; /* Reserved */
|
399 |
|
|
UINT32 rus : 4; /* Receive unit status */
|
400 |
|
|
UINT32 cus : 2; /* Command unit status */
|
401 |
|
|
UINT32 rsrv2 : 2; /* Reserved */
|
402 |
|
|
UINT32 statack_swi : 1; /* Software generated int. */
|
403 |
|
|
UINT32 statack_mdi : 1; /* MDI read/write complete */
|
404 |
|
|
UINT32 statack_rnr : 1; /* RU not ready */
|
405 |
|
|
UINT32 statack_cna : 1; /* CU not active */
|
406 |
|
|
UINT32 statack_fr : 1; /* Frame reception done */
|
407 |
|
|
UINT32 statack_cx_tno : 1; /* Cmd exec completed */
|
408 |
|
|
UINT32 ruc : 3; /* Receive unit command */
|
409 |
|
|
UINT32 rsrv3 : 1; /* Reserved */
|
410 |
|
|
UINT32 cuc : 3; /* Command unit command */
|
411 |
|
|
UINT32 rsrv4 : 1; /* Reserved */
|
412 |
|
|
UINT32 m : 1; /* Interrupt mask bit */
|
413 |
|
|
UINT32 si : 1; /* Software generated int. */
|
414 |
|
|
UINT32 rsrv5 : 6; /* Reserved */
|
415 |
|
|
} bits;
|
416 |
|
|
struct
|
417 |
|
|
{
|
418 |
|
|
UINT16 status;
|
419 |
|
|
UINT16 command;
|
420 |
|
|
} words;
|
421 |
|
|
} CMD_STAT_U;
|
422 |
|
|
|
423 |
|
|
/* System command block - on chip for the 82557 */
|
424 |
|
|
struct SCBtype
|
425 |
|
|
{
|
426 |
|
|
CMD_STAT_U cmdStat;
|
427 |
|
|
UINT32 scb_general_ptr; /* SCB General Pointer */
|
428 |
|
|
};
|
429 |
|
|
|
430 |
|
|
/* Command blocks - declared as a union; some commands have different fields */
|
431 |
|
|
union cmdBlock {
|
432 |
|
|
/* No operation */
|
433 |
|
|
struct {
|
434 |
|
|
UINT32 rsrv1 : 13; /* reserved bits (set to 0) */
|
435 |
|
|
UINT32 ok : 1; /* 1 = command completed, no error */
|
436 |
|
|
UINT32 rsrv2 : 1; /* reserved bits (set to 0) */
|
437 |
|
|
UINT32 c : 1; /* 1 = command completed */
|
438 |
|
|
UINT32 code : 3; /* command code (0 = NOP) */
|
439 |
|
|
UINT32 rsrv3 : 10; /* reserved bits (set to 0) */
|
440 |
|
|
UINT32 i : 1; /* 1 = interrupt upon completion */
|
441 |
|
|
UINT32 s : 1; /* 1 = suspend CU upon completion */
|
442 |
|
|
UINT32 el : 1; /* 1 = last cmdBlock in list */
|
443 |
|
|
union cmdBlock *link; /* next block in list */
|
444 |
|
|
} nop;
|
445 |
|
|
/* Individual address setup */
|
446 |
|
|
struct {
|
447 |
|
|
UINT32 rsrv1 : 13; /* reserved bits (set to 0) */
|
448 |
|
|
UINT32 ok : 1; /* 1 = command completed, no error */
|
449 |
|
|
UINT32 rsrv2 : 1; /* reserved bits (set to 0) */
|
450 |
|
|
UINT32 c : 1; /* 1 = command completed */
|
451 |
|
|
UINT32 code : 3; /* command code (1 = ia setup) */
|
452 |
|
|
UINT32 rsrv3 : 10; /* reserved bits (set to 0) */
|
453 |
|
|
UINT32 i : 1; /* 1 = interrupt upon completion */
|
454 |
|
|
UINT32 s : 1; /* 1 = suspend CU upon completion */
|
455 |
|
|
UINT32 el : 1; /* 1 = last cmdBlock in list */
|
456 |
|
|
union cmdBlock *link; /* next block in list */
|
457 |
|
|
UINT8 enetAddr[6]; /* hardware ethernet address */
|
458 |
|
|
UINT16 rsrv4; /* padding */
|
459 |
|
|
} iaSetup;
|
460 |
|
|
/* Configure */
|
461 |
|
|
struct {
|
462 |
|
|
UINT32 rsrv1 : 13; /* reserved bits (set to 0) */
|
463 |
|
|
UINT32 ok : 1; /* 1 = command completed, no error */
|
464 |
|
|
UINT32 rsrv2 : 1; /* reserved bits (set to 0) */
|
465 |
|
|
UINT32 c : 1; /* 1 = command completed */
|
466 |
|
|
UINT32 code : 3; /* command code (2 = configure) */
|
467 |
|
|
UINT32 rsrv3 : 10; /* reserved bits (set to 0) */
|
468 |
|
|
UINT32 i : 1; /* 1 = interrupt upon completion */
|
469 |
|
|
UINT32 s : 1; /* 1 = suspend CU upon completion */
|
470 |
|
|
UINT32 el : 1; /* 1 = last cmdBlock in list */
|
471 |
|
|
union cmdBlock *link; /* next block in list */
|
472 |
|
|
UINT8 configData[20]; /* configuration data */
|
473 |
|
|
} configure;
|
474 |
|
|
/* Multicast address setup */
|
475 |
|
|
struct {
|
476 |
|
|
UINT32 rsrv1 : 13; /* reserved bits (set to 0) */
|
477 |
|
|
UINT32 ok : 1; /* 1 = command completed, no error */
|
478 |
|
|
UINT32 rsrv2 : 1; /* reserved bits (set to 0) */
|
479 |
|
|
UINT32 c : 1; /* 1 = command completed */
|
480 |
|
|
UINT32 code : 3; /* command code (3 = mc setup) */
|
481 |
|
|
UINT32 rsrv3 : 10; /* reserved bits (set to 0) */
|
482 |
|
|
UINT32 i : 1; /* 1 = interrupt upon completion */
|
483 |
|
|
UINT32 s : 1; /* 1 = suspend CU upon completion */
|
484 |
|
|
UINT32 el : 1; /* 1 = last cmdBlock in list */
|
485 |
|
|
union cmdBlock *link; /* next block in list */
|
486 |
|
|
UINT16 mcCount; /* # of bytes in mcAddrList[] */
|
487 |
|
|
UINT8 mcAddrList[6]; /* list of multicast addresses */
|
488 |
|
|
} mcSetup;
|
489 |
|
|
/* Transmit */
|
490 |
|
|
struct {
|
491 |
|
|
UINT32 rsrv1 : 12; /* reserved bits (set to 0) */
|
492 |
|
|
UINT32 u : 1; /* 1 = underrun was encountered */
|
493 |
|
|
UINT32 ok : 1; /* 1 = command completed, no error */
|
494 |
|
|
UINT32 rsrv2 : 1; /* reserved bits (set to 0) */
|
495 |
|
|
UINT32 c : 1; /* 1 = command completed */
|
496 |
|
|
UINT32 code : 3; /* command code (4 = transmit) */
|
497 |
|
|
UINT32 sf : 1; /* 1 = flexible mode */
|
498 |
|
|
UINT32 rsrv3 : 9; /* reserved bits (set to 0) */
|
499 |
|
|
UINT32 i : 1; /* 1 = interrupt upon completion */
|
500 |
|
|
UINT32 s : 1; /* 1 = suspend CU upon completion */
|
501 |
|
|
UINT32 el : 1; /* 1 = last cmdBlock in list */
|
502 |
|
|
union cmdBlock *link; /* next block in list */
|
503 |
|
|
UINT8 *tbdAddr; /* tx buf addr; all 1s for simp mode */
|
504 |
|
|
UINT32 tcbCount : 14; /* # bytes to be tx from cmd block */
|
505 |
|
|
UINT32 rsrv4 : 1; /* reserved (set to 0) */
|
506 |
|
|
UINT32 eof : 1; /* 1 = entire frame in cmd block */
|
507 |
|
|
UINT8 tx_threshold; /* # of bytes in FIFO before xmission */
|
508 |
|
|
UINT8 tbd_number; /* # of tx. buffers in TBD array */
|
509 |
|
|
UINT8 destAddr[6]; /* destination hardware address */
|
510 |
|
|
UINT16 length; /* 802.3 packet length (from packet) */
|
511 |
|
|
UINT8 txData[ETHERMTU]; /* optional data to tx */
|
512 |
|
|
} transmit;
|
513 |
|
|
/* Dump 82557 registers */
|
514 |
|
|
struct {
|
515 |
|
|
UINT32 rsrv1 : 13; /* reserved bits (set to 0) */
|
516 |
|
|
UINT32 ok : 1; /* 1 = command completed, no error */
|
517 |
|
|
UINT32 rsrv2 : 1; /* reserved bits (set to 0) */
|
518 |
|
|
UINT32 c : 1; /* 1 = command completed */
|
519 |
|
|
UINT32 code : 3; /* command code (6 = dump) */
|
520 |
|
|
UINT32 rsrv3 : 10; /* reserved bits (set to 0) */
|
521 |
|
|
UINT32 i : 1; /* 1 = interrupt upon completion */
|
522 |
|
|
UINT32 s : 1; /* 1 = suspend CU upon completion */
|
523 |
|
|
UINT32 el : 1; /* 1 = last cmdBlock in list */
|
524 |
|
|
union cmdBlock *link; /* next block in list */
|
525 |
|
|
UINT8 *bufAddr; /* where to dump registers */
|
526 |
|
|
} dump;
|
527 |
|
|
/* Diagnose - perform self test */
|
528 |
|
|
struct {
|
529 |
|
|
UINT32 rsrv1 : 11; /* reserved bits (set to 0) */
|
530 |
|
|
UINT32 f : 1; /* 1 = self test failed */
|
531 |
|
|
UINT32 rsrv2 : 1; /* reserved bits (set to 0) */
|
532 |
|
|
UINT32 ok : 1; /* 1 = command completed, no error */
|
533 |
|
|
UINT32 rsrv3 : 1; /* reserved bits (set to 0) */
|
534 |
|
|
UINT32 c : 1; /* 1 = command completed */
|
535 |
|
|
UINT32 code : 3; /* command code (7 = diagnose) */
|
536 |
|
|
UINT32 rsrv4 : 10; /* reserved bits (set to 0) */
|
537 |
|
|
UINT32 i : 1; /* 1 = interrupt upon completion */
|
538 |
|
|
UINT32 s : 1; /* 1 = suspend CU upon completion */
|
539 |
|
|
UINT32 el : 1; /* 1 = last cmdBlock in list */
|
540 |
|
|
union cmdBlock *link; /* next block in list */
|
541 |
|
|
} diagnose;
|
542 |
|
|
};
|
543 |
|
|
|
544 |
|
|
/* Receive frame descriptors (uses simplified memory structure) */
|
545 |
|
|
struct rfd {
|
546 |
|
|
UINT32 rxColl : 1; /* 1 = collision on reception */
|
547 |
|
|
UINT32 iaMatch : 1; /* Dest addr matched chip's hardware addr */
|
548 |
|
|
UINT32 rsrv1 : 2; /* reserved bits (set to 0) */
|
549 |
|
|
UINT32 rxErr : 1; /* RX_ER pin asserted during frame reception */
|
550 |
|
|
UINT32 typeFrame : 1; /* Type field of pkt. indicates a TYPE frame */
|
551 |
|
|
UINT32 rsrv2 : 1; /* reserved bits (set to 0) */
|
552 |
|
|
UINT32 frameTooshort : 1;
|
553 |
|
|
UINT32 dmaOverrun : 1; /* DMA overrun (couldn't get local bus) */
|
554 |
|
|
UINT32 noRsrc : 1; /* No resources (out of buffer space) */
|
555 |
|
|
UINT32 alignErr : 1; /* CRC error on misaligned frame */
|
556 |
|
|
UINT32 crcErr : 1; /* CRC error on aligned frame */
|
557 |
|
|
UINT32 rsrv3 : 1; /* reserved bits (set to 0) */
|
558 |
|
|
UINT32 ok : 1; /* 1 = command completed, no error */
|
559 |
|
|
UINT32 rsrv4 : 1; /* reserved bits (set to 0) */
|
560 |
|
|
UINT32 c : 1; /* 1 = command completed */
|
561 |
|
|
UINT32 rsrv5 : 3; /* reserved bits (set to 0) */
|
562 |
|
|
UINT32 sf : 1; /* 1 = Flexible mode */
|
563 |
|
|
UINT32 h : 1; /* 1 = Header RFD */
|
564 |
|
|
UINT32 rsrv6 : 9; /* reserved bits (set to 0) */
|
565 |
|
|
UINT32 s : 1; /* 1 = suspend CU upon completion */
|
566 |
|
|
UINT32 el : 1; /* 1 = last cmdBlock in list */
|
567 |
|
|
union cmdBlock *link; /* next block in list */
|
568 |
|
|
UINT8 *rbdAddr; /* rx buf desc addr; all 1s for simple mode */
|
569 |
|
|
UINT32 actCount : 14; /* # bytes in this buffer (set by 82557) */
|
570 |
|
|
UINT32 f : 1; /* 1 = buffer used */
|
571 |
|
|
UINT32 eof : 1; /* 1 = last buffer for this frame */
|
572 |
|
|
UINT32 size : 14; /* # bytes avail in this buffer (set by CPU) */
|
573 |
|
|
UINT32 rsrv7 : 2; /* reserved bits (set to 0) */
|
574 |
|
|
UINT8 destAddr[6]; /* destination address */
|
575 |
|
|
UINT8 sourceAddr[6]; /* source address */
|
576 |
|
|
UINT16 length; /* 802.3 packet length (from packet) */
|
577 |
|
|
UINT8 rxData[ETHERMTU]; /* optional data (simplified mode) */
|
578 |
|
|
};
|
579 |
|
|
|
580 |
|
|
/* Forward declarations */
|
581 |
|
|
static void portWrite (UINT32 val);
|
582 |
|
|
static void resetChip (void);
|
583 |
|
|
static void makePacket (UINT8 *, int);
|
584 |
|
|
static int checkPacket (UINT8 *, UINT8 *, int);
|
585 |
|
|
static int i557IntHandler (int);
|
586 |
|
|
static int waitForInt(void);
|
587 |
|
|
|
588 |
|
|
static void sendCommand (UINT8 cuc,
|
589 |
|
|
UINT8 ruc,
|
590 |
|
|
UINT32 scb_general_ptr);
|
591 |
|
|
|
592 |
|
|
static UINT16 readMDI (
|
593 |
|
|
int unit,
|
594 |
|
|
UINT8 phyAdd,
|
595 |
|
|
UINT8 regAdd
|
596 |
|
|
);
|
597 |
|
|
|
598 |
|
|
static void writeMDI (
|
599 |
|
|
int unit,
|
600 |
|
|
UINT8 phyAdd,
|
601 |
|
|
UINT8 regAdd,
|
602 |
|
|
UINT16 data
|
603 |
|
|
);
|
604 |
|
|
|
605 |
|
|
static int initPHY (UINT32 device_type, int loop_mode);
|
606 |
|
|
|
607 |
|
|
static int get_ether_addr (
|
608 |
|
|
int unit,
|
609 |
|
|
UINT8 *buffer,
|
610 |
|
|
int print_flag /* TRUE to print the information */
|
611 |
|
|
);
|
612 |
|
|
|
613 |
|
|
|