xref: /netbsd/sys/arch/vax/if/if_zereg.h (revision bf9ec67e)
1 /*	$NetBSD: if_zereg.h,v 1.1 1998/07/01 10:52:10 ragge Exp $	*/
2 /*
3  * Copyright (c) 1988 Regents of the University of California.
4  * All rights reserved.
5  *
6  * This code is derived from software contributed to Berkeley by
7  * Digital Equipment Corp.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  * 3. All advertising materials mentioning features or use of this software
18  *    must display the following acknowledgement:
19  *	This product includes software developed by the University of
20  *	California, Berkeley and its contributors.
21  * 4. Neither the name of the University nor the names of its contributors
22  *    may be used to endorse or promote products derived from this software
23  *    without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35  * SUCH DAMAGE.
36  *
37  */
38 
39 
40 /* Driver for SGEC (second generation Ethernet controller) chip, type DC-541,
41    found on the KA670 (and prob ably other) CPU.
42 
43    17 May 1998...Jay Maynard, jmaynard@phoenix.net
44 */
45 
46 /* SGEC CSRs */
47 struct zedevice {
48 	u_long ze_nicsr0;	/* vector address, IPL, sync mode */
49 	u_long ze_nicsr1;	/* TX poll demand */
50 	u_long ze_nicsr2;	/* RX poll demand */
51 	struct ze_rdes *ze_nicsr3;	/* RX descriptor list address */
52 	struct ze_tdes *ze_nicsr4;	/* TX descriptor list address */
53 	u_long ze_nicsr5;	/* SGEC status */
54 	u_long ze_nicsr6;	/* SGEC command/mode */
55 	u_long ze_nicsr7;	/* system page table base address */
56 	u_long ze_nivcsr8;	/* reserved virtual CSR */
57 	u_long ze_nivcsr9;	/* watchdog timers (virtual) */
58 	u_long ze_nivcsr10;	/* revision, missed frame count (v) */
59 	u_long ze_nivcsr11;	/* boot message verification (low) (v) */
60 	u_long ze_nivcsr12;	/* boot message verification (high) (v) */
61 	u_long ze_nivcsr13;	/* boot message processor (v) */
62 	u_long ze_nivcsr14;	/* diagnostic breakpoint (v) */
63 	u_long ze_nicsr15;	/* monitor command */
64 };
65 
66 /* SGEC bit definitions */
67 /* NICSR0: */
68 #define ZE_NICSR0_IPL 0xc0000000	/* interrupt priority level: */
69 #define ZE_NICSR0_IPL14 0x00000000	/* 0x14 */
70 #define ZE_NICSR0_IPL15 0x40000000	/* 0x15 */
71 #define ZE_NICSR0_IPL16 0x80000000	/* 0x16 */
72 #define ZE_NICSR0_IPL17 0xc0000000	/* 0x17 */
73 #define ZE_NICSR0_SA 0x20000000		/* sync(1)/async mode */
74 #define ZE_NICSR0_MBO 0x1fff0003	/* must be set to one on write */
75 #define ZE_NICSR0_IV_MASK 0x0000fffc	/* bits for the interrupt vector */
76 
77 /* NICSR1: */
78 #define ZE_NICSR1_TXPD 0xffffffff	/* transmit polling demand */
79 
80 /* NICSR2: */
81 #define ZE_NICSR2_RXPD 0xffffffff	/* receive polling demand */
82 
83 /* NICSR3 and NICSR4 are pure addresses */
84 /* NICSR5: */
85 #define ZE_NICSR5_ID 0x80000000		/* init done */
86 #define ZE_NICSR5_SF 0x40000000		/* self-test failed */
87 #define ZE_NICSR5_SS 0x3c000000		/* self-test status field */
88 #define ZE_NICSR5_TS 0x03000000		/* transmission state: */
89 #define ZE_NICSR5_TS_STOP 0x00000000	/* stopped */
90 #define ZE_NICSR5_TS_RUN 0x01000000	/* running */
91 #define ZE_NICSR5_TS_SUSP 0x02000000	/* suspended */
92 #define ZE_NICSR5_RS 0x00c00000		/* reception state: */
93 #define ZE_NICSR5_RS_STOP 0x00000000	/* stopped */
94 #define ZE_NICSR5_RS_RUN 0x00400000	/* running */
95 #define ZE_NICSR5_RS_SUSP 0x00800000	/* suspended */
96 #define ZE_NICSR5_OM 0x00060000		/* operating mode: */
97 #define ZE_NICSR5_OM_NORM 0x00000000	/* normal */
98 #define ZE_NICSR5_OM_ILBK 0x00020000	/* internal loopback */
99 #define ZE_NICSR5_OM_ELBK 0x00040000	/* external loopback */
100 #define ZE_NICSR5_OM_DIAG 0x00060000	/* reserved for diags */
101 #define ZE_NICSR5_DN 0x00010000		/* virtual CSR access done */
102 #define ZE_NICSR5_MBO 0x0038ff00	/* must be one */
103 #define ZE_NICSR5_BO 0x00000080		/* boot message received */
104 #define ZE_NICSR5_TW 0x00000040		/* transmit watchdog timeout */
105 #define ZE_NICSR5_RW 0x00000020		/* receive watchdog timeout */
106 #define ZE_NICSR5_ME 0x00000010		/* memory error */
107 #define ZE_NICSR5_RU 0x00000008		/* receive buffer unavailable */
108 #define ZE_NICSR5_RI 0x00000004		/* receiver interrupt */
109 #define ZE_NICSR5_TI 0x00000002		/* transmitter interrupt */
110 #define ZE_NICSR5_IS 0x00000001		/* interrupt summary */
111 /* whew! */
112 
113 /* NICSR6: */
114 #define ZE_NICSR6_RE 0x80000000		/* reset */
115 #define ZE_NICSR6_IE 0x40000000		/* interrupt enable */
116 #define ZE_NICSR6_MBO 0x01e7f000	/* must be one */
117 #define ZE_NICSR6_BL 0x1e000000		/* burst limit mask */
118 #define ZE_NICSR6_BL_8 0x10000000	/* 8 longwords */
119 #define ZE_NICSR6_BL_4 0x08000000	/* 4 longwords */
120 #define ZE_NICSR6_BL_2 0x04000000	/* 2 longwords */
121 #define ZE_NICSR6_BL_1 0x02000000	/* 1 longword */
122 #define ZE_NICSR6_BE 0x00100000		/* boot message enable */
123 #define ZE_NICSR6_SE 0x00080000		/* single cycle enable */
124 #define ZE_NICSR6_ST 0x00000800		/* start(1)/stop(0) transmission */
125 #define ZE_NICSR6_SR 0x00000400		/* start(1)/stop(0) reception */
126 #define ZE_NICSR6_OM 0x00000300		/* operating mode: */
127 #define ZE_NICSR6_OM_NORM 0x00000000	/* normal */
128 #define ZE_NICSR6_OM_ILBK 0x00000100	/* internal loopback */
129 #define ZE_NICSR6_OM_ELBK 0x00000200	/* external loopback */
130 #define ZE_NICSR6_OM_DIAG 0x00000300	/* reserved for diags */
131 #define ZE_NICSR6_DC 0x00000080		/* disable data chaining */
132 #define ZE_NICSR6_FC 0x00000040		/* force collision mode */
133 #define ZE_NICSR6_PB 0x00000008		/* pass bad frames */
134 #define ZE_NICSR6_AF 0x00000006		/* address filtering mode: */
135 #define ZE_NICSR6_AF_NORM 0x00000000	/* normal filtering */
136 #define ZE_NICSR6_AF_PROM 0x00000002	/* promiscuous mode */
137 #define ZE_NICSR6_AF_ALLM 0x00000004	/* all multicasts */
138 
139 /* NICSR7 is an address, NICSR8 is reserved */
140 /* NICSR9: */
141 #define ZE_VNICSR9_RT 0xffff0000	/* receiver timeout, *1.6 us */
142 #define ZE_VNICSR9_TT 0x0000ffff	/* transmitter timeout */
143 
144 /* NICSR10: */
145 #define ZE_VNICSR10_RN 0x001f0000	/* SGEC version */
146 #define ZE_VNICSR10_MFC 0x0000ffff	/* missed frame counter */
147 
148 /* if you want to know what's in NICSRs 11-15, define them yourself! */
149 
150 /* Descriptors: */
151 /* Receive descriptor */
152 struct ze_rdes {
153 	u_short ze_rdes0;		/* descriptor word 0 flags */
154 	u_short ze_framelen;		/* received frame length */
155 	u_char ze_rsvd1[3];		/* unused bytes */
156 	u_char ze_rdes1;		/* descriptor word 1 flags */
157 	short ze_pageoffset;		/* offset of buffer in page */
158 	short ze_bufsize;		/* length of data buffer */
159 	u_char *ze_bufaddr;		/* address of data buffer */
160 };
161 
162 /* Receive descriptor bits */
163 #define ZE_FRAMELEN_OW 0x8000		/* SGEC owns this descriptor */
164 #define ZE_RDES0_ES 0x8000		/* an error has occurred */
165 #define ZE_RDES0_LE 0x4000		/* length error */
166 #define ZE_RDES0_DT 0x3000		/* data type: */
167 #define ZE_RDES0_DT_NORM 0x0000		/* normal frame */
168 #define ZE_RDES0_DT_ILBK 0x1000		/* internally looped back frame */
169 #define ZE_RDES0_DT_ELBK 0x2000		/* externally looped back frame */
170 #define ZE_RDES0_RF 0x0800		/* runt frame */
171 #define ZE_RDES0_BO 0x0400		/* buffer overflow */
172 #define ZE_RDES0_FS 0x0200		/* first segment */
173 #define ZE_RDES0_LS 0x0100		/* last segment */
174 #define ZE_RDES0_TL 0x0080		/* frame too long */
175 #define ZE_RDES0_CS 0x0040		/* collision seen */
176 #define ZE_RDES0_FT 0x0020		/* Ethernet frame type */
177 #define ZE_RDES0_TN 0x0008		/* address translation not valid */
178 #define ZE_RDES0_DB 0x0004		/* dribbling bits seen */
179 #define ZE_RDES0_CE 0x0002		/* CRC error */
180 #define ZE_RDES0_OF 0x0001		/* internal FIFO overflow */
181 #define ZE_RDES1_CA 0x80		/* chain address */
182 #define ZE_RDES1_VA 0x40		/* virtual address */
183 #define ZE_RDES1_VT 0x20		/* virtual(1)/phys PTE address */
184 
185 /* Transmit descriptor */
186 struct ze_tdes {
187 	u_short ze_tdes0;		/* descriptor word 0 flags */
188 	u_short ze_tdr;			/* TDR count of cable fault */
189 	u_char ze_rsvd1[2];		/* unused bytes */
190 	u_short ze_tdes1;		/* descriptor word 1 flags */
191 	short ze_pageoffset;		/* offset of buffer in page */
192 	short ze_bufsize;		/* length of data buffer */
193 	u_char *ze_bufaddr;		/* address of data buffer */
194 };
195 
196 /* Receive descriptor bits */
197 #define ZE_TDR_OW 0x8000		/* SGEC owns this descriptor */
198 #define ZE_TDES0_ES 0x8000		/* an error has occurred */
199 #define ZE_TDES0_TO 0x4000		/* transmit watchdog timeout */
200 #define ZE_TDES0_LE 0x1000		/* length error */
201 #define ZE_TDES0_LO 0x0800		/* loss of carrier */
202 #define ZE_TDES0_NC 0x0400		/* no carrier */
203 #define ZE_TDES0_LC 0x0200		/* late collision */
204 #define ZE_TDES0_EC 0x0100		/* excessive collisions */
205 #define ZE_TDES0_HF 0x0080		/* heartbeat fail */
206 #define ZE_TDES0_CC 0x0078		/* collision count mask */
207 #define ZE_TDES0_TN 0x0004		/* address translation invalid */
208 #define ZE_TDES0_UF 0x0002		/* underflow */
209 #define ZE_TDES0_DE 0x0001		/* transmission deferred */
210 #define ZE_TDES1_CA 0x8000		/* chain address */
211 #define ZE_TDES1_VA 0x4000		/* virtual address */
212 #define ZE_TDES1_DT 0x3000		/* data type: */
213 #define ZE_TDES1_DT_NORM 0x0000		/* normal transmit frame */
214 #define ZE_TDES1_DT_SETUP 0x2000	/* setup frame */
215 #define ZE_TDES1_DT_DIAG 0x3000		/* diagnostic frame */
216 #define ZE_TDES1_AC 0x0800		/* CRC disable */
217 #define ZE_TDES1_FS 0x0400		/* first segment */
218 #define ZE_TDES1_LS 0x0200		/* last segment */
219 #define ZE_TDES1_IC 0x0100		/* interrupt on completion */
220 #define ZE_TDES1_VT 0x0080		/* virtual(1)/phys PTE address */
221 
222