Import 2.1.36
[davej-history.git] / drivers / net / eepro.c
blob72060c53b882d1dfec13b31b4b6ebd2ff7dbced8
1 /* eepro.c: Intel EtherExpress Pro/10 device driver for Linux. */
2 /*
3 Written 1994, 1995,1996 by Bao C. Ha.
5 Copyright (C) 1994, 1995,1996 by Bao C. Ha.
7 This software may be used and distributed
8 according to the terms of the GNU Public License,
9 incorporated herein by reference.
11 The author may be reached at bao.ha@srs.gov
12 or 418 Hastings Place, Martinez, GA 30907.
14 Things remaining to do:
15 Better record keeping of errors.
16 Eliminate transmit interrupt to reduce overhead.
17 Implement "concurrent processing". I won't be doing it!
19 Bugs:
21 If you have a problem of not detecting the 82595 during a
22 reboot (warm reset), disable the FLASH memory should fix it.
23 This is a compatibility hardware problem.
25 Versions:
27 0.09 Fixed a race condition in the transmit algorithm,
28 which causes crashes under heavy load with fast
29 pentium computers. The performance should also
30 improve a bit. The size of RX buffer, and hence
31 TX buffer, can also be changed via lilo or insmod.
32 (BCH, 7/31/96)
34 0.08 Implement 32-bit I/O for the 82595TX and 82595FX
35 based lan cards. Disable full-duplex mode if TPE
36 is not used. (BCH, 4/8/96)
38 0.07a Fix a stat report which counts every packet as a
39 heart-beat failure. (BCH, 6/3/95)
41 0.07 Modified to support all other 82595-based lan cards.
42 The IRQ vector of the EtherExpress Pro will be set
43 according to the value saved in the EEPROM. For other
44 cards, I will do autoirq_request() to grab the next
45 available interrupt vector. (BCH, 3/17/95)
47 0.06a,b Interim released. Minor changes in the comments and
48 print out format. (BCH, 3/9/95 and 3/14/95)
50 0.06 First stable release that I am comfortable with. (BCH,
51 3/2/95)
53 0.05 Complete testing of multicast. (BCH, 2/23/95)
55 0.04 Adding multicast support. (BCH, 2/14/95)
57 0.03 First widely alpha release for public testing.
58 (BCH, 2/14/95)
62 static const char *version =
63 "eepro.c: v0.09 7/31/96 Bao C. Ha (bao.ha@srs.gov)\n";
65 #include <linux/module.h>
68 Sources:
70 This driver wouldn't have been written without the availability
71 of the Crynwr's Lan595 driver source code. It helps me to
72 familiarize with the 82595 chipset while waiting for the Intel
73 documentation. I also learned how to detect the 82595 using
74 the packet driver's technique.
76 This driver is written by cutting and pasting the skeleton.c driver
77 provided by Donald Becker. I also borrowed the EEPROM routine from
78 Donald Becker's 82586 driver.
80 Datasheet for the Intel 82595 (including the TX and FX version). It
81 provides just enough info that the casual reader might think that it
82 documents the i82595.
84 The User Manual for the 82595. It provides a lot of the missing
85 information.
89 #include <linux/kernel.h>
90 #include <linux/sched.h>
91 #include <linux/types.h>
92 #include <linux/fcntl.h>
93 #include <linux/interrupt.h>
94 #include <linux/ptrace.h>
95 #include <linux/ioport.h>
96 #include <linux/in.h>
97 #include <linux/malloc.h>
98 #include <linux/string.h>
99 #include <asm/system.h>
100 #include <asm/bitops.h>
101 #include <asm/io.h>
102 #include <asm/dma.h>
103 #include <linux/errno.h>
104 #include <linux/init.h>
106 #include <linux/netdevice.h>
107 #include <linux/etherdevice.h>
108 #include <linux/skbuff.h>
111 /* First, a few definitions that the brave might change. */
112 /* A zero-terminated list of I/O addresses to be probed. */
113 static unsigned int eepro_portlist[] __initdata =
114 { 0x200, 0x240, 0x280, 0x2C0, 0x300, 0x320, 0x340, 0x360, 0};
116 /* use 0 for production, 1 for verification, >2 for debug */
117 #ifndef NET_DEBUG
118 #define NET_DEBUG 3
119 #endif
120 static unsigned int net_debug = NET_DEBUG;
122 /* The number of low I/O ports used by the ethercard. */
123 #define EEPRO_IO_EXTENT 16
125 /* Different 82595 chips */
126 #define LAN595 0
127 #define LAN595TX 1
128 #define LAN595FX 2
130 /* Information that need to be kept for each board. */
131 struct eepro_local {
132 struct net_device_stats stats;
133 unsigned rx_start;
134 unsigned tx_start; /* start of the transmit chain */
135 int tx_last; /* pointer to last packet in the transmit chain */
136 unsigned tx_end; /* end of the transmit chain (plus 1) */
137 int eepro; /* a flag, TRUE=1 for the EtherExpress Pro/10,
138 FALSE = 0 for other 82595-based lan cards. */
139 int version; /* a flag to indicate if this is a TX or FX
140 version of the 82595 chip. */
141 int stepping;
144 /* The station (ethernet) address prefix, used for IDing the board. */
145 #define SA_ADDR0 0x00
146 #define SA_ADDR1 0xaa
147 #define SA_ADDR2 0x00
149 /* Index to functions, as function prototypes. */
151 extern int eepro_probe(struct device *dev);
153 static int eepro_probe1(struct device *dev, short ioaddr);
154 static int eepro_open(struct device *dev);
155 static int eepro_send_packet(struct sk_buff *skb, struct device *dev);
156 static void eepro_interrupt(int irq, void *dev_id, struct pt_regs *regs);
157 static void eepro_rx(struct device *dev);
158 static void eepro_transmit_interrupt(struct device *dev);
159 static int eepro_close(struct device *dev);
160 static struct net_device_stats *eepro_get_stats(struct device *dev);
161 static void set_multicast_list(struct device *dev);
163 static int read_eeprom(int ioaddr, int location);
164 static void hardware_send_packet(struct device *dev, void *buf, short length);
165 static int eepro_grab_irq(struct device *dev);
168 Details of the i82595.
170 You will need either the datasheet or the user manual to understand what
171 is going on here. The 82595 is very different from the 82586, 82593.
173 The receive algorithm in eepro_rx() is just an implementation of the
174 RCV ring structure that the Intel 82595 imposes at the hardware level.
175 The receive buffer is set at 24K, and the transmit buffer is 8K. I
176 am assuming that the total buffer memory is 32K, which is true for the
177 Intel EtherExpress Pro/10. If it is less than that on a generic card,
178 the driver will be broken.
180 The transmit algorithm in the hardware_send_packet() is similar to the
181 one in the eepro_rx(). The transmit buffer is a ring linked list.
182 I just queue the next available packet to the end of the list. In my
183 system, the 82595 is so fast that the list seems to always contain a
184 single packet. In other systems with faster computers and more congested
185 network traffics, the ring linked list should improve performance by
186 allowing up to 8K worth of packets to be queued.
188 The sizes of the receive and transmit buffers can now be changed via lilo
189 or insmod. Lilo uses the appended line "ether=io,irq,debug,rx-buffer,eth0"
190 where rx-buffer is in KB unit. Modules uses the parameter mem which is
191 also in KB unit, for example "insmod io=io-address irq=0 mem=rx-buffer."
192 The receive buffer has to be more than 3K or less than 29K. Otherwise,
193 it is reset to the default of 24K, and, hence, 8K for the trasnmit
194 buffer (transmit-buffer = 32K - receive-buffer).
197 #define RAM_SIZE 0x8000
198 #define RCV_HEADER 8
199 #define RCV_RAM 0x6000 /* 24KB default for RCV buffer */
200 #define RCV_LOWER_LIMIT 0x00 /* 0x0000 */
201 /* #define RCV_UPPER_LIMIT ((RCV_RAM - 2) >> 8) */ /* 0x5ffe */
202 #define RCV_UPPER_LIMIT (((rcv_ram) - 2) >> 8)
203 /* #define XMT_RAM (RAM_SIZE - RCV_RAM) */ /* 8KB for XMT buffer */
204 #define XMT_RAM (RAM_SIZE - (rcv_ram)) /* 8KB for XMT buffer */
205 /* #define XMT_LOWER_LIMIT (RCV_RAM >> 8) */ /* 0x6000 */
206 #define XMT_LOWER_LIMIT ((rcv_ram) >> 8)
207 #define XMT_UPPER_LIMIT ((RAM_SIZE - 2) >> 8) /* 0x7ffe */
208 #define XMT_HEADER 8
210 #define RCV_DONE 0x0008
211 #define RX_OK 0x2000
212 #define RX_ERROR 0x0d81
214 #define TX_DONE_BIT 0x0080
215 #define CHAIN_BIT 0x8000
216 #define XMT_STATUS 0x02
217 #define XMT_CHAIN 0x04
218 #define XMT_COUNT 0x06
220 #define BANK0_SELECT 0x00
221 #define BANK1_SELECT 0x40
222 #define BANK2_SELECT 0x80
224 /* Bank 0 registers */
225 #define COMMAND_REG 0x00 /* Register 0 */
226 #define MC_SETUP 0x03
227 #define XMT_CMD 0x04
228 #define DIAGNOSE_CMD 0x07
229 #define RCV_ENABLE_CMD 0x08
230 #define RCV_DISABLE_CMD 0x0a
231 #define STOP_RCV_CMD 0x0b
232 #define RESET_CMD 0x0e
233 #define POWER_DOWN_CMD 0x18
234 #define RESUME_XMT_CMD 0x1c
235 #define SEL_RESET_CMD 0x1e
236 #define STATUS_REG 0x01 /* Register 1 */
237 #define RX_INT 0x02
238 #define TX_INT 0x04
239 #define EXEC_STATUS 0x30
240 #define ID_REG 0x02 /* Register 2 */
241 #define R_ROBIN_BITS 0xc0 /* round robin counter */
242 #define ID_REG_MASK 0x2c
243 #define ID_REG_SIG 0x24
244 #define AUTO_ENABLE 0x10
245 #define INT_MASK_REG 0x03 /* Register 3 */
246 #define RX_STOP_MASK 0x01
247 #define RX_MASK 0x02
248 #define TX_MASK 0x04
249 #define EXEC_MASK 0x08
250 #define ALL_MASK 0x0f
251 #define IO_32_BIT 0x10
252 #define RCV_BAR 0x04 /* The following are word (16-bit) registers */
253 #define RCV_STOP 0x06
254 #define XMT_BAR 0x0a
255 #define HOST_ADDRESS_REG 0x0c
256 #define IO_PORT 0x0e
257 #define IO_PORT_32_BIT 0x0c
259 /* Bank 1 registers */
260 #define REG1 0x01
261 #define WORD_WIDTH 0x02
262 #define INT_ENABLE 0x80
263 #define INT_NO_REG 0x02
264 #define RCV_LOWER_LIMIT_REG 0x08
265 #define RCV_UPPER_LIMIT_REG 0x09
266 #define XMT_LOWER_LIMIT_REG 0x0a
267 #define XMT_UPPER_LIMIT_REG 0x0b
269 /* Bank 2 registers */
270 #define XMT_Chain_Int 0x20 /* Interrupt at the end of the transmit chain */
271 #define XMT_Chain_ErrStop 0x40 /* Interrupt at the end of the chain even if there are errors */
272 #define RCV_Discard_BadFrame 0x80 /* Throw bad frames away, and continue to receive others */
273 #define REG2 0x02
274 #define PRMSC_Mode 0x01
275 #define Multi_IA 0x20
276 #define REG3 0x03
277 #define TPE_BIT 0x04
278 #define BNC_BIT 0x20
279 #define REG13 0x0d
280 #define FDX 0x00
281 #define A_N_ENABLE 0x02
283 #define I_ADD_REG0 0x04
284 #define I_ADD_REG1 0x05
285 #define I_ADD_REG2 0x06
286 #define I_ADD_REG3 0x07
287 #define I_ADD_REG4 0x08
288 #define I_ADD_REG5 0x09
290 #define EEPROM_REG 0x0a
291 #define EESK 0x01
292 #define EECS 0x02
293 #define EEDI 0x04
294 #define EEDO 0x08
297 /* Check for a network adaptor of this type, and return '0' iff one exists.
298 If dev->base_addr == 0, probe all likely locations.
299 If dev->base_addr == 1, always return failure.
300 If dev->base_addr == 2, allocate space for the device and return success
301 (detachable devices only).
303 #ifdef HAVE_DEVLIST
304 /* Support for an alternate probe manager, which will eliminate the
305 boilerplate below. */
306 struct netdev_entry netcard_drv =
307 {"eepro", eepro_probe1, EEPRO_IO_EXTENT, eepro_portlist};
308 #else
309 __initfunc(int
310 eepro_probe(struct device *dev))
312 int i;
313 int base_addr = dev ? dev->base_addr : 0;
315 if (base_addr > 0x1ff) /* Check a single specified location. */
316 return eepro_probe1(dev, base_addr);
317 else if (base_addr != 0) /* Don't probe at all. */
318 return ENXIO;
320 for (i = 0; eepro_portlist[i]; i++) {
321 int ioaddr = eepro_portlist[i];
322 if (check_region(ioaddr, EEPRO_IO_EXTENT))
323 continue;
324 if (eepro_probe1(dev, ioaddr) == 0)
325 return 0;
328 return ENODEV;
330 #endif
332 /* This is the real probe routine. Linux has a history of friendly device
333 probes on the ISA bus. A good device probes avoids doing writes, and
334 verifies that the correct device exists and functions. */
336 __initfunc(int eepro_probe1(struct device *dev, short ioaddr))
338 unsigned short station_addr[6], id, counter;
339 int i;
340 int eepro; /* a flag, TRUE=1 for the EtherExpress Pro/10,
341 FALSE = 0 for other 82595-based lan cards. */
342 const char *ifmap[] = {"AUI", "10Base2", "10BaseT"};
343 enum iftype { AUI=0, BNC=1, TPE=2 };
345 /* Now, we are going to check for the signature of the
346 ID_REG (register 2 of bank 0) */
348 if (((id=inb(ioaddr + ID_REG)) & ID_REG_MASK) == ID_REG_SIG) {
350 /* We seem to have the 82595 signature, let's
351 play with its counter (last 2 bits of
352 register 2 of bank 0) to be sure. */
354 counter = (id & R_ROBIN_BITS);
355 if (((id=inb(ioaddr+ID_REG)) & R_ROBIN_BITS) ==
356 (counter + 0x40)) {
358 /* Yes, the 82595 has been found */
360 /* Now, get the ethernet hardware address from
361 the EEPROM */
363 station_addr[0] = read_eeprom(ioaddr, 2);
364 station_addr[1] = read_eeprom(ioaddr, 3);
365 station_addr[2] = read_eeprom(ioaddr, 4);
367 /* Check the station address for the manufacturer's code */
369 if (station_addr[2] != 0x00aa || (station_addr[1] & 0xff00) != 0x0000) {
370 eepro = 0;
371 printk("%s: Intel 82595-based lan card at %#x,",
372 dev->name, ioaddr);
374 else {
375 eepro = 1;
376 printk("%s: Intel EtherExpress Pro/10 at %#x,",
377 dev->name, ioaddr);
380 /* Fill in the 'dev' fields. */
381 dev->base_addr = ioaddr;
383 for (i=0; i < 6; i++) {
384 dev->dev_addr[i] = ((unsigned char *) station_addr)[5-i];
385 printk("%c%02x", i ? ':' : ' ', dev->dev_addr[i]);
388 if ((dev->mem_end & 0x3f) < 3 || /* RX buffer must be more than 3K */
389 (dev->mem_end & 0x3f) > 29) /* and less than 29K */
390 dev->mem_end = RCV_RAM; /* or it will be set to 24K */
391 else dev->mem_end = 1024*dev->mem_end; /* Maybe I should shift << 10 */
393 /* From now on, dev->mem_end contains the actual size of rx buffer */
395 if (net_debug > 3)
396 printk(", %dK RCV buffer", (int)(dev->mem_end)/1024);
398 outb(BANK2_SELECT, ioaddr); /* be CAREFUL, BANK 2 now */
399 id = inb(ioaddr + REG3);
400 if (id & TPE_BIT)
401 dev->if_port = TPE;
402 else dev->if_port = BNC;
404 if (dev->irq < 2 && eepro) {
405 i = read_eeprom(ioaddr, 1);
406 switch (i & 0x07) {
407 case 0: dev->irq = 9; break;
408 case 1: dev->irq = 3; break;
409 case 2: dev->irq = 5; break;
410 case 3: dev->irq = 10; break;
411 case 4: dev->irq = 11; break;
412 default: /* should never get here !!!!! */
413 printk(" illegal interrupt vector stored in EEPROM.\n");
414 return ENODEV;
417 else if (dev->irq == 2)
418 dev->irq = 9;
420 if (dev->irq > 2) {
421 printk(", IRQ %d, %s.\n", dev->irq,
422 ifmap[dev->if_port]);
423 if (request_irq(dev->irq, &eepro_interrupt, 0, "eepro", NULL)) {
424 printk("%s: unable to get IRQ %d.\n", dev->name, dev->irq);
425 return -EAGAIN;
428 else printk(", %s.\n", ifmap[dev->if_port]);
430 if ((dev->mem_start & 0xf) > 0) /* I don't know if this is */
431 net_debug = dev->mem_start & 7; /* still useful or not */
433 if (net_debug > 3) {
434 i = read_eeprom(ioaddr, 5);
435 if (i & 0x2000) /* bit 13 of EEPROM word 5 */
436 printk("%s: Concurrent Processing is enabled but not used!\n",
437 dev->name);
440 if (net_debug)
441 printk(version);
443 /* Grab the region so we can find another board if autoIRQ fails. */
444 request_region(ioaddr, EEPRO_IO_EXTENT, "eepro");
446 /* Initialize the device structure */
447 dev->priv = kmalloc(sizeof(struct eepro_local), GFP_KERNEL);
448 if (dev->priv == NULL)
449 return -ENOMEM;
450 memset(dev->priv, 0, sizeof(struct eepro_local));
452 dev->open = eepro_open;
453 dev->stop = eepro_close;
454 dev->hard_start_xmit = eepro_send_packet;
455 dev->get_stats = eepro_get_stats;
456 dev->set_multicast_list = &set_multicast_list;
458 /* Fill in the fields of the device structure with
459 ethernet generic values */
461 ether_setup(dev);
463 outb(RESET_CMD, ioaddr); /* RESET the 82595 */
465 return 0;
467 else return ENODEV;
469 else if (net_debug > 3)
470 printk ("EtherExpress Pro probed failed!\n");
471 return ENODEV;
474 /* Open/initialize the board. This is called (in the current kernel)
475 sometime after booting when the 'ifconfig' program is run.
477 This routine should set everything up anew at each open, even
478 registers that "should" only need to be set once at boot, so that
479 there is non-reboot way to recover if something goes wrong.
482 static char irqrmap[] = {-1,-1,0,1,-1,2,-1,-1,-1,0,3,4,-1,-1,-1,-1};
483 static int eepro_grab_irq(struct device *dev)
485 int irqlist[] = { 5, 9, 10, 11, 4, 3, 0};
486 int *irqp = irqlist, temp_reg, ioaddr = dev->base_addr;
488 outb(BANK1_SELECT, ioaddr); /* be CAREFUL, BANK 1 now */
490 /* Enable the interrupt line. */
491 temp_reg = inb(ioaddr + REG1);
492 outb(temp_reg | INT_ENABLE, ioaddr + REG1);
494 outb(BANK0_SELECT, ioaddr); /* be CAREFUL, BANK 0 now */
496 /* clear all interrupts */
497 outb(ALL_MASK, ioaddr + STATUS_REG);
498 /* Let EXEC event to interrupt */
499 outb(ALL_MASK & ~(EXEC_MASK), ioaddr + INT_MASK_REG);
501 do {
502 outb(BANK1_SELECT, ioaddr); /* be CAREFUL, BANK 1 now */
504 temp_reg = inb(ioaddr + INT_NO_REG);
505 outb((temp_reg & 0xf8) | irqrmap[*irqp], ioaddr + INT_NO_REG);
507 outb(BANK0_SELECT, ioaddr); /* Switch back to Bank 0 */
509 if (request_irq (*irqp, NULL, 0, "bogus", NULL) != EBUSY) {
510 /* Twinkle the interrupt, and check if it's seen */
511 autoirq_setup(0);
513 outb(DIAGNOSE_CMD, ioaddr); /* RESET the 82595 */
515 if (*irqp == autoirq_report(2) && /* It's a good IRQ line */
516 (request_irq(dev->irq = *irqp, &eepro_interrupt, 0, "eepro", NULL) == 0))
517 break;
519 /* clear all interrupts */
520 outb(ALL_MASK, ioaddr + STATUS_REG);
522 } while (*++irqp);
524 outb(BANK1_SELECT, ioaddr); /* Switch back to Bank 1 */
526 /* Disable the physical interrupt line. */
527 temp_reg = inb(ioaddr + REG1);
528 outb(temp_reg & 0x7f, ioaddr + REG1);
530 outb(BANK0_SELECT, ioaddr); /* Switch back to Bank 0 */
532 /* Mask all the interrupts. */
533 outb(ALL_MASK, ioaddr + INT_MASK_REG);
535 /* clear all interrupts */
536 outb(ALL_MASK, ioaddr + STATUS_REG);
538 return dev->irq;
541 static int
542 eepro_open(struct device *dev)
544 unsigned short temp_reg, old8, old9;
545 int i, ioaddr = dev->base_addr, rcv_ram = dev->mem_end;
546 struct eepro_local *lp = (struct eepro_local *)dev->priv;
548 if (net_debug > 3)
549 printk("eepro: entering eepro_open routine.\n");
551 if (dev->dev_addr[0] == SA_ADDR0 &&
552 dev->dev_addr[1] == SA_ADDR1 &&
553 dev->dev_addr[2] == SA_ADDR2)
554 lp->eepro = 1; /* Yes, an Intel EtherExpress Pro/10 */
555 else lp->eepro = 0; /* No, it is a generic 82585 lan card */
557 /* Get the interrupt vector for the 82595 */
558 if (dev->irq < 2 && eepro_grab_irq(dev) == 0) {
559 printk("%s: unable to get IRQ %d.\n", dev->name, dev->irq);
560 return -EAGAIN;
563 if (irq2dev_map[dev->irq] != 0
564 || (irq2dev_map[dev->irq] = dev) == 0)
565 return -EAGAIN;
567 /* Initialize the 82595. */
569 outb(BANK2_SELECT, ioaddr); /* be CAREFUL, BANK 2 now */
570 temp_reg = inb(ioaddr + EEPROM_REG);
572 lp->stepping = temp_reg >> 5; /* Get the stepping number of the 595 */
574 if (net_debug > 3)
575 printk("The stepping of the 82595 is %d\n", lp->stepping);
577 if (temp_reg & 0x10) /* Check the TurnOff Enable bit */
578 outb(temp_reg & 0xef, ioaddr + EEPROM_REG);
579 for (i=0; i < 6; i++)
580 outb(dev->dev_addr[i] , ioaddr + I_ADD_REG0 + i);
582 temp_reg = inb(ioaddr + REG1); /* Setup Transmit Chaining */
583 outb(temp_reg | XMT_Chain_Int | XMT_Chain_ErrStop /* and discard bad RCV frames */
584 | RCV_Discard_BadFrame, ioaddr + REG1);
586 temp_reg = inb(ioaddr + REG2); /* Match broadcast */
587 outb(temp_reg | 0x14, ioaddr + REG2);
589 temp_reg = inb(ioaddr + REG3);
590 outb(temp_reg & 0x3f, ioaddr + REG3); /* clear test mode */
592 /* Set the receiving mode */
593 outb(BANK1_SELECT, ioaddr); /* be CAREFUL, BANK 1 now */
595 temp_reg = inb(ioaddr + INT_NO_REG);
596 outb((temp_reg & 0xf8) | irqrmap[dev->irq], ioaddr + INT_NO_REG);
598 /* Initialize the RCV and XMT upper and lower limits */
599 outb(RCV_LOWER_LIMIT, ioaddr + RCV_LOWER_LIMIT_REG);
600 outb(RCV_UPPER_LIMIT, ioaddr + RCV_UPPER_LIMIT_REG);
601 outb(XMT_LOWER_LIMIT, ioaddr + XMT_LOWER_LIMIT_REG);
602 outb(XMT_UPPER_LIMIT, ioaddr + XMT_UPPER_LIMIT_REG);
604 /* Enable the interrupt line. */
605 temp_reg = inb(ioaddr + REG1);
606 outb(temp_reg | INT_ENABLE, ioaddr + REG1);
608 outb(BANK0_SELECT, ioaddr); /* Switch back to Bank 0 */
610 /* Let RX and TX events to interrupt */
611 outb(ALL_MASK & ~(RX_MASK | TX_MASK), ioaddr + INT_MASK_REG);
612 /* clear all interrupts */
613 outb(ALL_MASK, ioaddr + STATUS_REG);
615 /* Initialize RCV */
616 outw(RCV_LOWER_LIMIT << 8, ioaddr + RCV_BAR);
617 lp->rx_start = (RCV_LOWER_LIMIT << 8) ;
618 outw((RCV_UPPER_LIMIT << 8) | 0xfe, ioaddr + RCV_STOP);
620 /* Initialize XMT */
621 outw(XMT_LOWER_LIMIT << 8, ioaddr + XMT_BAR);
623 /* Check for the i82595TX and i82595FX */
624 old8 = inb(ioaddr + 8);
625 outb(~old8, ioaddr + 8);
626 if ((temp_reg = inb(ioaddr + 8)) == old8) {
627 if (net_debug > 3)
628 printk("i82595 detected!\n");
629 lp->version = LAN595;
631 else {
632 lp->version = LAN595TX;
633 outb(old8, ioaddr + 8);
634 old9 = inb(ioaddr + 9);
635 outb(~old9, ioaddr + 9);
636 if ((temp_reg = inb(ioaddr + 9)) == ~old9) {
637 enum iftype { AUI=0, BNC=1, TPE=2 };
638 if (net_debug > 3)
639 printk("i82595FX detected!\n");
640 lp->version = LAN595FX;
641 outb(old9, ioaddr + 9);
642 if (dev->if_port != TPE) { /* Hopefully, this will fix the
643 problem of using Pentiums and
644 pro/10 w/ BNC. */
645 outb(BANK2_SELECT, ioaddr); /* be CAREFUL, BANK 2 now */
646 temp_reg = inb(ioaddr + REG13);
647 /* disable the full duplex mode since it is not
648 applicable with the 10Base2 cable. */
649 outb(temp_reg & ~(FDX | A_N_ENABLE), REG13);
650 outb(BANK0_SELECT, ioaddr); /* be CAREFUL, BANK 0 now */
653 else if (net_debug > 3)
654 printk("i82595TX detected!\n");
657 outb(SEL_RESET_CMD, ioaddr);
658 /* We are supposed to wait for 2 us after a SEL_RESET */
659 SLOW_DOWN_IO;
660 SLOW_DOWN_IO;
662 lp->tx_start = lp->tx_end = XMT_LOWER_LIMIT << 8; /* or = RCV_RAM */
663 lp->tx_last = 0;
665 dev->tbusy = 0;
666 dev->interrupt = 0;
667 dev->start = 1;
669 if (net_debug > 3)
670 printk("eepro: exiting eepro_open routine.\n");
672 outb(RCV_ENABLE_CMD, ioaddr);
674 MOD_INC_USE_COUNT;
675 return 0;
678 static int
679 eepro_send_packet(struct sk_buff *skb, struct device *dev)
681 struct eepro_local *lp = (struct eepro_local *)dev->priv;
682 int ioaddr = dev->base_addr;
683 int rcv_ram = dev->mem_end;
685 if (net_debug > 5)
686 printk("eepro: entering eepro_send_packet routine.\n");
688 if (dev->tbusy) {
689 /* If we get here, some higher level has decided we are broken.
690 There should really be a "kick me" function call instead. */
691 int tickssofar = jiffies - dev->trans_start;
692 if (tickssofar < 40)
693 return 1;
694 if (net_debug > 1)
695 printk("%s: transmit timed out, %s?\n", dev->name,
696 "network cable problem");
697 lp->stats.tx_errors++;
699 /* Try to restart the adaptor. */
700 outb(SEL_RESET_CMD, ioaddr);
701 /* We are supposed to wait for 2 us after a SEL_RESET */
702 SLOW_DOWN_IO;
703 SLOW_DOWN_IO;
705 /* Do I also need to flush the transmit buffers here? YES? */
706 lp->tx_start = lp->tx_end = rcv_ram;
707 lp->tx_last = 0;
709 dev->tbusy=0;
710 dev->trans_start = jiffies;
712 outb(RCV_ENABLE_CMD, ioaddr);
716 /* Block a timer-based transmit from overlapping. */
717 if (set_bit(0, (void*)&dev->tbusy) != 0)
718 printk("%s: Transmitter access conflict.\n", dev->name);
719 else {
720 short length = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN;
721 unsigned char *buf = skb->data;
723 hardware_send_packet(dev, buf, length);
724 dev->trans_start = jiffies;
727 dev_kfree_skb (skb, FREE_WRITE);
729 /* You might need to clean up and record Tx statistics here. */
730 /* lp->stats.tx_aborted_errors++; */
732 if (net_debug > 5)
733 printk("eepro: exiting eepro_send_packet routine.\n");
735 return 0;
739 /* The typical workload of the driver:
740 Handle the network interface interrupts. */
741 static void
742 eepro_interrupt(int irq, void *dev_id, struct pt_regs * regs)
744 struct device *dev = (struct device *)(irq2dev_map[irq]);
745 int ioaddr, status, boguscount = 20;
747 if (net_debug > 5)
748 printk("eepro: entering eepro_interrupt routine.\n");
750 if (dev == NULL) {
751 printk ("eepro_interrupt(): irq %d for unknown device.\n", irq);
752 return;
754 dev->interrupt = 1;
756 ioaddr = dev->base_addr;
758 do {
759 status = inb(ioaddr + STATUS_REG);
761 if (status & RX_INT) {
762 if (net_debug > 4)
763 printk("eepro: packet received interrupt.\n");
765 /* Acknowledge the RX_INT */
766 outb(RX_INT, ioaddr + STATUS_REG);
768 /* Get the received packets */
769 eepro_rx(dev);
772 else if (status & TX_INT) {
773 if (net_debug > 4)
774 printk("eepro: packet transmit interrupt.\n");
776 /* Acknowledge the TX_INT */
777 outb(TX_INT, ioaddr + STATUS_REG);
779 /* Process the status of transmitted packets */
780 eepro_transmit_interrupt(dev);
783 } while ((boguscount-- > 0) && (status & 0x06));
785 dev->interrupt = 0;
786 if (net_debug > 5)
787 printk("eepro: exiting eepro_interrupt routine.\n");
789 return;
792 static int
793 eepro_close(struct device *dev)
795 struct eepro_local *lp = (struct eepro_local *)dev->priv;
796 int ioaddr = dev->base_addr;
797 int rcv_ram = dev->mem_end;
798 short temp_reg;
800 dev->tbusy = 1;
801 dev->start = 0;
803 outb(BANK1_SELECT, ioaddr); /* Switch back to Bank 1 */
805 /* Disable the physical interrupt line. */
806 temp_reg = inb(ioaddr + REG1);
807 outb(temp_reg & 0x7f, ioaddr + REG1);
809 outb(BANK0_SELECT, ioaddr); /* Switch back to Bank 0 */
811 /* Flush the Tx and disable Rx. */
812 outb(STOP_RCV_CMD, ioaddr);
813 lp->tx_start = lp->tx_end = rcv_ram ;
814 lp->tx_last = 0;
816 /* Mask all the interrupts. */
817 outb(ALL_MASK, ioaddr + INT_MASK_REG);
819 /* clear all interrupts */
820 outb(ALL_MASK, ioaddr + STATUS_REG);
822 /* Reset the 82595 */
823 outb(RESET_CMD, ioaddr);
825 /* release the interrupt */
826 free_irq(dev->irq, NULL);
828 irq2dev_map[dev->irq] = 0;
830 /* Update the statistics here. What statistics? */
832 /* We are supposed to wait for 200 us after a RESET */
833 SLOW_DOWN_IO;
834 SLOW_DOWN_IO; /* May not be enough? */
836 MOD_DEC_USE_COUNT;
837 return 0;
840 /* Get the current statistics. This may be called with the card open or
841 closed. */
842 static struct net_device_stats *
843 eepro_get_stats(struct device *dev)
845 struct eepro_local *lp = (struct eepro_local *)dev->priv;
847 return &lp->stats;
850 /* Set or clear the multicast filter for this adaptor.
852 static void
853 set_multicast_list(struct device *dev)
855 struct eepro_local *lp = (struct eepro_local *)dev->priv;
856 short ioaddr = dev->base_addr;
857 unsigned short mode;
858 struct dev_mc_list *dmi=dev->mc_list;
860 if (dev->flags&(IFF_ALLMULTI|IFF_PROMISC) || dev->mc_count > 63)
863 * We must make the kernel realise we had to move
864 * into promisc mode or we start all out war on
865 * the cable. If it was a promisc request the
866 * flag is already set. If not we assert it.
868 dev->flags|=IFF_PROMISC;
870 outb(BANK2_SELECT, ioaddr); /* be CAREFUL, BANK 2 now */
871 mode = inb(ioaddr + REG2);
872 outb(mode | PRMSC_Mode, ioaddr + REG2);
873 mode = inb(ioaddr + REG3);
874 outb(mode, ioaddr + REG3); /* writing reg. 3 to complete the update */
875 outb(BANK0_SELECT, ioaddr); /* Return to BANK 0 now */
876 printk("%s: promiscuous mode enabled.\n", dev->name);
878 else if (dev->mc_count==0 )
880 outb(BANK2_SELECT, ioaddr); /* be CAREFUL, BANK 2 now */
881 mode = inb(ioaddr + REG2);
882 outb(mode & 0xd6, ioaddr + REG2); /* Turn off Multi-IA and PRMSC_Mode bits */
883 mode = inb(ioaddr + REG3);
884 outb(mode, ioaddr + REG3); /* writing reg. 3 to complete the update */
885 outb(BANK0_SELECT, ioaddr); /* Return to BANK 0 now */
887 else
889 unsigned short status, *eaddrs;
890 int i, boguscount = 0;
892 /* Disable RX and TX interrupts. Necessary to avoid
893 corruption of the HOST_ADDRESS_REG by interrupt
894 service routines. */
895 outb(ALL_MASK, ioaddr + INT_MASK_REG);
897 outb(BANK2_SELECT, ioaddr); /* be CAREFUL, BANK 2 now */
898 mode = inb(ioaddr + REG2);
899 outb(mode | Multi_IA, ioaddr + REG2);
900 mode = inb(ioaddr + REG3);
901 outb(mode, ioaddr + REG3); /* writing reg. 3 to complete the update */
902 outb(BANK0_SELECT, ioaddr); /* Return to BANK 0 now */
903 outw(lp->tx_end, ioaddr + HOST_ADDRESS_REG);
904 outw(MC_SETUP, ioaddr + IO_PORT);
905 outw(0, ioaddr + IO_PORT);
906 outw(0, ioaddr + IO_PORT);
907 outw(6*(dev->mc_count + 1), ioaddr + IO_PORT);
908 for (i = 0; i < dev->mc_count; i++)
910 eaddrs=(unsigned short *)dmi->dmi_addr;
911 dmi=dmi->next;
912 outw(*eaddrs++, ioaddr + IO_PORT);
913 outw(*eaddrs++, ioaddr + IO_PORT);
914 outw(*eaddrs++, ioaddr + IO_PORT);
916 eaddrs = (unsigned short *) dev->dev_addr;
917 outw(eaddrs[0], ioaddr + IO_PORT);
918 outw(eaddrs[1], ioaddr + IO_PORT);
919 outw(eaddrs[2], ioaddr + IO_PORT);
920 outw(lp->tx_end, ioaddr + XMT_BAR);
921 outb(MC_SETUP, ioaddr);
923 /* Update the transmit queue */
924 i = lp->tx_end + XMT_HEADER + 6*(dev->mc_count + 1);
925 if (lp->tx_start != lp->tx_end)
927 /* update the next address and the chain bit in the
928 last packet */
929 outw(lp->tx_last + XMT_CHAIN, ioaddr + HOST_ADDRESS_REG);
930 outw(i, ioaddr + IO_PORT);
931 outw(lp->tx_last + XMT_COUNT, ioaddr + HOST_ADDRESS_REG);
932 status = inw(ioaddr + IO_PORT);
933 outw(status | CHAIN_BIT, ioaddr + IO_PORT);
934 lp->tx_end = i ;
936 else {
937 lp->tx_start = lp->tx_end = i ;
940 /* Acknowledge that the MC setup is done */
941 do { /* We should be doing this in the eepro_interrupt()! */
942 SLOW_DOWN_IO;
943 SLOW_DOWN_IO;
944 if (inb(ioaddr + STATUS_REG) & 0x08)
946 i = inb(ioaddr);
947 outb(0x08, ioaddr + STATUS_REG);
948 if (i & 0x20) { /* command ABORTed */
949 printk("%s: multicast setup failed.\n",
950 dev->name);
951 break;
952 } else if ((i & 0x0f) == 0x03) { /* MC-Done */
953 printk("%s: set Rx mode to %d addresses.\n",
954 dev->name, dev->mc_count);
955 break;
958 } while (++boguscount < 100);
960 /* Re-enable RX and TX interrupts */
961 outb(ALL_MASK & ~(RX_MASK | TX_MASK), ioaddr + INT_MASK_REG);
964 outb(RCV_ENABLE_CMD, ioaddr);
967 /* The horrible routine to read a word from the serial EEPROM. */
968 /* IMPORTANT - the 82595 will be set to Bank 0 after the eeprom is read */
970 /* The delay between EEPROM clock transitions. */
971 #define eeprom_delay() { int _i = 40; while (--_i > 0) { __SLOW_DOWN_IO; }}
972 #define EE_READ_CMD (6 << 6)
975 read_eeprom(int ioaddr, int location)
977 int i;
978 unsigned short retval = 0;
979 short ee_addr = ioaddr + EEPROM_REG;
980 int read_cmd = location | EE_READ_CMD;
981 short ctrl_val = EECS ;
983 outb(BANK2_SELECT, ioaddr);
984 outb(ctrl_val, ee_addr);
986 /* Shift the read command bits out. */
987 for (i = 8; i >= 0; i--) {
988 short outval = (read_cmd & (1 << i)) ? ctrl_val | EEDI
989 : ctrl_val;
990 outb(outval, ee_addr);
991 outb(outval | EESK, ee_addr); /* EEPROM clock tick. */
992 eeprom_delay();
993 outb(outval, ee_addr); /* Finish EEPROM a clock tick. */
994 eeprom_delay();
996 outb(ctrl_val, ee_addr);
998 for (i = 16; i > 0; i--) {
999 outb(ctrl_val | EESK, ee_addr); eeprom_delay();
1000 retval = (retval << 1) | ((inb(ee_addr) & EEDO) ? 1 : 0);
1001 outb(ctrl_val, ee_addr); eeprom_delay();
1004 /* Terminate the EEPROM access. */
1005 ctrl_val &= ~EECS;
1006 outb(ctrl_val | EESK, ee_addr);
1007 eeprom_delay();
1008 outb(ctrl_val, ee_addr);
1009 eeprom_delay();
1010 outb(BANK0_SELECT, ioaddr);
1011 return retval;
1014 static void
1015 hardware_send_packet(struct device *dev, void *buf, short length)
1017 struct eepro_local *lp = (struct eepro_local *)dev->priv;
1018 short ioaddr = dev->base_addr;
1019 int rcv_ram = dev->mem_end;
1020 unsigned status, tx_available, last, end, boguscount = 100;
1022 if (net_debug > 5)
1023 printk("eepro: entering hardware_send_packet routine.\n");
1025 while (boguscount-- > 0) {
1027 /* Disable RX and TX interrupts. Necessary to avoid
1028 corruption of the HOST_ADDRESS_REG by interrupt
1029 service routines. */
1030 outb(ALL_MASK, ioaddr + INT_MASK_REG);
1032 if (dev->interrupt == 1) {
1033 /* Enable RX and TX interrupts */
1034 outb(ALL_MASK & ~(RX_MASK | TX_MASK), ioaddr + INT_MASK_REG);
1035 continue;
1038 /* determine how much of the transmit buffer space is available */
1039 if (lp->tx_end > lp->tx_start)
1040 tx_available = XMT_RAM - (lp->tx_end - lp->tx_start);
1041 else if (lp->tx_end < lp->tx_start)
1042 tx_available = lp->tx_start - lp->tx_end;
1043 else tx_available = XMT_RAM;
1045 if (((((length + 3) >> 1) << 1) + 2*XMT_HEADER)
1046 >= tx_available) /* No space available ??? */
1048 eepro_transmit_interrupt(dev); /* Clean up the transmiting queue */
1050 /* Enable RX and TX interrupts */
1051 outb(ALL_MASK & ~(RX_MASK | TX_MASK), ioaddr + INT_MASK_REG);
1052 continue;
1055 last = lp->tx_end;
1056 end = last + (((length + 3) >> 1) << 1) + XMT_HEADER;
1058 if (end >= RAM_SIZE) { /* the transmit buffer is wrapped around */
1059 if ((RAM_SIZE - last) <= XMT_HEADER) {
1060 /* Arrrr!!!, must keep the xmt header together,
1061 several days were lost to chase this one down. */
1062 last = rcv_ram;
1063 end = last + (((length + 3) >> 1) << 1) + XMT_HEADER;
1065 else end = rcv_ram + (end - RAM_SIZE);
1068 outw(last, ioaddr + HOST_ADDRESS_REG);
1069 outw(XMT_CMD, ioaddr + IO_PORT);
1070 outw(0, ioaddr + IO_PORT);
1071 outw(end, ioaddr + IO_PORT);
1072 outw(length, ioaddr + IO_PORT);
1074 if (lp->version == LAN595)
1075 outsw(ioaddr + IO_PORT, buf, (length + 3) >> 1);
1076 else { /* LAN595TX or LAN595FX, capable of 32-bit I/O processing */
1077 unsigned short temp = inb(ioaddr + INT_MASK_REG);
1078 outb(temp | IO_32_BIT, ioaddr + INT_MASK_REG);
1079 outsl(ioaddr + IO_PORT_32_BIT, buf, (length + 3) >> 2);
1080 outb(temp & ~(IO_32_BIT), ioaddr + INT_MASK_REG);
1083 /* A dummy read to flush the DRAM write pipeline */
1084 status = inw(ioaddr + IO_PORT);
1086 if (lp->tx_start == lp->tx_end) {
1087 outw(last, ioaddr + XMT_BAR);
1088 outb(XMT_CMD, ioaddr);
1089 lp->tx_start = last; /* I don't like to change tx_start here */
1091 else {
1092 /* update the next address and the chain bit in the
1093 last packet */
1094 if (lp->tx_end != last) {
1095 outw(lp->tx_last + XMT_CHAIN, ioaddr + HOST_ADDRESS_REG);
1096 outw(last, ioaddr + IO_PORT);
1098 outw(lp->tx_last + XMT_COUNT, ioaddr + HOST_ADDRESS_REG);
1099 status = inw(ioaddr + IO_PORT);
1100 outw(status | CHAIN_BIT, ioaddr + IO_PORT);
1102 /* Continue the transmit command */
1103 outb(RESUME_XMT_CMD, ioaddr);
1106 lp->tx_last = last;
1107 lp->tx_end = end;
1109 /* Enable RX and TX interrupts */
1110 outb(ALL_MASK & ~(RX_MASK | TX_MASK), ioaddr + INT_MASK_REG);
1112 if (dev->tbusy) {
1113 dev->tbusy = 0;
1116 if (net_debug > 5)
1117 printk("eepro: exiting hardware_send_packet routine.\n");
1118 return;
1121 dev->tbusy = 1;
1122 if (net_debug > 5)
1123 printk("eepro: exiting hardware_send_packet routine.\n");
1126 static void
1127 eepro_rx(struct device *dev)
1129 struct eepro_local *lp = (struct eepro_local *)dev->priv;
1130 short ioaddr = dev->base_addr, rcv_ram = dev->mem_end;
1131 short boguscount = 20;
1132 short rcv_car = lp->rx_start;
1133 unsigned rcv_event, rcv_status, rcv_next_frame, rcv_size;
1135 if (net_debug > 5)
1136 printk("eepro: entering eepro_rx routine.\n");
1138 /* Set the read pointer to the start of the RCV */
1139 outw(rcv_car, ioaddr + HOST_ADDRESS_REG);
1140 rcv_event = inw(ioaddr + IO_PORT);
1142 while (rcv_event == RCV_DONE) {
1143 rcv_status = inw(ioaddr + IO_PORT);
1144 rcv_next_frame = inw(ioaddr + IO_PORT);
1145 rcv_size = inw(ioaddr + IO_PORT);
1147 if ((rcv_status & (RX_OK | RX_ERROR)) == RX_OK) {
1148 /* Malloc up new buffer. */
1149 struct sk_buff *skb;
1151 rcv_size &= 0x3fff;
1152 skb = dev_alloc_skb(rcv_size+5);
1153 if (skb == NULL) {
1154 printk("%s: Memory squeeze, dropping packet.\n", dev->name);
1155 lp->stats.rx_dropped++;
1156 break;
1158 skb->dev = dev;
1159 skb_reserve(skb,2);
1161 if (lp->version == LAN595)
1162 insw(ioaddr+IO_PORT, skb_put(skb,rcv_size), (rcv_size + 3) >> 1);
1163 else { /* LAN595TX or LAN595FX, capable of 32-bit I/O processing */
1164 unsigned short temp = inb(ioaddr + INT_MASK_REG);
1165 outb(temp | IO_32_BIT, ioaddr + INT_MASK_REG);
1166 insl(ioaddr+IO_PORT_32_BIT, skb_put(skb,rcv_size), (rcv_size + 3) >> 2);
1167 outb(temp & ~(IO_32_BIT), ioaddr + INT_MASK_REG);
1171 skb->protocol = eth_type_trans(skb,dev);
1172 netif_rx(skb);
1173 lp->stats.rx_packets++;
1175 else { /* Not sure will ever reach here,
1176 I set the 595 to discard bad received frames */
1177 lp->stats.rx_errors++;
1178 if (rcv_status & 0x0100)
1179 lp->stats.rx_over_errors++;
1180 else if (rcv_status & 0x0400)
1181 lp->stats.rx_frame_errors++;
1182 else if (rcv_status & 0x0800)
1183 lp->stats.rx_crc_errors++;
1184 printk("%s: event = %#x, status = %#x, next = %#x, size = %#x\n",
1185 dev->name, rcv_event, rcv_status, rcv_next_frame, rcv_size);
1187 if (rcv_status & 0x1000)
1188 lp->stats.rx_length_errors++;
1189 if (--boguscount == 0)
1190 break;
1192 rcv_car = lp->rx_start + RCV_HEADER + rcv_size;
1193 lp->rx_start = rcv_next_frame;
1194 outw(rcv_next_frame, ioaddr + HOST_ADDRESS_REG);
1195 rcv_event = inw(ioaddr + IO_PORT);
1198 if (rcv_car == 0)
1199 rcv_car = (RCV_UPPER_LIMIT << 8) | 0xff;
1200 outw(rcv_car - 1, ioaddr + RCV_STOP);
1202 if (net_debug > 5)
1203 printk("eepro: exiting eepro_rx routine.\n");
1206 static void
1207 eepro_transmit_interrupt(struct device *dev)
1209 struct eepro_local *lp = (struct eepro_local *)dev->priv;
1210 short ioaddr = dev->base_addr;
1211 short boguscount = 20;
1212 short xmt_status;
1214 while (lp->tx_start != lp->tx_end) {
1216 outw(lp->tx_start, ioaddr + HOST_ADDRESS_REG);
1217 xmt_status = inw(ioaddr+IO_PORT);
1218 if ((xmt_status & TX_DONE_BIT) == 0) break;
1220 xmt_status = inw(ioaddr+IO_PORT);
1221 lp->tx_start = inw(ioaddr+IO_PORT);
1223 dev->tbusy = 0;
1224 mark_bh(NET_BH);
1226 if (xmt_status & 0x2000)
1227 lp->stats.tx_packets++;
1228 else {
1229 lp->stats.tx_errors++;
1230 if (xmt_status & 0x0400)
1231 lp->stats.tx_carrier_errors++;
1232 printk("%s: XMT status = %#x\n",
1233 dev->name, xmt_status);
1235 if (xmt_status & 0x000f) {
1236 lp->stats.collisions += (xmt_status & 0x000f);
1238 if ((xmt_status & 0x0040) == 0x0) {
1239 lp->stats.tx_heartbeat_errors++;
1242 if (--boguscount == 0)
1243 break;
1247 #ifdef MODULE
1248 static char devicename[9] = { 0, };
1249 static struct device dev_eepro = {
1250 devicename, /* device name is inserted by linux/drivers/net/net_init.c */
1251 0, 0, 0, 0,
1252 0, 0,
1253 0, 0, 0, NULL, eepro_probe };
1255 static int io = 0x200;
1256 static int irq = 0;
1257 static int mem = (RCV_RAM/1024); /* Size of the rx buffer in KB */
1259 MODULE_PARM(io, "i");
1260 MODULE_PARM(irq, "i");
1261 MODULE_PARM(mem, "i");
1264 init_module(void)
1266 if (io == 0)
1267 printk("eepro: You should not use auto-probing with insmod!\n");
1268 dev_eepro.base_addr = io;
1269 dev_eepro.irq = irq;
1270 dev_eepro.mem_end = mem;
1272 if (register_netdev(&dev_eepro) != 0)
1273 return -EIO;
1274 return 0;
1277 void
1278 cleanup_module(void)
1280 unregister_netdev(&dev_eepro);
1281 kfree_s(dev_eepro.priv,sizeof(struct eepro_local));
1282 dev_eepro.priv=NULL;
1284 /* If we don't do this, we can't re-insmod it later. */
1285 release_region(dev_eepro.base_addr, EEPRO_IO_EXTENT);
1287 #endif /* MODULE */