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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [sw/] [drivers/] [ethmac/] [include/] [ethmac.h] - Blame information for rev 413

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 409 julius
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  Ethernet MAC driver functions                               ////
4
////                                                              ////
5
////  Description                                                 ////
6
////  A collection of functions to help control the OpenCores     ////
7
////  10/100 ethernet mac (ethmac) core.                          ////
8
////                                                              ////
9
////                                                              ////
10
////  Author(s):                                                  ////
11
////      - Julius Baxter, julius@opencores.org                   ////
12
////      - Parts taken from Linux kernel's open_eth driver.      ////
13
////                                                              ////
14
////                                                              ////
15
//////////////////////////////////////////////////////////////////////
16
////                                                              ////
17
//// Copyright (C) 2009,2010 Authors and OPENCORES.ORG            ////
18
////                                                              ////
19
//// This source file may be used and distributed without         ////
20
//// restriction provided that this copyright statement is not    ////
21
//// removed from the file and that any derivative work contains  ////
22
//// the original copyright notice and the associated disclaimer. ////
23
////                                                              ////
24
//// This source file is free software; you can redistribute it   ////
25
//// and/or modify it under the terms of the GNU Lesser General   ////
26
//// Public License as published by the Free Software Foundation; ////
27
//// either version 2.1 of the License, or (at your option) any   ////
28
//// later version.                                               ////
29
////                                                              ////
30
//// This source is distributed in the hope that it will be       ////
31
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
32
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
33
//// PURPOSE.  See the GNU Lesser General Public License for more ////
34
//// details.                                                     ////
35
////                                                              ////
36
//// You should have received a copy of the GNU Lesser General    ////
37
//// Public License along with this source; if not, download it   ////
38
//// from http://www.opencores.org/lgpl.shtml                     ////
39
////                                                              ////
40
//////////////////////////////////////////////////////////////////////
41 408 julius
 
42 409 julius
#ifndef _ETHMAC_H_
43
#define _ETHMAC_H
44 408 julius
typedef unsigned int uint;
45
 
46
/* Ethernet configuration registers */
47
typedef struct _oeth_regs {
48
        uint    moder;          /* Mode Register */
49
        uint    int_src;        /* Interrupt Source Register */
50
        uint    int_mask;       /* Interrupt Mask Register */
51
        uint    ipgt;           /* Back to Bak Inter Packet Gap Register */
52
        uint    ipgr1;          /* Non Back to Back Inter Packet Gap Register 1 */
53
        uint    ipgr2;          /* Non Back to Back Inter Packet Gap Register 2 */
54
        uint    packet_len;     /* Packet Length Register (min. and max.) */
55
        uint    collconf;       /* Collision and Retry Configuration Register */
56
        uint    tx_bd_num;      /* Transmit Buffer Descriptor Number Register */
57
        uint    ctrlmoder;      /* Control Module Mode Register */
58
        uint    miimoder;       /* MII Mode Register */
59
        uint    miicommand;     /* MII Command Register */
60
        uint    miiaddress;     /* MII Address Register */
61
        uint    miitx_data;     /* MII Transmit Data Register */
62
        uint    miirx_data;     /* MII Receive Data Register */
63
        uint    miistatus;      /* MII Status Register */
64
        uint    mac_addr0;      /* MAC Individual Address Register 0 */
65
        uint    mac_addr1;      /* MAC Individual Address Register 1 */
66
        uint    hash_addr0;     /* Hash Register 0 */
67
        uint    hash_addr1;     /* Hash Register 1 */
68
} oeth_regs;
69
 
70
/* Ethernet buffer descriptor */
71
typedef struct _oeth_bd {
72
#if 0
73
        ushort  len;            /* Buffer length */
74
        ushort  status;         /* Buffer status */
75
#else
76
        uint    len_status;
77
#endif
78
        uint    addr;           /* Buffer address */
79
} oeth_bd;
80
 
81
// From board.h
82
#define ETH_BASE_ADD    ETH0_BASE
83
 
84
#define OETH_REG_BASE           ETH_BASE_ADD
85
#define OETH_BD_BASE            (ETH_BASE_ADD + 0x400)
86
#define OETH_TOTAL_BD           128
87
#define OETH_MAXBUF_LEN         0x600
88
 
89
/* Tx BD */
90
#define OETH_TX_BD_READY        0x8000 /* Tx BD Ready */
91
#define OETH_TX_BD_IRQ          0x4000 /* Tx BD IRQ Enable */
92
#define OETH_TX_BD_WRAP         0x2000 /* Tx BD Wrap (last BD) */
93
#define OETH_TX_BD_PAD          0x1000 /* Tx BD Pad Enable */
94
#define OETH_TX_BD_CRC          0x0800 /* Tx BD CRC Enable */
95
 
96
#define OETH_TX_BD_UNDERRUN     0x0100 /* Tx BD Underrun Status */
97
#define OETH_TX_BD_RETRY        0x00F0 /* Tx BD Retry Status */
98
#define OETH_TX_BD_RETLIM       0x0008 /* Tx BD Retransmission Limit Status */
99
#define OETH_TX_BD_LATECOL      0x0004 /* Tx BD Late Collision Status */
100
#define OETH_TX_BD_DEFER        0x0002 /* Tx BD Defer Status */
101
#define OETH_TX_BD_CARRIER      0x0001 /* Tx BD Carrier Sense Lost Status */
102
#define OETH_TX_BD_STATS        (OETH_TX_BD_UNDERRUN            | \
103
                                OETH_TX_BD_RETRY                | \
104
                                OETH_TX_BD_RETLIM               | \
105
                                OETH_TX_BD_LATECOL              | \
106
                                OETH_TX_BD_DEFER                | \
107
                                OETH_TX_BD_CARRIER)
108
 
109
/* Rx BD */
110
#define OETH_RX_BD_EMPTY        0x8000 /* Rx BD Empty */
111
#define OETH_RX_BD_IRQ          0x4000 /* Rx BD IRQ Enable */
112
#define OETH_RX_BD_WRAP         0x2000 /* Rx BD Wrap (last BD) */
113
 
114
#define OETH_RX_BD_MISS         0x0080 /* Rx BD Miss Status */
115
#define OETH_RX_BD_OVERRUN      0x0040 /* Rx BD Overrun Status */
116
#define OETH_RX_BD_INVSIMB      0x0020 /* Rx BD Invalid Symbol Status */
117
#define OETH_RX_BD_DRIBBLE      0x0010 /* Rx BD Dribble Nibble Status */
118
#define OETH_RX_BD_TOOLONG      0x0008 /* Rx BD Too Long Status */
119
#define OETH_RX_BD_SHORT        0x0004 /* Rx BD Too Short Frame Status */
120
#define OETH_RX_BD_CRCERR       0x0002 /* Rx BD CRC Error Status */
121
#define OETH_RX_BD_LATECOL      0x0001 /* Rx BD Late Collision Status */
122
#define OETH_RX_BD_STATS        (OETH_RX_BD_MISS                | \
123
                                OETH_RX_BD_OVERRUN              | \
124
                                OETH_RX_BD_INVSIMB              | \
125
                                OETH_RX_BD_DRIBBLE              | \
126
                                OETH_RX_BD_TOOLONG              | \
127
                                OETH_RX_BD_SHORT                | \
128
                                OETH_RX_BD_CRCERR               | \
129
                                OETH_RX_BD_LATECOL)
130
 
131
/* MODER Register */
132
#define OETH_MODER_RXEN         0x00000001 /* Receive Enable  */
133
#define OETH_MODER_TXEN         0x00000002 /* Transmit Enable */
134
#define OETH_MODER_NOPRE        0x00000004 /* No Preamble  */
135
#define OETH_MODER_BRO          0x00000008 /* Reject Broadcast */
136
#define OETH_MODER_IAM          0x00000010 /* Use Individual Hash */
137
#define OETH_MODER_PRO          0x00000020 /* Promiscuous (receive all) */
138
#define OETH_MODER_IFG          0x00000040 /* Min. IFG not required */
139
#define OETH_MODER_LOOPBCK      0x00000080 /* Loop Back */
140
#define OETH_MODER_NOBCKOF      0x00000100 /* No Backoff */
141
#define OETH_MODER_EXDFREN      0x00000200 /* Excess Defer */
142
#define OETH_MODER_FULLD        0x00000400 /* Full Duplex */
143
#define OETH_MODER_RST          0x00000800 /* Reset MAC */
144
#define OETH_MODER_DLYCRCEN     0x00001000 /* Delayed CRC Enable */
145
#define OETH_MODER_CRCEN        0x00002000 /* CRC Enable */
146
#define OETH_MODER_HUGEN        0x00004000 /* Huge Enable */
147
#define OETH_MODER_PAD          0x00008000 /* Pad Enable */
148
#define OETH_MODER_RECSMALL     0x00010000 /* Receive Small */
149
 
150
/* Interrupt Source Register */
151
#define OETH_INT_TXB            0x00000001 /* Transmit Buffer IRQ */
152
#define OETH_INT_TXE            0x00000002 /* Transmit Error IRQ */
153
#define OETH_INT_RXF            0x00000004 /* Receive Frame IRQ */
154
#define OETH_INT_RXE            0x00000008 /* Receive Error IRQ */
155
#define OETH_INT_BUSY           0x00000010 /* Busy IRQ */
156
#define OETH_INT_TXC            0x00000020 /* Transmit Control Frame IRQ */
157
#define OETH_INT_RXC            0x00000040 /* Received Control Frame IRQ */
158
 
159
/* Interrupt Mask Register */
160
#define OETH_INT_MASK_TXB       0x00000001 /* Transmit Buffer IRQ Mask */
161
#define OETH_INT_MASK_TXE       0x00000002 /* Transmit Error IRQ Mask */
162
#define OETH_INT_MASK_RXF       0x00000004 /* Receive Frame IRQ Mask */
163
#define OETH_INT_MASK_RXE       0x00000008 /* Receive Error IRQ Mask */
164
#define OETH_INT_MASK_BUSY      0x00000010 /* Busy IRQ Mask */
165
#define OETH_INT_MASK_TXC       0x00000020 /* Transmit Control Frame IRQ Mask */
166
#define OETH_INT_MASK_RXC       0x00000040 /* Received Control Frame IRQ Mask */
167
 
168
/* Control Module Mode Register */
169
#define OETH_CTRLMODER_PASSALL  0x00000001 /* Pass Control Frames */
170
#define OETH_CTRLMODER_RXFLOW   0x00000002 /* Receive Control Flow Enable */
171
#define OETH_CTRLMODER_TXFLOW   0x00000004 /* Transmit Control Flow Enable */
172
 
173
/* MII Mode Register */
174
#define OETH_MIIMODER_CLKDIV    0x000000FF /* Clock Divider */
175
#define OETH_MIIMODER_NOPRE     0x00000100 /* No Preamble */
176
#define OETH_MIIMODER_RST       0x00000200 /* MIIM Reset */
177
 
178
/* MII Command Register */
179
#define OETH_MIICOMMAND_SCANSTAT  0x00000001 /* Scan Status */
180
#define OETH_MIICOMMAND_RSTAT     0x00000002 /* Read Status */
181
#define OETH_MIICOMMAND_WCTRLDATA 0x00000004 /* Write Control Data */
182
 
183
/* MII Address Register */
184
#define OETH_MIIADDRESS_FIAD    0x0000001F /* PHY Address */
185
#define OETH_MIIADDRESS_RGAD    0x00001F00 /* RGAD Address */
186
 
187
/* MII Status Register */
188
#define OETH_MIISTATUS_LINKFAIL 0x00000001 /* Link Fail */
189
#define OETH_MIISTATUS_BUSY     0x00000002 /* MII Busy */
190
#define OETH_MIISTATUS_NVALID   0x00000004 /* Data in MII Status Register is invalid */
191
 
192 409 julius
/* Dummy function for now, just to make the driver compile */
193
void ethmac_init();
194
 
195 408 julius
#endif

powered by: WebSVN 2.1.0

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