1 #ifndef CYGONCE_DEVS_ETH_REALTEK_8139_INFO_H
2 #define CYGONCE_DEVS_ETH_REALTEK_8139_INFO_H
3 /*==========================================================================
8 //==========================================================================
9 //####ECOSGPLCOPYRIGHTBEGIN####
10 // -------------------------------------------
11 // This file is part of eCos, the Embedded Configurable Operating System.
12 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
14 // eCos is free software; you can redistribute it and/or modify it under
15 // the terms of the GNU General Public License as published by the Free
16 // Software Foundation; either version 2 or (at your option) any later version.
18 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
19 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23 // You should have received a copy of the GNU General Public License along
24 // with eCos; if not, write to the Free Software Foundation, Inc.,
25 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
27 // As a special exception, if other files instantiate templates or use macros
28 // or inline functions from this file, or you compile this file and link it
29 // with other works to produce a work based on this file, this file does not
30 // by itself cause the resulting work to be covered by the GNU General Public
31 // License. However the source code for this file must still be made available
32 // in accordance with section (3) of the GNU General Public License.
34 // This exception does not invalidate any other reasons why a work based on
35 // this file might be covered by the GNU General Public License.
37 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
38 // at http://sources.redhat.com/ecos/ecos-license/
39 // -------------------------------------------
40 //####ECOSGPLCOPYRIGHTEND####
41 //==========================================================================
42 //#####DESCRIPTIONBEGIN####
44 // Author(s): Eric Doenges
45 // Contributors: Chris Nimmers, Gary Thomas, Andy Dyer
49 //####DESCRIPTIONEND####
51 #include <pkgconf/devs_eth_rltk_8139.h>
55 * Used to define all vendor/device ID combinations we know about to find
64 #define PCI_ANY_ID (0xFFFF)
67 * Valid receive buffer sizes are 8k+16, 16k+16, 32k+16, or 64k+16.
68 * For the last case, WRAP mode should not be enabled. Since we do not
69 * currently want to support unwrapped mode, do not use 64k+16 at this
70 * point. The buffer length is set via the configuration mechanism.
72 #if (CYGNUM_DEVS_ETH_RLTK_8139_RX_BUF_LEN_IDX < 0) |\
73 (CYGNUM_DEVS_ETH_RLTK_8139_RX_BUF_LEN_IDX > 2)
74 #error "The receive ring size index must be in the range of 0 to 2"
76 #define RX_BUF_LEN (8192 << (CYGNUM_DEVS_ETH_RLTK_8139_RX_BUF_LEN_IDX))
78 #define RX_BUF_WRAP_PAD 2048 /* spare padding to handle lack of packet wrap */
79 #define RX_BUF_TOT_LEN (RX_BUF_LEN + RX_BUF_PAD + RX_BUF_WRAP_PAD)
81 /* Number of Tx descriptor registers. */
85 * Max supported ethernet frame size. The 8139 cannot transmit packets more
86 * than 1792 bytes long. Also, since transmit buffers must be 32-bit
87 * aligned, MAX_ETH_FRAME_SIZE should always be a multiple of 4.
89 #define MIN_ETH_FRAME_SIZE 60 /* without FCS */
90 #define MAX_ETH_FRAME_SIZE 1536 /* is this with/without FCS ? */
92 /* Size of the Tx buffers. */
93 #define TX_BUF_SIZE MAX_ETH_FRAME_SIZE
94 #define TX_BUF_TOT_LEN (TX_BUF_SIZE * NUM_TX_DESC)
96 /* Rx buffer level before first PCI transfer ('5' is 512 bytes) */
97 #define RX_FIFO_THRESH 5
100 * Maximum PCI rx and tx bursts. This value ranges from '0' (16 bytes)
101 * to '7' (unlimited), with MXDMA = 2^(4 + 'value').
103 #define RX_DMA_BURST 6
104 #define TX_DMA_BURST 6
107 * Device driver private data
110 /* Device number. Used for actually finding the device */
111 cyg_uint32 device_num;
113 /* Receive buffer ring area */
116 /* Transmit buffer area */
117 cyg_uint8 *tx_buffer;
120 cyg_pci_device_id pci_device_id;
122 /* Address for memory mapped I/O */
123 cyg_uint32 base_address;
125 /* Our current MAC address */
126 unsigned char mac[6];
128 /* tx FIFO threshold. */
129 cyg_uint8 tx_threshold;
131 /* This is the first free descriptor. */
134 /* This is the number of currently free descriptors */
135 int tx_num_free_desc;
137 /* Keys to match _send calls with the tx_done callback */
138 unsigned long tx_desc_key[NUM_TX_DESC];
141 * This is used to (temporarily) store the address of the current
142 * received packet. We save it here to avoid having to calculate it
145 cyg_uint8 *rx_current;
148 /* Interrupt handling stuff */
150 cyg_handle_t interrupt_handle;
151 cyg_interrupt interrupt;
156 * Register offsets and bit definitions. These use the names in the 8139
157 * data sheet, not those found e.g. in the Linux driver for the 8139.
160 IDR0 = 0x0, /* mac address, seemingly in big-endian order */
166 MAR0 = 0x8, /* multicast registers (0-7) */
174 TSD0 = 0x10, /* L, transmit status of descriptor 0 */
178 TSAD0 = 0x20, /* L, transmit start address of descriptor 0 */
182 RBSTART = 0x30, /* L, receive buffer start address */
183 ERBCR = 0x34, /* W, early receive byte count register */
184 ERSR = 0x36, /* B, early receive status register */
185 CR = 0x37, /* B, command register */
186 CAPR = 0x38, /* W, current address of packet read */
187 CBR = 0x3A, /* W, current buffer address */
188 IMR = 0x3C, /* W, interrupt mask register */
189 ISR = 0x3E, /* W, interrupt status register */
190 TCR = 0x40, /* L, transmit configuration register */
191 RCR = 0x44, /* L, receive configuration register */
192 TCTR = 0x48, /* L, timer count register */
193 MPC = 0x4C, /* L, missed packet counter */
194 CR9346 = 0x50, /* B, 93C46 (serial eeprom) command register */
195 CONFIG0 = 0x51, /* B, configuration register 0 */
196 CONFIG1 = 0x52, /* B, configuration register 1 */
197 TIMERINT= 0x54, /* L, timer interrupt register */
198 MSR = 0x58, /* B, media status register */
199 CONFIG3 = 0x59, /* B, configuration register 0 */
200 CONFIG4 = 0x5A, /* B, configuration register 1 */
201 MULINT = 0x5C, /* W, multiple interrupt select */
202 RERID = 0x5E, /* B, PCI revision ID; should be 0x10 */
203 TSAD = 0x60, /* W, transmit status of all descriptors */
204 BMCR = 0x62, /* W, basic mode control register */
205 BMSR = 0x64, /* W, basic mode status register */
206 ANAR = 0x66, /* W, auto-negotiation advertisement register */
207 ANLPAR = 0x68, /* W, auto-negotiation link partner register */
208 ANER = 0x6A, /* W, auto-negotiation expansion register */
209 DIS = 0x6C, /* W, disconnect counter */
210 FCSC = 0x6E, /* W, false carrier sense counter */
211 NWAYTR = 0x70, /* W, N-way test register */
212 REC = 0x72, /* W, RX_ER counter */
213 CSCR = 0x74, /* W, CS configuration register */
214 PHY1_PARM = 0x78, /* L, PHY parameter 1 */
215 TW_PARM = 0x7C, /* L, twister parameter */
216 PHY2_PARM = 0x80, /* B, PHY parameter 2 */
217 CRC0 = 0x84, /* B, power management CRC register for wakeup frame 0 */
218 CRC1 = 0x85, /* B, power management CRC register for wakeup frame 1 */
219 CRC2 = 0x86, /* B, power management CRC register for wakeup frame 2 */
220 CRC3 = 0x87, /* B, power management CRC register for wakeup frame 3 */
221 CRC4 = 0x88, /* B, power management CRC register for wakeup frame 4 */
222 CRC5 = 0x89, /* B, power management CRC register for wakeup frame 5 */
223 CRC6 = 0x8A, /* B, power management CRC register for wakeup frame 6 */
224 CRC7 = 0x8B, /* B, power management CRC register for wakeup frame 7 */
225 WAKEUP0 = 0x8C, /* Q, power management wakeup frame 0 (64 bits) */
226 WAKEUP1 = 0x94, /* Q, power management wakeup frame 1 (64 bits) */
227 WAKEUP2 = 0x9C, /* Q, power management wakeup frame 2 (64 bits) */
228 WAKEUP3 = 0xA4, /* Q, power management wakeup frame 3 (64 bits) */
229 WAKEUP4 = 0xAC, /* Q, power management wakeup frame 4 (64 bits) */
230 WAKEUP5 = 0xB4, /* Q, power management wakeup frame 5 (64 bits) */
231 WAKEUP6 = 0xBC, /* Q, power management wakeup frame 6 (64 bits) */
232 WAKEUP7 = 0xC4, /* Q, power management wakeup frame 7 (64 bits) */
233 LSBCRC0 = 0xCC, /* B, LSB of mask byte of wakeup frame 0 offset 12 to 75 */
234 LSBCRC1 = 0xCD, /* B, LSB of mask byte of wakeup frame 1 offset 12 to 75 */
235 LSBCRC2 = 0xCE, /* B, LSB of mask byte of wakeup frame 2 offset 12 to 75 */
236 LSBCRC3 = 0xCF, /* B, LSB of mask byte of wakeup frame 3 offset 12 to 75 */
237 LSBCRC4 = 0xD0, /* B, LSB of mask byte of wakeup frame 4 offset 12 to 75 */
238 LSBCRC5 = 0xD1, /* B, LSB of mask byte of wakeup frame 5 offset 12 to 75 */
239 LSBCRC6 = 0xD2, /* B, LSB of mask byte of wakeup frame 6 offset 12 to 75 */
240 LSBCRC7 = 0xD3, /* B, LSB of mask byte of wakeup frame 7 offset 12 to 75 */
241 FLASH = 0xD4, /* L, flash memory read/write register */
242 CONFIG5 = 0xD8, /* B, configuration register #5 */
243 FER = 0xF0, /* L, function event register (CardBus only) */
244 FEMR = 0xF4, /* L, function event mask register (CardBus only) */
245 FPSR = 0xF8, /* L, function present state register (CardBus only) */
246 FFER = 0xFC /* L, function force event register (CardBus only) */
249 /* Receive status register in Rx packet header */
251 MAR = (1<<15), /* multicast address received */
252 PAM = (1<<14), /* physical address matched */
253 BAR = (1<<13), /* broadcast address received */
254 ISE = (1<<5), /* invalid symbol error */
255 RUNT = (1<<4), /* runt packet (<64 bytes) received */
256 LONG = (1<<3), /* long packet (>4K bytes) received */
257 CRC = (1<<2), /* CRC error */
258 FAE = (1<<1), /* frame alignment error */
259 ROK = (1<<0) /* receive OK */
262 /* Transmit status register */
264 CRS = (1<<31), /* carrier sense lost */
265 TABT = (1<<30), /* transmit abort */
266 OWC = (1<<29), /* out of window collision */
267 CDH = (1<<28), /* CD heart beat */
269 NCC = (0xF<<24), /* number of collision count */
271 ERTXTH = (0x1F<<16), /* early tx threshold, in multiples of 32 bytes */
272 TOK = (1<<15), /* transmission OK */
273 TUN = (1<<14), /* transmit FIFO underrun */
274 OWN = (1<<13), /* own */
275 SIZE = 0xFFF /* descriptor size */
278 /* Command register */
280 RST = (1<<4), /* reset */
281 RE = (1<<3), /* receiver enable */
282 TE = (1<<2), /* transmitter enable */
283 BUFE = (1<<0) /* buffer empty */
286 /* Transmit configuration register */
288 CLRABT = (1<<0) /* clear abort */
291 /* Receive configuration register */
293 ERTH_SHIFT = 24, /* Early Rx threshold bits (4) */
294 MULERINT = (1<<17), /* multiple early interrupt */
295 RER8 = (1<<16), /* ? */
296 RXFTH_SHIFT= 13, /* Rx FIFO threshold */
297 RBLEN_SHIFT= 11, /* Rx buffer length */
298 MXDMA_SHIFT= 8, /* max DMA burst size per Rx DMA burst */
299 WRAP = (1<<7), /* WRAP mode */
300 SEL9356 = (1<<6), /* EEPROM select */
301 AER = (1<<5), /* accept error packets */
302 AR = (1<<4), /* accept runt packets */
303 AB = (1<<3), /* accept broadcast packets */
304 AM = (1<<2), /* accept multicast packets */
305 APM = (1<<1), /* accept physical match packets (our MAC) */
306 AAP = (1<<0), /* accept physical address packets (any MAC) */
309 /* TSAD (transmit status of all descriptors */
329 /* Interrupt mask/status register */
331 IR_SERR = (1<<15), /* system error interrupt */
332 IR_TIMEOUT = (1<<14), /* time out interrupt */
333 IR_LENCHG = (1<<13), /* cable length change interrupt */
334 IR_FOVW = (1<<6), /* Rx FIFO overflow */
335 IR_FUN = (1<<5), /* Packet underrun or link change interrupt */
336 IR_RXOVW = (1<<4), /* Rx buffer overflow */
337 IR_TER = (1<<3), /* transmit error interrupt */
338 IR_TOK = (1<<2), /* transmit OK interrupt */
339 IR_RER = (1<<1), /* receive error interrupt */
340 IR_ROK = (1<<0) /* receive OK interrupt */
343 /* Packet header bits */
345 HDR_MAR = (1<<15), /* multicast address received */
346 HDR_PAM = (1<<14), /* physical address matched */
347 HDR_BAR = (1<<13), /* broadcast address matched */
348 HDR_ISE = (1<<5), /* invalid symbol error */
349 HDR_RUNT = (1<<4), /* runt packet received (packet < 64 bytes) */
350 HDR_LONG = (1<<3), /* long packet (>4k) */
351 HDR_CRC = (1<<2), /* CRC error */
352 HDR_FAE = (1<<1), /* frame alignment error */
353 HDR_ROK = (1<<0) /* receive OK */
358 * Define some options to use
360 #define TXCFG ((0x3 << 24) | (TX_DMA_BURST << MXDMA_SHIFT))
361 #define RXCFG ((RX_FIFO_THRESH << RXFTH_SHIFT) |\
362 (RX_BUF_LEN_IDX << RBLEN_SHIFT) |\
363 (RX_DMA_BURST << MXDMA_SHIFT) |\
366 #endif /* ifndef CYGONCE_DEVS_ETH_REALTEK_8139_INFO_H */