1 |
1622 |
jcastillo |
/*
|
2 |
|
|
* linux/arch/arm/drivers/net/ether1.h
|
3 |
|
|
*
|
4 |
|
|
* network driver for Acorn Ether1 cards.
|
5 |
|
|
*
|
6 |
|
|
* (c) 1996 Russell King
|
7 |
|
|
*/
|
8 |
|
|
|
9 |
|
|
#ifndef _LINUX_ether1_H
|
10 |
|
|
#define _LINUX_ether1_H
|
11 |
|
|
|
12 |
|
|
#ifdef __ETHER1_C
|
13 |
|
|
/* use 0 for production, 1 for verification, >2 for debug */
|
14 |
|
|
#ifndef NET_DEBUG
|
15 |
|
|
#define NET_DEBUG 0
|
16 |
|
|
#endif
|
17 |
|
|
|
18 |
|
|
/* Page register */
|
19 |
|
|
#define REG_PAGE (dev->base_addr + 0x00)
|
20 |
|
|
|
21 |
|
|
/* Control register */
|
22 |
|
|
#define REG_CONTROL (dev->base_addr + 0x01)
|
23 |
|
|
#define CTRL_RST 0x01
|
24 |
|
|
#define CTRL_LOOPBACK 0x02
|
25 |
|
|
#define CTRL_CA 0x04
|
26 |
|
|
#define CTRL_ACK 0x08
|
27 |
|
|
|
28 |
|
|
#define ETHER1_RAM (dev->base_addr + 0x800)
|
29 |
|
|
|
30 |
|
|
/* HW address */
|
31 |
|
|
#define IDPROM_ADDRESS (dev->base_addr + 0x09)
|
32 |
|
|
|
33 |
|
|
struct ether1_priv {
|
34 |
|
|
struct enet_statistics stats;
|
35 |
|
|
unsigned int tx_link;
|
36 |
|
|
unsigned int tx_head;
|
37 |
|
|
volatile unsigned int tx_tail;
|
38 |
|
|
volatile unsigned int rx_head;
|
39 |
|
|
volatile unsigned int rx_tail;
|
40 |
|
|
unsigned char bus_type;
|
41 |
|
|
unsigned char resetting;
|
42 |
|
|
unsigned char initialising : 1;
|
43 |
|
|
unsigned char restart : 1;
|
44 |
|
|
};
|
45 |
|
|
|
46 |
|
|
static int ether1_open (struct device *dev);
|
47 |
|
|
static int ether1_sendpacket (struct sk_buff *skb, struct device *dev);
|
48 |
|
|
static void ether1_interrupt (int irq, void *dev_id, struct pt_regs *regs);
|
49 |
|
|
static int ether1_close (struct device *dev);
|
50 |
|
|
static struct enet_statistics *ether1_getstats (struct device *dev);
|
51 |
|
|
static void ether1_setmulticastlist (struct device *dev);
|
52 |
|
|
|
53 |
|
|
#define I82586_NULL (-1)
|
54 |
|
|
|
55 |
|
|
typedef struct {
|
56 |
|
|
unsigned short status;
|
57 |
|
|
unsigned short command;
|
58 |
|
|
} cmd_hdr_t;
|
59 |
|
|
|
60 |
|
|
typedef struct { /* tdr */
|
61 |
|
|
cmd_hdr_t hdr;
|
62 |
|
|
unsigned short tdr_link;
|
63 |
|
|
unsigned short tdr_result;
|
64 |
|
|
#define TDR_TIME (0x7ff)
|
65 |
|
|
#define TDR_SHORT (1 << 12)
|
66 |
|
|
#define TDR_OPEN (1 << 13)
|
67 |
|
|
#define TDR_XCVRPROB (1 << 14)
|
68 |
|
|
#define TDR_LNKOK (1 << 15)
|
69 |
|
|
} tdr_t;
|
70 |
|
|
|
71 |
|
|
typedef struct { /* transmit */
|
72 |
|
|
cmd_hdr_t hdr;
|
73 |
|
|
unsigned short tx_link;
|
74 |
|
|
unsigned short tx_tbdoffset;
|
75 |
|
|
} tx_t;
|
76 |
|
|
|
77 |
|
|
typedef struct { /* tbd */
|
78 |
|
|
unsigned short tbd_opts;
|
79 |
|
|
#define TBD_CNT (0x3fff)
|
80 |
|
|
#define TBD_EOL (1 << 15)
|
81 |
|
|
unsigned short tbd_link;
|
82 |
|
|
unsigned short tbd_bufl;
|
83 |
|
|
unsigned short tbd_bufh;
|
84 |
|
|
} tbd_t;
|
85 |
|
|
|
86 |
|
|
typedef struct { /* rfd */
|
87 |
|
|
cmd_hdr_t hdr;
|
88 |
|
|
#define RFD_NOEOF (1 << 6)
|
89 |
|
|
#define RFD_FRAMESHORT (1 << 7)
|
90 |
|
|
#define RFD_DMAOVRN (1 << 8)
|
91 |
|
|
#define RFD_NORESOURCES (1 << 9)
|
92 |
|
|
#define RFD_ALIGNERROR (1 << 10)
|
93 |
|
|
#define RFD_CRCERROR (1 << 11)
|
94 |
|
|
#define RFD_OK (1 << 13)
|
95 |
|
|
#define RFD_FDCONSUMED (1 << 14)
|
96 |
|
|
#define RFD_COMPLETE (1 << 15)
|
97 |
|
|
|
98 |
|
|
#define RFD_CMDSUSPEND (1 << 14)
|
99 |
|
|
#define RFD_CMDEL (1 << 15)
|
100 |
|
|
unsigned short rfd_link;
|
101 |
|
|
unsigned short rfd_rbdoffset;
|
102 |
|
|
unsigned char rfd_dest[6];
|
103 |
|
|
unsigned char rfd_src[6];
|
104 |
|
|
unsigned short rfd_len;
|
105 |
|
|
} rfd_t;
|
106 |
|
|
|
107 |
|
|
typedef struct { /* rbd */
|
108 |
|
|
unsigned short rbd_status;
|
109 |
|
|
#define RBD_ACNT (0x3fff)
|
110 |
|
|
#define RBD_ACNTVALID (1 << 14)
|
111 |
|
|
#define RBD_EOF (1 << 15)
|
112 |
|
|
unsigned short rbd_link;
|
113 |
|
|
unsigned short rbd_bufl;
|
114 |
|
|
unsigned short rbd_bufh;
|
115 |
|
|
unsigned short rbd_len;
|
116 |
|
|
} rbd_t;
|
117 |
|
|
|
118 |
|
|
typedef struct { /* nop */
|
119 |
|
|
cmd_hdr_t hdr;
|
120 |
|
|
unsigned short nop_link;
|
121 |
|
|
} nop_t;
|
122 |
|
|
|
123 |
|
|
typedef struct { /* set multicast */
|
124 |
|
|
cmd_hdr_t hdr;
|
125 |
|
|
unsigned short mc_link;
|
126 |
|
|
unsigned short mc_cnt;
|
127 |
|
|
unsigned char mc_addrs[1][6];
|
128 |
|
|
} mc_t;
|
129 |
|
|
|
130 |
|
|
typedef struct { /* set address */
|
131 |
|
|
cmd_hdr_t hdr;
|
132 |
|
|
unsigned short sa_link;
|
133 |
|
|
unsigned char sa_addr[6];
|
134 |
|
|
} sa_t;
|
135 |
|
|
|
136 |
|
|
typedef struct { /* config command */
|
137 |
|
|
cmd_hdr_t hdr;
|
138 |
|
|
unsigned short cfg_link;
|
139 |
|
|
unsigned char cfg_bytecnt; /* size foll data: 4 - 12 */
|
140 |
|
|
unsigned char cfg_fifolim; /* FIFO threshold */
|
141 |
|
|
unsigned char cfg_byte8;
|
142 |
|
|
#define CFG8_SRDY (1 << 6)
|
143 |
|
|
#define CFG8_SAVEBADF (1 << 7)
|
144 |
|
|
unsigned char cfg_byte9;
|
145 |
|
|
#define CFG9_ADDRLEN(x) (x)
|
146 |
|
|
#define CFG9_ADDRLENBUF (1 << 3)
|
147 |
|
|
#define CFG9_PREAMB2 (0 << 4)
|
148 |
|
|
#define CFG9_PREAMB4 (1 << 4)
|
149 |
|
|
#define CFG9_PREAMB8 (2 << 4)
|
150 |
|
|
#define CFG9_PREAMB16 (3 << 4)
|
151 |
|
|
#define CFG9_ILOOPBACK (1 << 6)
|
152 |
|
|
#define CFG9_ELOOPBACK (1 << 7)
|
153 |
|
|
unsigned char cfg_byte10;
|
154 |
|
|
#define CFG10_LINPRI(x) (x)
|
155 |
|
|
#define CFG10_ACR(x) (x << 4)
|
156 |
|
|
#define CFG10_BOFMET (1 << 7)
|
157 |
|
|
unsigned char cfg_ifs;
|
158 |
|
|
unsigned char cfg_slotl;
|
159 |
|
|
unsigned char cfg_byte13;
|
160 |
|
|
#define CFG13_SLOTH(x) (x)
|
161 |
|
|
#define CFG13_RETRY(x) (x << 4)
|
162 |
|
|
unsigned char cfg_byte14;
|
163 |
|
|
#define CFG14_PROMISC (1 << 0)
|
164 |
|
|
#define CFG14_DISBRD (1 << 1)
|
165 |
|
|
#define CFG14_MANCH (1 << 2)
|
166 |
|
|
#define CFG14_TNCRS (1 << 3)
|
167 |
|
|
#define CFG14_NOCRC (1 << 4)
|
168 |
|
|
#define CFG14_CRC16 (1 << 5)
|
169 |
|
|
#define CFG14_BTSTF (1 << 6)
|
170 |
|
|
#define CFG14_FLGPAD (1 << 7)
|
171 |
|
|
unsigned char cfg_byte15;
|
172 |
|
|
#define CFG15_CSTF(x) (x)
|
173 |
|
|
#define CFG15_ICSS (1 << 3)
|
174 |
|
|
#define CFG15_CDTF(x) (x << 4)
|
175 |
|
|
#define CFG15_ICDS (1 << 7)
|
176 |
|
|
unsigned short cfg_minfrmlen;
|
177 |
|
|
} cfg_t;
|
178 |
|
|
|
179 |
|
|
typedef struct { /* scb */
|
180 |
|
|
unsigned short scb_status; /* status of 82586 */
|
181 |
|
|
#define SCB_STRXMASK (7 << 4) /* Receive unit status */
|
182 |
|
|
#define SCB_STRXIDLE (0 << 4) /* Idle */
|
183 |
|
|
#define SCB_STRXSUSP (1 << 4) /* Suspended */
|
184 |
|
|
#define SCB_STRXNRES (2 << 4) /* No resources */
|
185 |
|
|
#define SCB_STRXRDY (4 << 4) /* Ready */
|
186 |
|
|
#define SCB_STCUMASK (7 << 8) /* Command unit status */
|
187 |
|
|
#define SCB_STCUIDLE (0 << 8) /* Idle */
|
188 |
|
|
#define SCB_STCUSUSP (1 << 8) /* Suspended */
|
189 |
|
|
#define SCB_STCUACTV (2 << 8) /* Active */
|
190 |
|
|
#define SCB_STRNR (1 << 12) /* Receive unit not ready */
|
191 |
|
|
#define SCB_STCNA (1 << 13) /* Command unit not ready */
|
192 |
|
|
#define SCB_STFR (1 << 14) /* Frame received */
|
193 |
|
|
#define SCB_STCX (1 << 15) /* Command completed */
|
194 |
|
|
unsigned short scb_command; /* Next command */
|
195 |
|
|
#define SCB_CMDRXSTART (1 << 4) /* Start (at rfa_offset) */
|
196 |
|
|
#define SCB_CMDRXRESUME (2 << 4) /* Resume reception */
|
197 |
|
|
#define SCB_CMDRXSUSPEND (3 << 4) /* Suspend reception */
|
198 |
|
|
#define SCB_CMDRXABORT (4 << 4) /* Abort reception */
|
199 |
|
|
#define SCB_CMDCUCSTART (1 << 8) /* Start (at cbl_offset) */
|
200 |
|
|
#define SCB_CMDCUCRESUME (2 << 8) /* Resume execution */
|
201 |
|
|
#define SCB_CMDCUCSUSPEND (3 << 8) /* Suspend execution */
|
202 |
|
|
#define SCB_CMDCUCABORT (4 << 8) /* Abort execution */
|
203 |
|
|
#define SCB_CMDACKRNR (1 << 12) /* Ack RU not ready */
|
204 |
|
|
#define SCB_CMDACKCNA (1 << 13) /* Ack CU not ready */
|
205 |
|
|
#define SCB_CMDACKFR (1 << 14) /* Ack Frame received */
|
206 |
|
|
#define SCB_CMDACKCX (1 << 15) /* Ack Command complete */
|
207 |
|
|
unsigned short scb_cbl_offset; /* Offset of first command unit */
|
208 |
|
|
unsigned short scb_rfa_offset; /* Offset of first receive frame area */
|
209 |
|
|
unsigned short scb_crc_errors; /* Properly aligned frame with CRC error*/
|
210 |
|
|
unsigned short scb_aln_errors; /* Misaligned frames */
|
211 |
|
|
unsigned short scb_rsc_errors; /* Frames lost due to no space */
|
212 |
|
|
unsigned short scb_ovn_errors; /* Frames lost due to slow bus */
|
213 |
|
|
} scb_t;
|
214 |
|
|
|
215 |
|
|
typedef struct { /* iscp */
|
216 |
|
|
unsigned short iscp_busy; /* set by CPU before CA */
|
217 |
|
|
unsigned short iscp_offset; /* offset of SCB */
|
218 |
|
|
unsigned short iscp_basel; /* base of SCB */
|
219 |
|
|
unsigned short iscp_baseh;
|
220 |
|
|
} iscp_t;
|
221 |
|
|
|
222 |
|
|
/* this address must be 0xfff6 */
|
223 |
|
|
typedef struct { /* scp */
|
224 |
|
|
unsigned short scp_sysbus; /* bus size */
|
225 |
|
|
#define SCP_SY_16BBUS 0x00
|
226 |
|
|
#define SCP_SY_8BBUS 0x01
|
227 |
|
|
unsigned short scp_junk[2]; /* junk */
|
228 |
|
|
unsigned short scp_iscpl; /* lower 16 bits of iscp */
|
229 |
|
|
unsigned short scp_iscph; /* upper 16 bits of iscp */
|
230 |
|
|
} scp_t;
|
231 |
|
|
|
232 |
|
|
/* commands */
|
233 |
|
|
#define CMD_NOP 0
|
234 |
|
|
#define CMD_SETADDRESS 1
|
235 |
|
|
#define CMD_CONFIG 2
|
236 |
|
|
#define CMD_SETMULTICAST 3
|
237 |
|
|
#define CMD_TX 4
|
238 |
|
|
#define CMD_TDR 5
|
239 |
|
|
#define CMD_DUMP 6
|
240 |
|
|
#define CMD_DIAGNOSE 7
|
241 |
|
|
|
242 |
|
|
#define CMD_MASK 7
|
243 |
|
|
|
244 |
|
|
#define CMD_INTR (1 << 13)
|
245 |
|
|
#define CMD_SUSP (1 << 14)
|
246 |
|
|
#define CMD_EOL (1 << 15)
|
247 |
|
|
|
248 |
|
|
#define STAT_COLLISIONS (15)
|
249 |
|
|
#define STAT_COLLEXCESSIVE (1 << 5)
|
250 |
|
|
#define STAT_COLLAFTERTX (1 << 6)
|
251 |
|
|
#define STAT_TXDEFERRED (1 << 7)
|
252 |
|
|
#define STAT_TXSLOWDMA (1 << 8)
|
253 |
|
|
#define STAT_TXLOSTCTS (1 << 9)
|
254 |
|
|
#define STAT_NOCARRIER (1 << 10)
|
255 |
|
|
#define STAT_FAIL (1 << 11)
|
256 |
|
|
#define STAT_ABORTED (1 << 12)
|
257 |
|
|
#define STAT_OK (1 << 13)
|
258 |
|
|
#define STAT_BUSY (1 << 14)
|
259 |
|
|
#define STAT_COMPLETE (1 << 15)
|
260 |
|
|
#endif
|
261 |
|
|
#endif
|
262 |
|
|
|
263 |
|
|
/*
|
264 |
|
|
* Ether1 card definitions:
|
265 |
|
|
*
|
266 |
|
|
* FAST accesses:
|
267 |
|
|
* +0 Page register
|
268 |
|
|
* 16 pages
|
269 |
|
|
* +4 Control
|
270 |
|
|
* '1' = reset
|
271 |
|
|
* '2' = loopback
|
272 |
|
|
* '4' = CA
|
273 |
|
|
* '8' = int ack
|
274 |
|
|
*
|
275 |
|
|
* RAM at address + 0x2000
|
276 |
|
|
* Pod. Prod id = 3
|
277 |
|
|
* Words after ID block [base + 8 words]
|
278 |
|
|
* +0 pcb issue (0x0c and 0xf3 invalid)
|
279 |
|
|
* +1 - +6 eth hw address
|
280 |
|
|
*/
|