/* lance.c: An AMD LANCE/PCnet ethernet driver for Linux. */
/*
Written/copyright 1993-1998 by Donald Becker.
Copyright 1993 United States Government as represented by the
Director, National Security Agency.
This software may be used and distributed according to the terms
of the GNU General Public License, incorporated herein by reference.
This driver is for the Allied Telesis AT1500 and HP J2405A, and should work
with most other LANCE-based bus-master (NE2100/NE2500) ethercards.
The author may be reached as becker@scyld.com, or C/O
Scyld Computing Corporation
410 Severn Ave., Suite 210
Annapolis MD 21403
Andrey V. Savochkin:
- alignment problem with 1.3.* kernel and some minor changes.
Thomas Bogendoerfer (tsbogend@bigbug.franken.de):
- added support for Linux/Alpha, but removed most of it, because
it worked only for the PCI chip.
- added hook for the 32bit lance driver
- added PCnetPCI II (79C970A) to chip table
Paul Gortmaker (gpg109@rsphy1.anu.edu.au):
- hopefully fix above so Linux/Alpha can use ISA cards too.
8/20/96 Fixed 7990 autoIRQ failure and reversed unneeded alignment -djb
v1.12 10/27/97 Module support -djb
v1.14 2/3/98 Module support modified, made PCI support optional -djb
v1.15 5/27/99 Fixed bug in the cleanup_module(). dev->priv was freed
before unregister_netdev() which caused NULL pointer
reference later in the chain (in rtnetlink_fill_ifinfo())
-- Mika Kuoppala <miku@iki.fi>
Forward ported v1.14 to 2.1.129, merged the PCI and misc changes from
the 2.1 version of the old driver - Alan Cox
Get rid of check_region, check kmalloc return in lance_probe1
Arnaldo Carvalho de Melo <acme@conectiva.com.br> - 11/01/2001
Reworked detection, added support for Racal InterLan EtherBlaster cards
Vesselin Kostadinov <vesok at yahoo dot com > - 22/4/2004
*/
static const char version[] = "lance.c:v1.16 2006/11/09 dplatt@3do.com, becker@cesdis.gsfc.nasa.gov\n";
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/delay.h>
#include <linux/errno.h>
#include <linux/ioport.h>
#include <linux/slab.h>
#include <linux/interrupt.h>
#include <linux/pci.h>
#include <linux/init.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
#include <linux/mm.h>
#include <linux/bitops.h>
#include <asm/io.h>
#include <asm/dma.h>
static unsigned int lance_portlist[] __initdata = { 0x300, 0x320, 0x340, 0x360, 0};
static int lance_probe1(struct net_device *dev, int ioaddr, int irq, int options);
static int __init do_lance_probe(struct net_device *dev);
static struct card {
char id_offset14;
char id_offset15;
} cards[] = {
{ //"normal"
.id_offset14 = 0x57,
.id_offset15 = 0x57,
},
{ //NI6510EB
.id_offset14 = 0x52,
.id_offset15 = 0x44,
},
{ //Racal InterLan EtherBlaster
.id_offset14 = 0x52,
.id_offset15 = 0x49,
},
};
#define NUM_CARDS 3
#ifdef LANCE_DEBUG
static int lance_debug = LANCE_DEBUG;
#else
static int lance_debug = 1;
#endif
/*
Theory of Operation
I. Board Compatibility
This device driver is designed for the AMD 79C960, the "PCnet-ISA
single-chip ethernet controller for ISA". This chip is used in a wide
variety of boards from vendors such as Allied Telesis, HP, Kingston,
and Boca. This driver is also intended to work with older AMD 7990
designs, such as the NE1500 and NE2100, and newer 79C961. For convenience,
I use the name LANCE to refer to all of the AMD chips, even though it properly
refers only to the original 7990.
II. Board-specific settings
The driver is designed to work the boards that use the faster
bus-master mode, rather than in shared memory mode. (Only older designs
have on-board buffer memory needed to support the slower shared memory mode.)
Most ISA boards have jumpered settings for the I/O base, IRQ line, and DMA
channel. This driver probes the likely base addresses:
{0x300, 0x320, 0x340, 0x360}.
After the board is found it generates a DMA-timeout interrupt and uses
autoIRQ to find the IRQ line. The DMA channel can be set with the low bits
of the otherwise-unused dev->mem_start value (aka PARAM1). If unset it is
probed for by enabling each free DMA channel in turn and checking if
initialization succeeds.
The HP-J2405A board is an exception: with this board it is easy to read the