38 #include <linux/errno.h>
39 #include <linux/netdevice.h>
41 #include <linux/module.h>
42 #include <linux/kernel.h>
43 #include <linux/types.h>
44 #include <linux/fcntl.h>
49 #include <linux/string.h>
52 #include <linux/bitops.h>
60 #define DRV_NAME "at1700"
65 #define MC_FILTERBREAK 64
70 0x220, 0x240, 0x260, 0x280, 0x2a0, 0x2c0, 0x300, 0x340, 0
77 static unsigned at1700_probe_list[]
__initdata = {
78 0x260, 0x280, 0x2a0, 0x240, 0x340, 0x320, 0x380, 0x300, 0
119 #define EEPROM_Ctrl 16
120 #define EEPROM_Data 17
121 #define CARDSTATUS 16
122 #define CARDSTATUS1 17
128 #define AT1700_IO_EXTENT 32
129 #define PORT_OFFSET(o) (o)
132 #define TX_TIMEOUT (HZ/10)
137 static int at1700_probe1(
struct net_device *
dev,
int ioaddr);
156 static int io = 0x260;
186 err = at1700_probe1(dev,
io);
187 }
else if (
io != 0) {
190 for (port = at1700_probe_list; *
port; port++) {
191 if (at1700_probe1(dev, *port) == 0)
212 .ndo_open = net_open,
213 .ndo_stop = net_close,
214 .ndo_start_xmit = net_send_packet,
215 .ndo_set_rx_mode = set_rx_mode,
216 .ndo_tx_timeout = net_tx_timeout,
232 static const char fmv_irqmap[4] = {3, 7, 10, 15};
233 static const char fmv_irqmap_pnp[8] = {3, 4, 5, 7, 9, 10, 11, 15};
234 static const char at1700_irqmap[8] = {3, 4, 5, 9, 10, 11, 14, 15};
235 unsigned int i,
irq, is_fmv18x = 0, is_at1700 = 0;
247 printk(
"at1700 probe at %#x, eeprom is %4.4x %4.4x %4.4x ctrl %4.4x.\n",
253 if (at1700_probe_list[
inb(ioaddr +
IOCONFIG1) & 0x07] == ioaddr &&
257 else if (
inb(ioaddr +
SAPROM ) == 0x00 &&
276 for (i = 0; i < 8; i++) {
277 if (irq == fmv_irqmap_pnp[i])
284 if (fmv18x_probe_list[
inb(ioaddr +
IOCONFIG) & 0x07] != ioaddr)
286 irq = fmv_irqmap[(
inb(ioaddr +
IOCONFIG)>>6) & 0x03];
290 printk(
"%s: %s found at %#3x, IRQ %d, address ", dev->
name,
291 is_at1700 ?
"AT1700" :
"FMV-18X", ioaddr, irq);
297 for(i = 0; i < 3; i++) {
298 unsigned short eeprom_val =
read_eeprom(ioaddr, 4+i);
302 for(i = 0; i < 6; i++) {
316 const char *porttype[] = {
"auto-sense",
"10baseT",
"auto-sense",
"10base2"};
319 dev->
if_port = setup_value >> 8;
322 switch (setup_value & 0x07) {
341 for (i = 0; i < 6; i++)
346 for (i = 0; i < 8; i++)
369 "conflict on IRQ %d.\n",
383 #define EE_SHIFT_CLK 0x40
385 #define EE_DATA_WRITE 0x80
386 #define EE_DATA_READ 0x80
389 #define EE_WRITE_CMD (5 << 6)
390 #define EE_READ_CMD (6 << 6)
391 #define EE_ERASE_CMD (7 << 6)
396 unsigned short retval = 0;
402 for (i = 9; i >= 0; i--) {
405 outb(dataval, ee_daddr);
409 for (i = 16; i > 0; i--) {
451 netif_start_queue(dev);
455 static void net_tx_timeout (
struct net_device *dev)
460 printk (
"%s: transmit timed out with status %04x, %s?\n", dev->
name,
462 ?
"IRQ conflict" :
"network cable problem");
463 printk (
"%s: timeout registers: %04x %04x %04x %04x %04x %04x %04x %04x.\n",
467 dev->
stats.tx_errors++;
485 netif_wake_queue(dev);
496 unsigned char *
buf = skb->
data;
499 netif_stop_queue (dev);
517 if (length != skb->
len)
531 netif_start_queue (dev);
534 netif_start_queue (dev);
550 printk (
"at1700_interrupt(): irq %d for unknown device.\n", irq);
555 lp = netdev_priv(dev);
557 spin_lock (&lp->
lock);
563 printk(
"%s: Interrupt with status %04x.\n", dev->
name, status);
565 (status & 0xff00 || (
inb(ioaddr +
RX_MODE) & 0x40) == 0)) {
579 if (status & 0x00ff) {
584 printk(
"%s: 16 Collision occur during Txing.\n", dev->
name);
587 dev->
stats.collisions++;
590 dev->
stats.tx_packets++;
599 netif_wake_queue (dev);
602 netif_wake_queue (dev);
607 spin_unlock (&lp->
lock);
623 printk(
"%s: Rxing packet mode %02x status %04x.\n",
625 #ifndef final_version
632 if ((status & 0xF0) != 0x20) {
633 dev->
stats.rx_errors++;
634 if (status & 0x08) dev->
stats.rx_length_errors++;
635 if (status & 0x04) dev->
stats.rx_frame_errors++;
636 if (status & 0x02) dev->
stats.rx_crc_errors++;
637 if (status & 0x01) dev->
stats.rx_over_errors++;
642 if (pkt_len > 1550) {
643 printk(
"%s: The AT1700 claimed a very large packet, size %d.\n",
648 dev->
stats.rx_errors++;
651 skb = netdev_alloc_skb(dev, pkt_len + 3);
653 printk(
"%s: Memory squeeze, dropping packet (len %d).\n",
658 dev->
stats.rx_dropped++;
666 dev->
stats.rx_packets++;
669 if (--boguscount <= 0)
678 for (i = 0; i < 20; i++) {
686 printk(
"%s: Exint Rx packet with mode %02x after %d ticks.\n",
697 netif_stop_queue(dev);
726 memset(mc_filter, 0xff,
sizeof(mc_filter));
731 memset(mc_filter, 0xff,
sizeof(mc_filter));
734 memset(mc_filter, 0x00,
sizeof(mc_filter));
739 memset(mc_filter, 0,
sizeof(mc_filter));
743 mc_filter[bit >> 3] |= (1 <<
bit);
753 outw((saved_bank & ~0x0C00) | 0x0480, ioaddr +
CONFIG_0);
754 for (i = 0; i < 8; i++)
759 spin_unlock_irqrestore (&lp->
lock, flags);
772 static int __init at1700_module_init(
void)
775 printk(
"at1700: You should not use auto-probing with insmod!\n");
777 if (IS_ERR(dev_at1700))
778 return PTR_ERR(dev_at1700);
782 static void __exit at1700_module_exit(
void)
785 cleanup_card(dev_at1700);