1 /*
2 Written 1994 by David C. Davies.
3
4 Copyright 1994 Digital Equipment Corporation.
5
6 This software may be used and distributed according to the terms of the
7 GNU Public License, incorporated herein by reference.
8
9 The author may be reached as davies@wanton.lkg.dec.com or Digital
10 Equipment Corporation, 550 King Street, Littleton MA 01460.
11
12 =========================================================================
13 */
14
15 /*
16 ** I/O Address Register Map
17 */
18 #define EWRK3_CSR iobase+0x00 /* Control and Status Register */
19 #define EWRK3_CR iobase+0x01 /* Control Register */
20 #define EWRK3_ICR iobase+0x02 /* Interrupt Control Register */
21 #define EWRK3_TSR iobase+0x03 /* Transmit Status Register */
22 #define EWRK3_RSVD1 iobase+0x04 /* RESERVED */
23 #define EWRK3_RSVD2 iobase+0x05 /* RESERVED */
24 #define EWRK3_FMQ iobase+0x06 /* Free Memory Queue */
25 #define EWRK3_FMQC iobase+0x07 /* Free Memory Queue Counter */
26 #define EWRK3_RQ iobase+0x08 /* Receive Queue */
27 #define EWRK3_RQC iobase+0x09 /* Receive Queue Counter */
28 #define EWRK3_TQ iobase+0x0a /* Transmit Queue */
29 #define EWRK3_TQC iobase+0x0b /* Transmit Queue Counter */
30 #define EWRK3_TDQ iobase+0x0c /* Transmit Done Queue */
31 #define EWRK3_TDQC iobase+0x0d /* Transmit Done Queue Counter */
32 #define EWRK3_PIR1 iobase+0x0e /* Page Index Register 1 */
33 #define EWRK3_PIR2 iobase+0x0f /* Page Index Register 2 */
34 #define EWRK3_DATA iobase+0x10 /* Data Register */
35 #define EWRK3_IOPR iobase+0x11 /* I/O Page Register */
36 #define EWRK3_IOBR iobase+0x12 /* I/O Base Register */
37 #define EWRK3_MPR iobase+0x13 /* Memory Page Register */
38 #define EWRK3_MBR iobase+0x14 /* Memory Base Register */
39 #define EWRK3_APROM iobase+0x15 /* Address PROM */
40 #define EWRK3_EPROM1 iobase+0x16 /* EEPROM Data Register 1 */
41 #define EWRK3_EPROM2 iobase+0x17 /* EEPROM Data Register 2 */
42 #define EWRK3_PAR0 iobase+0x18 /* Physical Address Register 0 */
43 #define EWRK3_PAR1 iobase+0x19 /* Physical Address Register 1 */
44 #define EWRK3_PAR2 iobase+0x1a /* Physical Address Register 2 */
45 #define EWRK3_PAR3 iobase+0x1b /* Physical Address Register 3 */
46 #define EWRK3_PAR4 iobase+0x1c /* Physical Address Register 4 */
47 #define EWRK3_PAR5 iobase+0x1d /* Physical Address Register 5 */
48 #define EWRK3_CMR iobase+0x1e /* Configuration/Management Register */
49
50 /*
51 ** Control Page Map
52 */
53 #define PAGE0_FMQ 0x000 /* Free Memory Queue */
54 #define PAGE0_RQ 0x080 /* Receive Queue */
55 #define PAGE0_TQ 0x100 /* Transmit Queue */
56 #define PAGE0_TDQ 0x180 /* Transmit Done Queue */
57 #define PAGE0_HTE 0x200 /* Hash Table Entries */
58 #define PAGE0_RSVD 0x240 /* RESERVED */
59 #define PAGE0_USRD 0x600 /* User Data */
60
61 /*
62 ** Control and Status Register bit definitions (EWRK3_CSR)
63 */
64 #define RA 0x80 /* Runt Accept */
65 #define PME 0x40 /* Promiscuous Mode Enable */
66 #define MCE 0x20 /* Multicast Enable */
67 #define TNE 0x08 /* TX Done Queue Not Empty */
68 #define RNE 0x04 /* RX Queue Not Empty */
69 #define TXD 0x02 /* TX Disable */
70 #define RXD 0x01 /* RX Disable */
71
72 /*
73 ** Control Register bit definitions (EWRK3_CR)
74 */
75 #define APD 0x80 /* Auto Port Disable */
76 #define PSEL 0x40 /* Port Select (0->TP port) */
77 #define LBCK 0x20 /* LoopBaCK enable */
78 #define FDUP 0x10 /* Full DUPlex enable */
79 #define FBUS 0x08 /* Fast BUS enable (ISA clk > 8.33MHz) */
80 #define EN_16 0x04 /* ENable 16 bit memory accesses */
81 #define LED 0x02 /* LED (1-> turn on) */
82
83 /*
84 ** Interrupt Control Register bit definitions (EWRK3_ICR)
85 */
86 #define IE 0x80 /* Interrupt Enable */
87 #define IS 0x60 /* Interrupt Selected */
88 #define TNEM 0x08 /* TNE Mask (0->mask) */
89 #define RNEM 0x04 /* RNE Mask (0->mask) */
90 #define TXDM 0x02 /* TXD Mask (0->mask) */
91 #define RXDM 0x01 /* RXD Mask (0->mask) */
92
93 /*
94 ** Transmit Status Register bit definitions (EWRK3_TSR)
95 */
96 #define NCL 0x80 /* No Carrier Loopback */
97 #define ID 0x40 /* Initially Deferred */
98 #define LCL 0x20 /* Late CoLlision */
99 #define ECL 0x10 /* Excessive CoLlisions */
100 #define RCNTR 0x0f /* Retries CouNTeR */
101
102 /*
103 ** I/O Page Register bit definitions (EWRK3_IOPR)
104 */
105 #define EEPROM_INIT 0xc0 /* EEPROM INIT command */
106 #define EEPROM_WR_EN 0xc8 /* EEPROM WRITE ENABLE command */
107 #define EEPROM_WR 0xd0 /* EEPROM WRITE command */
108 #define EEPROM_WR_DIS 0xd8 /* EEPROM WRITE DISABLE command */
109 #define EEPROM_RD 0xe0 /* EEPROM READ command */
110
111 /*
112 ** I/O Base Register bit definitions (EWRK3_IOBR)
113 */
114 #define EISA 0x20 /* Enable EISA ID and Control Registers */
115 #define IOB 0x1f /* Compare bits for I/O Base Address */
116
117 /*
118 ** I/O Configuration/Management Register bit definitions (EWRK3_CMR)
119 */
120 #define RA 0x80 /* Read Ahead */
121 #define WB 0x40 /* Write Behind */
122 #define LINK 0x20 /* 0->TP */
123 #define POLARITY 0x10 /* Informational */
124 #define NO_EEPROM 0x0c /* NO_EEPROM<1:0> pin status */
125 #define HS 0x08 /* Hard Strapped pin status (LeMAC2) */
126 #define PNP 0x04 /* Plug 'n Play */
127 #define DRAM 0x02 /* 0-> 1DRAM, 1-> 2 DRAM on board */
128 #define _0WS 0x01 /* Zero Wait State */
129
130 /*
131 ** MAC Receive Status Register bit definitions
132 */
133
134 #define ROK 0x80 /* Receive OK summary */
135 #define IAM 0x10 /* Individual Address Match */
136 #define MCM 0x08 /* MultiCast Match */
137 #define DBE 0x04 /* Dribble Bit Error */
138 #define CRC 0x02 /* CRC error */
139 #define PLL 0x01 /* Phase Lock Lost */
140
141 /*
142 ** MAC Transmit Control Register bit definitions
143 */
144
145 #define SQEE 0x40 /* SQE Enable - look for heartbeat */
146 #define SED 0x20 /* Stop when Error Detected */
147 #define QMODE 0x10 /* Q_MODE */
148 #define LAB 0x08 /* Less Aggressive Backoff */
149 #define PAD 0x04 /* PAD Runt Packets */
150 #define IFC 0x02 /* Insert Frame Check */
151 #define ISA 0x01 /* Insert Source Address */
152
153 /*
154 ** MAC Transmit Status Register bit definitions
155 */
156
157 #define VSTS 0x80 /* Valid STatuS */
158 #define MAC_CTU 0x40 /* Cut Through Used */
159 #define MAC_SQE 0x20 /* Signal Quality Error */
160 #define MAC_NCL 0x10 /* No Carrier Loopback */
161 #define MAC_LCL 0x08 /* Late Collision */
162 #define MAC_ID 0x04 /* Initially Deferred */
163 #define MAC_COLL 0x03 /* COLLision status */
164 #define MAC_XCOLL 0x03 /* Excessive Collisions */
165 #define MAC_MCOLL 0x02 /* Multiple Collisions */
166 #define MAC_OCOLL 0x01 /* One Collision */
167 #define MAC_NOCOLL 0x00 /* No Collisions */
168 #define MAC_XUR 0x03 /* Excessive Underruns */
169 #define MAC_TXE 0x7f /* TX Errors */
170
171 /*
172 ** EISA Configuration Register bit definitions
173 */
174
175 #define EISA_ID0 iobase + 0x0c80 /* EISA ID Register 0 */
176 #define EISA_ID1 iobase + 0x0c81 /* EISA ID Register 1 */
177 #define EISA_ID2 iobase + 0x0c82 /* EISA ID Register 2 */
178 #define EISA_ID3 iobase + 0x0c83 /* EISA ID Register 3 */
179 #define EISA_CR iobase + 0x0c84 /* EISA Control Register */
180
181 /*
182 ** EEPROM BYTES
183 */
184 #define EEPROM_MEMB 0x00
185 #define EEPROM_IOB 0x01
186 #define EEPROM_EISA_ID0 0x02
187 #define EEPROM_EISA_ID1 0x03
188 #define EEPROM_EISA_ID2 0x04
189 #define EEPROM_EISA_ID3 0x05
190 #define EEPROM_MISC0 0x06
191 #define EEPROM_MISC1 0x07
192 #define EEPROM_PNAME7 0x08
193 #define EEPROM_PNAME6 0x09
194 #define EEPROM_PNAME5 0x0a
195 #define EEPROM_PNAME4 0x0b
196 #define EEPROM_PNAME3 0x0c
197 #define EEPROM_PNAME2 0x0d
198 #define EEPROM_PNAME1 0x0e
199 #define EEPROM_PNAME0 0x0f
200 #define EEPROM_SWFLAGS 0x10
201 #define EEPROM_HWCAT 0x11
202 #define EEPROM_NETMAN2 0x12
203 #define EEPROM_REVLVL 0x13
204 #define EEPROM_NETMAN0 0x14
205 #define EEPROM_NETMAN1 0x15
206 #define EEPROM_CHIPVER 0x16
207 #define EEPROM_SETUP 0x17
208 #define EEPROM_PADDR0 0x18
209 #define EEPROM_PADDR1 0x19
210 #define EEPROM_PADDR2 0x1a
211 #define EEPROM_PADDR3 0x1b
212 #define EEPROM_PADDR4 0x1c
213 #define EEPROM_PADDR5 0x1d
214 #define EEPROM_PA_CRC 0x1e
215 #define EEPROM_CHKSUM 0x1f
216
217 /*
218 ** EEPROM bytes for checksumming
219 */
220 #define EEPROM_MAX 32 /* bytes */
221
222 /*
223 ** EEPROM MISCELLANEOUS FLAGS
224 */
225 #define RBE_SHADOW 0x0100 /* Remote Boot Enable Shadow */
226 #define READ_AHEAD 0x0080 /* Read Ahead feature */
227 #define IRQ_SEL2 0x0070 /* IRQ line selection (LeMAC2) */
228 #define IRQ_SEL 0x0060 /* IRQ line selection */
229 #define FAST_BUS 0x0008 /* ISA Bus speeds > 8.33MHz */
230 #define ENA_16 0x0004 /* Enables 16 bit memory transfers */
231 #define WRITE_BEHIND 0x0002 /* Write Behind feature */
232 #define _0WS_ENA 0x0001 /* Zero Wait State Enable */
233
234 /*
235 ** EEPROM NETWORK MANAGEMENT FLAGS
236 */
237 #define NETMAN_POL 0x04 /* Polarity defeat */
238 #define NETMAN_LINK 0x02 /* Link defeat */
239 #define NETMAN_CCE 0x01 /* Custom Counters Enable */
240
241 /*
242 ** EEPROM SW FLAGS
243 */
244 #define SW_SQE 0x10 /* Signal Quality Error */
245 #define SW_LAB 0x08 /* Less Aggressive Backoff */
246 #define SW_INIT 0x04 /* Initialized */
247 #define SW_TIMEOUT 0x02 /* 0:2.5 mins, 1: 30 secs */
248 #define SW_REMOTE 0x01 /* Remote Boot Enable -> 1 */
249
250 /*
251 ** EEPROM SETUP FLAGS
252 */
253 #define SETUP_APD 0x80 /* AutoPort Disable */
254 #define SETUP_PS 0x40 /* Port Select */
255 #define SETUP_MP 0x20 /* MultiPort */
256 #define SETUP_1TP 0x10 /* 1 port, TP */
257 #define SETUP_1COAX 0x00 /* 1 port, Coax */
258 #define SETUP_DRAM 0x02 /* Number of DRAMS on board */
259
260 /*
261 ** EEPROM MANAGEMENT FLAGS
262 */
263 #define MGMT_CCE 0x01 /* Custom Counters Enable */
264
265 /*
266 ** EEPROM VERSIONS
267 */
268 #define LeMAC 0x11
269 #define LeMAC2 0x12
270
271 /*
272 ** Miscellaneous
273 */
274
275 #define EEPROM_WAIT_TIME 1000 /* Number of microseconds */
276 #define EISA_EN 0x0001 /* Enable EISA bus buffers */
277
278 #define HASH_TABLE_LEN 512 /* Bits */
279
280 #define XCT 0x80 /* Transmit Cut Through */
281 #define PRELOAD 16 /* 4 long words */
282
283 #define MASK_INTERRUPTS 1
284 #define UNMASK_INTERRUPTS 0
285
286 /*
287 ** Include the IOCTL stuff
288 */
289 #include <linux/sockios.h>
290
291 #define EWRK3IOCTL SIOCDEVPRIVATE
292
293 struct ewrk3_ioctl {
294 unsigned short cmd; /* Command to run */
295 unsigned short len; /* Length of the data buffer */
296 unsigned char *data; /* Pointer to the data buffer */
297 };
298
299 /*
300 ** Recognised commands for the driver
301 */
302 #define EWRK3_GET_HWADDR 0x01 /* Get the hardware address */
303 #define EWRK3_SET_HWADDR 0x02 /* Get the hardware address */
304 #define EWRK3_SET_PROM 0x03 /* Set Promiscuous Mode */
305 #define EWRK3_CLR_PROM 0x04 /* Clear Promiscuous Mode */
306 #define EWRK3_SAY_BOO 0x05 /* Say "Boo!" to the kernel log file */
307 #define EWRK3_GET_MCA 0x06 /* Get a multicast address */
308 #define EWRK3_SET_MCA 0x07 /* Set a multicast address */
309 #define EWRK3_CLR_MCA 0x08 /* Clear a multicast address */
310 #define EWRK3_MCA_EN 0x09 /* Enable a multicast address group */
311 #define EWRK3_GET_STATS 0x0a /* Get the driver statistics */
312 #define EWRK3_CLR_STATS 0x0b /* Zero out the driver statistics */
313 #define EWRK3_GET_CSR 0x0c /* Get the CSR Register contents */
314 #define EWRK3_SET_CSR 0x0d /* Set the CSR Register contents */
315 #define EWRK3_GET_EEPROM 0x0e /* Get the EEPROM contents */
316 #define EWRK3_SET_EEPROM 0x0f /* Set the EEPROM contents */
317 #define EWRK3_GET_CMR 0x10 /* Get the CMR Register contents */
318 #define EWRK3_CLR_TX_CUT_THRU 0x11 /* Clear the TX cut through mode */
319 #define EWRK3_SET_TX_CUT_THRU 0x12 /* Set the TX cut through mode */