1 |
27 |
unneback |
//==========================================================================
|
2 |
|
|
//
|
3 |
|
|
// fec.h
|
4 |
|
|
//
|
5 |
|
|
// PowerPC MPC8xxT fast ethernet (FEC)
|
6 |
|
|
//
|
7 |
|
|
//==========================================================================
|
8 |
|
|
//####ECOSGPLCOPYRIGHTBEGIN####
|
9 |
|
|
// -------------------------------------------
|
10 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
11 |
|
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
12 |
|
|
//
|
13 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
14 |
|
|
// the terms of the GNU General Public License as published by the Free
|
15 |
|
|
// Software Foundation; either version 2 or (at your option) any later version.
|
16 |
|
|
//
|
17 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
18 |
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
19 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
20 |
|
|
// for more details.
|
21 |
|
|
//
|
22 |
|
|
// You should have received a copy of the GNU General Public License along
|
23 |
|
|
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
24 |
|
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
25 |
|
|
//
|
26 |
|
|
// As a special exception, if other files instantiate templates or use macros
|
27 |
|
|
// or inline functions from this file, or you compile this file and link it
|
28 |
|
|
// with other works to produce a work based on this file, this file does not
|
29 |
|
|
// by itself cause the resulting work to be covered by the GNU General Public
|
30 |
|
|
// License. However the source code for this file must still be made available
|
31 |
|
|
// in accordance with section (3) of the GNU General Public License.
|
32 |
|
|
//
|
33 |
|
|
// This exception does not invalidate any other reasons why a work based on
|
34 |
|
|
// this file might be covered by the GNU General Public License.
|
35 |
|
|
//
|
36 |
|
|
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
|
37 |
|
|
// at http://sources.redhat.com/ecos/ecos-license/
|
38 |
|
|
// -------------------------------------------
|
39 |
|
|
//####ECOSGPLCOPYRIGHTEND####
|
40 |
|
|
//==========================================================================
|
41 |
|
|
//#####DESCRIPTIONBEGIN####
|
42 |
|
|
//
|
43 |
|
|
// Author(s): gthomas
|
44 |
|
|
// Contributors: gthomas
|
45 |
|
|
// Date: 2001-01-21
|
46 |
|
|
// Purpose:
|
47 |
|
|
// Description:
|
48 |
|
|
//
|
49 |
|
|
//
|
50 |
|
|
//####DESCRIPTIONEND####
|
51 |
|
|
//
|
52 |
|
|
//==========================================================================
|
53 |
|
|
|
54 |
|
|
// PowerPC FEC (MPC8xxT) Fast Ethernet
|
55 |
|
|
|
56 |
|
|
// Buffer descriptor
|
57 |
|
|
struct fec_bd {
|
58 |
|
|
unsigned short ctrl;
|
59 |
|
|
unsigned short length;
|
60 |
|
|
unsigned char *buffer;
|
61 |
|
|
};
|
62 |
|
|
|
63 |
|
|
// control flags differ for Rx and Tx buffers
|
64 |
|
|
#define FEC_BD_Rx_Empty 0x8000 // Buffer is empty [FEC can fill it]
|
65 |
|
|
#define FEC_BD_Rx_Wrap 0x2000 // Last buffer in ring [wrap]
|
66 |
|
|
#define FEC_BD_Rx_Last 0x0800 // Last buffer in frame
|
67 |
|
|
#define FEC_BD_Rx_Miss 0x0100 //
|
68 |
|
|
#define FEC_BD_Rx_BC 0x0080
|
69 |
|
|
#define FEC_BD_Rx_MC 0x0040
|
70 |
|
|
#define FEC_BD_Rx_LG 0x0020
|
71 |
|
|
#define FEC_BD_Rx_NO 0x0010
|
72 |
|
|
#define FEC_BD_Rx_SH 0x0008 // Short frame
|
73 |
|
|
#define FEC_BD_Rx_CR 0x0004 // CRC error
|
74 |
|
|
#define FEC_BD_Rx_OV 0x0002 // Overrun
|
75 |
|
|
#define FEC_BD_Rx_TR 0x0001 // Frame truncated
|
76 |
|
|
|
77 |
|
|
#define FEC_BD_Tx_Ready 0x8000 // Frame ready
|
78 |
|
|
#define FEC_BD_Tx_Wrap 0x2000 // Last buffer in ring
|
79 |
|
|
#define FEC_BD_Tx_Intr 0x1000 // Generate interrupt
|
80 |
|
|
#define FEC_BD_Tx_Last 0x0800 // Last buffer in frame
|
81 |
|
|
#define FEC_BD_Tx_TC 0x0400 // Send CRC after data
|
82 |
|
|
#define FEC_BD_Tx_DEF 0x0200
|
83 |
|
|
#define FEC_BD_Tx_HB 0x0100
|
84 |
|
|
#define FEC_BD_Tx_LC 0x0080
|
85 |
|
|
#define FEC_BD_Tx_RL 0x0040
|
86 |
|
|
#define FEC_BD_Tx_RC 0x003C
|
87 |
|
|
#define FEC_BD_Tx_UN 0x0002 // Underrun
|
88 |
|
|
#define FEC_BD_Tx_CSL 0x0001 // Carrier sense lost
|
89 |
|
|
|
90 |
|
|
#define FEC_BD_Tx_STATS 0x03FF // Status mask
|
91 |
|
|
|
92 |
|
|
struct fec_eth_info {
|
93 |
|
|
volatile struct fec *fec;
|
94 |
|
|
volatile struct fec_bd *txbd, *rxbd; // Next Tx,Rx descriptor to use
|
95 |
|
|
volatile struct fec_bd *tbase, *rbase; // First Tx,Rx descriptor
|
96 |
|
|
volatile struct fec_bd *tnext, *rnext; // Next descriptor to check for interrupt
|
97 |
|
|
int txsize, rxsize; // Length of individual buffers
|
98 |
|
|
int txactive; // Count of active Tx buffers
|
99 |
|
|
unsigned long txkey[CYGNUM_DEVS_ETH_POWERPC_FEC_TxNUM];
|
100 |
|
|
};
|
101 |
|
|
|
102 |
|
|
// Fast Ethernet Controller [in PPC8xxT parameter RAM space]
|
103 |
|
|
|
104 |
|
|
struct fec {
|
105 |
|
|
unsigned long addr[2]; // ESA
|
106 |
|
|
unsigned long hash[2]; // Address hash mask
|
107 |
|
|
volatile struct fec_bd *RxRing;
|
108 |
|
|
volatile struct fec_bd *TxRing;
|
109 |
|
|
unsigned long RxBufSize;
|
110 |
|
|
unsigned char _fill0[0x40-0x1C];
|
111 |
|
|
unsigned long eControl; // Master control register
|
112 |
|
|
unsigned long iEvent; // Interrupt event
|
113 |
|
|
unsigned long iMask; // Interrupt mask
|
114 |
|
|
unsigned long iVector; // Interrupt vector
|
115 |
|
|
unsigned long RxUpdate; // RxRing updated
|
116 |
|
|
unsigned long TxUpdate; // TxRing updated
|
117 |
|
|
unsigned char _fill1[0x80-0x58];
|
118 |
|
|
unsigned long MiiData;
|
119 |
|
|
unsigned long MiiSpeed;
|
120 |
|
|
unsigned char _fill2[0xCC-0x88];
|
121 |
|
|
unsigned long RxBound; // End of FIFO RAM
|
122 |
|
|
unsigned long RxStart; // Start of FIFO RAM
|
123 |
|
|
unsigned char _fill3[0xE4-0xD4];
|
124 |
|
|
unsigned long TxWater; // Transmit watermark
|
125 |
|
|
unsigned char _fill4[0xEC-0xE8];
|
126 |
|
|
unsigned long TxStart; // Start of Tx FIFO
|
127 |
|
|
unsigned char _fill5[0x134-0xF0];
|
128 |
|
|
unsigned long FunCode; // DMA function codes
|
129 |
|
|
unsigned char _fill6[0x144-0x138];
|
130 |
|
|
unsigned long RxControl; // Receiver control
|
131 |
|
|
unsigned long RxHash; // Receive hash
|
132 |
|
|
unsigned char _fill7[0x184-0x14C];
|
133 |
|
|
unsigned long TxControl; // Transmitter control
|
134 |
|
|
};
|
135 |
|
|
|
136 |
|
|
#define FEC_OFFSET 0x0E00 // Offset in 8xx parameter RAM
|
137 |
|
|
|
138 |
|
|
// Master control register (eControl)
|
139 |
|
|
#define eControl_MUX 0x0004 // Select proper pin MUX functions
|
140 |
|
|
#define eControl_EN 0x0002 // Enable ethernet controller
|
141 |
|
|
#define eControl_RESET 0x0001 // Reset controller
|
142 |
|
|
|
143 |
|
|
// Receiver control register (RxControl)
|
144 |
|
|
#define RxControl_BC_REJ 0x0010 // Reject broadcast frames
|
145 |
|
|
#define RxControl_PROM 0x0008 // Promiscuous mode
|
146 |
|
|
#define RxControl_MII 0x0004 // MII (1) or 7 wire (0) mode
|
147 |
|
|
#define RxControl_DRT 0x0002 // Disable receive on transmit
|
148 |
|
|
#define RxControl_LOOP 0x0001 // Internal loopback
|
149 |
|
|
|
150 |
|
|
// Interrupt events
|
151 |
|
|
#define iEvent_HBERR 0x80000000 // No heartbeat error
|
152 |
|
|
#define iEvent_BABR 0x40000000 // Babling receiver
|
153 |
|
|
#define iEvent_BABT 0x20000000 // Babling transmitter
|
154 |
|
|
#define iEvent_GRA 0x10000000 // Graceful shutdown
|
155 |
|
|
#define iEvent_TFINT 0x08000000 // Transmit frame interrupt
|
156 |
|
|
#define iEvent_TXB 0x04000000 // Transmit buffer
|
157 |
|
|
#define iEvent_RFINT 0x02000000 // Receive frame
|
158 |
|
|
#define iEvent_RXB 0x01000000 // Receive buffer
|
159 |
|
|
#define iEvent_MII 0x00800000 // MII complete
|
160 |
|
|
#define iEvent_EBERR 0x00400000 // Ethernet BUS error
|
161 |
|
|
#define iEvent_all 0xFFC00000 // Any interrupt
|
162 |
|
|
|
163 |
|
|
// MII interface
|
164 |
|
|
#define MII_Start 0x40000000
|
165 |
|
|
#define MII_Read 0x20000000
|
166 |
|
|
#define MII_Write 0x10000000
|
167 |
|
|
#define MII_Phy(phy) (phy << 23)
|
168 |
|
|
#define MII_Reg(reg) (reg << 18)
|
169 |
|
|
#define MII_TA 0x00020000
|
170 |
|
|
|
171 |
|
|
// Transceiver mode
|
172 |
|
|
#define PHY_BMCR 0x00 // Register number
|
173 |
|
|
#define PHY_BMCR_RESET 0x8000
|
174 |
|
|
#define PHY_BMCR_LOOPBACK 0x4000
|
175 |
|
|
#define PHY_BMCR_100MB 0x2000
|
176 |
|
|
#define PHY_BMCR_AUTO_NEG 0x1000
|
177 |
|
|
#define PHY_BMCR_POWER_DOWN 0x0800
|
178 |
|
|
#define PHY_BMCR_ISOLATE 0x0400
|
179 |
|
|
#define PHY_BMCR_RESTART 0x0200
|
180 |
|
|
#define PHY_BMCR_FULL_DUPLEX 0x0100
|
181 |
|
|
#define PHY_BMCR_COLL_TEST 0x0080
|
182 |
|
|
|
183 |
|
|
#define PHY_BMSR 0x01 // Status register
|
184 |
|
|
#define PHY_BMSR_AUTO_NEG 0x0020
|
185 |
|
|
#define PHY_BMSR_LINK 0x0004
|
186 |
|
|
|
187 |
|
|
#define IEEE_8023_MAX_FRAME 1518 // Largest possible ethernet frame
|
188 |
|
|
#define IEEE_8023_MIN_FRAME 60 // Smallest possible ethernet frame
|
189 |
|
|
|