xref: /original-bsd/sys/pmax/dev/if_lereg.h (revision 433e7553)
1 /*-
2  * Copyright (c) 1992, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * This code is derived from software contributed to Berkeley by
6  * Ralph Campbell and Rick Macklem.
7  *
8  * %sccs.include.redist.c%
9  *
10  *	@(#)if_lereg.h	8.1 (Berkeley) 06/10/93
11  */
12 
13 #define	LEMTU		1518
14 #define	LEBLEN		1520	/* LEMTU up to a multiple of 16 */
15 #define	LEMINSIZE	60	/* should be 64 if mode DTCR is set */
16 #define	LERBUF		32
17 #define	LERBUFLOG2	5
18 #define	LE_RLEN		(LERBUFLOG2 << 13)
19 #define	LETBUF		8
20 #define	LETBUFLOG2	3
21 #define	LE_TLEN		(LETBUFLOG2 << 13)
22 
23 /*
24  * LANCE registers.
25  */
26 struct lereg1 {
27 	u_short	ler1_rdp;	/* data port */
28 	short	pad0;
29 	u_short	ler1_rap;	/* register select port */
30 	short	pad1;
31 };
32 
33 /*
34  * This structure is overlayed on the network dual-port RAM.
35  * Currently 32 * 1520 receive plus 8 * 1520 transmit buffers plus
36  * buffer descriptor rings.
37  * There are two variants of the structure, one for the Pmax/3min/maxine
38  * with 2 byte pads between entries and one for the 3max and turbochannel
39  * option densely packed.
40  */
41 struct	lermd {			/* +0x0020 */
42 	u_short	rmd0;
43 	u_short	rmd1;
44 	short	rmd2;
45 	u_short	rmd3;
46 };
47 
48 struct	letmd {			/* +0x0058 */
49 	u_short	tmd0;
50 	u_short	tmd1;
51 	short	tmd2;
52 	u_short	tmd3;
53 };
54 
55 struct	lermdpad {			/* +0x0020 */
56 	u_short	rmd0;
57 	short	pad0;
58 	u_short	rmd1;
59 	short	pad1;
60 	short	rmd2;
61 	short	pad2;
62 	u_short	rmd3;
63 	short	pad3;
64 };
65 
66 struct	letmdpad {			/* +0x0058 */
67 	u_short	tmd0;
68 	short	pad0;
69 	u_short	tmd1;
70 	short	pad1;
71 	short	tmd2;
72 	short	pad2;
73 	u_short	tmd3;
74 	short	pad3;
75 };
76 
77 struct lereg2 {
78 	/* init block */		/* CHIP address */
79 	u_short	ler2_mode;		/* +0x0000 */
80 	u_short	ler2_padr0;		/* +0x0002 */
81 	u_short	ler2_padr1;		/* +0x0004 */
82 	u_short	ler2_padr2;		/* +0x0006 */
83 	u_short	ler2_ladrf0;		/* +0x0008 */
84 	u_short	ler2_ladrf1;		/* +0x000A */
85 	u_short	ler2_ladrf2;		/* +0x000C */
86 	u_short	ler2_ladrf3;		/* +0x000E */
87 	u_short	ler2_rdra;		/* +0x0010 */
88 	u_short	ler2_rlen;		/* +0x0012 */
89 	u_short	ler2_tdra;		/* +0x0014 */
90 	u_short	ler2_tlen;		/* +0x0016 */
91 	short	pad0[4];		/* Pad to 16 shorts */
92 	/* receive message descriptors */
93 	struct lermd ler2_rmd[LERBUF];
94 	/* transmit message descriptors */
95 	struct letmd ler2_tmd[LETBUF];
96 	char	ler2_rbuf[LERBUF][LEBLEN]; /* +0x0060 */
97 	char	ler2_tbuf[LETBUF][LEBLEN]; /* +0x2FD0 */
98 };
99 
100 struct lereg2pad {
101 	/* init block */		/* CHIP address */
102 	u_short	ler2_mode;		/* +0x0000 */
103 	short	pad0;
104 	u_short	ler2_padr0;		/* +0x0002 */
105 	short	pad1;
106 	u_short	ler2_padr1;		/* +0x0004 */
107 	short	pad2;
108 	u_short	ler2_padr2;		/* +0x0006 */
109 	short	pad3;
110 	u_short	ler2_ladrf0;		/* +0x0008 */
111 	short	pad4;
112 	u_short	ler2_ladrf1;		/* +0x000A */
113 	short	pad5;
114 	u_short	ler2_ladrf2;		/* +0x000C */
115 	short	pad6;
116 	u_short	ler2_ladrf3;		/* +0x000E */
117 	short	pad7;
118 	u_short	ler2_rdra;		/* +0x0010 */
119 	short	pad8;
120 	u_short	ler2_rlen;		/* +0x0012 */
121 	short	pad9;
122 	u_short	ler2_tdra;		/* +0x0014 */
123 	short	pad10;
124 	u_short	ler2_tlen;		/* +0x0016 */
125 	short	pad11[9];		/* Pad to 32 shorts */
126 	/* receive message descriptors */
127 	struct lermdpad ler2_rmd[LERBUF];
128 	/* transmit message descriptors */
129 	struct letmdpad ler2_tmd[LETBUF];
130 	short	ler2_rbuf[LERBUF][LEBLEN]; /* +0x0060 */
131 	short	ler2_tbuf[LETBUF][LEBLEN]; /* +0x2FD0 */
132 };
133 
134 /*
135  * Now for some truly ugly macros to access the structure fields
136  * padded/non-padded at runtime. (For once, a Pascal like record variant
137  * would be nice to have.)
138  */
139 #define	LER2_RMDADDR(p, i) \
140 		(le->sc_ler2pad ? \
141 		 (volatile void *)&(((struct lereg2pad *)(p))->ler2_rmd[(i)]) : \
142 		 (volatile void *)&(((struct lereg2 *)(p))->ler2_rmd[(i)]))
143 
144 #define	LER2_TMDADDR(p, i) \
145 		((le->sc_ler2pad ? \
146 		 (volatile void *)&(((struct lereg2pad *)(p))->ler2_tmd[(i)]) : \
147 		 (volatile void *)&(((struct lereg2 *)(p))->ler2_tmd[(i)])))
148 
149 #define	LER2_RBUFADDR(p, i) \
150 		((le->sc_ler2pad ? \
151 		 (volatile void *)(((struct lereg2pad *)(p))->ler2_rbuf[(i)]) : \
152 		 (volatile void *)(((struct lereg2 *)(p))->ler2_rbuf[(i)])))
153 
154 #define	LER2_TBUFADDR(p, i) \
155 		((le->sc_ler2pad ? \
156 		 (volatile void *)(((struct lereg2pad *)(p))->ler2_tbuf[(i)]) : \
157 		 (volatile void *)(((struct lereg2 *)(p))->ler2_tbuf[(i)])))
158 
159 #define LER2_mode(p, v) \
160 	(le->sc_ler2pad ? (((volatile struct lereg2pad *)(p))->ler2_mode = (v)) : \
161 	 (((volatile struct lereg2 *)(p))->ler2_mode = (v)))
162 #define	LER2V_mode(p) \
163 	(le->sc_ler2pad ? ((volatile struct lereg2pad *)(p))->ler2_mode : \
164 	 ((volatile struct lereg2 *)(p))->ler2_mode)
165 
166 #define LER2_padr0(p, v) \
167 	(le->sc_ler2pad ? (((volatile struct lereg2pad *)(p))->ler2_padr0 = (v)) : \
168 	 (((volatile struct lereg2 *)(p))->ler2_padr0 = (v)))
169 #define	LER2V_padr0(p) \
170 	(le->sc_ler2pad ? ((volatile struct lereg2pad *)(p))->ler2_padr0 : \
171 	 ((volatile struct lereg2 *)(p))->ler2_padr0)
172 
173 #define LER2_padr1(p, v) \
174 	(le->sc_ler2pad ? (((volatile struct lereg2pad *)(p))->ler2_padr1 = (v)) : \
175 	 (((volatile struct lereg2 *)(p))->ler2_padr1 = (v)))
176 #define	LER2V_padr1(p) \
177 	(le->sc_ler2pad ? ((volatile struct lereg2pad *)(p))->ler2_padr1 : \
178 	 ((volatile struct lereg2 *)(p))->ler2_padr1)
179 
180 #define LER2_padr2(p, v) \
181 	(le->sc_ler2pad ? (((volatile struct lereg2pad *)(p))->ler2_padr2 = (v)) : \
182 	 (((volatile struct lereg2 *)(p))->ler2_padr2 = (v)))
183 #define	LER2V_padr2(p) \
184 	(le->sc_ler2pad ? ((volatile struct lereg2pad *)(p))->ler2_padr2 : \
185 	 ((volatile struct lereg2 *)(p))->ler2_padr2)
186 
187 #define LER2_ladrf0(p, v) \
188 	(le->sc_ler2pad ? (((volatile struct lereg2pad *)(p))->ler2_ladrf0 = (v)) : \
189 	 (((volatile struct lereg2 *)(p))->ler2_ladrf0 = (v)))
190 #define	LER2V_ladrf0(p) \
191 	(le->sc_ler2pad ? ((volatile struct lereg2pad *)(p))->ler2_ladrf0 : \
192 	 ((volatile struct lereg2 *)(p))->ler2_ladrf0)
193 
194 #define LER2_ladrf1(p, v) \
195 	(le->sc_ler2pad ? (((volatile struct lereg2pad *)(p))->ler2_ladrf1 = (v)) : \
196 	 (((volatile struct lereg2 *)(p))->ler2_ladrf1 = (v)))
197 #define	LER2V_ladrf1(p) \
198 	(le->sc_ler2pad ? ((volatile struct lereg2pad *)(p))->ler2_ladrf1 : \
199 	 ((volatile struct lereg2 *)(p))->ler2_ladrf1)
200 
201 #define LER2_ladrf2(p, v) \
202 	(le->sc_ler2pad ? (((volatile struct lereg2pad *)(p))->ler2_ladrf2 = (v)) : \
203 	 (((volatile struct lereg2 *)(p))->ler2_ladrf2 = (v)))
204 #define	LER2V_ladrf2(p) \
205 	(le->sc_ler2pad ? ((volatile struct lereg2pad *)(p))->ler2_ladrf2 : \
206 	 ((volatile struct lereg2 *)(p))->ler2_ladrf2)
207 
208 #define LER2_ladrf3(p, v) \
209 	(le->sc_ler2pad ? (((volatile struct lereg2pad *)(p))->ler2_ladrf3 = (v)) : \
210 	 (((volatile struct lereg2 *)(p))->ler2_ladrf3 = (v)))
211 #define	LER2V_ladrf3(p) \
212 	(le->sc_ler2pad ? ((volatile struct lereg2pad *)(p))->ler2_ladrf3 : \
213 	 ((volatile struct lereg2 *)(p))->ler2_ladrf3)
214 
215 #define LER2_rdra(p, v) \
216 	(le->sc_ler2pad ? (((volatile struct lereg2pad *)(p))->ler2_rdra = (v)) : \
217 	 (((volatile struct lereg2 *)(p))->ler2_rdra = (v)))
218 #define	LER2V_rdra(p) \
219 	(le->sc_ler2pad ? ((volatile struct lereg2pad *)(p))->ler2_rdra : \
220 	 ((volatile struct lereg2 *)(p))->ler2_rdra)
221 
222 #define LER2_rlen(p, v) \
223 	(le->sc_ler2pad ? (((volatile struct lereg2pad *)(p))->ler2_rlen = (v)) : \
224 	 (((volatile struct lereg2 *)(p))->ler2_rlen = (v)))
225 #define	LER2V_rlen(p) \
226 	(le->sc_ler2pad ? ((volatile struct lereg2pad *)(p))->ler2_rlen : \
227 	 ((volatile struct lereg2 *)(p))->ler2_rlen)
228 
229 #define LER2_tdra(p, v) \
230 	(le->sc_ler2pad ? (((volatile struct lereg2pad *)(p))->ler2_tdra = (v)) : \
231 	 (((volatile struct lereg2 *)(p))->ler2_tdra = (v)))
232 #define	LER2V_tdra(p) \
233 	(le->sc_ler2pad ? ((volatile struct lereg2pad *)(p))->ler2_tdra : \
234 	 ((volatile struct lereg2 *)(p))->ler2_tdra)
235 
236 #define LER2_tlen(p, v) \
237 	(le->sc_ler2pad ? (((volatile struct lereg2pad *)(p))->ler2_tlen = (v)) : \
238 	 (((volatile struct lereg2 *)(p))->ler2_tlen = (v)))
239 #define	LER2V_tlen(p) \
240 	(le->sc_ler2pad ? ((volatile struct lereg2pad *)(p))->ler2_tlen : \
241 	 ((volatile struct lereg2 *)(p))->ler2_tlen)
242 
243 #define LER2_rmd0(p, v) \
244 	(le->sc_ler2pad ? (((volatile struct lermdpad *)(p))->rmd0 = (v)) : \
245 	 ((((volatile struct lermd *)(p))->rmd0 = (v))))
246 #define LER2V_rmd0(p) \
247 	(le->sc_ler2pad ? ((volatile struct lermdpad *)(p))->rmd0 : \
248 	 ((volatile struct lermd *)(p))->rmd0)
249 
250 #define LER2_rmd1(p, v) \
251 	(le->sc_ler2pad ? (((volatile struct lermdpad *)(p))->rmd1 = (v)) : \
252 	 (((volatile struct lermd *)(p))->rmd1 = (v)))
253 #define LER2V_rmd1(p) \
254 	(le->sc_ler2pad ? ((volatile struct lermdpad *)(p))->rmd1 : \
255 	 ((volatile struct lermd *)(p))->rmd1)
256 
257 #define LER2_rmd2(p, v) \
258 	(le->sc_ler2pad ? (((volatile struct lermdpad *)(p))->rmd2 = (v)) : \
259 	 (((volatile struct lermd *)(p))->rmd2 = (v)))
260 #define LER2V_rmd2(p) \
261 	(le->sc_ler2pad ? ((volatile struct lermdpad *)(p))->rmd2 : \
262 	 ((volatile struct lermd *)(p))->rmd2)
263 
264 #define LER2_rmd3(p, v) \
265 	(le->sc_ler2pad ? (((volatile struct lermdpad *)(p))->rmd3 = (v)) : \
266 	 (((volatile struct lermd *)(p))->rmd3 = (v)))
267 #define LER2V_rmd3(p) \
268 	(le->sc_ler2pad ? ((volatile struct lermdpad *)(p))->rmd3 : \
269 	 ((volatile struct lermd *)(p))->rmd3)
270 
271 #define LER2_tmd0(p, v) \
272 	(le->sc_ler2pad ? (((volatile struct letmdpad *)(p))->tmd0 = (v)) : \
273 	 (((volatile struct letmd *)(p))->tmd0 = (v)))
274 #define LER2V_tmd0(p) \
275 	(le->sc_ler2pad ? ((volatile struct letmdpad *)(p))->tmd0 : \
276 	 ((volatile struct letmd *)(p))->tmd0)
277 
278 #define LER2_tmd1(p, v) \
279 	(le->sc_ler2pad ? (((volatile struct letmdpad *)(p))->tmd1 = (v)) : \
280 	 (((volatile struct letmd *)(p))->tmd1 = (v)))
281 #define LER2V_tmd1(p) \
282 	(le->sc_ler2pad ? ((volatile struct letmdpad *)(p))->tmd1 : \
283 	 ((volatile struct letmd *)(p))->tmd1)
284 
285 #define LER2_tmd2(p, v) \
286 	(le->sc_ler2pad ? (((volatile struct letmdpad *)(p))->tmd2 = (v)) : \
287 	 (((volatile struct letmd *)(p))->tmd2 = (v)))
288 #define LER2V_tmd2(p) \
289 	(le->sc_ler2pad ? ((volatile struct letmdpad *)(p))->tmd2 : \
290 	 ((volatile struct letmd *)(p))->tmd2)
291 
292 #define LER2_tmd3(p, v) \
293 	(le->sc_ler2pad ? (((volatile struct letmdpad *)(p))->tmd3 = (v)) : \
294 	 (((volatile struct letmd *)(p))->tmd3 = (v)))
295 #define LER2V_tmd3(p) \
296 	(le->sc_ler2pad ? ((volatile struct letmdpad *)(p))->tmd3 : \
297 	 ((volatile struct letmd *)(p))->tmd3)
298 
299 /*
300  * Control and status bits -- lereg0
301  */
302 #define	LE_IE		0x80		/* interrupt enable */
303 #define	LE_IR		0x40		/* interrupt requested */
304 #define	LE_LOCK		0x08		/* lock status register */
305 #define	LE_ACK		0x04		/* ack of lock */
306 #define	LE_JAB		0x02		/* loss of tx clock (???) */
307 #define LE_IPL(x)	((((x) >> 4) & 0x3) + 3)
308 
309 /*
310  * Control and status bits -- lereg1
311  */
312 #define	LE_CSR0		0
313 #define	LE_CSR1		1
314 #define	LE_CSR2		2
315 #define	LE_CSR3		3
316 
317 #define	LE_SERR		0x8000
318 #define	LE_BABL		0x4000
319 #define	LE_CERR		0x2000
320 #define	LE_MISS		0x1000
321 #define	LE_MERR		0x0800
322 #define	LE_RINT		0x0400
323 #define	LE_TINT		0x0200
324 #define	LE_IDON		0x0100
325 #define	LE_INTR		0x0080
326 #define	LE_INEA		0x0040
327 #define	LE_RXON		0x0020
328 #define	LE_TXON		0x0010
329 #define	LE_TDMD		0x0008
330 #define	LE_STOP		0x0004
331 #define	LE_STRT		0x0002
332 #define	LE_INIT		0x0001
333 
334 #define	LE_BSWP		0x4
335 #define	LE_MODE		0x0
336 
337 /*
338  * Control and status bits -- lereg2
339  */
340 #define	LE_OWN		0x8000
341 #define	LE_ERR		0x4000
342 #define	LE_STP		0x0200
343 #define	LE_ENP		0x0100
344 
345 #define	LE_FRAM		0x2000
346 #define	LE_OFLO		0x1000
347 #define	LE_CRC		0x0800
348 #define	LE_RBUFF	0x0400
349 
350 #define	LE_MORE		0x1000
351 #define	LE_ONE		0x0800
352 #define	LE_DEF		0x0400
353 
354 #define	LE_TBUFF	0x8000
355 #define	LE_UFLO		0x4000
356 #define	LE_LCOL		0x1000
357 #define	LE_LCAR		0x0800
358 #define	LE_RTRY		0x0400
359