sgecreg.h revision 1.2 1 /* $NetBSD: sgecreg.h,v 1.2 2003/01/06 21:05:38 matt 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 #ifndef _DEV_IC_SGECREG_H_
40 #define _DEV_IC_SGECREG_H_
41
42 /* Driver for SGEC (second generation Ethernet controller) chip, type DC-541,
43 found on the KA670 (and prob ably other) CPU.
44
45 17 May 1998...Jay Maynard, jmaynard (at) phoenix.net
46 */
47
48 /* SGEC CSRs */
49 struct zedevice {
50 u_long ze_nicsr0; /* vector address, IPL, sync mode */
51 u_long ze_nicsr1; /* TX poll demand */
52 u_long ze_nicsr2; /* RX poll demand */
53 struct ze_rdes *ze_nicsr3; /* RX descriptor list address */
54 struct ze_tdes *ze_nicsr4; /* TX descriptor list address */
55 u_long ze_nicsr5; /* SGEC status */
56 u_long ze_nicsr6; /* SGEC command/mode */
57 u_long ze_nicsr7; /* system page table base address */
58 u_long ze_nivcsr8; /* reserved virtual CSR */
59 u_long ze_nivcsr9; /* watchdog timers (virtual) */
60 u_long ze_nivcsr10; /* revision, missed frame count (v) */
61 u_long ze_nivcsr11; /* boot message verification (low) (v) */
62 u_long ze_nivcsr12; /* boot message verification (high) (v) */
63 u_long ze_nivcsr13; /* boot message processor (v) */
64 u_long ze_nivcsr14; /* diagnostic breakpoint (v) */
65 u_long ze_nicsr15; /* monitor command */
66 };
67
68 /*
69 * Register offsets.
70 */
71 #define ZE_CSR0 0
72 #define ZE_CSR1 4
73 #define ZE_CSR2 8
74 #define ZE_CSR3 12
75 #define ZE_CSR4 16
76 #define ZE_CSR5 20
77 #define ZE_CSR6 24
78 #define ZE_CSR7 28
79 #define ZE_CSR8 32
80 #define ZE_CSR9 36
81 #define ZE_CSR10 40
82 #define ZE_CSR11 44
83 #define ZE_CSR12 48
84 #define ZE_CSR13 52
85 #define ZE_CSR14 56
86 #define ZE_CSR15 60
87
88 /* SGEC bit definitions */
89 /* NICSR0: */
90 #define ZE_NICSR0_IPL 0xc0000000 /* interrupt priority level: */
91 #define ZE_NICSR0_IPL14 0x00000000 /* 0x14 */
92 #define ZE_NICSR0_IPL15 0x40000000 /* 0x15 */
93 #define ZE_NICSR0_IPL16 0x80000000 /* 0x16 */
94 #define ZE_NICSR0_IPL17 0xc0000000 /* 0x17 */
95 #define ZE_NICSR0_SA 0x20000000 /* sync(1)/async mode */
96 #define ZE_NICSR0_MBO 0x1fff0003 /* must be set to one on write */
97 #define ZE_NICSR0_IV_MASK 0x0000fffc /* bits for the interrupt vector */
98
99 /* NICSR1: */
100 #define ZE_NICSR1_TXPD 0xffffffff /* transmit polling demand */
101
102 /* NICSR2: */
103 #define ZE_NICSR2_RXPD 0xffffffff /* receive polling demand */
104
105 /* NICSR3 and NICSR4 are pure addresses */
106 /* NICSR5: */
107 #define ZE_NICSR5_ID 0x80000000 /* init done */
108 #define ZE_NICSR5_SF 0x40000000 /* self-test failed */
109 #define ZE_NICSR5_SS 0x3c000000 /* self-test status field */
110 #define ZE_NICSR5_TS 0x03000000 /* transmission state: */
111 #define ZE_NICSR5_TS_STOP 0x00000000 /* stopped */
112 #define ZE_NICSR5_TS_RUN 0x01000000 /* running */
113 #define ZE_NICSR5_TS_SUSP 0x02000000 /* suspended */
114 #define ZE_NICSR5_RS 0x00c00000 /* reception state: */
115 #define ZE_NICSR5_RS_STOP 0x00000000 /* stopped */
116 #define ZE_NICSR5_RS_RUN 0x00400000 /* running */
117 #define ZE_NICSR5_RS_SUSP 0x00800000 /* suspended */
118 #define ZE_NICSR5_OM 0x00060000 /* operating mode: */
119 #define ZE_NICSR5_OM_NORM 0x00000000 /* normal */
120 #define ZE_NICSR5_OM_ILBK 0x00020000 /* internal loopback */
121 #define ZE_NICSR5_OM_ELBK 0x00040000 /* external loopback */
122 #define ZE_NICSR5_OM_DIAG 0x00060000 /* reserved for diags */
123 #define ZE_NICSR5_DN 0x00010000 /* virtual CSR access done */
124 #define ZE_NICSR5_MBO 0x0038ff00 /* must be one */
125 #define ZE_NICSR5_BO 0x00000080 /* boot message received */
126 #define ZE_NICSR5_TW 0x00000040 /* transmit watchdog timeout */
127 #define ZE_NICSR5_RW 0x00000020 /* receive watchdog timeout */
128 #define ZE_NICSR5_ME 0x00000010 /* memory error */
129 #define ZE_NICSR5_RU 0x00000008 /* receive buffer unavailable */
130 #define ZE_NICSR5_RI 0x00000004 /* receiver interrupt */
131 #define ZE_NICSR5_TI 0x00000002 /* transmitter interrupt */
132 #define ZE_NICSR5_IS 0x00000001 /* interrupt summary */
133 /* whew! */
134
135 /* NICSR6: */
136 #define ZE_NICSR6_RE 0x80000000 /* reset */
137 #define ZE_NICSR6_IE 0x40000000 /* interrupt enable */
138 #define ZE_NICSR6_MBO 0x01e7f000 /* must be one */
139 #define ZE_NICSR6_BL 0x1e000000 /* burst limit mask */
140 #define ZE_NICSR6_BL_8 0x10000000 /* 8 longwords */
141 #define ZE_NICSR6_BL_4 0x08000000 /* 4 longwords */
142 #define ZE_NICSR6_BL_2 0x04000000 /* 2 longwords */
143 #define ZE_NICSR6_BL_1 0x02000000 /* 1 longword */
144 #define ZE_NICSR6_BE 0x00100000 /* boot message enable */
145 #define ZE_NICSR6_SE 0x00080000 /* single cycle enable */
146 #define ZE_NICSR6_ST 0x00000800 /* start(1)/stop(0) transmission */
147 #define ZE_NICSR6_SR 0x00000400 /* start(1)/stop(0) reception */
148 #define ZE_NICSR6_OM 0x00000300 /* operating mode: */
149 #define ZE_NICSR6_OM_NORM 0x00000000 /* normal */
150 #define ZE_NICSR6_OM_ILBK 0x00000100 /* internal loopback */
151 #define ZE_NICSR6_OM_ELBK 0x00000200 /* external loopback */
152 #define ZE_NICSR6_OM_DIAG 0x00000300 /* reserved for diags */
153 #define ZE_NICSR6_DC 0x00000080 /* disable data chaining */
154 #define ZE_NICSR6_FC 0x00000040 /* force collision mode */
155 #define ZE_NICSR6_PB 0x00000008 /* pass bad frames */
156 #define ZE_NICSR6_AF 0x00000006 /* address filtering mode: */
157 #define ZE_NICSR6_AF_NORM 0x00000000 /* normal filtering */
158 #define ZE_NICSR6_AF_PROM 0x00000002 /* promiscuous mode */
159 #define ZE_NICSR6_AF_ALLM 0x00000004 /* all multicasts */
160
161 /* NICSR7 is an address, NICSR8 is reserved */
162 /* NICSR9: */
163 #define ZE_VNICSR9_RT 0xffff0000 /* receiver timeout, *1.6 us */
164 #define ZE_VNICSR9_TT 0x0000ffff /* transmitter timeout */
165
166 /* NICSR10: */
167 #define ZE_VNICSR10_RN 0x001f0000 /* SGEC version */
168 #define ZE_VNICSR10_MFC 0x0000ffff /* missed frame counter */
169
170 /* if you want to know what's in NICSRs 11-15, define them yourself! */
171
172 /* Descriptors: */
173 /* Receive descriptor */
174 struct ze_rdes {
175 u_short ze_rdes0; /* descriptor word 0 flags */
176 u_short ze_framelen; /* received frame length */
177 u_char ze_rsvd1[3]; /* unused bytes */
178 u_char ze_rdes1; /* descriptor word 1 flags */
179 short ze_pageoffset; /* offset of buffer in page */
180 short ze_bufsize; /* length of data buffer */
181 u_char *ze_bufaddr; /* address of data buffer */
182 };
183
184 /* Receive descriptor bits */
185 #define ZE_FRAMELEN_OW 0x8000 /* SGEC owns this descriptor */
186 #define ZE_RDES0_ES 0x8000 /* an error has occurred */
187 #define ZE_RDES0_LE 0x4000 /* length error */
188 #define ZE_RDES0_DT 0x3000 /* data type: */
189 #define ZE_RDES0_DT_NORM 0x0000 /* normal frame */
190 #define ZE_RDES0_DT_ILBK 0x1000 /* internally looped back frame */
191 #define ZE_RDES0_DT_ELBK 0x2000 /* externally looped back frame */
192 #define ZE_RDES0_RF 0x0800 /* runt frame */
193 #define ZE_RDES0_BO 0x0400 /* buffer overflow */
194 #define ZE_RDES0_FS 0x0200 /* first segment */
195 #define ZE_RDES0_LS 0x0100 /* last segment */
196 #define ZE_RDES0_TL 0x0080 /* frame too long */
197 #define ZE_RDES0_CS 0x0040 /* collision seen */
198 #define ZE_RDES0_FT 0x0020 /* Ethernet frame type */
199 #define ZE_RDES0_TN 0x0008 /* address translation not valid */
200 #define ZE_RDES0_DB 0x0004 /* dribbling bits seen */
201 #define ZE_RDES0_CE 0x0002 /* CRC error */
202 #define ZE_RDES0_OF 0x0001 /* internal FIFO overflow */
203 #define ZE_RDES1_CA 0x80 /* chain address */
204 #define ZE_RDES1_VA 0x40 /* virtual address */
205 #define ZE_RDES1_VT 0x20 /* virtual(1)/phys PTE address */
206
207 /* Transmit descriptor */
208 struct ze_tdes {
209 u_short ze_tdes0; /* descriptor word 0 flags */
210 u_short ze_tdr; /* TDR count of cable fault */
211 u_char ze_rsvd1[2]; /* unused bytes */
212 u_short ze_tdes1; /* descriptor word 1 flags */
213 short ze_pageoffset; /* offset of buffer in page */
214 short ze_bufsize; /* length of data buffer */
215 u_char *ze_bufaddr; /* address of data buffer */
216 };
217
218 /* Receive descriptor bits */
219 #define ZE_TDR_OW 0x8000 /* SGEC owns this descriptor */
220 #define ZE_TDES0_ES 0x8000 /* an error has occurred */
221 #define ZE_TDES0_TO 0x4000 /* transmit watchdog timeout */
222 #define ZE_TDES0_LE 0x1000 /* length error */
223 #define ZE_TDES0_LO 0x0800 /* loss of carrier */
224 #define ZE_TDES0_NC 0x0400 /* no carrier */
225 #define ZE_TDES0_LC 0x0200 /* late collision */
226 #define ZE_TDES0_EC 0x0100 /* excessive collisions */
227 #define ZE_TDES0_HF 0x0080 /* heartbeat fail */
228 #define ZE_TDES0_CC 0x0078 /* collision count mask */
229 #define ZE_TDES0_TN 0x0004 /* address translation invalid */
230 #define ZE_TDES0_UF 0x0002 /* underflow */
231 #define ZE_TDES0_DE 0x0001 /* transmission deferred */
232 #define ZE_TDES1_CA 0x8000 /* chain address */
233 #define ZE_TDES1_VA 0x4000 /* virtual address */
234 #define ZE_TDES1_DT 0x3000 /* data type: */
235 #define ZE_TDES1_DT_NORM 0x0000 /* normal transmit frame */
236 #define ZE_TDES1_DT_SETUP 0x2000 /* setup frame */
237 #define ZE_TDES1_DT_DIAG 0x3000 /* diagnostic frame */
238 #define ZE_TDES1_AC 0x0800 /* CRC disable */
239 #define ZE_TDES1_FS 0x0400 /* first segment */
240 #define ZE_TDES1_LS 0x0200 /* last segment */
241 #define ZE_TDES1_IC 0x0100 /* interrupt on completion */
242 #define ZE_TDES1_VT 0x0080 /* virtual(1)/phys PTE address */
243
244 #endif /* _DEV_IC_SGECREG_H_ */
245