1 /* ne2.c: A NE/2 Ethernet Driver for Linux. */
3 Based on the NE2000 driver written by Donald Becker (1992-94).
4 modified by Wim Dumon (Apr 1996)
6 This software may be used and distributed according to the terms
7 of the GNU General Public License, incorporated herein by reference.
9 The author may be reached as wimpie@linux.cc.kuleuven.ac.be
11 Currently supported: NE/2
12 This patch was never tested on other MCA-ethernet adapters, but it
13 might work. Just give it a try and let me know if you have problems.
14 Also mail me if it really works, please!
17 Mon Feb 3 16:26:02 MET 1997
18 - adapted the driver to work with the 2.1.25 kernel
19 - multiple ne2 support (untested)
20 - module support (untested)
22 Fri Aug 28 00:18:36 CET 1998 (David Weinehall)
23 - fixed a few minor typos
24 - made the MODULE_PARM conditional (it only works with the v2.1.x kernels)
25 - fixed the module support (Now it's working...)
27 Mon Sep 7 19:01:44 CET 1998 (David Weinehall)
28 - added support for Arco Electronics AE/2-card (experimental)
30 Mon Sep 14 09:53:42 CET 1998 (David Weinehall)
31 - added support for Compex ENET-16MC/P (experimental)
33 Tue Sep 15 16:21:12 CET 1998 (David Weinehall, Magnus Jonsson, Tomas Ogren)
34 - Miscellaneous bugfixes
36 Tue Sep 19 16:21:12 CET 1998 (Magnus Jonsson)
39 Wed Sep 23 14:33:34 CET 1998 (David Weinehall)
40 - Restructuring and rewriting for v2.1.x compliance
42 Wed Oct 14 17:19:21 CET 1998 (David Weinehall)
43 - Added code that unregisters irq and proc-info
46 Mon Nov 16 15:28:23 CET 1998 (Wim Dumon)
47 - pass 'dev' as last parameter of request_irq in stead of 'NULL'
49 Wed Feb 7 21:24:00 CET 2001 (Alfred Arnold)
50 - added support for the D-Link DE-320CT
54 This is alpha-test software. It is not guaranteed to work. As a
55 matter of fact, I'm quite sure there are *LOTS* of bugs in here. I
56 would like to hear from you if you use this driver, even if it works.
57 If it doesn't work, be sure to send me a mail with the problems !
60 static const char *version
= "ne2.c:v0.91 Nov 16 1998 Wim Dumon <wimpie@kotnet.org>\n";
62 #include <linux/module.h>
63 #include <linux/kernel.h>
64 #include <linux/types.h>
65 #include <linux/fcntl.h>
66 #include <linux/interrupt.h>
67 #include <linux/ioport.h>
69 #include <linux/slab.h>
70 #include <linux/string.h>
71 #include <linux/errno.h>
72 #include <linux/init.h>
73 #include <linux/mca-legacy.h>
74 #include <linux/netdevice.h>
75 #include <linux/etherdevice.h>
76 #include <linux/skbuff.h>
77 #include <linux/bitops.h>
78 #include <linux/jiffies.h>
80 #include <asm/system.h>
86 #define DRV_NAME "ne2"
88 /* Some defines that people can play with if so inclined. */
90 /* Do we perform extra sanity checks on stuff ? */
91 /* #define NE_SANITY_CHECK */
93 /* Do we implement the read before write bugfix ? */
94 /* #define NE_RW_BUGFIX */
96 /* Do we have a non std. amount of memory? (in units of 256 byte pages) */
97 /* #define PACKETBUF_MEMSIZE 0x40 */
100 /* ---- No user-serviceable parts below ---- */
102 #define NE_BASE (dev->base_addr)
104 #define NE_DATAPORT 0x10 /* NatSemi-defined port window offset. */
105 #define NE_RESET 0x20 /* Issue a read to reset, a write to clear. */
106 #define NE_IO_EXTENT 0x30
108 #define NE1SM_START_PG 0x20 /* First page of TX buffer */
109 #define NE1SM_STOP_PG 0x40 /* Last page +1 of RX ring */
110 #define NESM_START_PG 0x40 /* First page of TX buffer */
111 #define NESM_STOP_PG 0x80 /* Last page +1 of RX ring */
113 /* From the .ADF file: */
114 static unsigned int addresses
[7] __initdata
=
115 {0x1000, 0x2020, 0x8020, 0xa0a0, 0xb0b0, 0xc0c0, 0xc3d0};
116 static int irqs
[4] __initdata
= {3, 4, 5, 9};
118 /* From the D-Link ADF file: */
119 static unsigned int dlink_addresses
[4] __initdata
=
120 {0x300, 0x320, 0x340, 0x360};
121 static int dlink_irqs
[8] __initdata
= {3, 4, 5, 9, 10, 11, 14, 15};
123 struct ne2_adapters_t
{
128 static struct ne2_adapters_t ne2_adapters
[] __initdata
= {
129 { 0x6354, "Arco Ethernet Adapter AE/2" },
130 { 0x70DE, "Compex ENET-16 MC/P" },
131 { 0x7154, "Novell Ethernet Adapter NE/2" },
132 { 0x56ea, "D-Link DE-320CT" },
136 extern int netcard_probe(struct net_device
*dev
);
138 static int ne2_probe1(struct net_device
*dev
, int slot
);
140 static int ne_open(struct net_device
*dev
);
141 static int ne_close(struct net_device
*dev
);
143 static void ne_reset_8390(struct net_device
*dev
);
144 static void ne_get_8390_hdr(struct net_device
*dev
, struct e8390_pkt_hdr
*hdr
,
146 static void ne_block_input(struct net_device
*dev
, int count
,
147 struct sk_buff
*skb
, int ring_offset
);
148 static void ne_block_output(struct net_device
*dev
, const int count
,
149 const unsigned char *buf
, const int start_page
);
153 * special code to read the DE-320's MAC address EEPROM. In contrast to a
154 * standard NE design, this is a serial EEPROM (93C46) that has to be read
155 * bit by bit. The EEPROM cotrol port at base + 0x1e has the following
158 * Bit 0 = Data out (read from EEPROM)
159 * Bit 1 = Data in (write to EEPROM)
161 * Bit 3 = Chip Select
162 * Bit 7 = ~50 kHz clock for defined delays
166 static void __init
dlink_put_eeprom(unsigned char value
, unsigned int addr
)
169 unsigned char v1
, v2
;
171 /* write the value to the NIC EEPROM register */
173 outb(value
, addr
+ 0x1e);
175 /* now wait the clock line to toggle twice. Effectively, we are
176 waiting (at least) for one clock cycle */
178 for (z
= 0; z
< 2; z
++) {
180 v1
= inb(addr
+ 0x1e);
181 v2
= inb(addr
+ 0x1e);
183 while (!((v1
^ v2
) & 0x80));
187 static void __init
dlink_send_eeprom_bit(unsigned int bit
, unsigned int addr
)
189 /* shift data bit into correct position */
193 /* write value, keep clock line high for two cycles */
195 dlink_put_eeprom(0x09 | bit
, addr
);
196 dlink_put_eeprom(0x0d | bit
, addr
);
197 dlink_put_eeprom(0x0d | bit
, addr
);
198 dlink_put_eeprom(0x09 | bit
, addr
);
201 static void __init
dlink_send_eeprom_word(unsigned int value
, unsigned int len
, unsigned int addr
)
205 /* adjust bits so that they are left-aligned in a 16-bit-word */
207 value
= value
<< (16 - len
);
209 /* shift bits out to the EEPROM */
211 for (z
= 0; z
< len
; z
++) {
212 dlink_send_eeprom_bit((value
& 0x8000) >> 15, addr
);
217 static unsigned int __init
dlink_get_eeprom(unsigned int eeaddr
, unsigned int addr
)
220 unsigned int value
= 0;
222 /* pull the CS line low for a moment. This resets the EEPROM-
223 internal logic, and makes it ready for a new command. */
225 dlink_put_eeprom(0x01, addr
);
226 dlink_put_eeprom(0x09, addr
);
228 /* send one start bit, read command (1 - 0), plus the address to
231 dlink_send_eeprom_word(0x0180 | (eeaddr
& 0x3f), 9, addr
);
233 /* get the data word. We clock by sending 0s to the EEPROM, which
234 get ignored during the read process */
236 for (z
= 0; z
< 16; z
++) {
237 dlink_send_eeprom_bit(0, addr
);
238 value
= (value
<< 1) | (inb(addr
+ 0x1e) & 0x01);
245 * Note that at boot, this probe only picks up one card at a time.
248 static int __init
do_ne2_probe(struct net_device
*dev
)
250 static int current_mca_slot
= -1;
252 int adapter_found
= 0;
254 /* Do not check any supplied i/o locations.
255 POS registers usually don't fail :) */
257 /* MCA cards have POS registers.
258 Autodetecting MCA cards is extremely simple.
259 Just search for the card. */
261 for(i
= 0; (ne2_adapters
[i
].name
!= NULL
) && !adapter_found
; i
++) {
263 mca_find_unused_adapter(ne2_adapters
[i
].id
, 0);
265 if((current_mca_slot
!= MCA_NOTFOUND
) && !adapter_found
) {
267 mca_set_adapter_name(current_mca_slot
,
268 ne2_adapters
[i
].name
);
269 mca_mark_as_used(current_mca_slot
);
271 res
= ne2_probe1(dev
, current_mca_slot
);
273 mca_mark_as_unused(current_mca_slot
);
281 struct net_device
* __init
ne2_probe(int unit
)
283 struct net_device
*dev
= alloc_ei_netdev();
287 return ERR_PTR(-ENOMEM
);
289 sprintf(dev
->name
, "eth%d", unit
);
290 netdev_boot_setup_check(dev
);
292 err
= do_ne2_probe(dev
);
302 static int ne2_procinfo(char *buf
, int slot
, struct net_device
*dev
)
305 DECLARE_MAC_BUF(mac
);
307 len
+= sprintf(buf
+len
, "The NE/2 Ethernet Adapter\n" );
308 len
+= sprintf(buf
+len
, "Driver written by Wim Dumon ");
309 len
+= sprintf(buf
+len
, "<wimpie@kotnet.org>\n");
310 len
+= sprintf(buf
+len
, "Modified by ");
311 len
+= sprintf(buf
+len
, "David Weinehall <tao@acc.umu.se>\n");
312 len
+= sprintf(buf
+len
, "and by Magnus Jonsson <bigfoot@acc.umu.se>\n");
313 len
+= sprintf(buf
+len
, "Based on the original NE2000 drivers\n" );
314 len
+= sprintf(buf
+len
, "Base IO: %#x\n", (unsigned int)dev
->base_addr
);
315 len
+= sprintf(buf
+len
, "IRQ : %d\n", dev
->irq
);
316 len
+= sprintf(buf
+len
, "HW addr : %s\n", print_mac(mac
, dev
->dev_addr
));
321 static int __init
ne2_probe1(struct net_device
*dev
, int slot
)
323 int i
, base_addr
, irq
, retval
;
325 unsigned char SA_prom
[32];
326 const char *name
= "NE/2";
327 int start_page
, stop_page
;
328 static unsigned version_printed
;
329 DECLARE_MAC_BUF(mac
);
331 if (ei_debug
&& version_printed
++ == 0)
334 printk("NE/2 ethercard found in slot %d:", slot
);
336 /* Read base IO and IRQ from the POS-registers */
337 POS
= mca_read_stored_pos(slot
, 2);
339 printk(" disabled.\n");
343 /* handle different POS register structure for D-Link card */
345 if (mca_read_stored_pos(slot
, 0) == 0xea) {
346 base_addr
= dlink_addresses
[(POS
>> 5) & 0x03];
347 irq
= dlink_irqs
[(POS
>> 2) & 0x07];
351 /* printk("Halleluja sdog, als er na de pijl een 1 staat is 1 - 1 == 0"
352 " en zou het moeten werken -> %d\n", i);
353 The above line was for remote testing, thanx to sdog ... */
354 base_addr
= addresses
[i
- 1];
355 irq
= irqs
[(POS
& 0x60)>>5];
358 if (!request_region(base_addr
, NE_IO_EXTENT
, DRV_NAME
))
362 printk("POS info : pos 2 = %#x ; base = %#x ; irq = %ld\n", POS
,
367 /* Reset the card the way they do it in the Crynwr packet driver */
369 outb(0x0, base_addr
+ NE_RESET
);
370 inb(base_addr
+ NE_RESET
);
371 outb(0x21, base_addr
+ NE_CMD
);
372 if (inb(base_addr
+ NE_CMD
) != 0x21) {
373 printk("NE/2 adapter not responding\n");
378 /* In the crynwr sources they do a RAM-test here. I skip it. I suppose
379 my RAM is okay. Suppose your memory is broken. Then this test
380 should fail and you won't be able to use your card. But if I do not
381 test, you won't be able to use your card, neither. So this test
384 #else /* _I_ never tested it this way .. Go ahead and try ...*/
385 /* Reset card. Who knows what dain-bramaged state it was left in. */
387 unsigned long reset_start_time
= jiffies
;
389 /* DON'T change these to inb_p/outb_p or reset will fail on
391 outb(inb(base_addr
+ NE_RESET
), base_addr
+ NE_RESET
);
393 while ((inb_p(base_addr
+ EN0_ISR
) & ENISR_RESET
) == 0)
394 if (time_after(jiffies
, reset_start_time
+ 2*HZ
/100)) {
395 printk(" not found (no reset ack).\n");
400 outb_p(0xff, base_addr
+ EN0_ISR
); /* Ack all intr. */
405 /* Read the 16 bytes of station address PROM.
406 We must first initialize registers, similar to
407 NS8390_init(eifdev, 0).
408 We can't reliably read the SAPROM address without this.
409 (I learned the hard way!). */
412 unsigned char value
, offset
;
415 {E8390_NODMA
+E8390_PAGE0
+E8390_STOP
, E8390_CMD
},
416 {0x49, EN0_DCFG
}, /* Set WORD-wide (0x49) access. */
417 {0x00, EN0_RCNTLO
}, /* Clear the count regs. */
419 {0x00, EN0_IMR
}, /* Mask completion irq. */
421 {E8390_RXOFF
, EN0_RXCR
}, /* 0x20 Set to monitor */
422 {E8390_TXOFF
, EN0_TXCR
}, /* 0x02 and loopback mode. */
425 {0x00, EN0_RSARLO
}, /* DMA starting at 0x0000. */
427 {E8390_RREAD
+E8390_START
, E8390_CMD
},
430 for (i
= 0; i
< ARRAY_SIZE(program_seq
); i
++)
431 outb_p(program_seq
[i
].value
, base_addr
+
432 program_seq
[i
].offset
);
435 for(i
= 0; i
< 6 /*sizeof(SA_prom)*/; i
+=1) {
436 SA_prom
[i
] = inb(base_addr
+ NE_DATAPORT
);
439 /* I don't know whether the previous sequence includes the general
440 board reset procedure, so better don't omit it and just overwrite
441 the garbage read from a DE-320 with correct stuff. */
443 if (mca_read_stored_pos(slot
, 0) == 0xea) {
446 for (i
= 0; i
< 3; i
++) {
447 v
= dlink_get_eeprom(i
, base_addr
);
448 SA_prom
[(i
<< 1) ] = v
& 0xff;
449 SA_prom
[(i
<< 1) + 1] = (v
>> 8) & 0xff;
453 start_page
= NESM_START_PG
;
454 stop_page
= NESM_STOP_PG
;
458 /* Snarf the interrupt now. There's no point in waiting since we cannot
459 share and the board will usually be enabled. */
460 retval
= request_irq(dev
->irq
, ei_interrupt
, 0, DRV_NAME
, dev
);
462 printk (" unable to get IRQ %d (irqval=%d).\n",
467 dev
->base_addr
= base_addr
;
469 for(i
= 0; i
< ETHER_ADDR_LEN
; i
++)
470 dev
->dev_addr
[i
] = SA_prom
[i
];
472 printk(" %s\n", print_mac(mac
, dev
->dev_addr
));
474 printk("%s: %s found at %#x, using IRQ %d.\n",
475 dev
->name
, name
, base_addr
, dev
->irq
);
477 mca_set_adapter_procfn(slot
, (MCA_ProcFn
) ne2_procinfo
, dev
);
479 ei_status
.name
= name
;
480 ei_status
.tx_start_page
= start_page
;
481 ei_status
.stop_page
= stop_page
;
482 ei_status
.word16
= (2 == 2);
484 ei_status
.rx_start_page
= start_page
+ TX_PAGES
;
485 #ifdef PACKETBUF_MEMSIZE
486 /* Allow the packet buffer size to be overridden by know-it-alls. */
487 ei_status
.stop_page
= ei_status
.tx_start_page
+ PACKETBUF_MEMSIZE
;
490 ei_status
.reset_8390
= &ne_reset_8390
;
491 ei_status
.block_input
= &ne_block_input
;
492 ei_status
.block_output
= &ne_block_output
;
493 ei_status
.get_8390_hdr
= &ne_get_8390_hdr
;
495 ei_status
.priv
= slot
;
497 dev
->open
= &ne_open
;
498 dev
->stop
= &ne_close
;
499 #ifdef CONFIG_NET_POLL_CONTROLLER
500 dev
->poll_controller
= ei_poll
;
504 retval
= register_netdev(dev
);
509 mca_set_adapter_procfn( ei_status
.priv
, NULL
, NULL
);
510 free_irq(dev
->irq
, dev
);
512 release_region(base_addr
, NE_IO_EXTENT
);
516 static int ne_open(struct net_device
*dev
)
522 static int ne_close(struct net_device
*dev
)
525 printk("%s: Shutting down ethercard.\n", dev
->name
);
530 /* Hard reset the card. This used to pause for the same period that a
531 8390 reset command required, but that shouldn't be necessary. */
532 static void ne_reset_8390(struct net_device
*dev
)
534 unsigned long reset_start_time
= jiffies
;
537 printk("resetting the 8390 t=%ld...", jiffies
);
539 /* DON'T change these to inb_p/outb_p or reset will fail on clones. */
540 outb(inb(NE_BASE
+ NE_RESET
), NE_BASE
+ NE_RESET
);
543 ei_status
.dmaing
= 0;
545 /* This check _should_not_ be necessary, omit eventually. */
546 while ((inb_p(NE_BASE
+EN0_ISR
) & ENISR_RESET
) == 0)
547 if (time_after(jiffies
, reset_start_time
+ 2*HZ
/100)) {
548 printk("%s: ne_reset_8390() did not complete.\n",
552 outb_p(ENISR_RESET
, NE_BASE
+ EN0_ISR
); /* Ack intr. */
555 /* Grab the 8390 specific header. Similar to the block_input routine, but
556 we don't need to be concerned with ring wrap as the header will be at
557 the start of a page, so we optimize accordingly. */
559 static void ne_get_8390_hdr(struct net_device
*dev
, struct e8390_pkt_hdr
*hdr
,
563 int nic_base
= dev
->base_addr
;
565 /* This *shouldn't* happen.
566 If it does, it's the last thing you'll see */
567 if (ei_status
.dmaing
) {
568 printk("%s: DMAing conflict in ne_get_8390_hdr "
569 "[DMAstat:%d][irqlock:%d].\n",
570 dev
->name
, ei_status
.dmaing
, ei_status
.irqlock
);
574 ei_status
.dmaing
|= 0x01;
575 outb_p(E8390_NODMA
+E8390_PAGE0
+E8390_START
, nic_base
+ NE_CMD
);
576 outb_p(sizeof(struct e8390_pkt_hdr
), nic_base
+ EN0_RCNTLO
);
577 outb_p(0, nic_base
+ EN0_RCNTHI
);
578 outb_p(0, nic_base
+ EN0_RSARLO
); /* On page boundary */
579 outb_p(ring_page
, nic_base
+ EN0_RSARHI
);
580 outb_p(E8390_RREAD
+E8390_START
, nic_base
+ NE_CMD
);
582 if (ei_status
.word16
)
583 insw(NE_BASE
+ NE_DATAPORT
, hdr
,
584 sizeof(struct e8390_pkt_hdr
)>>1);
586 insb(NE_BASE
+ NE_DATAPORT
, hdr
,
587 sizeof(struct e8390_pkt_hdr
));
589 outb_p(ENISR_RDC
, nic_base
+ EN0_ISR
); /* Ack intr. */
590 ei_status
.dmaing
&= ~0x01;
593 /* Block input and output, similar to the Crynwr packet driver. If you
594 are porting to a new ethercard, look at the packet driver source for
595 hints. The NEx000 doesn't share the on-board packet memory -- you have
596 to put the packet out through the "remote DMA" dataport using outb. */
598 static void ne_block_input(struct net_device
*dev
, int count
, struct sk_buff
*skb
,
601 #ifdef NE_SANITY_CHECK
602 int xfer_count
= count
;
604 int nic_base
= dev
->base_addr
;
605 char *buf
= skb
->data
;
607 /* This *shouldn't* happen.
608 If it does, it's the last thing you'll see */
609 if (ei_status
.dmaing
) {
610 printk("%s: DMAing conflict in ne_block_input "
611 "[DMAstat:%d][irqlock:%d].\n",
612 dev
->name
, ei_status
.dmaing
, ei_status
.irqlock
);
615 ei_status
.dmaing
|= 0x01;
616 outb_p(E8390_NODMA
+E8390_PAGE0
+E8390_START
, nic_base
+ NE_CMD
);
617 outb_p(count
& 0xff, nic_base
+ EN0_RCNTLO
);
618 outb_p(count
>> 8, nic_base
+ EN0_RCNTHI
);
619 outb_p(ring_offset
& 0xff, nic_base
+ EN0_RSARLO
);
620 outb_p(ring_offset
>> 8, nic_base
+ EN0_RSARHI
);
621 outb_p(E8390_RREAD
+E8390_START
, nic_base
+ NE_CMD
);
622 if (ei_status
.word16
) {
623 insw(NE_BASE
+ NE_DATAPORT
,buf
,count
>>1);
625 buf
[count
-1] = inb(NE_BASE
+ NE_DATAPORT
);
626 #ifdef NE_SANITY_CHECK
631 insb(NE_BASE
+ NE_DATAPORT
, buf
, count
);
634 #ifdef NE_SANITY_CHECK
635 /* This was for the ALPHA version only, but enough people have
636 been encountering problems so it is still here. If you see
637 this message you either 1) have a slightly incompatible clone
638 or 2) have noise/speed problems with your bus. */
639 if (ei_debug
> 1) { /* DMA termination address check... */
640 int addr
, tries
= 20;
642 /* DON'T check for 'inb_p(EN0_ISR) & ENISR_RDC' here
643 -- it's broken for Rx on some cards! */
644 int high
= inb_p(nic_base
+ EN0_RSARHI
);
645 int low
= inb_p(nic_base
+ EN0_RSARLO
);
646 addr
= (high
<< 8) + low
;
647 if (((ring_offset
+ xfer_count
) & 0xff) == low
)
649 } while (--tries
> 0);
651 printk("%s: RX transfer address mismatch,"
652 "%#4.4x (expected) vs. %#4.4x (actual).\n",
653 dev
->name
, ring_offset
+ xfer_count
, addr
);
656 outb_p(ENISR_RDC
, nic_base
+ EN0_ISR
); /* Ack intr. */
657 ei_status
.dmaing
&= ~0x01;
660 static void ne_block_output(struct net_device
*dev
, int count
,
661 const unsigned char *buf
, const int start_page
)
663 int nic_base
= NE_BASE
;
664 unsigned long dma_start
;
665 #ifdef NE_SANITY_CHECK
669 /* Round the count up for word writes. Do we need to do this?
670 What effect will an odd byte count have on the 8390?
671 I should check someday. */
672 if (ei_status
.word16
&& (count
& 0x01))
675 /* This *shouldn't* happen.
676 If it does, it's the last thing you'll see */
677 if (ei_status
.dmaing
) {
678 printk("%s: DMAing conflict in ne_block_output."
679 "[DMAstat:%d][irqlock:%d]\n",
680 dev
->name
, ei_status
.dmaing
, ei_status
.irqlock
);
683 ei_status
.dmaing
|= 0x01;
684 /* We should already be in page 0, but to be safe... */
685 outb_p(E8390_PAGE0
+E8390_START
+E8390_NODMA
, nic_base
+ NE_CMD
);
687 #ifdef NE_SANITY_CHECK
691 #ifdef NE8390_RW_BUGFIX
692 /* Handle the read-before-write bug the same way as the
693 Crynwr packet driver -- the NatSemi method doesn't work.
694 Actually this doesn't always work either, but if you have
695 problems with your NEx000 this is better than nothing! */
696 outb_p(0x42, nic_base
+ EN0_RCNTLO
);
697 outb_p(0x00, nic_base
+ EN0_RCNTHI
);
698 outb_p(0x42, nic_base
+ EN0_RSARLO
);
699 outb_p(0x00, nic_base
+ EN0_RSARHI
);
700 outb_p(E8390_RREAD
+E8390_START
, nic_base
+ NE_CMD
);
701 /* Make certain that the dummy read has occurred. */
707 outb_p(ENISR_RDC
, nic_base
+ EN0_ISR
);
709 /* Now the normal output. */
710 outb_p(count
& 0xff, nic_base
+ EN0_RCNTLO
);
711 outb_p(count
>> 8, nic_base
+ EN0_RCNTHI
);
712 outb_p(0x00, nic_base
+ EN0_RSARLO
);
713 outb_p(start_page
, nic_base
+ EN0_RSARHI
);
715 outb_p(E8390_RWRITE
+E8390_START
, nic_base
+ NE_CMD
);
716 if (ei_status
.word16
) {
717 outsw(NE_BASE
+ NE_DATAPORT
, buf
, count
>>1);
719 outsb(NE_BASE
+ NE_DATAPORT
, buf
, count
);
724 #ifdef NE_SANITY_CHECK
725 /* This was for the ALPHA version only, but enough people have
726 been encountering problems so it is still here. */
728 if (ei_debug
> 1) { /* DMA termination address check... */
729 int addr
, tries
= 20;
731 int high
= inb_p(nic_base
+ EN0_RSARHI
);
732 int low
= inb_p(nic_base
+ EN0_RSARLO
);
733 addr
= (high
<< 8) + low
;
734 if ((start_page
<< 8) + count
== addr
)
736 } while (--tries
> 0);
738 printk("%s: Tx packet transfer address mismatch,"
739 "%#4.4x (expected) vs. %#4.4x (actual).\n",
740 dev
->name
, (start_page
<< 8) + count
, addr
);
747 while ((inb_p(nic_base
+ EN0_ISR
) & ENISR_RDC
) == 0)
748 if (time_after(jiffies
, dma_start
+ 2*HZ
/100)) { /* 20ms */
749 printk("%s: timeout waiting for Tx RDC.\n", dev
->name
);
755 outb_p(ENISR_RDC
, nic_base
+ EN0_ISR
); /* Ack intr. */
756 ei_status
.dmaing
&= ~0x01;
762 #define MAX_NE_CARDS 4 /* Max number of NE cards per module */
763 static struct net_device
*dev_ne
[MAX_NE_CARDS
];
764 static int io
[MAX_NE_CARDS
];
765 static int irq
[MAX_NE_CARDS
];
766 static int bad
[MAX_NE_CARDS
]; /* 0xbad = bad sig or no reset ack */
767 MODULE_LICENSE("GPL");
769 module_param_array(io
, int, NULL
, 0);
770 module_param_array(irq
, int, NULL
, 0);
771 module_param_array(bad
, int, NULL
, 0);
772 MODULE_PARM_DESC(io
, "(ignored)");
773 MODULE_PARM_DESC(irq
, "(ignored)");
774 MODULE_PARM_DESC(bad
, "(ignored)");
776 /* Module code fixed by David Weinehall */
778 int __init
init_module(void)
780 struct net_device
*dev
;
781 int this_dev
, found
= 0;
783 for (this_dev
= 0; this_dev
< MAX_NE_CARDS
; this_dev
++) {
784 dev
= alloc_ei_netdev();
787 dev
->irq
= irq
[this_dev
];
788 dev
->mem_end
= bad
[this_dev
];
789 dev
->base_addr
= io
[this_dev
];
790 if (do_ne2_probe(dev
) == 0) {
791 dev_ne
[found
++] = dev
;
799 printk(KERN_WARNING
"ne2.c: No NE/2 card found\n");
803 static void cleanup_card(struct net_device
*dev
)
805 mca_mark_as_unused(ei_status
.priv
);
806 mca_set_adapter_procfn( ei_status
.priv
, NULL
, NULL
);
807 free_irq(dev
->irq
, dev
);
808 release_region(dev
->base_addr
, NE_IO_EXTENT
);
811 void __exit
cleanup_module(void)
815 for (this_dev
= 0; this_dev
< MAX_NE_CARDS
; this_dev
++) {
816 struct net_device
*dev
= dev_ne
[this_dev
];
818 unregister_netdev(dev
);