OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [devs/] [eth/] [mcf52xx/] [mcf5272/] [current/] [include/] [if_mcf5272.h] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
#ifndef _IF_MCF5272_FEC
2
#define _IF_MCF5272_FEC
3
//==========================================================================
4
// ####ECOSGPLCOPYRIGHTBEGIN####                                            
5
// -------------------------------------------                              
6
// This file is part of eCos, the Embedded Configurable Operating System.   
7
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
8
//
9
// eCos is free software; you can redistribute it and/or modify it under    
10
// the terms of the GNU General Public License as published by the Free     
11
// Software Foundation; either version 2 or (at your option) any later      
12
// version.                                                                 
13
//
14
// eCos is distributed in the hope that it will be useful, but WITHOUT      
15
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
16
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
17
// for more details.                                                        
18
//
19
// You should have received a copy of the GNU General Public License        
20
// along with eCos; if not, write to the Free Software Foundation, Inc.,    
21
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
22
//
23
// As a special exception, if other files instantiate templates or use      
24
// macros or inline functions from this file, or you compile this file      
25
// and link it with other works to produce a work based on this file,       
26
// this file does not by itself cause the resulting work to be covered by   
27
// the GNU General Public License. However the source code for this file    
28
// must still be made available in accordance with section (3) of the GNU   
29
// General Public License v2.                                               
30
//
31
// This exception does not invalidate any other reasons why a work based    
32
// on this file might be covered by the GNU General Public License.         
33
// -------------------------------------------                              
34
// ####ECOSGPLCOPYRIGHTEND####                                              
35
//==========================================================================
36
 
37
#include <cyg/hal/drv_api.h>
38
#include <cyg/io/eth/eth_drv_stats.h>
39
#include <cyg/devs/eth/nbuf.h>
40
 
41
 /* Ethernet controller inetrrupt priority level. */
42
#define MCF5272_INT_LEVEL 4
43
 
44
/* Bit level definitions and macros */
45
#define MCF5272_FEC_ECR_RESET           (0x00000001)
46
#define MCF5272_FEC_ECR_ETHER_EN        (0x00000002)
47
#define MCF5272_FEC_EIR_GRA                     (0x10000000)
48
 
49
#define MCF5272_FEC_EIR_HBE                 (0x80000000)
50
#define MCF5272_FEC_EIR_BR                  (0x40000000)
51
#define MCF5272_FEC_EIR_BT                  (0x20000000)
52
#define MCF5272_FEC_EIR_GRA                 (0x10000000)
53
#define MCF5272_FEC_EIR_TXF                 (0x08000000)
54
#define MCF5272_FEC_EIR_TXB                 (0x04000000)
55
#define MCF5272_FEC_EIR_RXF                 (0x02000000)
56
#define MCF5272_FEC_EIR_RXB                 (0x01000000)
57
#define MCF5272_FEC_EIR_MII                 (0x00800000)
58
#define MCF5272_FEC_EIR_EBERR           (0x00400000)
59
#define MCF5272_FEC_EIR_UMINT       (1<<21)
60
 
61
#define MCF5272_FEC_IMR_HBEEN           (0x80000000)
62
#define MCF5272_FEC_IMR_BREN            (0x40000000)
63
#define MCF5272_FEC_IMR_BTEN            (0x20000000)
64
#define MCF5272_FEC_IMR_GRAEN           (0x10000000)
65
#define MCF5272_FEC_IMR_TXFEN           (0x08000000)
66
#define MCF5272_FEC_IMR_TXBEN           (0x04000000)
67
#define MCF5272_FEC_IMR_RXFEN           (0x02000000)
68
#define MCF5272_FEC_IMR_RXBEN           (0x01000000)
69
#define MCF5272_FEC_IMR_MIIEN           (0x00800000)
70
#define MCF5272_FEC_IMR_EBERREN         (0x00400000)
71
#define MCF5272_FEC_RCR_PROM            (0x00000008)
72
#define MCF5272_FEC_RCR_MII_MODE        (0x00000004)
73
#define MCF5272_FEC_RCR_DRT                     (0x00000002)
74
#define MCF5272_FEC_RCR_LOOP            (0x00000001)
75
#define MCF5272_FEC_TCR_GTS                     (0x00000001)
76
#define MCF5272_FEC_TCR_HBC                     (0x00000002)
77
#define MCF5272_FEC_TCR_FDEN            (0x00000004)
78
#define MCF5272_FEC_RDAR_DESTACT    (0x01000000)
79
#define MCF5272_FEC_MFLR_BRDCAST    (0x80000000)
80
#define MCF5272_FEC_MFLR_MLTCAST    (0x40000000)
81
#define MCF5272_FEC_XWMRK_64        (0x00000000)
82
#define MCF5272_FEC_XWMRK_128       (0x00000002)
83
#define MCF5272_FEC_XWMRK_192       (0x00000003)
84
 
85
/*      Define the PHY addresss.  This address specifies which 32  attached */
86
/* PHY devices.                                                             */
87
 
88
//#define MCF5272_PHY_ADD            (0)
89
#define MCF5272_PHY_ADD            (0 << 23)
90
 
91
 
92
/*      Start of frame delimter for valid MII management frame.             */
93
 
94
#define MCF5272_FEC_MII_ST          (0x40000000)
95
 
96
/*      Operation code.  This field bust be programmed to generate a  valid */
97
/* MII management frame.                                                    */
98
 
99
#define MCF5272_FEC_MII_OP_READ     (0x20000000)
100
#define MCF5272_FEC_MII_OP_WRITE    (0x10000000)
101
 
102
/*      Register address.  Specifies one of the 32 attached PHY devices.    */
103
 
104
#define MCF5272_FEC_MII_RA_POS      (18)
105
#define MCF5272_FEC_MII_RA_MASK     (0x1F)
106
 
107
/*      Turn around.  Must  be programmed  to 10  to generate  a valid  MII */
108
/* management frame.                                                        */
109
 
110
#define MCF5272_FEC_MII_TA          (0x00020000)
111
 
112
 
113
/*      The management frame data maske.  Field  for data to be written  to */
114
/* or read from PHY register.                                               */
115
 
116
#define MCF5272_FEC_MII_DATA_MASK   (0x0000FFFF)
117
 
118
 
119
/*      This define the MII unchanged MII frame management bits.            */
120
 
121
#define MCF5272_FEC_MII_FIX_HDR     (0 |                  \
122
                                     MCF5272_FEC_MII_ST | \
123
                                     MCF5272_PHY_ADD |    \
124
                                     MCF5272_FEC_MII_TA)
125
 
126
 
127
/*      The PHY address mask.                                               */
128
 
129
#define MCF5272_FEC_MII_PA          (0x1F << 23)
130
 
131
/*      Define the interrupt mask.                                          */
132
 
133
#define MCF5272_FEC_INTERRUPT_MASK (MCF5272_FEC_IMR_TXFEN    | \
134
                                    MCF5272_FEC_IMR_RXFEN    )
135
 
136
 
137
/**************************************************
138
 * FEC diagnostic counters
139
 **************************************************/
140
typedef struct MCF5272_FEC_DIAG
141
{
142
 
143
    /*   We put all the receive statistics first.                           */
144
 
145
    unsigned long     rx_pk_cnt;             /*   The   total   number   of */
146
                                             /* received packets            */
147
 
148
    unsigned long     rx_pk_cnt_sec;
149
 
150
    unsigned long     rx_bytes_cnt;          /*   The   total   number   of */
151
                                             /* received bytes              */
152
 
153
    unsigned long     rx_bytes_cnt_sec;
154
 
155
    unsigned long     rx_err_cnt;            /*   The total  number of  bad */
156
                                             /* packets received            */
157
 
158
    unsigned long     rx_long_frm_err_cnt;   /*   The total number of  long */
159
                                             /* frame errors.               */
160
 
161
    unsigned long     rx_short_frm_err_cnt;  /*   The total number of short */
162
                                             /* frame errors.               */
163
 
164
    unsigned long     rx_crc_err_cnt;        /*   The total  number of  CRC */
165
                                             /* errors.                     */
166
 
167
    unsigned long     rx_overrun_err_cnt;    /*   The   total   number   of */
168
                                             /* overrun errors.             */
169
 
170
    unsigned long     rx_trunc_error_cnt;    /*   The  total   numbers   of */
171
                                             /* receieve  truncated  packet */
172
                                             /* errors.                     */
173
 
174
    /*   We  put  all  the  transmit  statistics  next.   start_of_transmit */
175
    /* doesn't take any  space but  only separates  the receive  statistics */
176
    /* from the transmit statistics.                                        */
177
 
178
    char              start_of_transmit[0];
179
 
180
    unsigned long     tx_pk_cnt;          /*   The    total    number    of */
181
                                          /* transmitted packet             */
182
 
183
    unsigned long     tx_pk_cnt_sec;
184
 
185
    unsigned long     tx_bytes_cnt;       /*   The    total    number    of */
186
                                          /* transmitted bytes              */
187
 
188
    unsigned long     tx_bytes_cnt_sec;
189
 
190
    unsigned long     tx_err_cnt;         /*   The total  number of  failed */
191
                                          /* packet transmission            */
192
 
193
    unsigned long     tx_def_cnt;         /*   The total number of  tansmit */
194
                                          /* defers.                        */
195
 
196
    unsigned long     tx_hb_err_cnt;      /*   The total  number  of  heart */
197
                                          /* beat errors.                   */
198
 
199
    unsigned long     tx_late_col_cnt;    /*   The  total  number  of  late */
200
                                          /* collisions.                    */
201
 
202
    unsigned long     tx_exes_retry_cnt;  /*   Excessive rettry count.      */
203
 
204
    unsigned long     tx_retry_cnt;       /*   The total number of transmit */
205
                                          /* retries.                       */
206
 
207
    unsigned long     tx_underrun_cnt;    /*   The total number of transmit */
208
                                          /* underruns.                     */
209
 
210
    unsigned long     tx_carrrier_loss_cnt; /*   The   total   number    of */
211
                                            /* trasnmit carrier losses.     */
212
 
213
    unsigned long     tx_free_bd_cnt;     /*   The total  number  of  freed */
214
                                          /* buffer descriptor.             */
215
 
216
    unsigned long     tx_free_min_bd_cnt; /*   The minimum  number of  free */
217
                                          /* buffer descriptor count.       */
218
 
219
    unsigned long     tx_full_cnt;        /*   The  number  of  times  when */
220
                                          /* there is no transmit buffer.   */
221
 
222
    unsigned long     tx_not_complete_cnt;  /*   The number  of  times  the */
223
                                            /* device   driver   discovered */
224
                                            /* that the BD is still in  use */
225
                                            /* by the FEC.                  */
226
 
227
    unsigned long     internal_bus_error_cnt; /*   FEC bus error count.   A */
228
                                              /* bus  error  occurred  when */
229
                                              /* the FEC  was accessing  an */
230
                                              /* internal bus.              */
231
 
232
}MCF5272_FEC_DIAG __attribute__ ((aligned, packed));
233
 
234
/* Ethernet driver status. */
235
enum eth_drv_status_t
236
{
237
    ETH_DEV_UNKNOWN = 1,
238
    ETH_DEV_DOWN = 2,
239
    ETH_DEV_UP = 3
240
};
241
 
242
/* Ethernet duplex mode. */
243
enum eth_drv_mode_t
244
{
245
    ETH_MODE_UNKNOWN = 1,
246
    ETH_MODE_SIMPLEX = 2,
247
    ETH_MODE_DUPLEX = 3
248
};
249
 
250
 
251
/* Ethernet speed values. */
252
enum eth_speed_t
253
{
254
    ETH_SPEED_10MB  =   10*1000*1000,
255
    ETH_SPEED_100MB =  100*1000*1000
256
};
257
 
258
/* Ethernet driver statistics information structure. */
259
 
260
struct mcf5272_ether_drv_stats
261
{
262
    struct ifreq ifreq;                 // tell ioctl() which interface.
263
 
264
    char description[ DESC_LEN ];       // Textual description of hardware
265
    unsigned char snmp_chipset[ SNMP_CHIPSET_LEN ];
266
                                        // SNMP ID of chipset
267
    enum eth_drv_mode_t  duplex;               // 1 = UNKNOWN, 2 = SIMPLEX, 3 = DUPLEX
268
    enum eth_drv_status_t operational;          // 1 = UNKNOWN, 2 = DOWN, 3 = UP
269
    // These are general status information:
270
    unsigned int speed;                 // 10,000,000 or 100,000,000
271
                                        //     to infinity and beyond?
272
 
273
    MCF5272_FEC_DIAG stats;
274
 
275
}__attribute__ ((aligned, packed));
276
 
277
#ifndef FIELD_OFFSET
278
#define FIELD_OFFSET(type,field) (cyg_uint32)(&(((type*)0)->field)
279
#endif /* FIELD_OFFSET */
280
 
281
/* The value of 1 second in nanosecond. */
282
#define SEC_IN_NS 1000000000
283
 
284
/* 48-bit Ethernet Addresses */
285
typedef u8_t ETH_ADDR[6];
286
 
287
/* 16-bit Ethernet Frame Type, ie. Protocol */
288
typedef u16_t ETH_FTYPE;
289
 
290
/* Maximum and Minimum Ethernet Frame Size (Data Field) */
291
#define ETH_DATA_MAX_SIZE       (1500)
292
#define ETH_DATA_MIN_SIZE       (46)
293
 
294
/* Maximum and Minimum Ethernet Frame Size (Entire frame) */
295
#define ETH_MAX_SIZE    (ETH_DATA_MAX_SIZE+14)
296
#define ETH_MIN_SIZE    (ETH_DATA_MIN_SIZE+14)
297
 
298
/* Common Ethernet Frame definition */
299
typedef struct
300
{
301
        ETH_ADDR dest;
302
        ETH_ADDR src;
303
        ETH_FTYPE type;
304
        u8_t data[ETH_DATA_MAX_SIZE];
305
    u32_t fcs;
306
} eth_frame_hdr  __attribute__ ((aligned, packed));
307
 
308
/* 802.1Q Ethernet Frame definition */
309
typedef struct
310
{
311
        ETH_ADDR dest;
312
        ETH_ADDR src;
313
    u32_t header_802_1q;
314
        ETH_FTYPE type;
315
        u8_t data[ETH_DATA_MAX_SIZE];
316
    u32_t fcs;
317
} eth_802_1Q_frame_hdr  __attribute__ ((aligned, packed));
318
 
319
/* Definition of macros that access the FEC registers */
320
#define put_reg(_addr_,_value_) \
321
   *((volatile u32_t*)&(_addr_)) = (cyg_uint32)(_value_)
322
 
323
#define get_reg(_addr_) \
324
   *(((volatile u32_t*)&(_addr_)))
325
 
326
 
327
#endif /* _IF_MCF5272_FEC */
328
 
329
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.