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 */
41 #define XIIF_V123B_IISR_OFFSET 32UL /* IP interrupt status register */
42 #define XIIF_V123B_RESET_MASK 0xAUL
43 #define XIIF_V123B_RESETR_OFFSET 64UL /* reset register */
45 /* This constant is used with the Reset Register */
46 #define XPF_RESET_FIFO_MASK 0x0000000A
47 #define XPF_COUNT_STATUS_REG_OFFSET 4UL
49 /* * These constants are used with the Occupancy/Vacancy Count Register. This
50 * register also contains FIFO status */
51 #define XPF_COUNT_MASK 0x0000FFFF
52 #define XPF_DEADLOCK_MASK 0x20000000
54 /* Offset of the MAC registers from the IPIF base address */
55 #define XEM_REG_OFFSET 0x1100UL
58 * Register offsets for the Ethernet MAC. Each register is 32 bits.
60 #define XEM_ECR_OFFSET (XEM_REG_OFFSET + 0x4) /* MAC Control */
61 #define XEM_SAH_OFFSET (XEM_REG_OFFSET + 0xC) /* Station addr, high */
62 #define XEM_SAL_OFFSET (XEM_REG_OFFSET + 0x10) /* Station addr, low */
63 #define XEM_RPLR_OFFSET (XEM_REG_OFFSET + 0x1C) /* Rx packet length */
64 #define XEM_TPLR_OFFSET (XEM_REG_OFFSET + 0x20) /* Tx packet length */
65 #define XEM_TSR_OFFSET (XEM_REG_OFFSET + 0x24) /* Tx status */
69 #define XEM_PFIFO_OFFSET 0x2000UL
70 #define XEM_PFIFO_TXREG_OFFSET (XEM_PFIFO_OFFSET + 0x0) /* Tx registers */
71 #define XEM_PFIFO_RXREG_OFFSET (XEM_PFIFO_OFFSET + 0x10) /* Rx registers */
72 #define XEM_PFIFO_TXDATA_OFFSET (XEM_PFIFO_OFFSET + 0x100) /* Tx keyhole */
73 #define XEM_PFIFO_RXDATA_OFFSET (XEM_PFIFO_OFFSET + 0x200) /* Rx keyhole */
77 * EMAC Interrupt Registers (Status and Enable) masks. These registers are
78 * part of the IPIF IP Interrupt registers
80 /* A mask for all transmit interrupts, used in polled mode */
81 #define XEM_EIR_XMIT_ALL_MASK (XEM_EIR_XMIT_DONE_MASK | \
82 XEM_EIR_XMIT_ERROR_MASK | \
83 XEM_EIR_XMIT_SFIFO_EMPTY_MASK | \
84 XEM_EIR_XMIT_LFIFO_FULL_MASK)
86 #define XEM_EIR_XMIT_DONE_MASK 0x00000001UL /* Xmit complete */
87 #define XEM_EIR_RECV_DONE_MASK 0x00000002UL /* Recv complete */
88 #define XEM_EIR_XMIT_ERROR_MASK 0x00000004UL /* Xmit error */
89 #define XEM_EIR_RECV_ERROR_MASK 0x00000008UL /* Recv error */
90 #define XEM_EIR_XMIT_SFIFO_EMPTY_MASK 0x00000010UL /* Xmit status fifo empty */
91 #define XEM_EIR_RECV_LFIFO_EMPTY_MASK 0x00000020UL /* Recv length fifo empty */
92 #define XEM_EIR_XMIT_LFIFO_FULL_MASK 0x00000040UL /* Xmit length fifo full */
93 #define XEM_EIR_RECV_LFIFO_OVER_MASK 0x00000080UL /* Recv length fifo
95 #define XEM_EIR_RECV_LFIFO_UNDER_MASK 0x00000100UL /* Recv length fifo
97 #define XEM_EIR_XMIT_SFIFO_OVER_MASK 0x00000200UL /* Xmit status fifo
99 #define XEM_EIR_XMIT_SFIFO_UNDER_MASK 0x00000400UL /* Transmit status fifo
101 #define XEM_EIR_XMIT_LFIFO_OVER_MASK 0x00000800UL /* Transmit length fifo
103 #define XEM_EIR_XMIT_LFIFO_UNDER_MASK 0x00001000UL /* Transmit length fifo
105 #define XEM_EIR_XMIT_PAUSE_MASK 0x00002000UL /* Transmit pause pkt
109 * EMAC Control Register (ECR)
111 #define XEM_ECR_FULL_DUPLEX_MASK 0x80000000UL /* Full duplex mode */
112 #define XEM_ECR_XMIT_RESET_MASK 0x40000000UL /* Reset transmitter */
113 #define XEM_ECR_XMIT_ENABLE_MASK 0x20000000UL /* Enable transmitter */
114 #define XEM_ECR_RECV_RESET_MASK 0x10000000UL /* Reset receiver */
115 #define XEM_ECR_RECV_ENABLE_MASK 0x08000000UL /* Enable receiver */
116 #define XEM_ECR_PHY_ENABLE_MASK 0x04000000UL /* Enable PHY */
117 #define XEM_ECR_XMIT_PAD_ENABLE_MASK 0x02000000UL /* Enable xmit pad
119 #define XEM_ECR_XMIT_FCS_ENABLE_MASK 0x01000000UL /* Enable xmit FCS
121 #define XEM_ECR_UNICAST_ENABLE_MASK 0x00020000UL /* Enable unicast
123 #define XEM_ECR_BROAD_ENABLE_MASK 0x00008000UL /* Enable broadcast
126 /* Transmit Status Register (TSR) */
127 #define XEM_TSR_EXCESS_DEFERRAL_MASK 0x80000000UL /* Transmit excess deferral */
128 #define XEM_TSR_LATE_COLLISION_MASK 0x01000000UL /* Transmit late collision */