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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [ARM9_STR91X_IAR/] [Library/] [include/] [91x_enet.h] - Blame information for rev 577

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 577 jeremybenn
/******************** (C) COPYRIGHT 2006 STMicroelectronics ********************
2
* File Name          : 91x_enet.h
3
* Author             : MCD Application Team
4
* Date First Issued  : May 2006
5
* Description        : ENET driver defines & function prototypes
6
********************************************************************************
7
* History:
8
* May 2006: v1.0
9
********************************************************************************
10
* THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
11
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
12
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
13
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
14
* CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
15
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
16
*******************************************************************************/
17
 
18
#ifndef _ENET_H_
19
#define _ENET_H_
20
 
21
#include <91x_lib.h>
22
 
23
#define ENET_BUFFER_SIZE 1520
24
/*Structures typedef----------------------------------------------------------*/
25
 
26
/*Struct containing the DMA Descriptor data */
27
typedef struct  {
28
  volatile u32 dmaStatCntl;           /* DMA Status and Control Register          */
29
  volatile u32 dmaAddr;               /* DMA Start Address Register               */
30
  volatile u32 dmaNext;               /* DMA Next Descriptor Register             */
31
  volatile u32 dmaPackStatus;         /* DMA Packet Status and Control Register   */
32
} ENET_DMADSCRBase;
33
 
34
 
35
/* ENET_MACConfig Struct*/
36
typedef struct {
37
  FunctionalState ReceiveALL;                 /* Receive All frames: no address rule filtering */
38
  u32             MIIPrescaler;               /* MII Clock Prescaler value */
39
  FunctionalState LoopbackMode;               /* MAC Loopback mode */
40
  u32             AddressFilteringMode;       /* Address Filtering Mode */
41
  u32             VLANFilteringMode;          /* VLAN Filtering Mode */
42
  FunctionalState PassWrongFrame;             /* Pass wrong frame (CRC, overlength, runt..)*/
43
  FunctionalState LateCollision;              /* Retransmit frame when late collision*/
44
  FunctionalState BroadcastFrameReception;    /* Accept broardcast frame */
45
  FunctionalState PacketRetry;                /* Retransmit frame in case of collision */
46
  FunctionalState RxFrameFiltering;           /* Filter early runt frame and address filter fail frames*/
47
  FunctionalState AutomaticPadRemoval;        /* Automatic Padding removal */
48
  FunctionalState DeferralCheck;              /* Excessive Defferal check */
49
} ENET_MACConfig;
50
 
51
/* ENET_TxStatus Struct*/
52
typedef struct {
53
  FlagStatus PacketRetry;
54
  u8         ByteCount;
55
  u8         collisionCount;
56
  FlagStatus LateCollisionObserved;
57
  FlagStatus Deffered;
58
  FlagStatus UnderRun;
59
  FlagStatus ExcessiveCollision;
60
  FlagStatus LateCollision;
61
  FlagStatus ExcessiveDefferal;
62
  FlagStatus LossOfCarrier;
63
  FlagStatus NoCarrier;
64
  FlagStatus FrameAborted;
65
} ENET_TxStatus;
66
 
67
/* ENET_RxStatus Struct*/
68
typedef struct {
69
  FlagStatus FrameAborted;
70
  FlagStatus PacketFilter;
71
  FlagStatus FilteringFail;
72
  FlagStatus BroadCastFrame;
73
  FlagStatus MulticastFrame;
74
  FlagStatus UnsupportedControFrame;
75
  FlagStatus ControlFrame;
76
  FlagStatus LengthError;
77
  FlagStatus Vlan2Tag;
78
  FlagStatus Vlan1Tag;
79
  FlagStatus CRCError;
80
  FlagStatus ExtraBit;
81
  FlagStatus MIIError;
82
  FlagStatus FrameType;
83
  FlagStatus LateCollision;
84
  FlagStatus OverLength;
85
  FlagStatus RuntFrame;
86
  FlagStatus WatchDogTimout;
87
  FlagStatus FalseCarrierIndication;
88
  u16        FrameLength;
89
} ENET_RxStatus;
90
 
91
/*Constants-------------------------------------------------------------------*/
92
 
93
 
94
/* AddressFilteringMode */
95
#define MAC_Perfect_Multicast_Perfect 0x0
96
#define MAC_Perfect_Multicast_Hash    0x1<<17
97
#define MAC_Hash_Multicast_Hash       0x2<<17
98
#define MAC_Inverse                   0x3<<17
99
#define MAC_Promiscuous               0x4<<17
100
#define MAC_Perfect_Multicast_All     0x5<<17
101
#define MAC_Hash_Multicast_All        0x6<<17
102
 
103
/* VLANFilteringMode */
104
#define VLANFilter_VLTAG_VLID        1
105
#define VLANfilter_VLTAG             0
106
 
107
/* MIIPrescaler */
108
#define MIIPrescaler_1  0       /* Prescaler for MDC clock when HCLK < 50 MHz */
109
#define MIIPrescaler_2  1       /* Precaler for MDC when HCLK > = 50 MHz */
110
 
111
 
112
/* MAC Address*/
113
#define MAC_ADDR0 0x00
114
#define MAC_ADDR1 0x0A
115
#define MAC_ADDR2 0x08
116
#define MAC_ADDR3 0x04
117
#define MAC_ADDR4 0x02
118
#define MAC_ADDR5 0x01
119
 
120
/* Multicast Address */
121
#define MCAST_ADDR0   0xFF
122
#define MCAST_ADDR1   0x00
123
#define MCAST_ADDR2   0xFF
124
#define MCAST_ADDR3   0x00
125
#define MCAST_ADDR4   0xFF
126
#define MCAST_ADDR5   0x00
127
 
128
 
129
 
130
#define ENET_MAX_PACKET_SIZE 1520
131
#define ENET_NEXT_ENABLE        0x4000
132
 
133
/*ENET_OperatingMode*/
134
/* Set the full/half-duplex mode at 100 Mb/s */
135
#define PHY_FULLDUPLEX_100M       0x2100
136
#define PHY_HALFDUPLEX_100M       0x2000
137
/* Set the full/half-duplex mode at 10 Mb/s */
138
#define PHY_FULLDUPLEX_10M        0x0100
139
#define PHY_HALFDUPLEX_10M        0x0000
140
 
141
 
142
/*----------------------------functions----------------------------------------*/
143
 
144
void ENET_MACControlConfig(ENET_MACConfig *MAC_Config);
145
void ENET_GetRxStatus(ENET_RxStatus * RxStatus);
146
void ENET_GetTxStatus(ENET_TxStatus * TxStatus);
147
long ENET_SetOperatingMode(void);
148
void ENET_InitClocksGPIO(void);
149
void ENET_MIIWriteReg (u8 phyDev, u8 phyReg, u32  phyVal);
150
u32 ENET_MIIReadReg (u8 phyDev, u32 phyReg );
151
void ENET_RxDscrInit(void);
152
void ENET_TxDscrInit(void);
153
void ENET_Init(void);
154
void ENET_Start(void);
155
u32 ENET_RxPacketGetSize(void);
156
void ENET_TxPkt(void *ppkt, u16 size);
157
u32 ENET_HandleRxPkt(void *ppkt);
158
 
159
 
160
/*Driver internal constants---------------------------------------------------*/
161
 
162
/* MII Address */
163
/* Description of bit field values of the MII Address Register */
164
#define MAC_MIIA_PADDR         0x0000F800
165
#define MAC_MII_ADDR_PHY_ADDR  MAC_MIIA_PADDR /* Phy Address (default: 0): select one of 32 dev */
166
#define MAC_MII_ADDR_MII_REG   0x000007C0          /* MII Register (default: 0) */
167
#define MAC_MII_ADDR_MII_WRITE 0x00000002          /* MII Write */
168
#define MAC_MIIA_PHY_DEV_ADDR  (0x00005000 & MAC_MIIA_PADDR)  /*To be changed if PHY device address changes */
169
#define MAC_MII_ADDR_MII_BUSY  0x00000001 /* MII Busy */
170
 
171
 
172
/* MII DATA register */
173
#define MAC_MII_DATA_REG  0x0000FFFF /* MII Data */
174
 
175
/* MII Read / write timeouts*/
176
#define MII_READ_TO   0x0004FFFF
177
#define MII_WRITE_TO  0x0004FFFF
178
 
179
/* Description of common PHY registers */
180
#define MAC_MII_REG_XCR    0x00000000 /* Tranceiver control register */
181
#define MAC_MII_REG_XSR    0x00000001 /* Tranceiver status register */
182
#define MAC_MII_REG_PID1   0x00000002 /* Tranceiver PHY identifier 1 */
183
#define MAC_MII_REG_PID2   0x00000003 /* Tranceiver PHY identifier 2 */
184
#define MAC_MII_REG_ANA    0x00000004 /* Auto-Negociation Advertissement register */
185
#define MAC_MII_REG_ANLPA  0x00000005 /* Auto-Negociation  Link Partner Ability register */
186
#define MAC_MII_REG_ANE    0x00000006 /* Auto-Negociation  Expansion register */
187
 
188
 
189
 
190
 
191
/* MAC_MCR register fields */
192
#define MAC_MCR_RA    0x80000000
193
#define MAC_MCR_EN    0x40000000
194
#define MAC_MCR_PS    0x03000000
195
#define MAC_MCR_DRO   0x00800000
196
#define MAC_MCR_LM    0x00600000
197
#define MAC_MCR_FDM   0x00100000
198
#define MAC_MCR_AFM   0x000E0000
199
#define MAC_MCR_PWF   0x00010000
200
#define MAC_MCR_VFM   0x00008000
201
#define MAC_MCR_ELC   0x00001000
202
#define MAC_MCR_DBF   0x00000800
203
#define MAC_MCR_DPR   0x00000400
204
#define MAC_MCR_RVFF  0x00000200
205
#define MAC_MCR_APR   0x00000100
206
#define MAC_MCR_BL    0x000000C0
207
#define MAC_MCR_DCE   0x00000020
208
#define MAC_MCR_RVBE  0x00000010
209
#define MAC_MCR_TE    0x00000008
210
#define MAC_MCR_RE    0x00000004
211
#define MAC_MCR_RCFA  0x00000001
212
 
213
/* MTS */
214
#define MAC_MTS_FA  0x00000001
215
#define MAC_MTS_NC  0x00000004
216
#define MAC_MTS_LOC 0x00000008
217
#define MAC_MTS_ED  0x00000010
218
#define MAC_MTS_LC  0x00000020
219
#define MAC_MTS_EC  0x00000040
220
#define MAC_MTS_UR  0x00000080
221
#define MAC_MTS_DEF 0x00000100
222
#define MAC_MTS_LCO 0x00000200
223
#define MAC_MTS_CC  0x00003C00
224
#define MAC_MTS_BC  0x7FFC0000
225
#define MAC_MTS_PR  0x80000000
226
 
227
/* MRS */
228
#define MAC_MRS_FL  0x000007FF
229
#define MAC_MRS_FCI 0x00002000
230
#define MAC_MRS_WT  0x00004000
231
#define MAC_MRS_RF  0x00008000
232
#define MAC_MRS_OL  0x00010000
233
#define MAC_MRS_LC  0x00020000
234
#define MAC_MRS_FT  0x00040000
235
#define MAC_MRS_ME  0x00080000
236
#define MAC_MRS_EB  0x00100000
237
#define MAC_MRS_CE  0x00200000
238
#define MAC_MRS_VL1 0x00400000
239
#define MAC_MRS_VL2 0x00800000
240
#define MAC_MRS_LE  0x01000000
241
#define MAC_MRS_CF  0x02000000
242
#define MAC_MRS_UCF 0x04000000
243
#define MAC_MRS_MCF 0x08000000
244
#define MAC_MRS_BF  0x10000000
245
#define MAC_MRS_FF  0x20000000
246
#define MAC_MRS_PF  0x40000000
247
#define MAC_MRS_FA  0x80000000
248
 
249
/* SCR */
250
#define DMA_SCR_SRESET               0x00000001 /* Soft Reset (DMA_SCR_RESET) */
251
#define DMA_SCR_LOOPB                0x00000002 /* Loopback mode (DMA_SCR_LOOPB) */
252
#define DMA_SCR_RX_MBSIZE            0x00000010 /* Max defined burst length in RX mode (DMA_SCR_RX_MAX_BURST_...) */
253
#define DMA_SCR_TX_MBSIZE            0x000000C0 /* Max defined burst length in TX mode (DMA_SCR_TX_MAX_BURST_...) */
254
#define DMA_SCR_RX_MAX_BURST_SZ DMA_SCR_RX_MBSIZE /* Maximum value of defined burst length in RX mode */
255
#define DMA_SCR_RX_MAX_BURST_SZ_VAL     0x00000000 /* Default value of burst length in RX mode */
256
#define DMA_SCR_TX_MAX_BURST_SZ DMA_SCR_TX_MBSIZE /* Maximum value of defined burst length in TX mode */
257
#define DMA_SCR_TX_MAX_BURST_SZ_VAL     0x000000C0 /* Default value of burst length in TX mode */
258
 
259
 
260
/* DMA_RX_START   */
261
#define DMA_RX_START_DMAEN              0x00000001
262
#define DMA_RX_START_STFETCH            0x00000004
263
#define DMA_RX_START_FFAIL              0x00000020
264
#define DMA_RX_START_RUNT               0x00000040
265
#define DMA_RX_START_COLLS              0x00000080
266
#define DMA_RX_START_DMA_EN             0x00000001 /* set = 0 by sw force a DMA abort */
267
#define DMA_RX_START_FETCH              0x00000004 /* start fetching the 1st descriptor */
268
#define DMA_RX_START_FILTER_FAIL        0x00000020 /* if = 1 the address filtering failed cond */
269
#define DMA_RX_START_RUNT               0x00000040 /* discard damaged RX frames from cpu charge */
270
#define DMA_RX_START_COLLS_SEEN         0x00000080 /* Late Collision Seen Cond discard frame automat. */
271
#define DMA_RX_START_DFETCH_DLY         0x00FFFF00 /* Descriptor Fetch Delay */
272
#define DMA_RX_START_DFETCH_DLY_POS     8
273
#define DMA_RX_START_DFETCH_DEFAULT     0x00010000 /* Descriptor Fetch Delay default value */
274
 
275
/* DMA_DSCR_PACK_STAT    */
276
#define DMA_DSCR_PACK_STAT              0x00010000
277
 
278
 
279
/* DMA_TX_START   */
280
#define DMA_TX_START_DMAEN              0x00000001
281
#define DMA_TX_START_STFETCH            0x00000004
282
#define DMA_TX_START_URUN               0x00000020
283
#define DMA_TX_START_DISPAD             0x00000040
284
#define DMA_TX_START_ADDCTC             0x00000080
285
#define DMA_TX_START_DMA_EN             0x00000001 /* set = 0 by sw force a DMA abort */
286
#define DMA_TX_START_FETCH              0x00000004 /* start fetching the 1st descriptor */
287
#define DMA_RX_START_FILTER_FAIL        0x00000020 /* if = 1 the address filtering failed cond */
288
#define DMA_TX_START_DFETCH_DLY         0x00FFFF00 /* Descriptor Fetch Delay */
289
#define DMA_TX_START_DFETCH_DEFAULT     0x00010000 /* Descriptor Fetch Delay */
290
#define DMA_TX_START_DFETCH_DLY_POS     0x8
291
#define DMA_TX_START_URUN               0x00000020
292
#define DMA_TX_START_DIS_PADDING        0x00000040 /* Avoid automatic addition of padding bits by MAC*/
293
#define DMA_TX_START_ADD_CRC_DIS        0x00000080 /* Tell MAC not to ADD CRC field at end of frame */
294
 
295
/* DMA_DSCR_CNTL    */
296
#define DMA_DSCR_CNTL_XFERCOUNT         0x00000FFF
297
#define DMA_DSCR_CNTL_NXTEN             0x00004000
298
 
299
/* DMA_DSCR_ADDR    */
300
#define DMA_DSCR_ADDR                   0xFFFFFFFC /* for DMA Start Address (32 bit Word Align) */
301
#define DMA_DSCR_ADDR_FIX_ADDR          0x00000002 /* Disable incrementing of DMA_ADDR */
302
#define DMA_DSCR_ADDR_WRAPEN_SET        0x00000001
303
#define DMA_DSCR_ADDR_WRAPEN_RST        0x00000000
304
 
305
/* DMA_DSCR_NEXT_ADDR    TX/RX */
306
#define DMA_DSCR_NXT_DSCR_ADDR          0xFFFFFFFC /* Points to Next descriptor starting address */
307
#define DMA_DSCR_NXT_NPOL_EN            0x00000001 /* Next Descriptor Polling Enable */
308
#define DMA_DSCR_NXT_NEXT_EN            0x00000002 /* Next Descriptor Fetch mode Enable */
309
 
310
/* DMA Descriptor Packet Status: TX */
311
#define DMA_DSCR_TX_STATUS_FA_MSK       0x00000001 /* Frame Aborted */
312
#define DMA_DSCR_TX_STATUS_JTO_MSK      0x00000002 /* Jabber Timeout. */
313
#define DMA_DSCR_TX_STATUS_NOC_MSK      0x00000004 /* No Carrier */
314
#define DMA_DSCR_TX_STATUS_LOC_MSK      0x00000008 /* Loss of Carrier */
315
#define DMA_DSCR_TX_STATUS_EXCD_MSK     0x00000010 /* Excessive Deferral */
316
#define DMA_DSCR_TX_STATUS_LCOLL_MSK    0x00000020 /* Late Collision */
317
#define DMA_DSCR_TX_STATUS_ECOLL_MSK    0x00000040 /* Excessive Collisions */
318
#define DMA_DSCR_TX_STATUS_URUN_MSK     0x00000080 /* Under Run */
319
#define DMA_DSCR_TX_STATUS_DEFER_MSK    0x00000100 /* Deferred */
320
#define DMA_DSCR_TX_STATUS_LCOLLO_MSK   0x00000200 /* Late Collision Observed */
321
#define DMA_DSCR_TX_STATUS_CCNT_MSK     0x00003C00 /* Collision Count */
322
#define DMA_DSCR_TX_STATUS_HBFAIL_MSK   0x00004000 /* Heart Beat Fail */
323
#define DMA_DSCR_TX_STATUS_VALID_MSK    0x00010000 /* Valid bit indicator - This bit marks the dscriptors this word belong */
324
#define DMA_DSCR_TX_STATUS_PKT_RTRY_MSK 0x80000000 /* Packet Retry */
325
#define DMA_DSCR_TX_STATUS_ORED_ERR_MSK 0x000003D7 /* for total number of errors */
326
 
327
/* DMA Descriptor Packet Status: RX */
328
#define DMA_DSCR_RX_STATUS_FLEN_MSK     0x000007ff /* 0x00003FFF * Frame Length (max 2047) */
329
#define DMA_DSCR_RX_STATUS_FTLONG_MSK   0x00001000 /* Over Lenght */
330
#define DMA_DSCR_RX_STATUS_FCI_MSK      0x00002000 /* Frame too Long */
331
#define DMA_DSCR_RX_STATUS_WDTO_MSK     0x00004000 /* Watchdog Timeout */
332
#define DMA_DSCR_RX_STATUS_RUNTFR_MSK   0x00008000 /* Runt Frame */
333
#define DMA_DSCR_RX_STATUS_VALID_MSK    0x00010000 /* Valid bit indicator - This bit marks the dscriptors this word  */
334
#define DMA_DSCR_RX_STATUS_COLLSEEN_MSK 0x00020000 /* Collision Seen */
335
#define DMA_DSCR_RX_STATUS_FTYPE_MSK    0x00040000 /* Frame Type */
336
#define DMA_DSCR_RX_STATUS_MII_ERR_MSK  0x00080000 /* MII Error */
337
#define DMA_DSCR_RX_STATUS_DRBBIT_MSK   0x00100000 /* Dribbling Bit */
338
#define DMA_DSCR_RX_STATUS_CRC_ERR_MSK  0x00200000 /* CRC Error */
339
#define DMA_DSCR_RX_STATUS_VLAN1_FR_MSK 0x00400000 /* One-Level VLAN Frame */
340
#define DMA_DSCR_RX_STATUS_VLAN2_FR_MSK 0x00800000 /* Two-Level VLAN Frame */
341
#define DMA_DSCR_RX_STATUS_LEN_ERR_MSK  0x01000000 /* Length Error */
342
#define DMA_DSCR_RX_STATUS_CTL_FR_MSK   0x02000000 /* Control Frame */
343
#define DMA_DSCR_RX_STATUS_UCTRL_FR_MSK 0x04000000 /* Unsupported Control Frame */
344
#define DMA_DSCR_RX_STATUS_MCAST_FR_MSK 0x08000000 /* Multicast Frame */
345
#define DMA_DSCR_RX_STATUS_BCAST_FR_MSK 0x10000000 /* BroadCast Frame */
346
#define DMA_DSCR_RX_STATUS_FLT_FAIL_MSK 0x20000000 /* Filtering Fail */
347
#define DMA_DSCR_RX_STATUS_PKT_FILT_MSK 0x40000000 /* Packet Filter */
348
#define DMA_DSCR_RX_STATUS_MIS_FR_MSK   0x80000000 /* Missed Frame */
349
#define DMA_DSCR_RX_STATUS_ERROR_MSK   (DMA_DSCR_RX_STATUS_LEN_ERR | DMA_DSCR_RX_STATUS_CRC_ERR | \
350
                                        DMA_DSCR_RX_STATUS_MII_ERR | DMA_DSCR_RX_STATUS_RUNTFR |  \
351
                                        DMA_DSCR_RX_STATUS_FTLONG | DMA_DSCR_RX_STATUS_COLLSEEN)
352
#define DMA_DSCR_RX_STATUS_ORED_ERR_MSK 0x00000000 /*Mask for total number of errors */
353
 
354
 
355
#endif  /* _ENET_H_ */
356
 
357
/******************** (C) COPYRIGHT 2006 STMicroelectronics *******************/
358
 

powered by: WebSVN 2.1.0

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