📄 de4x5.c
字号:
Updated debug flags. Fix sleep/wakeup calls for PCI cards, bug reported by <cross@gweep.lkg.dec.com>. Added multi-MAC, one SROM feature from discussion with <mjacob@feral.com>. Added full module autoprobe capability. Added attempt to use an SMC9332 with broken SROM. Added fix for ZYNX multi-mac cards that didn't get their IRQs wired correctly. 0.51 13-Feb-97 Added endian fixes for the SROM accesses from <paubert@iram.es> Fix init_connection() to remove extra device reset. Fix MAC/PHY reset ordering in dc21140m_autoconf(). Fix initialisation problem with lp->timeout in typeX_infoblock() from <paubert@iram.es>. Fix MII PHY reset problem from work done by <paubert@iram.es>. 0.52 26-Apr-97 Some changes may not credit the right people - a disk crash meant I lost some mail. Change RX interrupt routine to drop rather than defer packets to avoid hang reported by <g.thomas@opengroup.org>. Fix srom_exec() to return for COMPACT and type 1 infoblocks. Added DC21142 and DC21143 functions. Added byte counters from <phil@tazenda.demon.co.uk> Added SA_INTERRUPT temporary fix from <mjacob@feral.com>. 0.53 12-Nov-97 Fix the *_probe() to include 'eth??' name during module load: bug reported by <Piete.Brooks@cl.cam.ac.uk> Fix multi-MAC, one SROM, to work with 2114x chips: bug reported by <cmetz@inner.net>. Make above search independent of BIOS device scan direction. Completed DC2114[23] autosense functions. 0.531 21-Dec-97 Fix DE500-XA 100Mb/s bug reported by <robin@intercore.com Fix type1_infoblock() bug introduced in 0.53, from problem reports by <parmee@postecss.ncrfran.france.ncr.com> and <jo@ice.dillingen.baynet.de>. Added argument list to set up each board from either a module's command line or a compiled in #define. Added generic MII PHY functionality to deal with newer PHY chips. Fix the mess in 2.1.67. 0.532 5-Jan-98 Fix bug in mii_get_phy() reported by <redhat@cococo.net>. Fix bug in pci_probe() for 64 bit systems reported by <belliott@accessone.com>. 0.533 9-Jan-98 Fix more 64 bit bugs reported by <jal@cs.brown.edu>. 0.534 24-Jan-98 Fix last (?) endian bug from <geert@linux-m68k.org> 0.535 21-Feb-98 Fix Ethernet Address PROM reset bug for DC21040. 0.536 21-Mar-98 Change pci_probe() to use the pci_dev structure. **Incompatible with 2.0.x from here.** 0.540 5-Jul-98 Atomicize assertion of dev->interrupt for SMP from <lma@varesearch.com> Add TP, AUI and BNC cases to 21140m_autoconf() for case where a 21140 under SROM control uses, e.g. AUI from problem report by <delchini@lpnp09.in2p3.fr> Add MII parallel detection to 2114x_autoconf() for case where no autonegotiation partner exists from problem report by <mlapsley@ndirect.co.uk>. Add ability to force connection type directly even when using SROM control from problem report by <earl@exis.net>. Updated the PCI interface to conform with the latest version. I hope nothing is broken... Add TX done interrupt modification from suggestion by <Austin.Donnelly@cl.cam.ac.uk>. Fix is_anc_capable() bug reported by <Austin.Donnelly@cl.cam.ac.uk>. Fix type[13]_infoblock() bug: during MII search, PHY lp->rst not run because lp->ibn not initialised - from report & fix by <paubert@iram.es>. Fix probe bug with EISA & PCI cards present from report by <eirik@netcom.com>. 0.541 24-Aug-98 Fix compiler problems associated with i386-string ops from multiple bug reports and temporary fix from <paubert@iram.es>. Fix pci_probe() to correctly emulate the old pcibios_find_class() function. Add an_exception() for old ZYNX346 and fix compile warning on PPC & SPARC, from <ecd@skynet.be>. Fix lastPCI to correctly work with compiled in kernels and modules from bug report by <Zlatko.Calusic@CARNet.hr> et al. 0.542 15-Sep-98 Fix dc2114x_autoconf() to stop multiple messages when media is unconnected. Change dev->interrupt to lp->interrupt to ensure alignment for Alpha's and avoid their unaligned access traps. This flag is merely for log messages: should do something more definitive though... 0.543 30-Dec-98 Add SMP spin locking. 0.544 8-May-99 Fix for buggy SROM in Motorola embedded boards using a 21143 by <mmporter@home.com>. Change PCI/EISA bus probing order. 0.545 28-Nov-99 Further Moto SROM bug fix from <mporter@eng.mcd.mot.com> Remove double checking for DEBUG_RX in de4x5_dbg_rx() from report by <geert@linux-m68k.org> 0.546 22-Feb-01 Fixes Alpha XP1000 oops. The srom_search function was causing a page fault when initializing the variable 'pb', on a non de4x5 PCI device, in this case a PCI bridge (DEC chip 21152). The value of 'pb' is now only initialized if a de4x5 chip is present. <france@handhelds.org> 0.547 08-Nov-01 Use library crc32 functions by <Matt_Domsch@dell.com> 0.548 30-Aug-03 Big 2.6 cleanup. Ported to PCI/EISA probing and generic DMA APIs. Fixed DE425 support on Alpha. <maz@wild-wind.fr.eu.org> =========================================================================*/#include <linux/config.h>#include <linux/module.h>#include <linux/kernel.h>#include <linux/string.h>#include <linux/interrupt.h>#include <linux/ptrace.h>#include <linux/errno.h>#include <linux/ioport.h>#include <linux/slab.h>#include <linux/pci.h>#include <linux/eisa.h>#include <linux/delay.h>#include <linux/init.h>#include <linux/spinlock.h>#include <linux/crc32.h>#include <linux/netdevice.h>#include <linux/etherdevice.h>#include <linux/skbuff.h>#include <linux/time.h>#include <linux/types.h>#include <linux/unistd.h>#include <linux/ctype.h>#include <linux/dma-mapping.h>#include <linux/moduleparam.h>#include <linux/bitops.h>#include <asm/io.h>#include <asm/dma.h>#include <asm/byteorder.h>#include <asm/unaligned.h>#include <asm/uaccess.h>#ifdef CONFIG_PPC_MULTIPLATFORM#include <asm/machdep.h>#endif /* CONFIG_PPC_MULTIPLATFORM */#include "de4x5.h"static char version[] __devinitdata = "de4x5.c:V0.546 2001/02/22 davies@maniac.ultranet.com\n";#define c_char const char#define TWIDDLE(a) (u_short)le16_to_cpu(get_unaligned((u_short *)(a)))/*** MII Information*/struct phy_table { int reset; /* Hard reset required? */ int id; /* IEEE OUI */ int ta; /* One cycle TA time - 802.3u is confusing here */ struct { /* Non autonegotiation (parallel) speed det. */ int reg; int mask; int value; } spd;};struct mii_phy { int reset; /* Hard reset required? */ int id; /* IEEE OUI */ int ta; /* One cycle TA time */ struct { /* Non autonegotiation (parallel) speed det. */ int reg; int mask; int value; } spd; int addr; /* MII address for the PHY */ u_char *gep; /* Start of GEP sequence block in SROM */ u_char *rst; /* Start of reset sequence in SROM */ u_int mc; /* Media Capabilities */ u_int ana; /* NWay Advertisement */ u_int fdx; /* Full DupleX capabilites for each media */ u_int ttm; /* Transmit Threshold Mode for each media */ u_int mci; /* 21142 MII Connector Interrupt info */};#define DE4X5_MAX_PHY 8 /* Allow upto 8 attached PHY devices per board */struct sia_phy { u_char mc; /* Media Code */ u_char ext; /* csr13-15 valid when set */ int csr13; /* SIA Connectivity Register */ int csr14; /* SIA TX/RX Register */ int csr15; /* SIA General Register */ int gepc; /* SIA GEP Control Information */ int gep; /* SIA GEP Data */};/*** Define the know universe of PHY devices that can be** recognised by this driver.*/static struct phy_table phy_info[] = { {0, NATIONAL_TX, 1, {0x19, 0x40, 0x00}}, /* National TX */ {1, BROADCOM_T4, 1, {0x10, 0x02, 0x02}}, /* Broadcom T4 */ {0, SEEQ_T4 , 1, {0x12, 0x10, 0x10}}, /* SEEQ T4 */ {0, CYPRESS_T4 , 1, {0x05, 0x20, 0x20}}, /* Cypress T4 */ {0, 0x7810 , 1, {0x14, 0x0800, 0x0800}} /* Level One LTX970 */};/*** These GENERIC values assumes that the PHY devices follow 802.3u and** allow parallel detection to set the link partner ability register.** Detection of 100Base-TX [H/F Duplex] and 100Base-T4 is supported.*/#define GENERIC_REG 0x05 /* Autoneg. Link Partner Advertisement Reg. */#define GENERIC_MASK MII_ANLPA_100M /* All 100Mb/s Technologies */#define GENERIC_VALUE MII_ANLPA_100M /* 100B-TX, 100B-TX FDX, 100B-T4 *//*** Define special SROM detection cases*/static c_char enet_det[][ETH_ALEN] = { {0x00, 0x00, 0xc0, 0x00, 0x00, 0x00}, {0x00, 0x00, 0xe8, 0x00, 0x00, 0x00}};#define SMC 1#define ACCTON 2/*** SROM Repair definitions. If a broken SROM is detected a card may** use this information to help figure out what to do. This is a** "stab in the dark" and so far for SMC9332's only.*/static c_char srom_repair_info[][100] = { {0x00,0x1e,0x00,0x00,0x00,0x08, /* SMC9332 */ 0x1f,0x01,0x8f,0x01,0x00,0x01,0x00,0x02, 0x01,0x00,0x00,0x78,0xe0,0x01,0x00,0x50, 0x00,0x18,}};#ifdef DE4X5_DEBUGstatic int de4x5_debug = DE4X5_DEBUG;#else/*static int de4x5_debug = (DEBUG_MII | DEBUG_SROM | DEBUG_PCICFG | DEBUG_MEDIA | DEBUG_VERSION);*/static int de4x5_debug = (DEBUG_MEDIA | DEBUG_VERSION);#endif/*** Allow per adapter set up. For modules this is simply a command line** parameter, e.g.: ** insmod de4x5 args='eth1:fdx autosense=BNC eth0:autosense=100Mb'.**** For a compiled in driver, place e.g.** #define DE4X5_PARM "eth0:fdx autosense=AUI eth2:autosense=TP"** here*/#ifdef DE4X5_PARMstatic char *args = DE4X5_PARM;#elsestatic char *args;#endifstruct parameters { int fdx; int autosense;};#define DE4X5_AUTOSENSE_MS 250 /* msec autosense tick (DE500) */#define DE4X5_NDA 0xffe0 /* No Device (I/O) Address *//*** Ethernet PROM defines*/#define PROBE_LENGTH 32#define ETH_PROM_SIG 0xAA5500FFUL/*** Ethernet Info*/#define PKT_BUF_SZ 1536 /* Buffer size for each Tx/Rx buffer */#define IEEE802_3_SZ 1518 /* Packet + CRC */#define MAX_PKT_SZ 1514 /* Maximum ethernet packet length */#define MAX_DAT_SZ 1500 /* Maximum ethernet data length */#define MIN_DAT_SZ 1 /* Minimum ethernet data length */#define PKT_HDR_LEN 14 /* Addresses and data length info */#define FAKE_FRAME_LEN (MAX_PKT_SZ + 1)#define QUEUE_PKT_TIMEOUT (3*HZ) /* 3 second timeout *//*** EISA bus defines*/#define DE4X5_EISA_IO_PORTS 0x0c00 /* I/O port base address, slot 0 */#define DE4X5_EISA_TOTAL_SIZE 0x100 /* I/O address extent */#define EISA_ALLOWED_IRQ_LIST {5, 9, 10, 11}#define DE4X5_SIGNATURE {"DE425","DE434","DE435","DE450","DE500"}#define DE4X5_NAME_LENGTH 8static c_char *de4x5_signatures[] = DE4X5_SIGNATURE;/*** Ethernet PROM defines for DC21040*/#define PROBE_LENGTH 32#define ETH_PROM_SIG 0xAA5500FFUL/*** PCI Bus defines*/#define PCI_MAX_BUS_NUM 8#define DE4X5_PCI_TOTAL_SIZE 0x80 /* I/O address extent */#define DE4X5_CLASS_CODE 0x00020000 /* Network controller, Ethernet *//*** Memory Alignment. Each descriptor is 4 longwords long. To force a** particular alignment on the TX descriptor, adjust DESC_SKIP_LEN and** DESC_ALIGN. ALIGN aligns the start address of the private memory area** and hence the RX descriptor ring's first entry.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -