elink3reg.h revision 1.2 1 /* $NetBSD: elink3reg.h,v 1.2 1996/04/30 22:32:39 thorpej Exp $ */
2
3 /*
4 * Copyright (c) 1995 Herb Peyerl <hpeyerl (at) novatel.ca>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Herb Peyerl.
18 * 4. The name of Herb Peyerl may not be used to endorse or promote products
19 * derived from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 */
33
34 /*
35 * These define the EEPROM data structure. They are used in the probe
36 * function to verify the existance of the adapter after having sent
37 * the ID_Sequence.
38 *
39 * There are others but only the ones we use are defined here.
40 */
41 #define EEPROM_NODE_ADDR_0 0x0 /* Word */
42 #define EEPROM_NODE_ADDR_1 0x1 /* Word */
43 #define EEPROM_NODE_ADDR_2 0x2 /* Word */
44 #define EEPROM_PROD_ID 0x3 /* 0x9[0-f]50 */
45 #define EEPROM_MFG_ID 0x7 /* 0x6d50 */
46 #define EEPROM_ADDR_CFG 0x8 /* Base addr */
47 #define EEPROM_RESOURCE_CFG 0x9 /* IRQ. Bits 12-15 */
48
49 /*
50 * These are the registers for the 3Com 3c509 and their bit patterns when
51 * applicable. They have been taken out the the "EtherLink III Parallel
52 * Tasking EISA and ISA Technical Reference" "Beta Draft 10/30/92" manual
53 * from 3com.
54 */
55 #define EP_COMMAND 0x0e /* Write. BASE+0x0e is always a command reg. */
56 #define EP_STATUS 0x0e /* Read. BASE+0x0e is always status reg. */
57 #define EP_WINDOW 0x0f /* Read. BASE+0x0f is always window reg. */
58
59 /*
60 * Window 0 registers. Setup.
61 */
62 /* Write */
63 #define EP_W0_EEPROM_DATA 0x0c
64 #define EP_W0_EEPROM_COMMAND 0x0a
65 #define EP_W0_RESOURCE_CFG 0x08
66 #define EP_W0_ADDRESS_CFG 0x06
67 #define EP_W0_CONFIG_CTRL 0x04
68 /* Read */
69 #define EP_W0_PRODUCT_ID 0x02
70 #define EP_W0_MFG_ID 0x00
71
72 /*
73 * Window 1 registers. Operating Set.
74 */
75 /* Write */
76 #define EP_W1_TX_PIO_WR_2 0x02
77 #define EP_W1_TX_PIO_WR_1 0x00
78 /* Read */
79 #define EP_W1_FREE_TX 0x0c
80 #define EP_W1_TX_STATUS 0x0b /* byte */
81 #define EP_W1_TIMER 0x0a /* byte */
82 #define EP_W1_RX_STATUS 0x08
83 #define EP_W1_RX_PIO_RD_2 0x02
84 #define EP_W1_RX_PIO_RD_1 0x00
85
86 /*
87 * Window 2 registers. Station Address Setup/Read
88 */
89 /* Read/Write */
90 #define EP_W2_ADDR_5 0x05
91 #define EP_W2_ADDR_4 0x04
92 #define EP_W2_ADDR_3 0x03
93 #define EP_W2_ADDR_2 0x02
94 #define EP_W2_ADDR_1 0x01
95 #define EP_W2_ADDR_0 0x00
96
97 /*
98 * Window 3 registers. FIFO Management.
99 */
100 /* Read */
101 #define EP_W3_FREE_TX 0x0c
102 #define EP_W3_FREE_RX 0x0a
103
104 /*
105 * Window 4 registers. Diagnostics.
106 */
107 /* Read/Write */
108 #define EP_W4_MEDIA_TYPE 0x0a
109 #define EP_W4_CTRLR_STATUS 0x08
110 #define EP_W4_NET_DIAG 0x06
111 #define EP_W4_FIFO_DIAG 0x04
112 #define EP_W4_HOST_DIAG 0x02
113 #define EP_W4_TX_DIAG 0x00
114
115 /*
116 * Window 5 Registers. Results and Internal status.
117 */
118 /* Read */
119 #define EP_W5_READ_0_MASK 0x0c
120 #define EP_W5_INTR_MASK 0x0a
121 #define EP_W5_RX_FILTER 0x08
122 #define EP_W5_RX_EARLY_THRESH 0x06
123 #define EP_W5_TX_AVAIL_THRESH 0x02
124 #define EP_W5_TX_START_THRESH 0x00
125
126 /*
127 * Window 6 registers. Statistics.
128 */
129 /* Read/Write */
130 #define TX_TOTAL_OK 0x0c
131 #define RX_TOTAL_OK 0x0a
132 #define TX_DEFERRALS 0x08
133 #define RX_FRAMES_OK 0x07
134 #define TX_FRAMES_OK 0x06
135 #define RX_OVERRUNS 0x05
136 #define TX_COLLISIONS 0x04
137 #define TX_AFTER_1_COLLISION 0x03
138 #define TX_AFTER_X_COLLISIONS 0x02
139 #define TX_NO_SQE 0x01
140 #define TX_CD_LOST 0x00
141
142 /*
143 * Register definitions.
144 */
145
146 /*
147 * Command register. All windows.
148 *
149 * 16 bit register.
150 * 15-11: 5-bit code for command to be executed.
151 * 10-0: 11-bit arg if any. For commands with no args;
152 * this can be set to anything.
153 */
154 #define GLOBAL_RESET (u_short) 0x0000 /* Wait at least 1ms after issuing */
155 #define WINDOW_SELECT (u_short) (0x1<<11)
156 #define START_TRANSCEIVER (u_short) (0x2<<11) /* Read ADDR_CFG reg to determine
157 whether this is needed. If so;
158 wait 800 uSec before using trans-
159 ceiver. */
160 #define RX_DISABLE (u_short) (0x3<<11) /* state disabled on power-up */
161 #define RX_ENABLE (u_short) (0x4<<11)
162 #define RX_RESET (u_short) (0x5<<11)
163 #define RX_DISCARD_TOP_PACK (u_short) (0x8<<11)
164 #define TX_ENABLE (u_short) (0x9<<11)
165 #define TX_DISABLE (u_short) (0xa<<11)
166 #define TX_RESET (u_short) (0xb<<11)
167 #define REQ_INTR (u_short) (0xc<<11)
168
169 /*
170 * The following C_* acknowledge the various interrupts.
171 * Some of them don't do anything. See the manual.
172 */
173 #define ACK_INTR (u_short) (0x6800)
174 # define C_INTR_LATCH (u_short) (ACK_INTR|0x01)
175 # define C_CARD_FAILURE (u_short) (ACK_INTR|0x02)
176 # define C_TX_COMPLETE (u_short) (ACK_INTR|0x04)
177 # define C_TX_AVAIL (u_short) (ACK_INTR|0x08)
178 # define C_RX_COMPLETE (u_short) (ACK_INTR|0x10)
179 # define C_RX_EARLY (u_short) (ACK_INTR|0x20)
180 # define C_INT_RQD (u_short) (ACK_INTR|0x40)
181 # define C_UPD_STATS (u_short) (ACK_INTR|0x80)
182 #define SET_INTR_MASK (u_short) (0x0e<<11)
183 #define SET_RD_0_MASK (u_short) (0x0f<<11)
184 #define SET_RX_FILTER (u_short) (0x10<<11)
185 # define FIL_INDIVIDUAL (u_short) (0x01)
186 # define FIL_MULTICAST (u_short) (0x02)
187 # define FIL_BRDCST (u_short) (0x04)
188 # define FIL_PROMISC (u_short) (0x08)
189 #define SET_RX_EARLY_THRESH (u_short) (0x11<<11)
190 #define SET_TX_AVAIL_THRESH (u_short) (0x12<<11)
191 #define SET_TX_START_THRESH (u_short) (0x13<<11)
192 #define STATS_ENABLE (u_short) (0x15<<11)
193 #define STATS_DISABLE (u_short) (0x16<<11)
194 #define STOP_TRANSCEIVER (u_short) (0x17<<11)
195
196 /*
197 * Status register. All windows.
198 *
199 * 15-13: Window number(0-7).
200 * 12: Command_in_progress.
201 * 11: reserved.
202 * 10: reserved.
203 * 9: reserved.
204 * 8: reserved.
205 * 7: Update Statistics.
206 * 6: Interrupt Requested.
207 * 5: RX Early.
208 * 4: RX Complete.
209 * 3: TX Available.
210 * 2: TX Complete.
211 * 1: Adapter Failure.
212 * 0: Interrupt Latch.
213 */
214 #define S_INTR_LATCH (u_short) (0x0001)
215 #define S_CARD_FAILURE (u_short) (0x0002)
216 #define S_TX_COMPLETE (u_short) (0x0004)
217 #define S_TX_AVAIL (u_short) (0x0008)
218 #define S_RX_COMPLETE (u_short) (0x0010)
219 #define S_RX_EARLY (u_short) (0x0020)
220 #define S_INT_RQD (u_short) (0x0040)
221 #define S_UPD_STATS (u_short) (0x0080)
222 #define S_COMMAND_IN_PROGRESS (u_short) (0x1000)
223
224 /*
225 * FIFO Registers. RX Status.
226 *
227 * 15: Incomplete or FIFO empty.
228 * 14: 1: Error in RX Packet 0: Incomplete or no error.
229 * 14-11: Type of error. [14-11]
230 * 1000 = Overrun.
231 * 1011 = Run Packet Error.
232 * 1100 = Alignment Error.
233 * 1101 = CRC Error.
234 * 1001 = Oversize Packet Error (>1514 bytes)
235 * 0010 = Dribble Bits.
236 * (all other error codes, no errors.)
237 *
238 * 10-0: RX Bytes (0-1514)
239 */
240 #define ERR_INCOMPLETE (u_short) (0x8000)
241 #define ERR_RX (u_short) (0x4000)
242 #define ERR_MASK (u_short) (0x7800)
243 #define ERR_OVERRUN (u_short) (0x4000)
244 #define ERR_RUNT (u_short) (0x5800)
245 #define ERR_ALIGNMENT (u_short) (0x6000)
246 #define ERR_CRC (u_short) (0x6800)
247 #define ERR_OVERSIZE (u_short) (0x4800)
248 #define ERR_DRIBBLE (u_short) (0x1000)
249
250 /*
251 * TX Status
252 *
253 * Reports the transmit status of a completed transmission. Writing this
254 * register pops the transmit completion stack.
255 *
256 * Window 1/Port 0x0b.
257 *
258 * 7: Complete
259 * 6: Interrupt on successful transmission requested.
260 * 5: Jabber Error (TP Only, TX Reset required. )
261 * 4: Underrun (TX Reset required. )
262 * 3: Maximum Collisions.
263 * 2: TX Status Overflow.
264 * 1-0: Undefined.
265 *
266 */
267 #define TXS_COMPLETE 0x80
268 #define TXS_INTR_REQ 0x40
269 #define TXS_JABBER 0x20
270 #define TXS_UNDERRUN 0x10
271 #define TXS_MAX_COLLISION 0x08
272 #define TXS_STATUS_OVERFLOW 0x04
273
274 /*
275 * FIFO Status (Window 4)
276 *
277 * Supports FIFO diagnostics
278 *
279 * Window 4/Port 0x04.1
280 *
281 * 15: 1=RX receiving (RO). Set when a packet is being received
282 * into the RX FIFO.
283 * 14: Reserved
284 * 13: 1=RX underrun (RO). Generates Adapter Failure interrupt.
285 * Requires RX Reset or Global Reset command to recover.
286 * It is generated when you read past the end of a packet -
287 * reading past what has been received so far will give bad
288 * data.
289 * 12: 1=RX status overrun (RO). Set when there are already 8
290 * packets in the RX FIFO. While this bit is set, no additional
291 * packets are received. Requires no action on the part of
292 * the host. The condition is cleared once a packet has been
293 * read out of the RX FIFO.
294 * 11: 1=RX overrun (RO). Set when the RX FIFO is full (there
295 * may not be an overrun packet yet). While this bit is set,
296 * no additional packets will be received (some additional
297 * bytes can still be pending between the wire and the RX
298 * FIFO). Requires no action on the part of the host. The
299 * condition is cleared once a few bytes have been read out
300 * from the RX FIFO.
301 * 10: 1=TX overrun (RO). Generates adapter failure interrupt.
302 * Requires TX Reset or Global Reset command to recover.
303 * Disables Transmitter.
304 * 9-8: Unassigned.
305 * 7-0: Built in self test bits for the RX and TX FIFO's.
306 */
307 #define FIFOS_RX_RECEIVING (u_short) 0x8000
308 #define FIFOS_RX_UNDERRUN (u_short) 0x2000
309 #define FIFOS_RX_STATUS_OVERRUN (u_short) 0x1000
310 #define FIFOS_RX_OVERRUN (u_short) 0x0800
311 #define FIFOS_TX_OVERRUN (u_short) 0x0400
312
313 /*
314 * Misc defines for various things.
315 */
316 #define TAG_ADAPTER 0xd0
317 #define ACTIVATE_ADAPTER_TO_CONFIG 0xff
318 #define ENABLE_DRQ_IRQ 0x0001
319 #define MFG_ID 0x506d /* `TCM' */
320 #define PROD_ID 0x5090
321 #define GO_WINDOW(x) bus_io_write_2(sc->sc_bc, \
322 sc->sc_ioh, EP_COMMAND, WINDOW_SELECT|x)
323 #define AUI 0x1
324 #define BNC 0x2
325 #define UTP 0x4
326 #define IS_AUI (1<<13)
327 #define IS_BNC (1<<12)
328 #define IS_UTP (1<<9)
329 #define EEPROM_BUSY (1<<15)
330 #define EEPROM_TST_MODE (1<<14)
331 #define READ_EEPROM (1<<7)
332 #define ENABLE_UTP 0xc0
333 #define DISABLE_UTP 0x0
334 #define RX_BYTES_MASK (u_short) (0x07ff)
335
336 #define IS_PCI_AUI (1<<5)
337 #define IS_PCI_BNC (1<<4)
338 #define IS_PCI_UTP (1<<3)
339