2 * (C) Copyright 2007 Michal Simek
4 * Michal SIMEK <monstr@monstr.eu>
6 * See file CREDITS for list of people who contributed to this
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.
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.
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,
24 * Based on Xilinx drivers
29 u32 regbaseaddress; /* Base address of registers */
30 u32 databaseaddress; /* Base address of data for FIFOs */
34 u32 baseaddress; /* Base address (of IPIF) */
35 u32 isstarted; /* Device is currently started 0-no, 1-yes */
36 xpacketfifov100b recvfifo; /* FIFO used to receive frames */
37 xpacketfifov100b sendfifo; /* FIFO used to send frames */
40 #define XIIF_V123B_IISR_OFFSET 32UL /* IP interrupt status register */
41 #define XIIF_V123B_RESET_MASK 0xAUL
42 #define XIIF_V123B_RESETR_OFFSET 64UL /* reset register */
44 /* This constant is used with the Reset Register */
45 #define XPF_RESET_FIFO_MASK 0x0000000A
46 #define XPF_COUNT_STATUS_REG_OFFSET 4UL
48 /* These constants are used with the Occupancy/Vacancy Count Register. This
49 * register also contains FIFO status */
50 #define XPF_COUNT_MASK 0x0000FFFF
51 #define XPF_DEADLOCK_MASK 0x20000000
53 /* Offset of the MAC registers from the IPIF base address */
54 #define XEM_REG_OFFSET 0x1100UL
57 * Register offsets for the Ethernet MAC. Each register is 32 bits.
59 #define XEM_ECR_OFFSET (XEM_REG_OFFSET + 0x4) /* MAC Control */
60 #define XEM_SAH_OFFSET (XEM_REG_OFFSET + 0xC) /* Station addr, high */
61 #define XEM_SAL_OFFSET (XEM_REG_OFFSET + 0x10) /* Station addr, low */
62 #define XEM_RPLR_OFFSET (XEM_REG_OFFSET + 0x1C) /* Rx packet length */
63 #define XEM_TPLR_OFFSET (XEM_REG_OFFSET + 0x20) /* Tx packet length */
64 #define XEM_TSR_OFFSET (XEM_REG_OFFSET + 0x24) /* Tx status */
68 #define XEM_PFIFO_OFFSET 0x2000UL
70 #define XEM_PFIFO_TXREG_OFFSET (XEM_PFIFO_OFFSET + 0x0)
72 #define XEM_PFIFO_RXREG_OFFSET (XEM_PFIFO_OFFSET + 0x10)
74 #define XEM_PFIFO_TXDATA_OFFSET (XEM_PFIFO_OFFSET + 0x100)
76 #define XEM_PFIFO_RXDATA_OFFSET (XEM_PFIFO_OFFSET + 0x200)
80 * EMAC Interrupt Registers (Status and Enable) masks. These registers are
81 * part of the IPIF IP Interrupt registers
83 /* A mask for all transmit interrupts, used in polled mode */
84 #define XEM_EIR_XMIT_ALL_MASK (XEM_EIR_XMIT_DONE_MASK |\
85 XEM_EIR_XMIT_ERROR_MASK | \
86 XEM_EIR_XMIT_SFIFO_EMPTY_MASK |\
87 XEM_EIR_XMIT_LFIFO_FULL_MASK)
90 #define XEM_EIR_XMIT_DONE_MASK 0x00000001UL
92 #define XEM_EIR_RECV_DONE_MASK 0x00000002UL
94 #define XEM_EIR_XMIT_ERROR_MASK 0x00000004UL
96 #define XEM_EIR_RECV_ERROR_MASK 0x00000008UL
97 /* Xmit status fifo empty */
98 #define XEM_EIR_XMIT_SFIFO_EMPTY_MASK 0x00000010UL
99 /* Recv length fifo empty */
100 #define XEM_EIR_RECV_LFIFO_EMPTY_MASK 0x00000020UL
101 /* Xmit length fifo full */
102 #define XEM_EIR_XMIT_LFIFO_FULL_MASK 0x00000040UL
103 /* Recv length fifo overrun */
104 #define XEM_EIR_RECV_LFIFO_OVER_MASK 0x00000080UL
105 /* Recv length fifo underrun */
106 #define XEM_EIR_RECV_LFIFO_UNDER_MASK 0x00000100UL
107 /* Xmit status fifo overrun */
108 #define XEM_EIR_XMIT_SFIFO_OVER_MASK 0x00000200UL
109 /* Transmit status fifo underrun */
110 #define XEM_EIR_XMIT_SFIFO_UNDER_MASK 0x00000400UL
111 /* Transmit length fifo overrun */
112 #define XEM_EIR_XMIT_LFIFO_OVER_MASK 0x00000800UL
113 /* Transmit length fifo underrun */
114 #define XEM_EIR_XMIT_LFIFO_UNDER_MASK 0x00001000UL
115 /* Transmit pause pkt received */
116 #define XEM_EIR_XMIT_PAUSE_MASK 0x00002000UL
119 * EMAC Control Register (ECR)
121 /* Full duplex mode */
122 #define XEM_ECR_FULL_DUPLEX_MASK 0x80000000UL
123 /* Reset transmitter */
124 #define XEM_ECR_XMIT_RESET_MASK 0x40000000UL
125 /* Enable transmitter */
126 #define XEM_ECR_XMIT_ENABLE_MASK 0x20000000UL
128 #define XEM_ECR_RECV_RESET_MASK 0x10000000UL
129 /* Enable receiver */
130 #define XEM_ECR_RECV_ENABLE_MASK 0x08000000UL
132 #define XEM_ECR_PHY_ENABLE_MASK 0x04000000UL
133 /* Enable xmit pad insert */
134 #define XEM_ECR_XMIT_PAD_ENABLE_MASK 0x02000000UL
135 /* Enable xmit FCS insert */
136 #define XEM_ECR_XMIT_FCS_ENABLE_MASK 0x01000000UL
137 /* Enable unicast addr */
138 #define XEM_ECR_UNICAST_ENABLE_MASK 0x00020000UL
139 /* Enable broadcast addr */
140 #define XEM_ECR_BROAD_ENABLE_MASK 0x00008000UL
143 * Transmit Status Register (TSR)
145 /* Transmit excess deferral */
146 #define XEM_TSR_EXCESS_DEFERRAL_MASK 0x80000000UL
147 /* Transmit late collision */
148 #define XEM_TSR_LATE_COLLISION_MASK 0x01000000UL