1 /* eth16i.c An ICL EtherTeam 16i and 32 EISA ethernet driver for Linux
3 Written 1994-1998 by Mika Kuoppala
5 Copyright (C) 1994-1998 by Mika Kuoppala
6 Based on skeleton.c and heavily on at1700.c by Donald Becker
8 This software may be used and distributed according to the terms
9 of the GNU Public Licence, incorporated herein by reference.
11 The author may be reached as miku@iki.fi
13 This driver supports following cards :
15 - ICL EtherTeam 32 EISA
16 (Uses true 32 bit transfers rather than 16i compability mode)
19 insmod eth16i.o ioaddr=0x2a0 mediatype=bnc
21 mediatype can be one of the following: bnc,tp,dix,auto,eprom
23 'auto' will try to autoprobe mediatype.
24 'eprom' will use whatever type defined in eprom.
26 I have benchmarked driver with PII/300Mhz as a ftp client
27 and 486/33Mhz as a ftp server. Top speed was 1128.37 kilobytes/sec.
30 - skeleton.c a sample network driver core for linux,
31 written by Donald Becker <becker@CESDIS.gsfc.nasa.gov>
32 - at1700.c a driver for Allied Telesis AT1700, written
34 - e16iSRV.asm a Netware 3.X Server Driver for ICL EtherTeam16i
35 written by Markku Viima
36 - The Fujitsu MB86965 databook.
38 Author thanks following persons due to their valueble assistance:
42 Kurt Huwig <kurt@huwig.de>
46 Version Date Description
48 0.01 15.12-94 Initial version (card detection)
49 0.02 23.01-95 Interrupt is now hooked correctly
50 0.03 01.02-95 Rewrote initialization part
51 0.04 07.02-95 Base skeleton done...
52 Made a few changes to signature checking
53 to make it a bit reliable.
54 - fixed bug in tx_buf mapping
55 - fixed bug in initialization (DLC_EN
56 wasn't enabled when initialization
58 0.05 08.02-95 If there were more than one packet to send,
59 transmit was jammed due to invalid
60 register write...now fixed
61 0.06 19.02-95 Rewrote interrupt handling
62 0.07 13.04-95 Wrote EEPROM read routines
63 Card configuration now set according to
65 0.08 23.06-95 Wrote part that tries to probe used interface
66 port if AUTO is selected
68 0.09 01.09-95 Added module support
70 0.10 04.09-95 Fixed receive packet allocation to work
73 0.20 20.09-95 Added support for EtherTeam32 EISA
75 0.21 17.10-95 Removed the unnecessary extern
76 init_etherdev() declaration. Some
79 0.22 22.02-96 Receive buffer was not flushed
80 correctly when faulty packet was
83 0.23 26.02-96 Made resetting the adapter
86 0.24 27.02-96 Rewrote faulty packet handling in eth16i_rx
88 0.25 22.05-96 kfree() was missing from cleanup_module.
90 0.26 11.06-96 Sometimes card was not found by
91 check_signature(). Now made more reliable.
93 0.27 23.06-96 Oops. 16 consecutive collisions halted
94 adapter. Now will try to retransmit
95 MAX_COL_16 times before finally giving up.
97 0.28 28.10-97 Added dev_id parameter (NULL) for free_irq
99 0.29 29.10-97 Multiple card support for module users
101 0.30 30.10-97 Fixed irq allocation bug.
102 (request_irq moved from probe to open)
104 0.30a 21.08-98 Card detection made more relaxed. Driver
105 had problems with some TCP/IP-PROM boots
106 to find the card. Suggested by
107 Kurt Huwig <kurt@huwig.de>
109 0.31 28.08-98 Media interface port can now be selected
110 with module parameters or kernel
113 0.32 31.08-98 IRQ was never freed if open/close
114 pair wasn't called. Now fixed.
116 0.33 10.09-98 When eth16i_open() was called after
117 eth16i_close() chip never recovered.
118 Now more shallow reset is made on
122 In some cases the media interface autoprobing code doesn't find
123 the correct interface type. In this case you can
124 manually choose the interface type in DOS with E16IC.EXE which is
125 configuration software for EtherTeam16i and EtherTeam32 cards.
126 This is also true for IRQ setting. You cannot use module
127 parameter to configure IRQ of the card (yet).
130 - Real multicast support
131 - Rewrite the media interface autoprobing code. Its _horrible_ !
132 - Possibly merge all the MB86965 specific code to external
133 module for use by eth16.c and Donald's at1700.c
134 - IRQ configuration with module parameter. I will do
135 this when i will get enough info about setting
136 irq without configuration utility.
139 static char *version
=
140 "eth16i.c: v0.33 10-09-98 Mika Kuoppala (miku@iki.fi)\n";
142 #include <linux/module.h>
144 #include <linux/kernel.h>
145 #include <linux/sched.h>
146 #include <linux/types.h>
147 #include <linux/fcntl.h>
148 #include <linux/interrupt.h>
149 #include <linux/ptrace.h>
150 #include <linux/ioport.h>
151 #include <linux/in.h>
152 #include <linux/malloc.h>
153 #include <linux/string.h>
154 #include <linux/errno.h>
156 #include <linux/netdevice.h>
157 #include <linux/etherdevice.h>
158 #include <linux/skbuff.h>
160 #include <asm/system.h>
161 #include <asm/bitops.h>
165 #ifndef LINUX_VERSION_CODE
166 #include <linux/version.h>
169 #if LINUX_VERSION_CODE >= 0x20123
170 #include <linux/init.h>
176 #if LINUX_VERSION_CODE < 0x20138
177 #define test_and_set_bit(val,addr) set_bit(val,addr)
180 #if LINUX_VERSION_CODE < 0x020100
181 typedef struct enet_statistics eth16i_stats_type
;
183 typedef struct net_device_stats eth16i_stats_type
;
187 #define BIT(a) ( (1 << (a)) )
188 #define BITSET(ioaddr, bnum) ((outb(((inb(ioaddr)) | (bnum)), ioaddr)))
189 #define BITCLR(ioaddr, bnum) ((outb(((inb(ioaddr)) & (~(bnum))), ioaddr)))
191 /* This is the I/O address space for Etherteam 16i adapter. */
192 #define ETH16I_IO_EXTENT 32
194 /* Ticks before deciding that transmit has timed out */
195 #define TX_TIMEOUT (400*HZ/1000)
197 /* Maximum loop count when receiving packets */
198 #define MAX_RX_LOOP 20
200 /* Some interrupt masks */
201 #define ETH16I_INTR_ON 0xef8a /* Higher is receive mask */
202 #define ETH16I_INTR_OFF 0x0000
204 /* Buffers header status byte meanings */
205 #define PKT_GOOD BIT(5)
206 #define PKT_GOOD_RMT BIT(4)
207 #define PKT_SHORT BIT(3)
208 #define PKT_ALIGN_ERR BIT(2)
209 #define PKT_CRC_ERR BIT(1)
210 #define PKT_RX_BUF_OVERFLOW BIT(0)
212 /* Transmit status register (DLCR0) */
213 #define TX_STATUS_REG 0
214 #define TX_DONE BIT(7)
215 #define NET_BUSY BIT(6)
216 #define TX_PKT_RCD BIT(5)
217 #define CR_LOST BIT(4)
218 #define TX_JABBER_ERR BIT(3)
219 #define COLLISION BIT(2)
220 #define COLLISIONS_16 BIT(1)
222 /* Receive status register (DLCR1) */
223 #define RX_STATUS_REG 1
224 #define RX_PKT BIT(7) /* Packet received */
225 #define BUS_RD_ERR BIT(6)
226 #define SHORT_PKT_ERR BIT(3)
227 #define ALIGN_ERR BIT(2)
228 #define CRC_ERR BIT(1)
229 #define RX_BUF_OVERFLOW BIT(0)
231 /* Transmit Interrupt Enable Register (DLCR2) */
232 #define TX_INTR_REG 2
233 #define TX_INTR_DONE BIT(7)
234 #define TX_INTR_COL BIT(2)
235 #define TX_INTR_16_COL BIT(1)
237 /* Receive Interrupt Enable Register (DLCR3) */
238 #define RX_INTR_REG 3
239 #define RX_INTR_RECEIVE BIT(7)
240 #define RX_INTR_SHORT_PKT BIT(3)
241 #define RX_INTR_CRC_ERR BIT(1)
242 #define RX_INTR_BUF_OVERFLOW BIT(0)
244 /* Transmit Mode Register (DLCR4) */
245 #define TRANSMIT_MODE_REG 4
246 #define LOOPBACK_CONTROL BIT(1)
247 #define CONTROL_OUTPUT BIT(2)
249 /* Receive Mode Register (DLCR5) */
250 #define RECEIVE_MODE_REG 5
251 #define RX_BUFFER_EMPTY BIT(6)
252 #define ACCEPT_BAD_PACKETS BIT(5)
253 #define RECEIVE_SHORT_ADDR BIT(4)
254 #define ACCEPT_SHORT_PACKETS BIT(3)
255 #define REMOTE_RESET BIT(2)
257 #define ADDRESS_FILTER_MODE BIT(1) | BIT(0)
260 #define MODE_1 1 /* NODE ID, BC, MC, 2-24th bit */
261 #define MODE_2 2 /* NODE ID, BC, MC, Hash Table */
263 /* Configuration Register 0 (DLCR6) */
264 #define CONFIG_REG_0 6
265 #define DLC_EN BIT(7)
266 #define SRAM_CYCLE_TIME_100NS BIT(6)
267 #define SYSTEM_BUS_WIDTH_8 BIT(5) /* 1 = 8bit, 0 = 16bit */
268 #define BUFFER_WIDTH_8 BIT(4) /* 1 = 8bit, 0 = 16bit */
271 #define SRAM_BS1 BIT(1) /* 00=8kb, 01=16kb */
272 #define SRAM_BS0 BIT(0) /* 10=32kb, 11=64kb */
274 #ifndef ETH16I_TX_BUF_SIZE /* 0 = 2kb, 1 = 4kb */
275 #define ETH16I_TX_BUF_SIZE 3 /* 2 = 8kb, 3 = 16kb */
277 #define TX_BUF_1x2048 0
278 #define TX_BUF_2x2048 1
279 #define TX_BUF_2x4098 2
280 #define TX_BUF_2x8192 3
282 /* Configuration Register 1 (DLCR7) */
283 #define CONFIG_REG_1 7
284 #define POWERUP BIT(5)
286 /* Transmit start register */
287 #define TRANSMIT_START_REG 10
288 #define TRANSMIT_START_RB 2
289 #define TX_START BIT(7) /* Rest of register bit indicate*/
290 /* number of packets in tx buffer*/
291 /* Node ID registers (DLCR8-13) */
295 /* Hash Table registers (HT8-15) */
296 #define HASH_TABLE_0 8
297 #define HASH_TABLE_RB 1
299 /* Buffer memory ports */
300 #define BUFFER_MEM_PORT_LB 8
301 #define DATAPORT BUFFER_MEM_PORT_LB
302 #define BUFFER_MEM_PORT_HB 9
304 /* 16 Collision control register (BMPR11) */
305 #define COL_16_REG 11
306 #define HALT_ON_16 0x00
307 #define RETRANS_AND_HALT_ON_16 0x02
309 /* Maximum number of attempts to send after 16 concecutive collisions */
310 #define MAX_COL_16 10
312 /* DMA Burst and Transceiver Mode Register (BMPR13) */
313 #define TRANSCEIVER_MODE_REG 13
314 #define TRANSCEIVER_MODE_RB 2
315 #define IO_BASE_UNLOCK BIT(7)
316 #define LOWER_SQUELCH_TRESH BIT(6)
317 #define LINK_TEST_DISABLE BIT(5)
318 #define AUI_SELECT BIT(4)
319 #define DIS_AUTO_PORT_SEL BIT(3)
321 /* Filter Self Receive Register (BMPR14) */
322 #define FILTER_SELF_RX_REG 14
323 #define SKIP_RX_PACKET BIT(2)
324 #define FILTER_SELF_RECEIVE BIT(0)
326 /* EEPROM Control Register (BMPR 16) */
327 #define EEPROM_CTRL_REG 16
329 /* EEPROM Data Register (BMPR 17) */
330 #define EEPROM_DATA_REG 17
332 /* NMC93CSx6 EEPROM Control Bits */
340 /* NMC93CSx6 EEPROM Instructions */
341 #define EEPROM_READ 0x80
343 /* NMC93CSx6 EEPROM Addresses */
344 #define E_NODEID_0 0x02
345 #define E_NODEID_1 0x03
346 #define E_NODEID_2 0x04
347 #define E_PORT_SELECT 0x14
348 #define E_PORT_BNC 0x00
349 #define E_PORT_DIX 0x01
350 #define E_PORT_TP 0x02
351 #define E_PORT_AUTO 0x03
352 #define E_PORT_FROM_EPROM 0x04
353 #define E_PRODUCT_CFG 0x30
356 /* Macro to slow down io between EEPROM clock transitions */
357 #define eeprom_slow_io() do { int _i = 40; while(--_i > 0) { inb(0x80); }}while(0)
359 /* Jumperless Configuration Register (BMPR19) */
360 #define JUMPERLESS_CONFIG 19
362 /* ID ROM registers, writing to them also resets some parts of chip */
365 #define RESET ID_ROM_0
367 /* This is the I/O address list to be probed when seeking the card */
368 static unsigned int eth16i_portlist
[] =
369 { 0x260, 0x280, 0x2A0, 0x240, 0x340, 0x320, 0x380, 0x300, 0 };
371 static unsigned int eth32i_portlist
[] =
372 { 0x1000, 0x2000, 0x3000, 0x4000, 0x5000, 0x6000, 0x7000, 0x8000,
373 0x9000, 0xA000, 0xB000, 0xC000, 0xD000, 0xE000, 0xF000, 0 };
375 /* This is the Interrupt lookup table for Eth16i card */
376 static unsigned int eth16i_irqmap
[] = { 9, 10, 5, 15, 0 };
377 #define NUM_OF_ISA_IRQS 4
379 /* This is the Interrupt lookup table for Eth32i card */
380 static unsigned int eth32i_irqmap
[] = { 3, 5, 7, 9, 10, 11, 12, 15, 0 };
381 #define EISA_IRQ_REG 0xc89
382 #define NUM_OF_EISA_IRQS 8
384 static unsigned int eth16i_tx_buf_map
[] = { 2048, 2048, 4096, 8192 };
385 static unsigned int boot
= 1;
387 /* Use 0 for production, 1 for verification, >2 for debug */
389 #define ETH16I_DEBUG 0
391 static unsigned int eth16i_debug
= ETH16I_DEBUG
;
393 /* Information for each board */
395 struct eth16i_local
{
396 eth16i_stats_type stats
;
397 unsigned char tx_started
;
398 unsigned char tx_buf_busy
;
399 unsigned short tx_queue
; /* Number of packets in transmit buffer */
400 unsigned short tx_queue_len
;
401 unsigned int tx_buf_size
;
402 unsigned long open_time
;
403 unsigned long tx_buffered_packets
;
404 unsigned long col_16
;
407 /* Function prototypes */
409 extern int eth16i_probe(struct net_device
*dev
);
411 static int eth16i_probe1(struct net_device
*dev
, int ioaddr
);
412 static int eth16i_check_signature(int ioaddr
);
413 static int eth16i_probe_port(int ioaddr
);
414 static void eth16i_set_port(int ioaddr
, int porttype
);
415 static int eth16i_send_probe_packet(int ioaddr
, unsigned char *b
, int l
);
416 static int eth16i_receive_probe_packet(int ioaddr
);
417 static int eth16i_get_irq(int ioaddr
);
418 static int eth16i_read_eeprom(int ioaddr
, int offset
);
419 static int eth16i_read_eeprom_word(int ioaddr
);
420 static void eth16i_eeprom_cmd(int ioaddr
, unsigned char command
);
421 static int eth16i_open(struct net_device
*dev
);
422 static int eth16i_close(struct net_device
*dev
);
423 static int eth16i_tx(struct sk_buff
*skb
, struct net_device
*dev
);
424 static void eth16i_rx(struct net_device
*dev
);
425 static void eth16i_interrupt(int irq
, void *dev_id
, struct pt_regs
*regs
);
426 static void eth16i_reset(struct net_device
*dev
);
427 static void eth16i_skip_packet(struct net_device
*dev
);
428 static void eth16i_multicast(struct net_device
*dev
);
429 static void eth16i_select_regbank(unsigned char regbank
, int ioaddr
);
430 static void eth16i_initialize(struct net_device
*dev
);
433 static int eth16i_set_irq(struct net_device
*dev
);
437 static ushort
eth16i_parse_mediatype(const char* s
);
440 static struct enet_statistics
*eth16i_get_stats(struct net_device
*dev
);
442 static char *cardname
= "ICL EtherTeam 16i/32";
446 /* Support for alternate probe manager */
447 /struct netdev_entry eth16i_drv
=
448 {"eth16i", eth16i_probe1
, ETH16I_IO_EXTENT
, eth16i_probe_list
};
450 #else /* Not HAVE_DEVLIST */
452 int __init
eth16i_probe(struct net_device
*dev
)
456 int base_addr
= dev
? dev
->base_addr
: 0;
459 printk(KERN_DEBUG
"Probing started for %s\n", cardname
);
461 if(base_addr
> 0x1ff) /* Check only single location */
462 return eth16i_probe1(dev
, base_addr
);
463 else if(base_addr
!= 0) /* Don't probe at all */
466 /* Seek card from the ISA io address space */
467 for(i
= 0; (ioaddr
= eth16i_portlist
[i
]) ; i
++) {
468 if(check_region(ioaddr
, ETH16I_IO_EXTENT
))
470 if(eth16i_probe1(dev
, ioaddr
) == 0)
474 /* Seek card from the EISA io address space */
475 for(i
= 0; (ioaddr
= eth32i_portlist
[i
]) ; i
++) {
476 if(check_region(ioaddr
, ETH16I_IO_EXTENT
))
478 if(eth16i_probe1(dev
, ioaddr
) == 0)
484 #endif /* Not HAVE_DEVLIST */
486 static int __init
eth16i_probe1(struct net_device
*dev
, int ioaddr
)
488 static unsigned version_printed
= 0;
489 boot
= 1; /* To inform initilization that we are in boot probe */
492 The MB86985 chip has on register which holds information in which
493 io address the chip lies. First read this register and compare
494 it to our current io address and if match then this could
498 if(ioaddr
< 0x1000) {
500 if(eth16i_portlist
[(inb(ioaddr
+ JUMPERLESS_CONFIG
) & 0x07)]
505 /* Now we will go a bit deeper and try to find the chip's signature */
507 if(eth16i_check_signature(ioaddr
) != 0)
511 Now it seems that we have found a ethernet chip in this particular
512 ioaddr. The MB86985 chip has this feature, that when you read a
513 certain register it will increase it's io base address to next
514 configurable slot. Now when we have found the chip, first thing is
515 to make sure that the chip's ioaddr will hold still here.
518 eth16i_select_regbank(TRANSCEIVER_MODE_RB
, ioaddr
);
519 outb(0x00, ioaddr
+ TRANSCEIVER_MODE_REG
);
521 outb(0x00, ioaddr
+ RESET
); /* Reset some parts of chip */
522 BITSET(ioaddr
+ CONFIG_REG_0
, BIT(7)); /* Disable the data link */
525 dev
= init_etherdev(0, 0);
527 if( (eth16i_debug
& version_printed
++) == 0)
528 printk(KERN_INFO
"%s", version
);
530 dev
->base_addr
= ioaddr
;
534 if(eth16i_set_irq(dev
)) {
535 dev
->irq
= eth16i_get_irq(ioaddr
);
542 dev
->irq
= eth16i_get_irq(ioaddr
);
544 /* Try to obtain interrupt vector */
546 if (request_irq(dev
->irq
, (void *)ð16i_interrupt
, 0, "eth16i", dev
)) {
547 printk(KERN_WARNING
"%s: %s at %#3x, but is unusable due conflicting IRQ %d.\n",
548 dev
->name
, cardname
, ioaddr
, dev
->irq
);
553 irq2dev_map
[dev
->irq
] = dev
;
556 printk(KERN_INFO
"%s: %s at %#3x, IRQ %d, ",
557 dev
->name
, cardname
, ioaddr
, dev
->irq
);
559 /* Let's grab the region */
560 request_region(ioaddr
, ETH16I_IO_EXTENT
, "eth16i");
562 /* Now we will have to lock the chip's io address */
563 eth16i_select_regbank(TRANSCEIVER_MODE_RB
, ioaddr
);
564 outb(0x38, ioaddr
+ TRANSCEIVER_MODE_REG
);
566 eth16i_initialize(dev
); /* Initialize rest of the chip's registers */
568 /* Now let's same some energy by shutting down the chip ;) */
569 BITCLR(ioaddr
+ CONFIG_REG_1
, POWERUP
);
571 /* Initialize the device structure */
572 if(dev
->priv
== NULL
) {
573 dev
->priv
= kmalloc(sizeof(struct eth16i_local
), GFP_KERNEL
);
574 if(dev
->priv
== NULL
)
578 memset(dev
->priv
, 0, sizeof(struct eth16i_local
));
580 dev
->open
= eth16i_open
;
581 dev
->stop
= eth16i_close
;
582 dev
->hard_start_xmit
= eth16i_tx
;
583 dev
->get_stats
= eth16i_get_stats
;
584 dev
->set_multicast_list
= ð16i_multicast
;
586 /* Fill in the fields of the device structure with ethernet values. */
595 static void eth16i_initialize(struct net_device
*dev
)
597 int ioaddr
= dev
->base_addr
;
599 unsigned char node_byte
= 0;
601 /* Setup station address */
602 eth16i_select_regbank(NODE_ID_RB
, ioaddr
);
603 for(i
= 0 ; i
< 3 ; i
++) {
604 unsigned short node_val
= eth16i_read_eeprom(ioaddr
, E_NODEID_0
+ i
);
605 ((unsigned short *)dev
->dev_addr
)[i
] = ntohs(node_val
);
608 for(i
= 0; i
< 6; i
++) {
609 outb( ((unsigned char *)dev
->dev_addr
)[i
], ioaddr
+ NODE_ID_0
+ i
);
611 printk("%02x", inb(ioaddr
+ NODE_ID_0
+ i
));
617 /* Now we will set multicast addresses to accept none */
618 eth16i_select_regbank(HASH_TABLE_RB
, ioaddr
);
619 for(i
= 0; i
< 8; i
++)
620 outb(0x00, ioaddr
+ HASH_TABLE_0
+ i
);
623 Now let's disable the transmitter and receiver, set the buffer ram
624 cycle time, bus width and buffer data path width. Also we shall
625 set transmit buffer size and total buffer size.
628 eth16i_select_regbank(2, ioaddr
);
631 node_w
= eth16i_read_eeprom(ioaddr
, E_PRODUCT_CFG
);
633 if( (node_w
& 0xFF00) == 0x0800)
634 node_byte
|= BUFFER_WIDTH_8
;
636 node_byte
|= SRAM_BS1
;
638 if( (node_w
& 0x00FF) == 64)
639 node_byte
|= SRAM_BS0
;
641 node_byte
|= DLC_EN
| SRAM_CYCLE_TIME_100NS
| (ETH16I_TX_BUF_SIZE
<< 2);
643 outb(node_byte
, ioaddr
+ CONFIG_REG_0
);
645 /* We shall halt the transmitting, if 16 collisions are detected */
646 outb(HALT_ON_16
, ioaddr
+ COL_16_REG
);
649 /* if_port already set by init_module() */
651 dev
->if_port
= (dev
->mem_start
< E_PORT_FROM_EPROM
) ?
652 dev
->mem_start
: E_PORT_FROM_EPROM
;
655 /* Set interface port type */
657 char *porttype
[] = {"BNC", "DIX", "TP", "AUTO", "FROM_EPROM" };
662 case E_PORT_FROM_EPROM
:
663 dev
->if_port
= eth16i_read_eeprom(ioaddr
, E_PORT_SELECT
);
667 dev
->if_port
= eth16i_probe_port(ioaddr
);
676 printk(" %s interface.\n", porttype
[dev
->if_port
]);
678 eth16i_set_port(ioaddr
, dev
->if_port
);
681 /* Set Receive Mode to normal operation */
682 outb(MODE_2
, ioaddr
+ RECEIVE_MODE_REG
);
685 static int eth16i_probe_port(int ioaddr
)
689 unsigned char dummy_packet
[64] = { 0 };
691 /* Powerup the chip */
692 outb(0xc0 | POWERUP
, ioaddr
+ CONFIG_REG_1
);
694 BITSET(ioaddr
+ CONFIG_REG_0
, DLC_EN
);
696 eth16i_select_regbank(NODE_ID_RB
, ioaddr
);
698 for(i
= 0; i
< 6; i
++) {
699 dummy_packet
[i
] = inb(ioaddr
+ NODE_ID_0
+ i
);
700 dummy_packet
[i
+6] = inb(ioaddr
+ NODE_ID_0
+ i
);
703 dummy_packet
[12] = 0x00;
704 dummy_packet
[13] = 0x04;
706 eth16i_select_regbank(2, ioaddr
);
708 for(i
= 0; i
< 3; i
++) {
709 BITSET(ioaddr
+ CONFIG_REG_0
, DLC_EN
);
710 BITCLR(ioaddr
+ CONFIG_REG_0
, DLC_EN
);
711 eth16i_set_port(ioaddr
, i
);
714 printk(KERN_DEBUG
"Set port number %d\n", i
);
716 retcode
= eth16i_send_probe_packet(ioaddr
, dummy_packet
, 64);
718 retcode
= eth16i_receive_probe_packet(ioaddr
);
721 printk(KERN_DEBUG
"Eth16i interface port found at %d\n", i
);
727 printk(KERN_DEBUG
"TRANSMIT_DONE timeout when probing interface port\n");
731 if( eth16i_debug
> 1)
732 printk(KERN_DEBUG
"Using default port\n");
737 static void eth16i_set_port(int ioaddr
, int porttype
)
739 unsigned short temp
= 0;
741 eth16i_select_regbank(TRANSCEIVER_MODE_RB
, ioaddr
);
742 outb(LOOPBACK_CONTROL
, ioaddr
+ TRANSMIT_MODE_REG
);
744 temp
|= DIS_AUTO_PORT_SEL
;
757 BITSET(ioaddr
+ TRANSMIT_MODE_REG
, CONTROL_OUTPUT
);
761 outb(temp
, ioaddr
+ TRANSCEIVER_MODE_REG
);
763 if(eth16i_debug
> 1) {
764 printk(KERN_DEBUG
"TRANSMIT_MODE_REG = %x\n", inb(ioaddr
+ TRANSMIT_MODE_REG
));
765 printk(KERN_DEBUG
"TRANSCEIVER_MODE_REG = %x\n",
766 inb(ioaddr
+TRANSCEIVER_MODE_REG
));
770 static int eth16i_send_probe_packet(int ioaddr
, unsigned char *b
, int l
)
774 outb(0xff, ioaddr
+ TX_STATUS_REG
);
776 outw(l
, ioaddr
+ DATAPORT
);
777 outsw(ioaddr
+ DATAPORT
, (unsigned short *)b
, (l
+ 1) >> 1);
780 outb(TX_START
| 1, ioaddr
+ TRANSMIT_START_REG
);
782 while( (inb(ioaddr
+ TX_STATUS_REG
) & 0x80) == 0) {
783 if( (jiffies
- starttime
) > TX_TIMEOUT
) {
791 static int eth16i_receive_probe_packet(int ioaddr
)
797 while((inb(ioaddr
+ TX_STATUS_REG
) & 0x20) == 0) {
798 if( (jiffies
- starttime
) > TX_TIMEOUT
) {
801 printk(KERN_DEBUG
"Timeout occurred waiting transmit packet received\n");
803 while((inb(ioaddr
+ RX_STATUS_REG
) & 0x80) == 0) {
804 if( (jiffies
- starttime
) > TX_TIMEOUT
) {
806 printk(KERN_DEBUG
"Timeout occurred waiting receive packet\n");
812 printk(KERN_DEBUG
"RECEIVE_PACKET\n");
813 return(0); /* Found receive packet */
817 if(eth16i_debug
> 1) {
818 printk(KERN_DEBUG
"TRANSMIT_PACKET_RECEIVED %x\n", inb(ioaddr
+ TX_STATUS_REG
));
819 printk(KERN_DEBUG
"RX_STATUS_REG = %x\n", inb(ioaddr
+ RX_STATUS_REG
));
822 return(0); /* Return success */
826 static int eth16i_set_irq(struct net_device
* dev
)
828 const int ioaddr
= dev
->base_addr
;
829 const int irq
= dev
->irq
;
832 if(ioaddr
< 0x1000) {
833 while(eth16i_irqmap
[i
] && eth16i_irqmap
[i
] != irq
)
836 if(i
< NUM_OF_ISA_IRQS
) {
837 u8 cbyte
= inb(ioaddr
+ JUMPERLESS_CONFIG
);
838 cbyte
= (cbyte
& 0x3F) | (i
<< 6);
839 outb(cbyte
, ioaddr
+ JUMPERLESS_CONFIG
);
844 printk(KERN_NOTICE
"%s: EISA Interrupt cannot be set. Use EISA Configuration utility.\n", dev
->name
);
852 static int eth16i_get_irq(int ioaddr
)
856 if( ioaddr
< 0x1000) {
857 cbyte
= inb(ioaddr
+ JUMPERLESS_CONFIG
);
858 return( eth16i_irqmap
[ ((cbyte
& 0xC0) >> 6) ] );
859 } else { /* Oh..the card is EISA so method getting IRQ different */
860 unsigned short index
= 0;
861 cbyte
= inb(ioaddr
+ EISA_IRQ_REG
);
862 while( (cbyte
& 0x01) == 0) {
866 return( eth32i_irqmap
[ index
] );
870 static int eth16i_check_signature(int ioaddr
)
873 unsigned char creg
[4] = { 0 };
875 for(i
= 0; i
< 4 ; i
++) {
877 creg
[i
] = inb(ioaddr
+ TRANSMIT_MODE_REG
+ i
);
880 printk("eth16i: read signature byte %x at %x\n",
882 ioaddr
+ TRANSMIT_MODE_REG
+ i
);
885 creg
[0] &= 0x0F; /* Mask collision cnr */
886 creg
[2] &= 0x7F; /* Mask DCLEN bit */
890 This was removed because the card was sometimes left to state
891 from which it couldn't be find anymore. If there is need
892 to more strict check still this have to be fixed.
894 if( ! ((creg
[0] == 0x06) && (creg
[1] == 0x41)) ) {
900 if( !((creg
[2] == 0x36) && (creg
[3] == 0xE0)) ) {
904 if( !((creg
[2] == 0x40) && (creg
[3] == 0x00)) )
908 if(eth16i_read_eeprom(ioaddr
, E_NODEID_0
) != 0)
911 if((eth16i_read_eeprom(ioaddr
, E_NODEID_1
) & 0xFF00) != 0x4B00)
917 static int eth16i_read_eeprom(int ioaddr
, int offset
)
921 eth16i_eeprom_cmd(ioaddr
, EEPROM_READ
| offset
);
922 outb(CS_1
, ioaddr
+ EEPROM_CTRL_REG
);
923 data
= eth16i_read_eeprom_word(ioaddr
);
924 outb(CS_0
| SK_0
, ioaddr
+ EEPROM_CTRL_REG
);
929 static int eth16i_read_eeprom_word(int ioaddr
)
934 for(i
= 16; i
> 0; i
--) {
935 outb(CS_1
| SK_0
, ioaddr
+ EEPROM_CTRL_REG
);
937 outb(CS_1
| SK_1
, ioaddr
+ EEPROM_CTRL_REG
);
940 ((inb(ioaddr
+ EEPROM_DATA_REG
) & DI_1
) ? 1 : 0);
948 static void eth16i_eeprom_cmd(int ioaddr
, unsigned char command
)
952 outb(CS_0
| SK_0
, ioaddr
+ EEPROM_CTRL_REG
);
953 outb(DI_0
, ioaddr
+ EEPROM_DATA_REG
);
954 outb(CS_1
| SK_0
, ioaddr
+ EEPROM_CTRL_REG
);
955 outb(DI_1
, ioaddr
+ EEPROM_DATA_REG
);
956 outb(CS_1
| SK_1
, ioaddr
+ EEPROM_CTRL_REG
);
958 for(i
= 7; i
>= 0; i
--) {
959 short cmd
= ( (command
& (1 << i
)) ? DI_1
: DI_0
);
960 outb(cmd
, ioaddr
+ EEPROM_DATA_REG
);
961 outb(CS_1
| SK_0
, ioaddr
+ EEPROM_CTRL_REG
);
963 outb(CS_1
| SK_1
, ioaddr
+ EEPROM_CTRL_REG
);
968 static int eth16i_open(struct net_device
*dev
)
970 struct eth16i_local
*lp
= (struct eth16i_local
*)dev
->priv
;
971 int ioaddr
= dev
->base_addr
;
973 /* Powerup the chip */
974 outb(0xc0 | POWERUP
, ioaddr
+ CONFIG_REG_1
);
976 /* Initialize the chip */
977 eth16i_initialize(dev
);
979 /* Set the transmit buffer size */
980 lp
->tx_buf_size
= eth16i_tx_buf_map
[ETH16I_TX_BUF_SIZE
& 0x03];
983 printk(KERN_DEBUG
"%s: transmit buffer size %d\n",
984 dev
->name
, lp
->tx_buf_size
);
986 /* Now enable Transmitter and Receiver sections */
987 BITCLR(ioaddr
+ CONFIG_REG_0
, DLC_EN
);
989 /* Now switch to register bank 2, for run time operation */
990 eth16i_select_regbank(2, ioaddr
);
992 lp
->open_time
= jiffies
;
995 lp
->tx_queue_len
= 0;
997 /* Turn on interrupts*/
998 outw(ETH16I_INTR_ON
, ioaddr
+ TX_INTR_REG
);
1009 static int eth16i_close(struct net_device
*dev
)
1011 struct eth16i_local
*lp
= (struct eth16i_local
*)dev
->priv
;
1012 int ioaddr
= dev
->base_addr
;
1016 /* Turn off interrupts*/
1017 outw(ETH16I_INTR_OFF
, ioaddr
+ TX_INTR_REG
);
1024 /* Disable transmit and receive */
1025 BITSET(ioaddr
+ CONFIG_REG_0
, DLC_EN
);
1027 /* Reset the chip */
1028 /* outb(0xff, ioaddr + RESET); */
1029 /* outw(0xffff, ioaddr + TX_STATUS_REG); */
1031 outb(0x00, ioaddr
+ CONFIG_REG_1
);
1038 static int eth16i_tx(struct sk_buff
*skb
, struct net_device
*dev
)
1040 struct eth16i_local
*lp
= (struct eth16i_local
*)dev
->priv
;
1041 int ioaddr
= dev
->base_addr
;
1047 If we get here, some higher level has decided that
1048 we are broken. There should really be a "kick me"
1049 function call instead.
1052 int tickssofar
= jiffies
- dev
->trans_start
;
1053 if(tickssofar
< TX_TIMEOUT
)
1056 outw(ETH16I_INTR_OFF
, ioaddr
+ TX_INTR_REG
);
1058 printk(KERN_WARNING
"%s: transmit timed out with status %04x, %s ?\n",
1060 inw(ioaddr
+ TX_STATUS_REG
),
1061 (inb(ioaddr
+ TX_STATUS_REG
) & TX_DONE
) ?
1062 "IRQ conflict" : "network cable problem");
1064 dev
->trans_start
= jiffies
;
1066 /* Let's dump all registers */
1067 if(eth16i_debug
> 0) {
1068 printk(KERN_DEBUG
"%s: timeout: %02x %02x %02x %02x %02x %02x %02x %02x.\n",
1069 dev
->name
, inb(ioaddr
+ 0),
1070 inb(ioaddr
+ 1), inb(ioaddr
+ 2),
1071 inb(ioaddr
+ 3), inb(ioaddr
+ 4),
1073 inb(ioaddr
+ 6), inb(ioaddr
+ 7));
1075 printk(KERN_DEBUG
"%s: transmit start reg: %02x. collision reg %02x\n",
1076 dev
->name
, inb(ioaddr
+ TRANSMIT_START_REG
),
1077 inb(ioaddr
+ COL_16_REG
));
1079 printk(KERN_DEBUG
"lp->tx_queue = %d\n", lp
->tx_queue
);
1080 printk(KERN_DEBUG
"lp->tx_queue_len = %d\n", lp
->tx_queue_len
);
1081 printk(KERN_DEBUG
"lp->tx_started = %d\n", lp
->tx_started
);
1085 lp
->stats
.tx_errors
++;
1089 dev
->trans_start
= jiffies
;
1091 outw(ETH16I_INTR_ON
, ioaddr
+ TX_INTR_REG
);
1096 If some higher layer thinks we've missed an tx-done interrupt
1097 we are passed NULL. Caution: dev_tint() handles the cli()/sti()
1102 #if LINUX_VERSION_CODE < 0x020100
1105 if(eth16i_debug
> 0)
1106 printk(KERN_WARNING
"%s: Missed tx-done interrupt.\n", dev
->name
);
1110 /* Block a timer based transmitter from overlapping.
1111 This could better be done with atomic_swap(1, dev->tbusy),
1112 but set_bit() works as well. */
1114 set_bit(0, (void *)&lp
->tx_buf_busy
);
1116 /* Turn off TX interrupts */
1117 outw(ETH16I_INTR_OFF
, ioaddr
+ TX_INTR_REG
);
1119 if(test_and_set_bit(0, (void *)&dev
->tbusy
) != 0) {
1120 printk(KERN_WARNING
"%s: Transmitter access conflict.\n", dev
->name
);
1124 ushort length
= ETH_ZLEN
< skb
->len
? skb
->len
: ETH_ZLEN
;
1125 unsigned char *buf
= skb
->data
;
1127 if( (length
+ 2) > (lp
->tx_buf_size
- lp
->tx_queue_len
)) {
1128 if(eth16i_debug
> 0)
1129 printk(KERN_WARNING
"%s: Transmit buffer full.\n", dev
->name
);
1132 outw(length
, ioaddr
+ DATAPORT
);
1134 if( ioaddr
< 0x1000 )
1135 outsw(ioaddr
+ DATAPORT
, buf
, (length
+ 1) >> 1);
1137 unsigned char frag
= length
% 4;
1139 outsl(ioaddr
+ DATAPORT
, buf
, length
>> 2);
1142 outsw(ioaddr
+ DATAPORT
, (buf
+ (length
& 0xFFFC)), 1);
1144 outsw(ioaddr
+ DATAPORT
,
1145 (buf
+ (length
& 0xFFFC) + 2), 1);
1149 lp
->tx_buffered_packets
++;
1151 lp
->tx_queue_len
+= length
+ 2;
1155 lp
->tx_buf_busy
= 0;
1157 if(lp
->tx_started
== 0) {
1158 /* If the transmitter is idle..always trigger a transmit */
1159 outb(TX_START
| lp
->tx_queue
, ioaddr
+ TRANSMIT_START_REG
);
1161 lp
->tx_queue_len
= 0;
1162 dev
->trans_start
= jiffies
;
1166 else if(lp
->tx_queue_len
< lp
->tx_buf_size
- (ETH_FRAME_LEN
+ 2)) {
1167 /* There is still more room for one more packet in tx buffer */
1171 outw(ETH16I_INTR_ON
, ioaddr
+ TX_INTR_REG
);
1173 /* Turn TX interrupts back on */
1174 /* outb(TX_INTR_DONE | TX_INTR_16_COL, ioaddr + TX_INTR_REG); */
1178 #if LINUX_VERSION_CODE >= 0x020100
1181 dev_kfree_skb(skb
, FREE_WRITE
);
1187 static void eth16i_rx(struct net_device
*dev
)
1189 struct eth16i_local
*lp
= (struct eth16i_local
*)dev
->priv
;
1190 int ioaddr
= dev
->base_addr
;
1191 int boguscount
= MAX_RX_LOOP
;
1193 /* Loop until all packets have been read */
1194 while( (inb(ioaddr
+ RECEIVE_MODE_REG
) & RX_BUFFER_EMPTY
) == 0) {
1196 /* Read status byte from receive buffer */
1197 ushort status
= inw(ioaddr
+ DATAPORT
);
1199 /* Get the size of the packet from receive buffer */
1200 ushort pkt_len
= inw(ioaddr
+ DATAPORT
);
1202 if(eth16i_debug
> 4)
1203 printk(KERN_DEBUG
"%s: Receiving packet mode %02x status %04x.\n",
1205 inb(ioaddr
+ RECEIVE_MODE_REG
), status
);
1207 if( !(status
& PKT_GOOD
) ) {
1208 lp
->stats
.rx_errors
++;
1210 if( (pkt_len
< ETH_ZLEN
) || (pkt_len
> ETH_FRAME_LEN
) ) {
1211 lp
->stats
.rx_length_errors
++;
1216 eth16i_skip_packet(dev
);
1217 lp
->stats
.rx_dropped
++;
1220 else { /* Ok so now we should have a good packet */
1221 struct sk_buff
*skb
;
1223 skb
= dev_alloc_skb(pkt_len
+ 3);
1225 printk(KERN_WARNING
"%s: Could'n allocate memory for packet (len %d)\n",
1226 dev
->name
, pkt_len
);
1227 eth16i_skip_packet(dev
);
1228 lp
->stats
.rx_dropped
++;
1236 Now let's get the packet out of buffer.
1237 size is (pkt_len + 1) >> 1, cause we are now reading words
1238 and it have to be even aligned.
1242 insw(ioaddr
+ DATAPORT
, skb_put(skb
, pkt_len
),
1243 (pkt_len
+ 1) >> 1);
1245 unsigned char *buf
= skb_put(skb
, pkt_len
);
1246 unsigned char frag
= pkt_len
% 4;
1248 insl(ioaddr
+ DATAPORT
, buf
, pkt_len
>> 2);
1251 unsigned short rest
[2];
1252 rest
[0] = inw( ioaddr
+ DATAPORT
);
1254 rest
[1] = inw( ioaddr
+ DATAPORT
);
1256 memcpy(buf
+ (pkt_len
& 0xfffc), (char *)rest
, frag
);
1260 skb
->protocol
=eth_type_trans(skb
, dev
);
1262 lp
->stats
.rx_packets
++;
1264 if( eth16i_debug
> 5 ) {
1266 printk(KERN_DEBUG
"%s: Received packet of length %d.\n",
1267 dev
->name
, pkt_len
);
1268 for(i
= 0; i
< 14; i
++)
1269 printk(KERN_DEBUG
" %02x", skb
->data
[i
]);
1270 printk(KERN_DEBUG
".\n");
1275 if(--boguscount
<= 0)
1284 for(i
= 0; i
< 20; i
++) {
1285 if( (inb(ioaddr
+RECEIVE_MODE_REG
) & RX_BUFFER_EMPTY
) ==
1288 inw(ioaddr
+ DATAPORT
);
1289 outb(SKIP_RX_PACKET
, ioaddr
+ FILTER_SELF_RX_REG
);
1292 if(eth16i_debug
> 1)
1293 printk(KERN_DEBUG
"%s: Flushed receive buffer.\n", dev
->name
);
1300 static void eth16i_interrupt(int irq
, void *dev_id
, struct pt_regs
*regs
)
1302 struct net_device
*dev
= dev_id
;
1303 struct eth16i_local
*lp
;
1308 printk(KERN_WARNING
"eth16i_interrupt(): irq %d for unknown device. \n", irq
);
1312 /* Turn off all interrupts from adapter */
1313 outw(ETH16I_INTR_OFF
, ioaddr
+ TX_INTR_REG
);
1315 set_bit(0, (void *)&dev
->tbusy
); /* Set the device busy so that */
1316 /* eth16i_tx wont be called */
1319 printk(KERN_WARNING
"%s: Re-entering the interrupt handler.\n", dev
->name
);
1322 ioaddr
= dev
->base_addr
;
1323 lp
= (struct eth16i_local
*)dev
->priv
;
1324 status
= inw(ioaddr
+ TX_STATUS_REG
); /* Get the status */
1325 outw(status
, ioaddr
+ TX_STATUS_REG
); /* Clear status bits */
1327 if(eth16i_debug
> 3)
1328 printk(KERN_DEBUG
"%s: Interrupt with status %04x.\n", dev
->name
, status
);
1330 if( status
& 0x7f00 ) {
1332 lp
->stats
.rx_errors
++;
1334 if(status
& (BUS_RD_ERR
<< 8) )
1335 printk(KERN_WARNING
"%s: Bus read error.\n",dev
->name
);
1336 if(status
& (SHORT_PKT_ERR
<< 8) ) lp
->stats
.rx_length_errors
++;
1337 if(status
& (ALIGN_ERR
<< 8) ) lp
->stats
.rx_frame_errors
++;
1338 if(status
& (CRC_ERR
<< 8) ) lp
->stats
.rx_crc_errors
++;
1339 if(status
& (RX_BUF_OVERFLOW
<< 8) ) lp
->stats
.rx_over_errors
++;
1341 if( status
& 0x001a) {
1343 lp
->stats
.tx_errors
++;
1345 if(status
& CR_LOST
) lp
->stats
.tx_carrier_errors
++;
1346 if(status
& TX_JABBER_ERR
) lp
->stats
.tx_window_errors
++;
1349 if(status
& COLLISION
) {
1350 lp
->stats
.collisions
+=
1351 ((inb(ioaddr
+TRANSMIT_MODE_REG
) & 0xF0) >> 4);
1354 if(status
& COLLISIONS_16
) {
1355 if(lp
->col_16
< MAX_COL_16
) {
1357 lp
->stats
.collisions
++;
1358 /* Resume transmitting, skip failed packet */
1359 outb(0x02, ioaddr
+ COL_16_REG
);
1362 printk(KERN_WARNING
"%s: bailing out due to many consecutive 16-in-a-row collisions. Network cable problem?\n", dev
->name
);
1367 if( status
& 0x00ff ) { /* Let's check the transmit status reg */
1369 if(status
& TX_DONE
) { /* The transmit has been done */
1370 lp
->stats
.tx_packets
= lp
->tx_buffered_packets
;
1373 if(lp
->tx_queue
) { /* Is there still packets ? */
1374 /* There was packet(s) so start transmitting and write also
1375 how many packets there is to be sended */
1376 outb(TX_START
| lp
->tx_queue
, ioaddr
+ TRANSMIT_START_REG
);
1378 lp
->tx_queue_len
= 0;
1380 dev
->trans_start
= jiffies
;
1390 if( ( status
& 0x8000 ) ||
1391 ( (inb(ioaddr
+ RECEIVE_MODE_REG
) & RX_BUFFER_EMPTY
) == 0) ) {
1392 eth16i_rx(dev
); /* We have packet in receive buffer */
1397 /* Turn interrupts back on */
1398 outw(ETH16I_INTR_ON
, ioaddr
+ TX_INTR_REG
);
1400 if(lp
->tx_queue_len
< lp
->tx_buf_size
- (ETH_FRAME_LEN
+ 2)) {
1401 /* There is still more room for one more packet in tx buffer */
1408 static void eth16i_skip_packet(struct net_device
*dev
)
1410 int ioaddr
= dev
->base_addr
;
1412 inw(ioaddr
+ DATAPORT
);
1413 inw(ioaddr
+ DATAPORT
);
1414 inw(ioaddr
+ DATAPORT
);
1416 outb(SKIP_RX_PACKET
, ioaddr
+ FILTER_SELF_RX_REG
);
1417 while( inb( ioaddr
+ FILTER_SELF_RX_REG
) != 0);
1420 static void eth16i_reset(struct net_device
*dev
)
1422 struct eth16i_local
*lp
= (struct eth16i_local
*)dev
->priv
;
1423 int ioaddr
= dev
->base_addr
;
1425 if(eth16i_debug
> 1)
1426 printk(KERN_DEBUG
"%s: Resetting device.\n", dev
->name
);
1428 BITSET(ioaddr
+ CONFIG_REG_0
, DLC_EN
);
1429 outw(0xffff, ioaddr
+ TX_STATUS_REG
);
1430 eth16i_select_regbank(2, ioaddr
);
1433 lp
->tx_buf_busy
= 0;
1435 lp
->tx_queue_len
= 0;
1440 BITCLR(ioaddr
+ CONFIG_REG_0
, DLC_EN
);
1443 static void eth16i_multicast(struct net_device
*dev
)
1445 int ioaddr
= dev
->base_addr
;
1447 if(dev
->mc_count
|| dev
->flags
&(IFF_ALLMULTI
|IFF_PROMISC
))
1449 dev
->flags
|=IFF_PROMISC
; /* Must do this */
1450 outb(3, ioaddr
+ RECEIVE_MODE_REG
);
1452 outb(2, ioaddr
+ RECEIVE_MODE_REG
);
1456 static struct enet_statistics
*eth16i_get_stats(struct net_device
*dev
)
1458 struct eth16i_local
*lp
= (struct eth16i_local
*)dev
->priv
;
1463 static void eth16i_select_regbank(unsigned char banknbr
, int ioaddr
)
1467 data
= inb(ioaddr
+ CONFIG_REG_1
);
1468 outb( ((data
& 0xF3) | ( (banknbr
& 0x03) << 2)), ioaddr
+ CONFIG_REG_1
);
1473 static ushort
eth16i_parse_mediatype(const char* s
)
1476 return E_PORT_FROM_EPROM
;
1478 if (!strncmp(s
, "bnc", 3))
1480 else if (!strncmp(s
, "tp", 2))
1482 else if (!strncmp(s
, "dix", 3))
1484 else if (!strncmp(s
, "auto", 4))
1487 return E_PORT_FROM_EPROM
;
1490 #define MAX_ETH16I_CARDS 4 /* Max number of Eth16i cards per module */
1491 #define NAMELEN 8 /* number of chars for storing dev->name */
1493 static char namelist
[NAMELEN
* MAX_ETH16I_CARDS
] = { 0, };
1494 static struct net_device dev_eth16i
[MAX_ETH16I_CARDS
] = {
1503 static int ioaddr
[MAX_ETH16I_CARDS
] = { 0, };
1505 static int irq
[MAX_ETH16I_CARDS
] = { 0, };
1507 static char* mediatype
[MAX_ETH16I_CARDS
] = { 0, };
1508 static int debug
= -1;
1510 #if (LINUX_VERSION_CODE >= 0x20115)
1511 MODULE_AUTHOR("Mika Kuoppala <miku@iki.fi>");
1512 MODULE_DESCRIPTION("ICL EtherTeam 16i/32 driver");
1514 MODULE_PARM(ioaddr
, "1-" __MODULE_STRING(MAX_ETH16I_CARDS
) "i");
1515 MODULE_PARM_DESC(ioaddr
, "eth16i io base address");
1518 MODULE_PARM(irq
, "1-" __MODULE_STRING(MAX_ETH16I_CARDS
) "i");
1519 MODULE_PARM_DESC(irq
, "eth16i interrupt request number");
1522 MODULE_PARM(mediatype
, "1-" __MODULE_STRING(MAX_ETH16I_CARDS
) "s");
1523 MODULE_PARM_DESC(mediatype
, "eth16i interfaceport mediatype");
1525 MODULE_PARM(debug
, "i");
1526 MODULE_PARM_DESC(debug
, "eth16i debug level (0-4)");
1529 int init_module(void)
1531 int this_dev
, found
= 0;
1533 for(this_dev
= 0; this_dev
< MAX_ETH16I_CARDS
; this_dev
++)
1535 struct net_device
*dev
= &dev_eth16i
[this_dev
];
1537 dev
->name
= namelist
+ (NAMELEN
*this_dev
);
1538 dev
->irq
= 0; /* irq[this_dev]; */
1539 dev
->base_addr
= ioaddr
[this_dev
];
1540 dev
->init
= eth16i_probe
;
1543 eth16i_debug
= debug
;
1545 if(eth16i_debug
> 1)
1546 printk(KERN_NOTICE
"eth16i(%d): interface type %s\n", this_dev
, mediatype
[this_dev
] ? mediatype
[this_dev
] : "none" );
1548 dev
->if_port
= eth16i_parse_mediatype(mediatype
[this_dev
]);
1550 if(ioaddr
[this_dev
] == 0)
1552 if(this_dev
!= 0) break; /* Only autoprobe 1st one */
1554 printk(KERN_NOTICE
"eth16i.c: Presently autoprobing (not recommended) for a single card.\n");
1557 if(register_netdev(dev
) != 0)
1559 printk(KERN_WARNING
"eth16i.c No Eth16i card found (i/o = 0x%x).\n",
1562 if(found
!= 0) return 0;
1571 void cleanup_module(void)
1575 for(this_dev
= 0; this_dev
< MAX_ETH16I_CARDS
; this_dev
++)
1577 struct net_device
* dev
= &dev_eth16i
[this_dev
];
1579 if(dev
->priv
!= NULL
)
1581 unregister_netdev(dev
);
1585 free_irq(dev
->irq
, dev
);
1586 release_region(dev
->base_addr
, ETH16I_IO_EXTENT
);
1595 * compile-command: "gcc -DMODULE -D__KERNEL__ -Wall -Wstrict-prototypes -O6 -c eth16i.c"
1596 * alt-compile-command: "gcc -DMODVERSIONS -DMODULE -D__KERNEL__ -Wall -Wstrict -prototypes -O6 -c eth16i.c"
1603 /* End of file eth16i.c */