blob: 7d5fbd327a4f79a2a4bb6a23bf6e6c34e92dd89a [file] [log] [blame]
Daniel Hellstromf1431792008-03-28 20:22:53 +01001/* Gaisler.com GRETH 10/100/1000 Ethernet MAC driver
2 *
3 * (C) Copyright 2007
4 * Daniel Hellstrom, Gaisler Research, daniel@gaisler.com
5 *
6 * See file CREDITS for list of people who contributed to this
7 * project.
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22 * MA 02111-1307 USA
23 */
24
25#define GRETH_FD 0x10
26#define GRETH_RESET 0x40
27#define GRETH_MII_BUSY 0x8
28#define GRETH_MII_NVALID 0x10
29
30/* MII registers */
31#define GRETH_MII_EXTADV_1000FD 0x00000200
32#define GRETH_MII_EXTADV_1000HD 0x00000100
33#define GRETH_MII_EXTPRT_1000FD 0x00000800
34#define GRETH_MII_EXTPRT_1000HD 0x00000400
35
36#define GRETH_MII_100T4 0x00000200
37#define GRETH_MII_100TXFD 0x00000100
38#define GRETH_MII_100TXHD 0x00000080
39#define GRETH_MII_10FD 0x00000040
40#define GRETH_MII_10HD 0x00000020
41
42#define GRETH_BD_EN 0x800
43#define GRETH_BD_WR 0x1000
44#define GRETH_BD_IE 0x2000
45#define GRETH_BD_LEN 0x7FF
46
47#define GRETH_TXEN 0x1
48#define GRETH_INT_TX 0x8
49#define GRETH_TXI 0x4
50#define GRETH_TXBD_STATUS 0x0001C000
51#define GRETH_TXBD_MORE 0x20000
52#define GRETH_TXBD_IPCS 0x40000
53#define GRETH_TXBD_TCPCS 0x80000
54#define GRETH_TXBD_UDPCS 0x100000
55#define GRETH_TXBD_ERR_LC 0x10000
56#define GRETH_TXBD_ERR_UE 0x4000
57#define GRETH_TXBD_ERR_AL 0x8000
58#define GRETH_TXBD_NUM 128
59#define GRETH_TXBD_NUM_MASK (GRETH_TXBD_NUM-1)
60#define GRETH_TX_BUF_SIZE 2048
61
62#define GRETH_INT_RX 0x4
63#define GRETH_RXEN 0x2
64#define GRETH_RXI 0x8
65#define GRETH_RXBD_STATUS 0xFFFFC000
66#define GRETH_RXBD_ERR_AE 0x4000
67#define GRETH_RXBD_ERR_FT 0x8000
68#define GRETH_RXBD_ERR_CRC 0x10000
69#define GRETH_RXBD_ERR_OE 0x20000
70#define GRETH_RXBD_ERR_LE 0x40000
71#define GRETH_RXBD_IP_DEC 0x80000
72#define GRETH_RXBD_IP_CSERR 0x100000
73#define GRETH_RXBD_UDP_DEC 0x200000
74#define GRETH_RXBD_UDP_CSERR 0x400000
75#define GRETH_RXBD_TCP_DEC 0x800000
76#define GRETH_RXBD_TCP_CSERR 0x1000000
77
78#define GRETH_RXBD_NUM 128
79#define GRETH_RXBD_NUM_MASK (GRETH_RXBD_NUM-1)
80#define GRETH_RX_BUF_SIZE 2048
81
82/* Ethernet configuration registers */
83typedef struct _greth_regs {
84 volatile unsigned int control;
85 volatile unsigned int status;
86 volatile unsigned int esa_msb;
87 volatile unsigned int esa_lsb;
88 volatile unsigned int mdio;
89 volatile unsigned int tx_desc_p;
90 volatile unsigned int rx_desc_p;
91} greth_regs;
92
93/* Ethernet buffer descriptor */
94typedef struct _greth_bd {
95 volatile unsigned int stat;
96 unsigned int addr; /* Buffer address not changed by HW */
97} greth_bd;