aereg.h revision 1.3 1 1.3 andvar /* $NetBSD: aereg.h,v 1.3 2021/08/02 12:56:23 andvar Exp $ */
2 1.1 gdamore
3 1.1 gdamore /*-
4 1.1 gdamore * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
5 1.1 gdamore * All rights reserved.
6 1.1 gdamore *
7 1.1 gdamore * This code is derived from software contributed to The NetBSD Foundation
8 1.1 gdamore * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 1.1 gdamore * NASA Ames Research Center.
10 1.1 gdamore *
11 1.1 gdamore * Redistribution and use in source and binary forms, with or without
12 1.1 gdamore * modification, are permitted provided that the following conditions
13 1.1 gdamore * are met:
14 1.1 gdamore * 1. Redistributions of source code must retain the above copyright
15 1.1 gdamore * notice, this list of conditions and the following disclaimer.
16 1.1 gdamore * 2. Redistributions in binary form must reproduce the above copyright
17 1.1 gdamore * notice, this list of conditions and the following disclaimer in the
18 1.1 gdamore * documentation and/or other materials provided with the distribution.
19 1.1 gdamore *
20 1.1 gdamore * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21 1.1 gdamore * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 1.1 gdamore * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 1.1 gdamore * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24 1.1 gdamore * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 1.1 gdamore * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 1.1 gdamore * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 1.1 gdamore * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 1.1 gdamore * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 1.1 gdamore * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 1.1 gdamore * POSSIBILITY OF SUCH DAMAGE.
31 1.1 gdamore */
32 1.1 gdamore
33 1.1 gdamore #ifndef _MIPS_ATHEROS_DEV_AEREG_H_
34 1.1 gdamore #define _MIPS_ATHEROS_DEV_AEREG_H_
35 1.1 gdamore
36 1.1 gdamore /*
37 1.1 gdamore * This device is much like a standard Tulip Ethernet chip, but it is
38 1.1 gdamore * an on-chip core on the AR5312 processors. It differs in having two
39 1.1 gdamore * register windows, and the details of some of the contents of those
40 1.1 gdamore * registers. It has about 80% in common to a typical tulip.
41 1.1 gdamore */
42 1.1 gdamore
43 1.1 gdamore /*
44 1.1 gdamore * Buffer descriptor. Must be 4-byte aligned.
45 1.1 gdamore *
46 1.1 gdamore * Note for receive descriptors, the byte count fields must
47 1.1 gdamore * be a multiple of 4.
48 1.1 gdamore */
49 1.1 gdamore struct ae_desc {
50 1.1 gdamore volatile u_int32_t ad_status; /* Status */
51 1.1 gdamore volatile u_int32_t ad_ctl; /* Control and Byte Counts */
52 1.1 gdamore volatile u_int32_t ad_bufaddr1; /* Buffer Address 1 */
53 1.1 gdamore volatile u_int32_t ad_bufaddr2; /* Buffer Address 2 */
54 1.1 gdamore };
55 1.1 gdamore
56 1.1 gdamore /*
57 1.1 gdamore * Descriptor Status bits common to transmit and receive.
58 1.1 gdamore */
59 1.1 gdamore #define ADSTAT_OWN 0x80000000 /* Tulip owns descriptor */
60 1.1 gdamore #define ADSTAT_ES 0x00008000 /* Error Summary */
61 1.1 gdamore
62 1.1 gdamore /*
63 1.1 gdamore * Descriptor Status bits for Receive Descriptor.
64 1.1 gdamore */
65 1.1 gdamore #define ADSTAT_Rx_FF 0x40000000 /* Filtering Fail */
66 1.1 gdamore #define ADSTAT_Rx_FL 0x3fff0000 /* Frame Length including CRC */
67 1.1 gdamore #define ADSTAT_Rx_DE 0x00004000 /* Descriptor Error */
68 1.1 gdamore #define ADSTAT_Rx_LE 0x00001000 /* Length Error */
69 1.1 gdamore #define ADSTAT_Rx_RF 0x00000800 /* Runt Frame */
70 1.1 gdamore #define ADSTAT_Rx_MF 0x00000400 /* Multicast Frame */
71 1.1 gdamore #define ADSTAT_Rx_FS 0x00000200 /* First Descriptor */
72 1.1 gdamore #define ADSTAT_Rx_LS 0x00000100 /* Last Descriptor */
73 1.1 gdamore #define ADSTAT_Rx_TL 0x00000080 /* Frame Too Long */
74 1.1 gdamore #define ADSTAT_Rx_CS 0x00000040 /* Collision Seen */
75 1.1 gdamore #define ADSTAT_Rx_RT 0x00000020 /* Frame Type */
76 1.1 gdamore #define ADSTAT_Rx_RW 0x00000010 /* Receive Watchdog */
77 1.1 gdamore #define ADSTAT_Rx_RE 0x00000008 /* Report on MII Error */
78 1.1 gdamore #define ADSTAT_Rx_DB 0x00000004 /* Dribbling Bit */
79 1.1 gdamore #define ADSTAT_Rx_CE 0x00000002 /* CRC Error */
80 1.1 gdamore #define ADSTAT_Rx_ZER 0x00000001 /* Zero (always 0) */
81 1.1 gdamore
82 1.1 gdamore #define ADSTAT_Rx_LENGTH(x) (((x) & ADSTAT_Rx_FL) >> 16)
83 1.1 gdamore
84 1.1 gdamore /*
85 1.1 gdamore * Descriptor Status bits for Transmit Descriptor.
86 1.1 gdamore */
87 1.1 gdamore #define ADSTAT_Tx_TO 0x00004000 /* Transmit Jabber Timeout */
88 1.1 gdamore #define ADSTAT_Tx_LO 0x00000800 /* Loss of Carrier */
89 1.1 gdamore #define ADSTAT_Tx_NC 0x00000400 /* No Carrier */
90 1.1 gdamore #define ADSTAT_Tx_LC 0x00000200 /* Late Collision */
91 1.1 gdamore #define ADSTAT_Tx_EC 0x00000100 /* Excessive Collisions */
92 1.1 gdamore #define ADSTAT_Tx_HF 0x00000080 /* Heartbeat Fail */
93 1.1 gdamore #define ADSTAT_Tx_CC 0x00000078 /* Collision Count */
94 1.1 gdamore #define ADSTAT_Tx_ED 0x00000004 /* Excessive Deferral */
95 1.1 gdamore #define ADSTAT_Tx_UF 0x00000002 /* Underflow Error */
96 1.1 gdamore #define ADSTAT_Tx_DE 0x00000001 /* Deferred */
97 1.1 gdamore
98 1.1 gdamore #define ADSTAT_Tx_COLLISIONS(x) (((x) & ADSTAT_Tx_CC) >> 3)
99 1.1 gdamore
100 1.1 gdamore /*
101 1.1 gdamore * Descriptor Control bits common to transmit and receive.
102 1.1 gdamore */
103 1.1 gdamore #define ADCTL_SIZE1 0x000007ff /* Size of buffer 1 */
104 1.1 gdamore #define ADCTL_SIZE1_SHIFT 0
105 1.1 gdamore
106 1.1 gdamore #define ADCTL_SIZE2 0x003ff800 /* Size of buffer 2 */
107 1.1 gdamore #define ADCTL_SIZE2_SHIFT 11
108 1.1 gdamore
109 1.1 gdamore #define ADCTL_ER 0x02000000 /* End of Ring */
110 1.1 gdamore #define ADCTL_CH 0x01000000 /* Second Address Chained */
111 1.1 gdamore
112 1.1 gdamore /*
113 1.1 gdamore * Descriptor Control bits for Transmit Descriptor.
114 1.1 gdamore */
115 1.1 gdamore #define ADCTL_Tx_IC 0x80000000 /* Interrupt on Completion */
116 1.1 gdamore #define ADCTL_Tx_LS 0x40000000 /* Last Segment */
117 1.1 gdamore #define ADCTL_Tx_FS 0x20000000 /* First Segment */
118 1.1 gdamore #define ADCTL_Tx_AC 0x04000000 /* Add CRC Disable */
119 1.1 gdamore #define ADCTL_Tx_DPD 0x00800000 /* Disabled Padding */
120 1.1 gdamore
121 1.1 gdamore /*
122 1.1 gdamore * Control registers.
123 1.1 gdamore */
124 1.1 gdamore
125 1.3 andvar /* these are registers only found on this part */
126 1.1 gdamore #define CSR_MACCTL 0x0000 /* mac control */
127 1.1 gdamore #define CSR_MACHI 0x0004
128 1.1 gdamore #define CSR_MACLO 0x0008
129 1.1 gdamore #define CSR_HTHI 0x000C /* multicast table high */
130 1.1 gdamore #define CSR_HTLO 0x0010 /* multicast table low */
131 1.1 gdamore #define CSR_MIIADDR 0x0014 /* mii address */
132 1.1 gdamore #define CSR_MIIDATA 0x0018 /* mii data */
133 1.1 gdamore #define CSR_FLOWC 0x001C /* flow control */
134 1.1 gdamore #define CSR_VL1 0x0020 /* vlan 1 tag */
135 1.1 gdamore
136 1.1 gdamore /* these are more or less normal Tulip registers */
137 1.1 gdamore #define CSR_BUSMODE 0x1000 /* bus mode */
138 1.1 gdamore #define CSR_TXPOLL 0x1004 /* tx poll demand */
139 1.1 gdamore #define CSR_RXPOLL 0x1008 /* rx poll demand */
140 1.1 gdamore #define CSR_RXLIST 0x100C /* rx base descriptor address */
141 1.1 gdamore #define CSR_TXLIST 0x1010 /* tx base descriptor address */
142 1.1 gdamore #define CSR_STATUS 0x1014 /* (interrupt) status */
143 1.1 gdamore #define CSR_OPMODE 0x1018 /* operation mode */
144 1.1 gdamore #define CSR_INTEN 0x101C /* interrupt enable */
145 1.1 gdamore #define CSR_MISSED 0x1020 /* missed frame counter */
146 1.1 gdamore #define CSR_HTBA 0x1050 /* host tx buffer address (ro) */
147 1.1 gdamore #define CSR_HRBA 0x1054 /* host rx buffer address (ro) */
148 1.1 gdamore
149 1.1 gdamore /* CSR_MACCTL - Mac Control */
150 1.1 gdamore #define MACCTL_RE 0x00000004 /* rx enable */
151 1.1 gdamore #define MACCTL_TE 0x00000008 /* tx enable */
152 1.1 gdamore #define MACCTL_DC 0x00000020 /* deferral check */
153 1.1 gdamore #define MACCTL_PSTR 0x00000100 /* automatic pad strip */
154 1.1 gdamore #define MACCTL_DTRY 0x00000400 /* disable retry */
155 1.1 gdamore #define MACCTL_DBF 0x00000800 /* disable broadcast frames */
156 1.1 gdamore #define MACCTL_LCC 0x00001000 /* late collision control */
157 1.1 gdamore #define MACCTL_HASH 0x00002000 /* hash filtering enable */
158 1.1 gdamore #define MACCTL_HO 0x00008000 /* disable perfect filtering */
159 1.1 gdamore #define MACCTL_PB 0x00010000 /* pass bad frames */
160 1.1 gdamore #define MACCTL_IF 0x00020000 /* inverse filtering */
161 1.1 gdamore #define MACCTL_PR 0x00040000 /* promiscuous mode */
162 1.1 gdamore #define MACCTL_PM 0x00080000 /* pass all multicast */
163 1.1 gdamore #define MACCTL_FDX 0x00100000 /* full duplex mode */
164 1.1 gdamore #define MACCTL_LOOP 0x00600000 /* loopback mask */
165 1.1 gdamore #define MACCTL_LOOP_INT 0x00200000 /* internal loopback */
166 1.1 gdamore #define MACCTL_LOOP_EXT 0x00400000 /* external loopback */
167 1.1 gdamore #define MACCTL_LOOP_NONE 0x00000000
168 1.1 gdamore #define MACCTL_DRO 0x00800000 /* disable receive own */
169 1.1 gdamore #define MACCTL_PS 0x08000000 /* port select, 0 = mii */
170 1.1 gdamore #define MACCTL_HBD 0x10000000 /* heartbeat disable */
171 1.1 gdamore #define MACCTL_BLE 0x40000000 /* mac big endian */
172 1.1 gdamore #define MACCTL_RA 0x80000000 /* receive all packets */
173 1.1 gdamore
174 1.3 andvar /* CSR_MIIADDR - MII Address */
175 1.1 gdamore #define MIIADDR_BUSY 0x00000001 /* mii busy */
176 1.1 gdamore #define MIIADDR_WRITE 0x00000002 /* mii write */
177 1.1 gdamore #define MIIADDR_REG_MASK 0x000007C0 /* mii register */
178 1.1 gdamore #define MIIADDR_REG_SHIFT 6
179 1.1 gdamore #define MIIADDR_PHY_MASK 0x0000F800 /* mii phy */
180 1.1 gdamore #define MIIADDR_PHY_SHIFT 11
181 1.1 gdamore
182 1.1 gdamore #define MIIADDR_GETREG(x) (((x) & MIIADDR_REG) >> 6)
183 1.1 gdamore #define MIIADDR_PUTREG(x) (((x) << 6) & MIIADR_REG)
184 1.1 gdamore #define MIIADDR_GETPHY(x) (((x) & MIIADDR_PHY) >> 11)
185 1.1 gdamore #define MIIADDR_PUTPHY(x) (((x) << 6) & MIIADR_PHY)
186 1.1 gdamore
187 1.1 gdamore /* CSR_FLOWC - Flow Control */
188 1.1 gdamore #define FLOWC_FCB 0x00000001 /* flow control busy */
189 1.1 gdamore #define FLOWC_FCE 0x00000002 /* flow control enable */
190 1.1 gdamore #define FLOWC_PCF 0x00000004 /* pass control frames */
191 1.1 gdamore #define FLOWC_PT 0xffff0000 /* pause time */
192 1.1 gdamore
193 1.1 gdamore /* CSR_BUSMODE - Bus Mode */
194 1.1 gdamore #define BUSMODE_SWR 0x00000001 /* software reset */
195 1.1 gdamore #define BUSMODE_BAR 0x00000002 /* bus arbitration */
196 1.1 gdamore #define BUSMODE_DSL 0x0000007c /* descriptor skip length */
197 1.1 gdamore #define BUSMODE_BLE 0x00000080 /* data buf endian */
198 1.1 gdamore /* programmable burst length */
199 1.1 gdamore #define BUSMODE_PBL_DEFAULT 0x00000000 /* default value */
200 1.1 gdamore #define BUSMODE_PBL_1LW 0x00000100 /* 1 longword */
201 1.1 gdamore #define BUSMODE_PBL_2LW 0x00000200 /* 2 longwords */
202 1.1 gdamore #define BUSMODE_PBL_4LW 0x00000400 /* 4 longwords */
203 1.1 gdamore #define BUSMODE_PBL_8LW 0x00000800 /* 8 longwords */
204 1.1 gdamore #define BUSMODE_PBL_16LW 0x00001000 /* 16 longwords */
205 1.1 gdamore #define BUSMODE_PBL_32LW 0x00002000 /* 32 longwords */
206 1.1 gdamore #define BUSMODE_DBO 0x00100000 /* descriptor endian */
207 1.1 gdamore #define BUSMODE_ALIGN_16B 0x01000000 /* force oddhw rx buf align */
208 1.1 gdamore
209 1.1 gdamore /* CSR_TXPOLL - Transmit Poll Demand */
210 1.1 gdamore #define TXPOLL_TPD 0x00000001 /* transmit poll demand */
211 1.1 gdamore
212 1.1 gdamore
213 1.1 gdamore /* CSR_RXPOLL - Receive Poll Demand */
214 1.1 gdamore #define RXPOLL_RPD 0x00000001 /* receive poll demand */
215 1.1 gdamore
216 1.1 gdamore /* CSR_STATUS - Status */
217 1.1 gdamore #define STATUS_TI 0x00000001 /* transmit interrupt */
218 1.1 gdamore #define STATUS_TPS 0x00000002 /* transmit process stopped */
219 1.1 gdamore #define STATUS_TU 0x00000004 /* transmit buffer unavail */
220 1.1 gdamore #define STATUS_TJT 0x00000008 /* transmit jabber timeout */
221 1.1 gdamore #define STATUS_UNF 0x00000020 /* transmit underflow */
222 1.1 gdamore #define STATUS_RI 0x00000040 /* receive interrupt */
223 1.1 gdamore #define STATUS_RU 0x00000080 /* receive buffer unavail */
224 1.1 gdamore #define STATUS_RPS 0x00000100 /* receive process stopped */
225 1.1 gdamore #define STATUS_ETI 0x00000400 /* early transmit interrupt */
226 1.1 gdamore #define STATUS_SE 0x00002000 /* system error */
227 1.1 gdamore #define STATUS_ER 0x00004000 /* early receive (21041) */
228 1.1 gdamore #define STATUS_AIS 0x00008000 /* abnormal intr summary */
229 1.1 gdamore #define STATUS_NIS 0x00010000 /* normal interrupt summary */
230 1.1 gdamore #define STATUS_RS 0x000e0000 /* receive process state */
231 1.1 gdamore #define STATUS_RS_STOPPED 0x00000000 /* Stopped */
232 1.1 gdamore #define STATUS_RS_FETCH 0x00020000 /* Running - fetch receive
233 1.1 gdamore descriptor */
234 1.1 gdamore #define STATUS_RS_CHECK 0x00040000 /* Running - check for end
235 1.1 gdamore of receive */
236 1.1 gdamore #define STATUS_RS_WAIT 0x00060000 /* Running - wait for packet */
237 1.1 gdamore #define STATUS_RS_SUSPENDED 0x00080000 /* Suspended */
238 1.1 gdamore #define STATUS_RS_CLOSE 0x000a0000 /* Running - close receive
239 1.1 gdamore descriptor */
240 1.1 gdamore #define STATUS_RS_FLUSH 0x000c0000 /* Running - flush current
241 1.1 gdamore frame from FIFO */
242 1.1 gdamore #define STATUS_RS_QUEUE 0x000e0000 /* Running - queue current
243 1.1 gdamore frame from FIFO into
244 1.1 gdamore buffer */
245 1.1 gdamore #define STATUS_TS 0x00700000 /* transmit process state */
246 1.1 gdamore #define STATUS_TS_STOPPED 0x00000000 /* Stopped */
247 1.1 gdamore #define STATUS_TS_FETCH 0x00100000 /* Running - fetch transmit
248 1.1 gdamore descriptor */
249 1.1 gdamore #define STATUS_TS_WAIT 0x00200000 /* Running - wait for end
250 1.1 gdamore of transmission */
251 1.1 gdamore #define STATUS_TS_READING 0x00300000 /* Running - read buffer from
252 1.1 gdamore memory and queue into
253 1.1 gdamore FIFO */
254 1.1 gdamore #define STATUS_TS_SUSPENDED 0x00600000 /* Suspended */
255 1.1 gdamore #define STATUS_TS_CLOSE 0x00700000 /* Running - close transmit
256 1.1 gdamore descriptor */
257 1.1 gdamore #define STATUS_TX_ABORT 0x00800000 /* Transmit bus abort */
258 1.1 gdamore #define STATUS_RX_ABORT 0x01000000 /* Transmit bus abort */
259 1.1 gdamore
260 1.1 gdamore /* CSR_OPMODE - Operation Mode */
261 1.1 gdamore #define OPMODE_SR 0x00000002 /* start receive */
262 1.1 gdamore #define OPMODE_OSF 0x00000004 /* operate on second frame */
263 1.1 gdamore #define OPMODE_ST 0x00002000 /* start transmitter */
264 1.1 gdamore #define OPMODE_TR 0x0000c000 /* threshold control */
265 1.1 gdamore #define OPMODE_TR_32 0x00000000 /* 32 words */
266 1.1 gdamore #define OPMODE_TR_64 0x00004000 /* 64 words */
267 1.1 gdamore #define OPMODE_TR_128 0x00008000 /* 128 words */
268 1.1 gdamore #define OPMODE_TR_256 0x0000c000 /* 256 words */
269 1.1 gdamore #define OPMODE_SF 0x00200000 /* store and forward mode */
270 1.1 gdamore
271 1.1 gdamore /* CSR_INTEN - Interrupt Enable */
272 1.1 gdamore /* See bits for CSR_STATUS -- Status */
273 1.1 gdamore
274 1.1 gdamore
275 1.1 gdamore /* CSR_MISSED - Missed Frames */
276 1.1 gdamore #define MISSED_MFC 0xffff0000 /* missed packet count */
277 1.1 gdamore #define MISSED_FOC 0x0000ffff /* fifo overflow counter */
278 1.1 gdamore
279 1.1 gdamore #define MISSED_GETMFC(x) ((x) & MISSED_MFC)
280 1.1 gdamore #define MISSED_GETFOC(x) (((x) & MISSED_FOC) >> 16)
281 1.1 gdamore
282 1.1 gdamore #endif /* _MIPS_ATHEROS_DEV_AEREG_H_ */
283