From b955f6ca776f3bab3d1e2c5fb1d247b203cbda14 Mon Sep 17 00:00:00 2001 From: Jeff Kirsher Date: Wed, 30 Mar 2011 07:46:36 -0700 Subject: amd: Move AMD (Lance) chipset drivers Moves the drivers for the AMD chipsets into drivers/net/ethernet/amd/ and the necessary Kconfig and Makfile changes. The au1000 (Alchemy) driver was also moved into the same directory even though it is not a "Lance" driver. CC: Peter Maydell CC: Roman Hodek CC: "Maciej W. Rozycki" CC: Donald Becker CC: Sam Creasey CC: Miguel de Icaza CC: Thomas Bogendoerfer CC: Don Fry CC: Geert Uytterhoeven CC: Russell King CC: David Davies CC: "M.Hipp" CC: Pete Popov CC: David Hinds CC: "Roger C. Pao" Signed-off-by: Jeff Kirsher --- MAINTAINERS | 4 +- drivers/net/7990.c | 662 -------- drivers/net/7990.h | 254 --- drivers/net/Kconfig | 153 -- drivers/net/Makefile | 14 - drivers/net/a2065.c | 781 --------- drivers/net/a2065.h | 173 -- drivers/net/amd8111e.c | 1992 ---------------------- drivers/net/amd8111e.h | 816 --------- drivers/net/ariadne.c | 793 --------- drivers/net/ariadne.h | 415 ----- drivers/net/arm/Kconfig | 7 - drivers/net/arm/Makefile | 1 - drivers/net/arm/am79c961a.c | 767 --------- drivers/net/arm/am79c961a.h | 145 -- drivers/net/atarilance.c | 1176 ------------- drivers/net/au1000_eth.c | 1332 --------------- drivers/net/au1000_eth.h | 134 -- drivers/net/declance.c | 1381 ---------------- drivers/net/depca.c | 2111 ------------------------ drivers/net/depca.h | 185 --- drivers/net/ethernet/Kconfig | 1 + drivers/net/ethernet/Makefile | 1 + drivers/net/ethernet/amd/7990.c | 662 ++++++++ drivers/net/ethernet/amd/7990.h | 254 +++ drivers/net/ethernet/amd/Kconfig | 192 +++ drivers/net/ethernet/amd/Makefile | 20 + drivers/net/ethernet/amd/a2065.c | 781 +++++++++ drivers/net/ethernet/amd/a2065.h | 173 ++ drivers/net/ethernet/amd/am79c961a.c | 767 +++++++++ drivers/net/ethernet/amd/am79c961a.h | 145 ++ drivers/net/ethernet/amd/amd8111e.c | 1992 ++++++++++++++++++++++ drivers/net/ethernet/amd/amd8111e.h | 816 +++++++++ drivers/net/ethernet/amd/ariadne.c | 793 +++++++++ drivers/net/ethernet/amd/ariadne.h | 415 +++++ drivers/net/ethernet/amd/atarilance.c | 1176 +++++++++++++ drivers/net/ethernet/amd/au1000_eth.c | 1332 +++++++++++++++ drivers/net/ethernet/amd/au1000_eth.h | 134 ++ drivers/net/ethernet/amd/declance.c | 1381 ++++++++++++++++ drivers/net/ethernet/amd/depca.c | 2111 ++++++++++++++++++++++++ drivers/net/ethernet/amd/depca.h | 185 +++ drivers/net/ethernet/amd/hplance.c | 242 +++ drivers/net/ethernet/amd/hplance.h | 26 + drivers/net/ethernet/amd/lance.c | 1313 +++++++++++++++ drivers/net/ethernet/amd/mvme147.c | 205 +++ drivers/net/ethernet/amd/ni65.c | 1254 ++++++++++++++ drivers/net/ethernet/amd/ni65.h | 121 ++ drivers/net/ethernet/amd/nmclan_cs.c | 1525 +++++++++++++++++ drivers/net/ethernet/amd/pcnet32.c | 2937 +++++++++++++++++++++++++++++++++ drivers/net/ethernet/amd/sun3lance.c | 961 +++++++++++ drivers/net/ethernet/amd/sunlance.c | 1556 +++++++++++++++++ drivers/net/hplance.c | 242 --- drivers/net/hplance.h | 26 - drivers/net/lance.c | 1313 --------------- drivers/net/mvme147.c | 205 --- drivers/net/ni65.c | 1254 -------------- drivers/net/ni65.h | 121 -- drivers/net/pcmcia/Kconfig | 9 - drivers/net/pcmcia/Makefile | 1 - drivers/net/pcmcia/nmclan_cs.c | 1525 ----------------- drivers/net/pcnet32.c | 2937 --------------------------------- drivers/net/sun3lance.c | 961 ----------- drivers/net/sunlance.c | 1556 ----------------- 63 files changed, 23473 insertions(+), 23444 deletions(-) delete mode 100644 drivers/net/7990.c delete mode 100644 drivers/net/7990.h delete mode 100644 drivers/net/a2065.c delete mode 100644 drivers/net/a2065.h delete mode 100644 drivers/net/amd8111e.c delete mode 100644 drivers/net/amd8111e.h delete mode 100644 drivers/net/ariadne.c delete mode 100644 drivers/net/ariadne.h delete mode 100644 drivers/net/arm/am79c961a.c delete mode 100644 drivers/net/arm/am79c961a.h delete mode 100644 drivers/net/atarilance.c delete mode 100644 drivers/net/au1000_eth.c delete mode 100644 drivers/net/au1000_eth.h delete mode 100644 drivers/net/declance.c delete mode 100644 drivers/net/depca.c delete mode 100644 drivers/net/depca.h create mode 100644 drivers/net/ethernet/amd/7990.c create mode 100644 drivers/net/ethernet/amd/7990.h create mode 100644 drivers/net/ethernet/amd/Kconfig create mode 100644 drivers/net/ethernet/amd/Makefile create mode 100644 drivers/net/ethernet/amd/a2065.c create mode 100644 drivers/net/ethernet/amd/a2065.h create mode 100644 drivers/net/ethernet/amd/am79c961a.c create mode 100644 drivers/net/ethernet/amd/am79c961a.h create mode 100644 drivers/net/ethernet/amd/amd8111e.c create mode 100644 drivers/net/ethernet/amd/amd8111e.h create mode 100644 drivers/net/ethernet/amd/ariadne.c create mode 100644 drivers/net/ethernet/amd/ariadne.h create mode 100644 drivers/net/ethernet/amd/atarilance.c create mode 100644 drivers/net/ethernet/amd/au1000_eth.c create mode 100644 drivers/net/ethernet/amd/au1000_eth.h create mode 100644 drivers/net/ethernet/amd/declance.c create mode 100644 drivers/net/ethernet/amd/depca.c create mode 100644 drivers/net/ethernet/amd/depca.h create mode 100644 drivers/net/ethernet/amd/hplance.c create mode 100644 drivers/net/ethernet/amd/hplance.h create mode 100644 drivers/net/ethernet/amd/lance.c create mode 100644 drivers/net/ethernet/amd/mvme147.c create mode 100644 drivers/net/ethernet/amd/ni65.c create mode 100644 drivers/net/ethernet/amd/ni65.h create mode 100644 drivers/net/ethernet/amd/nmclan_cs.c create mode 100644 drivers/net/ethernet/amd/pcnet32.c create mode 100644 drivers/net/ethernet/amd/sun3lance.c create mode 100644 drivers/net/ethernet/amd/sunlance.c delete mode 100644 drivers/net/hplance.c delete mode 100644 drivers/net/hplance.h delete mode 100644 drivers/net/lance.c delete mode 100644 drivers/net/mvme147.c delete mode 100644 drivers/net/ni65.c delete mode 100644 drivers/net/ni65.h delete mode 100644 drivers/net/pcmcia/nmclan_cs.c delete mode 100644 drivers/net/pcnet32.c delete mode 100644 drivers/net/sun3lance.c delete mode 100644 drivers/net/sunlance.c diff --git a/MAINTAINERS b/MAINTAINERS index 112e22696a77..6f9dc946fc9b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -746,7 +746,7 @@ L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) W: http://www.arm.linux.org.uk/ S: Maintained F: arch/arm/mach-ebsa110/ -F: drivers/net/arm/am79c961a.* +F: drivers/net/ethernet/amd/am79c961a.* ARM/EZX SMARTPHONES (A780, A910, A1200, E680, ROKR E2 and ROKR E6) M: Daniel Ribeiro @@ -4941,7 +4941,7 @@ PCNET32 NETWORK DRIVER M: Don Fry L: netdev@vger.kernel.org S: Maintained -F: drivers/net/pcnet32.c +F: drivers/net/ethernet/amd/pcnet32.c PCRYPT PARALLEL CRYPTO ENGINE M: Steffen Klassert diff --git a/drivers/net/7990.c b/drivers/net/7990.c deleted file mode 100644 index 60b35fb5f524..000000000000 --- a/drivers/net/7990.c +++ /dev/null @@ -1,662 +0,0 @@ -/* - * 7990.c -- LANCE ethernet IC generic routines. - * This is an attempt to separate out the bits of various ethernet - * drivers that are common because they all use the AMD 7990 LANCE - * (Local Area Network Controller for Ethernet) chip. - * - * Copyright (C) 05/1998 Peter Maydell - * - * Most of this stuff was obtained by looking at other LANCE drivers, - * in particular a2065.[ch]. The AMD C-LANCE datasheet was also helpful. - * NB: this was made easy by the fact that Jes Sorensen had cleaned up - * most of a2025 and sunlance with the aim of merging them, so the - * common code was pretty obvious. - */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -/* Used for the temporal inet entries and routing */ -#include -#include - -#include -#include -#include -#include -#ifdef CONFIG_HP300 -#include -#endif - -#include "7990.h" - -#define WRITERAP(lp,x) out_be16(lp->base + LANCE_RAP, (x)) -#define WRITERDP(lp,x) out_be16(lp->base + LANCE_RDP, (x)) -#define READRDP(lp) in_be16(lp->base + LANCE_RDP) - -#if defined(CONFIG_HPLANCE) || defined(CONFIG_HPLANCE_MODULE) -#include "hplance.h" - -#undef WRITERAP -#undef WRITERDP -#undef READRDP - -#if defined(CONFIG_MVME147_NET) || defined(CONFIG_MVME147_NET_MODULE) - -/* Lossage Factor Nine, Mr Sulu. */ -#define WRITERAP(lp,x) (lp->writerap(lp,x)) -#define WRITERDP(lp,x) (lp->writerdp(lp,x)) -#define READRDP(lp) (lp->readrdp(lp)) - -#else - -/* These inlines can be used if only CONFIG_HPLANCE is defined */ -static inline void WRITERAP(struct lance_private *lp, __u16 value) -{ - do { - out_be16(lp->base + HPLANCE_REGOFF + LANCE_RAP, value); - } while ((in_8(lp->base + HPLANCE_STATUS) & LE_ACK) == 0); -} - -static inline void WRITERDP(struct lance_private *lp, __u16 value) -{ - do { - out_be16(lp->base + HPLANCE_REGOFF + LANCE_RDP, value); - } while ((in_8(lp->base + HPLANCE_STATUS) & LE_ACK) == 0); -} - -static inline __u16 READRDP(struct lance_private *lp) -{ - __u16 value; - do { - value = in_be16(lp->base + HPLANCE_REGOFF + LANCE_RDP); - } while ((in_8(lp->base + HPLANCE_STATUS) & LE_ACK) == 0); - return value; -} - -#endif -#endif /* CONFIG_HPLANCE || CONFIG_HPLANCE_MODULE */ - -/* debugging output macros, various flavours */ -/* #define TEST_HITS */ -#ifdef UNDEF -#define PRINT_RINGS() \ -do { \ - int t; \ - for (t=0; t < RX_RING_SIZE; t++) { \ - printk("R%d: @(%02X %04X) len %04X, mblen %04X, bits %02X\n",\ - t, ib->brx_ring[t].rmd1_hadr, ib->brx_ring[t].rmd0,\ - ib->brx_ring[t].length,\ - ib->brx_ring[t].mblength, ib->brx_ring[t].rmd1_bits);\ - }\ - for (t=0; t < TX_RING_SIZE; t++) { \ - printk("T%d: @(%02X %04X) len %04X, misc %04X, bits %02X\n",\ - t, ib->btx_ring[t].tmd1_hadr, ib->btx_ring[t].tmd0,\ - ib->btx_ring[t].length,\ - ib->btx_ring[t].misc, ib->btx_ring[t].tmd1_bits);\ - }\ -} while (0) -#else -#define PRINT_RINGS() -#endif - -/* Load the CSR registers. The LANCE has to be STOPped when we do this! */ -static void load_csrs (struct lance_private *lp) -{ - volatile struct lance_init_block *aib = lp->lance_init_block; - int leptr; - - leptr = LANCE_ADDR (aib); - - WRITERAP(lp, LE_CSR1); /* load address of init block */ - WRITERDP(lp, leptr & 0xFFFF); - WRITERAP(lp, LE_CSR2); - WRITERDP(lp, leptr >> 16); - WRITERAP(lp, LE_CSR3); - WRITERDP(lp, lp->busmaster_regval); /* set byteswap/ALEctrl/byte ctrl */ - - /* Point back to csr0 */ - WRITERAP(lp, LE_CSR0); -} - -/* #define to 0 or 1 appropriately */ -#define DEBUG_IRING 0 -/* Set up the Lance Rx and Tx rings and the init block */ -static void lance_init_ring (struct net_device *dev) -{ - struct lance_private *lp = netdev_priv(dev); - volatile struct lance_init_block *ib = lp->init_block; - volatile struct lance_init_block *aib; /* for LANCE_ADDR computations */ - int leptr; - int i; - - aib = lp->lance_init_block; - - lp->rx_new = lp->tx_new = 0; - lp->rx_old = lp->tx_old = 0; - - ib->mode = LE_MO_PROM; /* normal, enable Tx & Rx */ - - /* Copy the ethernet address to the lance init block - * Notice that we do a byteswap if we're big endian. - * [I think this is the right criterion; at least, sunlance, - * a2065 and atarilance do the byteswap and lance.c (PC) doesn't. - * However, the datasheet says that the BSWAP bit doesn't affect - * the init block, so surely it should be low byte first for - * everybody? Um.] - * We could define the ib->physaddr as three 16bit values and - * use (addr[1] << 8) | addr[0] & co, but this is more efficient. - */ -#ifdef __BIG_ENDIAN - ib->phys_addr [0] = dev->dev_addr [1]; - ib->phys_addr [1] = dev->dev_addr [0]; - ib->phys_addr [2] = dev->dev_addr [3]; - ib->phys_addr [3] = dev->dev_addr [2]; - ib->phys_addr [4] = dev->dev_addr [5]; - ib->phys_addr [5] = dev->dev_addr [4]; -#else - for (i=0; i<6; i++) - ib->phys_addr[i] = dev->dev_addr[i]; -#endif - - if (DEBUG_IRING) - printk ("TX rings:\n"); - - lp->tx_full = 0; - /* Setup the Tx ring entries */ - for (i = 0; i < (1<lance_log_tx_bufs); i++) { - leptr = LANCE_ADDR(&aib->tx_buf[i][0]); - ib->btx_ring [i].tmd0 = leptr; - ib->btx_ring [i].tmd1_hadr = leptr >> 16; - ib->btx_ring [i].tmd1_bits = 0; - ib->btx_ring [i].length = 0xf000; /* The ones required by tmd2 */ - ib->btx_ring [i].misc = 0; - if (DEBUG_IRING) - printk ("%d: 0x%8.8x\n", i, leptr); - } - - /* Setup the Rx ring entries */ - if (DEBUG_IRING) - printk ("RX rings:\n"); - for (i = 0; i < (1<lance_log_rx_bufs); i++) { - leptr = LANCE_ADDR(&aib->rx_buf[i][0]); - - ib->brx_ring [i].rmd0 = leptr; - ib->brx_ring [i].rmd1_hadr = leptr >> 16; - ib->brx_ring [i].rmd1_bits = LE_R1_OWN; - /* 0xf000 == bits that must be one (reserved, presumably) */ - ib->brx_ring [i].length = -RX_BUFF_SIZE | 0xf000; - ib->brx_ring [i].mblength = 0; - if (DEBUG_IRING) - printk ("%d: 0x%8.8x\n", i, leptr); - } - - /* Setup the initialization block */ - - /* Setup rx descriptor pointer */ - leptr = LANCE_ADDR(&aib->brx_ring); - ib->rx_len = (lp->lance_log_rx_bufs << 13) | (leptr >> 16); - ib->rx_ptr = leptr; - if (DEBUG_IRING) - printk ("RX ptr: %8.8x\n", leptr); - - /* Setup tx descriptor pointer */ - leptr = LANCE_ADDR(&aib->btx_ring); - ib->tx_len = (lp->lance_log_tx_bufs << 13) | (leptr >> 16); - ib->tx_ptr = leptr; - if (DEBUG_IRING) - printk ("TX ptr: %8.8x\n", leptr); - - /* Clear the multicast filter */ - ib->filter [0] = 0; - ib->filter [1] = 0; - PRINT_RINGS(); -} - -/* LANCE must be STOPped before we do this, too... */ -static int init_restart_lance (struct lance_private *lp) -{ - int i; - - WRITERAP(lp, LE_CSR0); - WRITERDP(lp, LE_C0_INIT); - - /* Need a hook here for sunlance ledma stuff */ - - /* Wait for the lance to complete initialization */ - for (i = 0; (i < 100) && !(READRDP(lp) & (LE_C0_ERR | LE_C0_IDON)); i++) - barrier(); - if ((i == 100) || (READRDP(lp) & LE_C0_ERR)) { - printk ("LANCE unopened after %d ticks, csr0=%4.4x.\n", i, READRDP(lp)); - return -1; - } - - /* Clear IDON by writing a "1", enable interrupts and start lance */ - WRITERDP(lp, LE_C0_IDON); - WRITERDP(lp, LE_C0_INEA | LE_C0_STRT); - - return 0; -} - -static int lance_reset (struct net_device *dev) -{ - struct lance_private *lp = netdev_priv(dev); - int status; - - /* Stop the lance */ - WRITERAP(lp, LE_CSR0); - WRITERDP(lp, LE_C0_STOP); - - load_csrs (lp); - lance_init_ring (dev); - dev->trans_start = jiffies; /* prevent tx timeout */ - status = init_restart_lance (lp); -#ifdef DEBUG_DRIVER - printk ("Lance restart=%d\n", status); -#endif - return status; -} - -static int lance_rx (struct net_device *dev) -{ - struct lance_private *lp = netdev_priv(dev); - volatile struct lance_init_block *ib = lp->init_block; - volatile struct lance_rx_desc *rd; - unsigned char bits; -#ifdef TEST_HITS - int i; -#endif - -#ifdef TEST_HITS - printk ("["); - for (i = 0; i < RX_RING_SIZE; i++) { - if (i == lp->rx_new) - printk ("%s", - ib->brx_ring [i].rmd1_bits & LE_R1_OWN ? "_" : "X"); - else - printk ("%s", - ib->brx_ring [i].rmd1_bits & LE_R1_OWN ? "." : "1"); - } - printk ("]"); -#endif -#ifdef CONFIG_HP300 - blinken_leds(0x40, 0); -#endif - WRITERDP(lp, LE_C0_RINT | LE_C0_INEA); /* ack Rx int, reenable ints */ - for (rd = &ib->brx_ring [lp->rx_new]; /* For each Rx ring we own... */ - !((bits = rd->rmd1_bits) & LE_R1_OWN); - rd = &ib->brx_ring [lp->rx_new]) { - - /* We got an incomplete frame? */ - if ((bits & LE_R1_POK) != LE_R1_POK) { - dev->stats.rx_over_errors++; - dev->stats.rx_errors++; - continue; - } else if (bits & LE_R1_ERR) { - /* Count only the end frame as a rx error, - * not the beginning - */ - if (bits & LE_R1_BUF) dev->stats.rx_fifo_errors++; - if (bits & LE_R1_CRC) dev->stats.rx_crc_errors++; - if (bits & LE_R1_OFL) dev->stats.rx_over_errors++; - if (bits & LE_R1_FRA) dev->stats.rx_frame_errors++; - if (bits & LE_R1_EOP) dev->stats.rx_errors++; - } else { - int len = (rd->mblength & 0xfff) - 4; - struct sk_buff *skb = dev_alloc_skb (len+2); - - if (!skb) { - printk ("%s: Memory squeeze, deferring packet.\n", - dev->name); - dev->stats.rx_dropped++; - rd->mblength = 0; - rd->rmd1_bits = LE_R1_OWN; - lp->rx_new = (lp->rx_new + 1) & lp->rx_ring_mod_mask; - return 0; - } - - skb_reserve (skb, 2); /* 16 byte align */ - skb_put (skb, len); /* make room */ - skb_copy_to_linear_data(skb, - (unsigned char *)&(ib->rx_buf [lp->rx_new][0]), - len); - skb->protocol = eth_type_trans (skb, dev); - netif_rx (skb); - dev->stats.rx_packets++; - dev->stats.rx_bytes += len; - } - - /* Return the packet to the pool */ - rd->mblength = 0; - rd->rmd1_bits = LE_R1_OWN; - lp->rx_new = (lp->rx_new + 1) & lp->rx_ring_mod_mask; - } - return 0; -} - -static int lance_tx (struct net_device *dev) -{ - struct lance_private *lp = netdev_priv(dev); - volatile struct lance_init_block *ib = lp->init_block; - volatile struct lance_tx_desc *td; - int i, j; - int status; - -#ifdef CONFIG_HP300 - blinken_leds(0x80, 0); -#endif - /* csr0 is 2f3 */ - WRITERDP(lp, LE_C0_TINT | LE_C0_INEA); - /* csr0 is 73 */ - - j = lp->tx_old; - for (i = j; i != lp->tx_new; i = j) { - td = &ib->btx_ring [i]; - - /* If we hit a packet not owned by us, stop */ - if (td->tmd1_bits & LE_T1_OWN) - break; - - if (td->tmd1_bits & LE_T1_ERR) { - status = td->misc; - - dev->stats.tx_errors++; - if (status & LE_T3_RTY) dev->stats.tx_aborted_errors++; - if (status & LE_T3_LCOL) dev->stats.tx_window_errors++; - - if (status & LE_T3_CLOS) { - dev->stats.tx_carrier_errors++; - if (lp->auto_select) { - lp->tpe = 1 - lp->tpe; - printk("%s: Carrier Lost, trying %s\n", - dev->name, lp->tpe?"TPE":"AUI"); - /* Stop the lance */ - WRITERAP(lp, LE_CSR0); - WRITERDP(lp, LE_C0_STOP); - lance_init_ring (dev); - load_csrs (lp); - init_restart_lance (lp); - return 0; - } - } - - /* buffer errors and underflows turn off the transmitter */ - /* Restart the adapter */ - if (status & (LE_T3_BUF|LE_T3_UFL)) { - dev->stats.tx_fifo_errors++; - - printk ("%s: Tx: ERR_BUF|ERR_UFL, restarting\n", - dev->name); - /* Stop the lance */ - WRITERAP(lp, LE_CSR0); - WRITERDP(lp, LE_C0_STOP); - lance_init_ring (dev); - load_csrs (lp); - init_restart_lance (lp); - return 0; - } - } else if ((td->tmd1_bits & LE_T1_POK) == LE_T1_POK) { - /* - * So we don't count the packet more than once. - */ - td->tmd1_bits &= ~(LE_T1_POK); - - /* One collision before packet was sent. */ - if (td->tmd1_bits & LE_T1_EONE) - dev->stats.collisions++; - - /* More than one collision, be optimistic. */ - if (td->tmd1_bits & LE_T1_EMORE) - dev->stats.collisions += 2; - - dev->stats.tx_packets++; - } - - j = (j + 1) & lp->tx_ring_mod_mask; - } - lp->tx_old = j; - WRITERDP(lp, LE_C0_TINT | LE_C0_INEA); - return 0; -} - -static irqreturn_t -lance_interrupt (int irq, void *dev_id) -{ - struct net_device *dev = (struct net_device *)dev_id; - struct lance_private *lp = netdev_priv(dev); - int csr0; - - spin_lock (&lp->devlock); - - WRITERAP(lp, LE_CSR0); /* LANCE Controller Status */ - csr0 = READRDP(lp); - - PRINT_RINGS(); - - if (!(csr0 & LE_C0_INTR)) { /* Check if any interrupt has */ - spin_unlock (&lp->devlock); - return IRQ_NONE; /* been generated by the Lance. */ - } - - /* Acknowledge all the interrupt sources ASAP */ - WRITERDP(lp, csr0 & ~(LE_C0_INEA|LE_C0_TDMD|LE_C0_STOP|LE_C0_STRT|LE_C0_INIT)); - - if ((csr0 & LE_C0_ERR)) { - /* Clear the error condition */ - WRITERDP(lp, LE_C0_BABL|LE_C0_ERR|LE_C0_MISS|LE_C0_INEA); - } - - if (csr0 & LE_C0_RINT) - lance_rx (dev); - - if (csr0 & LE_C0_TINT) - lance_tx (dev); - - /* Log misc errors. */ - if (csr0 & LE_C0_BABL) - dev->stats.tx_errors++; /* Tx babble. */ - if (csr0 & LE_C0_MISS) - dev->stats.rx_errors++; /* Missed a Rx frame. */ - if (csr0 & LE_C0_MERR) { - printk("%s: Bus master arbitration failure, status %4.4x.\n", - dev->name, csr0); - /* Restart the chip. */ - WRITERDP(lp, LE_C0_STRT); - } - - if (lp->tx_full && netif_queue_stopped(dev) && (TX_BUFFS_AVAIL >= 0)) { - lp->tx_full = 0; - netif_wake_queue (dev); - } - - WRITERAP(lp, LE_CSR0); - WRITERDP(lp, LE_C0_BABL|LE_C0_CERR|LE_C0_MISS|LE_C0_MERR|LE_C0_IDON|LE_C0_INEA); - - spin_unlock (&lp->devlock); - return IRQ_HANDLED; -} - -int lance_open (struct net_device *dev) -{ - struct lance_private *lp = netdev_priv(dev); - int res; - - /* Install the Interrupt handler. Or we could shunt this out to specific drivers? */ - if (request_irq(lp->irq, lance_interrupt, IRQF_SHARED, lp->name, dev)) - return -EAGAIN; - - res = lance_reset(dev); - spin_lock_init(&lp->devlock); - netif_start_queue (dev); - - return res; -} -EXPORT_SYMBOL_GPL(lance_open); - -int lance_close (struct net_device *dev) -{ - struct lance_private *lp = netdev_priv(dev); - - netif_stop_queue (dev); - - /* Stop the LANCE */ - WRITERAP(lp, LE_CSR0); - WRITERDP(lp, LE_C0_STOP); - - free_irq(lp->irq, dev); - - return 0; -} -EXPORT_SYMBOL_GPL(lance_close); - -void lance_tx_timeout(struct net_device *dev) -{ - printk("lance_tx_timeout\n"); - lance_reset(dev); - dev->trans_start = jiffies; /* prevent tx timeout */ - netif_wake_queue (dev); -} -EXPORT_SYMBOL_GPL(lance_tx_timeout); - -int lance_start_xmit (struct sk_buff *skb, struct net_device *dev) -{ - struct lance_private *lp = netdev_priv(dev); - volatile struct lance_init_block *ib = lp->init_block; - int entry, skblen, len; - static int outs; - unsigned long flags; - - if (!TX_BUFFS_AVAIL) - return NETDEV_TX_LOCKED; - - netif_stop_queue (dev); - - skblen = skb->len; - -#ifdef DEBUG_DRIVER - /* dump the packet */ - { - int i; - - for (i = 0; i < 64; i++) { - if ((i % 16) == 0) - printk ("\n"); - printk ("%2.2x ", skb->data [i]); - } - } -#endif - len = (skblen <= ETH_ZLEN) ? ETH_ZLEN : skblen; - entry = lp->tx_new & lp->tx_ring_mod_mask; - ib->btx_ring [entry].length = (-len) | 0xf000; - ib->btx_ring [entry].misc = 0; - - if (skb->len < ETH_ZLEN) - memset((void *)&ib->tx_buf[entry][0], 0, ETH_ZLEN); - skb_copy_from_linear_data(skb, (void *)&ib->tx_buf[entry][0], skblen); - - /* Now, give the packet to the lance */ - ib->btx_ring [entry].tmd1_bits = (LE_T1_POK|LE_T1_OWN); - lp->tx_new = (lp->tx_new+1) & lp->tx_ring_mod_mask; - - outs++; - /* Kick the lance: transmit now */ - WRITERDP(lp, LE_C0_INEA | LE_C0_TDMD); - dev_kfree_skb (skb); - - spin_lock_irqsave (&lp->devlock, flags); - if (TX_BUFFS_AVAIL) - netif_start_queue (dev); - else - lp->tx_full = 1; - spin_unlock_irqrestore (&lp->devlock, flags); - - return NETDEV_TX_OK; -} -EXPORT_SYMBOL_GPL(lance_start_xmit); - -/* taken from the depca driver via a2065.c */ -static void lance_load_multicast (struct net_device *dev) -{ - struct lance_private *lp = netdev_priv(dev); - volatile struct lance_init_block *ib = lp->init_block; - volatile u16 *mcast_table = (u16 *)&ib->filter; - struct netdev_hw_addr *ha; - u32 crc; - - /* set all multicast bits */ - if (dev->flags & IFF_ALLMULTI){ - ib->filter [0] = 0xffffffff; - ib->filter [1] = 0xffffffff; - return; - } - /* clear the multicast filter */ - ib->filter [0] = 0; - ib->filter [1] = 0; - - /* Add addresses */ - netdev_for_each_mc_addr(ha, dev) { - crc = ether_crc_le(6, ha->addr); - crc = crc >> 26; - mcast_table [crc >> 4] |= 1 << (crc & 0xf); - } -} - - -void lance_set_multicast (struct net_device *dev) -{ - struct lance_private *lp = netdev_priv(dev); - volatile struct lance_init_block *ib = lp->init_block; - int stopped; - - stopped = netif_queue_stopped(dev); - if (!stopped) - netif_stop_queue (dev); - - while (lp->tx_old != lp->tx_new) - schedule(); - - WRITERAP(lp, LE_CSR0); - WRITERDP(lp, LE_C0_STOP); - lance_init_ring (dev); - - if (dev->flags & IFF_PROMISC) { - ib->mode |= LE_MO_PROM; - } else { - ib->mode &= ~LE_MO_PROM; - lance_load_multicast (dev); - } - load_csrs (lp); - init_restart_lance (lp); - - if (!stopped) - netif_start_queue (dev); -} -EXPORT_SYMBOL_GPL(lance_set_multicast); - -#ifdef CONFIG_NET_POLL_CONTROLLER -void lance_poll(struct net_device *dev) -{ - struct lance_private *lp = netdev_priv(dev); - - spin_lock (&lp->devlock); - WRITERAP(lp, LE_CSR0); - WRITERDP(lp, LE_C0_STRT); - spin_unlock (&lp->devlock); - lance_interrupt(dev->irq, dev); -} -#endif - -MODULE_LICENSE("GPL"); diff --git a/drivers/net/7990.h b/drivers/net/7990.h deleted file mode 100644 index 0a5837b96421..000000000000 --- a/drivers/net/7990.h +++ /dev/null @@ -1,254 +0,0 @@ -/* - * 7990.h -- LANCE ethernet IC generic routines. - * This is an attempt to separate out the bits of various ethernet - * drivers that are common because they all use the AMD 7990 LANCE - * (Local Area Network Controller for Ethernet) chip. - * - * Copyright (C) 05/1998 Peter Maydell - * - * Most of this stuff was obtained by looking at other LANCE drivers, - * in particular a2065.[ch]. The AMD C-LANCE datasheet was also helpful. - */ - -#ifndef _7990_H -#define _7990_H - -/* The lance only has two register locations. We communicate mostly via memory. */ -#define LANCE_RDP 0 /* Register Data Port */ -#define LANCE_RAP 2 /* Register Address Port */ - -/* Transmit/receive ring definitions. - * We allow the specific drivers to override these defaults if they want to. - * NB: according to lance.c, increasing the number of buffers is a waste - * of space and reduces the chance that an upper layer will be able to - * reorder queued Tx packets based on priority. [Clearly there is a minimum - * limit too: too small and we drop rx packets and can't tx at full speed.] - * 4+4 seems to be the usual setting; the atarilance driver uses 3 and 5. - */ - -/* Blast! This won't work. The problem is that we can't specify a default - * setting because that would cause the lance_init_block struct to be - * too long (and overflow the RAM on shared-memory cards like the HP LANCE. - */ -#ifndef LANCE_LOG_TX_BUFFERS -#define LANCE_LOG_TX_BUFFERS 1 -#define LANCE_LOG_RX_BUFFERS 3 -#endif - -#define TX_RING_SIZE (1<tx_old<=lp->tx_new)?\ - lp->tx_old+lp->tx_ring_mod_mask-lp->tx_new:\ - lp->tx_old - lp->tx_new-1) - -/* The LANCE only uses 24 bit addresses. This does the obvious thing. */ -#define LANCE_ADDR(x) ((int)(x) & ~0xff000000) - -/* Now the prototypes we export */ -extern int lance_open(struct net_device *dev); -extern int lance_close (struct net_device *dev); -extern int lance_start_xmit (struct sk_buff *skb, struct net_device *dev); -extern void lance_set_multicast (struct net_device *dev); -extern void lance_tx_timeout(struct net_device *dev); -#ifdef CONFIG_NET_POLL_CONTROLLER -extern void lance_poll(struct net_device *dev); -#endif - -#endif /* ndef _7990_H */ diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 0b3ea213b610..b686dab54ec6 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -287,27 +287,6 @@ config BMAC To compile this driver as a module, choose M here: the module will be called bmac. -config ARIADNE - tristate "Ariadne support" - depends on ZORRO - help - If you have a Village Tronic Ariadne Ethernet adapter, say Y. - Otherwise, say N. - - To compile this driver as a module, choose M here: the module - will be called ariadne. - -config A2065 - tristate "A2065 support" - depends on ZORRO - select CRC32 - help - If you have a Commodore A2065 Ethernet adapter, say Y. Otherwise, - say N. - - To compile this driver as a module, choose M here: the module - will be called a2065. - config HYDRA tristate "Hydra support" depends on ZORRO @@ -387,16 +366,6 @@ config MACMACE say Y and read the Ethernet-HOWTO, available from . -config MVME147_NET - tristate "MVME147 (Lance) Ethernet support" - depends on MVME147 - select CRC32 - help - Support for the on-board Ethernet interface on the Motorola MVME147 - single-board computer. Say Y here to include the - driver for this chip in your kernel. - To compile this driver as a module, choose M here. - config MVME16x_NET tristate "MVME16x Ethernet support" depends on MVME16x @@ -415,27 +384,6 @@ config BVME6000_NET in your kernel. To compile this driver as a module, choose M here. -config ATARILANCE - tristate "Atari Lance support" - depends on ATARI - help - Say Y to include support for several Atari Ethernet adapters based - on the AMD Lance chipset: RieblCard (with or without battery), or - PAMCard VME (also the version by Rhotron, with different addresses). - -config SUN3LANCE - tristate "Sun3/Sun3x on-board LANCE support" - depends on SUN3 || SUN3X - help - Most Sun3 and Sun3x motherboards (including the 3/50, 3/60 and 3/80) - featured an AMD Lance 10Mbit Ethernet controller on board; say Y - here to compile in the Linux driver for this and enable Ethernet. - General Linux information on the Sun 3 and 3x series (now - discontinued) is at - . - - If you're not building a kernel for a Sun 3, say N. - config SUN3_82586 bool "Sun3 on-board Intel 82586 support" depends on SUN3 @@ -445,14 +393,6 @@ config SUN3_82586 that this driver does not support 82586-based adapters on additional VME boards. -config HPLANCE - bool "HP on-board LANCE support" - depends on DIO - select CRC32 - help - If you want to use the builtin "LANCE" Ethernet controller on an - HP300 machine, say Y here. - config LASI_82596 tristate "Lasi ethernet" depends on GSC @@ -487,15 +427,6 @@ config XTENSA_XT2000_SONIC help This is the driver for the onboard card of the Xtensa XT2000 board. -config MIPS_AU1X00_ENET - tristate "MIPS AU1000 Ethernet support" - depends on MIPS_ALCHEMY - select PHYLIB - select CRC32 - help - If you have an Alchemy Semi AU1X00 based system - say Y. Otherwise, say N. - config SGI_IOC3_ETH bool "SGI IOC3 Ethernet" depends on PCI && SGI_IP27 @@ -545,19 +476,6 @@ config SH_ETH This driver supporting CPUs are: - SH7710, SH7712, SH7763, SH7619, SH7724, and SH7757. -config SUNLANCE - tristate "Sun LANCE support" - depends on SBUS - select CRC32 - help - This driver supports the "le" interface present on all 32-bit Sparc - systems, on some older Ultra systems and as an Sbus option. These - cards are based on the AMD Lance chipset, which is better known - via the NE2100 cards. - - To compile this driver as a module, choose M here: the module - will be called sunlance. - config HAPPYMEAL tristate "Sun Happy Meal 10/100baseT support" depends on SBUS || PCI @@ -673,18 +591,6 @@ config ELMC_II To compile this driver as a module, choose M here. The module will be called 3c527. -config LANCE - tristate "AMD LANCE and PCnet (AT1500 and NE2100) support" - depends on ISA && ISA_DMA_API - help - If you have a network (Ethernet) card of this type, say Y and read - the Ethernet-HOWTO, available from - . Some LinkSys cards are - of this type. - - To compile this driver as a module, choose M here: the module - will be called lance. This is recommended. - config NET_VENDOR_SMC bool "Western Digital/SMC cards" depends on ISA || MCA || EISA || MAC @@ -1020,17 +926,6 @@ config NI52 To compile this driver as a module, choose M here. The module will be called ni52. -config NI65 - tristate "NI6510 support" - depends on NET_VENDOR_RACAL && ISA && ISA_DMA_API - help - If you have a network (Ethernet) card of this type, say Y and read - the Ethernet-HOWTO, available from - . - - To compile this driver as a module, choose M here. The module - will be called ni65. - config DNET tristate "Dave ethernet support (DNET)" depends on NET_ETHERNET && HAS_IOMEM @@ -1056,19 +951,6 @@ config AT1700 To compile this driver as a module, choose M here. The module will be called at1700. -config DEPCA - tristate "DEPCA, DE10x, DE200, DE201, DE202, DE422 support" - depends on ISA || EISA || MCA - select CRC32 - ---help--- - If you have a network (Ethernet) card of this type, say Y and read - the Ethernet-HOWTO, available from - as well as - . - - To compile this driver as a module, choose M here. The module - will be called depca. - config HP100 tristate "HP 10/100VG PCLAN (ISA, EISA, PCI) support" depends on ISA || EISA || PCI @@ -1287,32 +1169,6 @@ config NET_PCI will be asked for your specific card in the following questions. If you are unsure, say Y. -config PCNET32 - tristate "AMD PCnet32 PCI support" - depends on NET_PCI && PCI - select CRC32 - select MII - help - If you have a PCnet32 or PCnetPCI based network (Ethernet) card, - answer Y here and read the Ethernet-HOWTO, available from - . - - To compile this driver as a module, choose M here. The module - will be called pcnet32. - -config AMD8111_ETH - tristate "AMD 8111 (new PCI lance) support" - depends on NET_PCI && PCI - select CRC32 - select MII - help - If you have an AMD 8111-based PCI lance ethernet card, - answer Y here and read the Ethernet-HOWTO, available from - . - - To compile this driver as a module, choose M here. The module - will be called amd8111e. - config ADAPTEC_STARFIRE tristate "Adaptec Starfire/DuraLAN support" depends on NET_PCI && PCI @@ -1834,15 +1690,6 @@ config SGISEEQ Say Y here if you have an Seeq based Ethernet network card. This is used in many Silicon Graphics machines. -config DECLANCE - tristate "DEC LANCE ethernet controller support" - depends on MACH_DECSTATION - select CRC32 - help - This driver is for the series of Ethernet controllers produced by - DEC (now Compaq) based on the AMD Lance chipset, including the - DEPCA series. (This chipset is better known via the NE2100 cards.) - config FEC bool "FEC ethernet controller (of ColdFire and some i.MX CPUs)" depends on M523x || M527x || M5272 || M528x || M520x || M532x || \ diff --git a/drivers/net/Makefile b/drivers/net/Makefile index d4d6744ab607..59b6cc932037 100644 --- a/drivers/net/Makefile +++ b/drivers/net/Makefile @@ -56,7 +56,6 @@ obj-$(CONFIG_PLIP) += plip.o obj-$(CONFIG_ROADRUNNER) += rrunner.o obj-$(CONFIG_HAPPYMEAL) += sunhme.o -obj-$(CONFIG_SUNLANCE) += sunlance.o obj-$(CONFIG_SUNQE) += sunqe.o obj-$(CONFIG_SUNBMAC) += sunbmac.o obj-$(CONFIG_SUNGEM) += sungem.o sungem_phy.o @@ -67,7 +66,6 @@ obj-$(CONFIG_MACE) += mace.o obj-$(CONFIG_BMAC) += bmac.o obj-$(CONFIG_NE2K_PCI) += ne2k-pci.o 8390.o -obj-$(CONFIG_PCNET32) += pcnet32.o obj-$(CONFIG_E100) += e100.o obj-$(CONFIG_TLAN) += tlan.o obj-$(CONFIG_EPIC100) += epic100.o @@ -177,9 +175,7 @@ obj-$(CONFIG_MACVLAN) += macvlan.o obj-$(CONFIG_MACVTAP) += macvtap.o obj-$(CONFIG_DE600) += de600.o obj-$(CONFIG_DE620) += de620.o -obj-$(CONFIG_LANCE) += lance.o obj-$(CONFIG_SUN3_82586) += sun3_82586.o -obj-$(CONFIG_SUN3LANCE) += sun3lance.o obj-$(CONFIG_DEFXX) += defxx.o obj-$(CONFIG_SGISEEQ) += sgiseeq.o obj-$(CONFIG_SGI_O2MACE_ETH) += meth.o @@ -194,12 +190,10 @@ obj-$(CONFIG_8139CP) += 8139cp.o obj-$(CONFIG_8139TOO) += 8139too.o obj-$(CONFIG_ZNET) += znet.o obj-$(CONFIG_CPMAC) += cpmac.o -obj-$(CONFIG_DEPCA) += depca.o obj-$(CONFIG_EWRK3) += ewrk3.o obj-$(CONFIG_ATP) += atp.o obj-$(CONFIG_NI5010) += ni5010.o obj-$(CONFIG_NI52) += ni52.o -obj-$(CONFIG_NI65) += ni65.o obj-$(CONFIG_ELPLUS) += 3c505.o obj-$(CONFIG_AC3200) += ac3200.o 8390.o obj-$(CONFIG_APRICOT) += 82596.o @@ -214,19 +208,12 @@ obj-$(CONFIG_LP486E) += lp486e.o obj-$(CONFIG_ETH16I) += eth16i.o obj-$(CONFIG_ZORRO8390) += zorro8390.o -obj-$(CONFIG_HPLANCE) += hplance.o 7990.o -obj-$(CONFIG_MVME147_NET) += mvme147.o 7990.o obj-$(CONFIG_EQUALIZER) += eql.o obj-$(CONFIG_KORINA) += korina.o obj-$(CONFIG_MIPS_JAZZ_SONIC) += jazzsonic.o -obj-$(CONFIG_MIPS_AU1X00_ENET) += au1000_eth.o obj-$(CONFIG_MIPS_SIM_NET) += mipsnet.o obj-$(CONFIG_SGI_IOC3_ETH) += ioc3-eth.o -obj-$(CONFIG_DECLANCE) += declance.o -obj-$(CONFIG_ATARILANCE) += atarilance.o -obj-$(CONFIG_A2065) += a2065.o obj-$(CONFIG_HYDRA) += hydra.o -obj-$(CONFIG_ARIADNE) += ariadne.o obj-$(CONFIG_CS89x0) += cs89x0.o obj-$(CONFIG_MACSONIC) += macsonic.o obj-$(CONFIG_MACMACE) += macmace.o @@ -236,7 +223,6 @@ obj-$(CONFIG_VETH) += veth.o obj-$(CONFIG_NET_NETX) += netx-eth.o obj-$(CONFIG_DL2K) += dl2k.o obj-$(CONFIG_R8169) += r8169.o -obj-$(CONFIG_AMD8111_ETH) += amd8111e.o obj-$(CONFIG_IBMVETH) += ibmveth.o obj-$(CONFIG_S2IO) += s2io.o obj-$(CONFIG_VXGE) += vxge/ diff --git a/drivers/net/a2065.c b/drivers/net/a2065.c deleted file mode 100644 index e1e1b07d9b8d..000000000000 --- a/drivers/net/a2065.c +++ /dev/null @@ -1,781 +0,0 @@ -/* - * Amiga Linux/68k A2065 Ethernet Driver - * - * (C) Copyright 1995-2003 by Geert Uytterhoeven - * - * Fixes and tips by: - * - Janos Farkas (CHEXUM@sparta.banki.hu) - * - Jes Degn Soerensen (jds@kom.auc.dk) - * - Matt Domsch (Matt_Domsch@dell.com) - * - * ---------------------------------------------------------------------------- - * - * This program is based on - * - * ariadne.?: Amiga Linux/68k Ariadne Ethernet Driver - * (C) Copyright 1995 by Geert Uytterhoeven, - * Peter De Schrijver - * - * lance.c: An AMD LANCE ethernet driver for linux. - * Written 1993-94 by Donald Becker. - * - * Am79C960: PCnet(tm)-ISA Single-Chip Ethernet Controller - * Advanced Micro Devices - * Publication #16907, Rev. B, Amendment/0, May 1994 - * - * ---------------------------------------------------------------------------- - * - * This file is subject to the terms and conditions of the GNU General Public - * License. See the file COPYING in the main directory of the Linux - * distribution for more details. - * - * ---------------------------------------------------------------------------- - * - * The A2065 is a Zorro-II board made by Commodore/Ameristar. It contains: - * - * - an Am7990 Local Area Network Controller for Ethernet (LANCE) with - * both 10BASE-2 (thin coax) and AUI (DB-15) connectors - */ - -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - -/*#define DEBUG*/ -/*#define TEST_HITS*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "a2065.h" - -/* Transmit/Receive Ring Definitions */ - -#define LANCE_LOG_TX_BUFFERS (2) -#define LANCE_LOG_RX_BUFFERS (4) - -#define TX_RING_SIZE (1 << LANCE_LOG_TX_BUFFERS) -#define RX_RING_SIZE (1 << LANCE_LOG_RX_BUFFERS) - -#define TX_RING_MOD_MASK (TX_RING_SIZE - 1) -#define RX_RING_MOD_MASK (RX_RING_SIZE - 1) - -#define PKT_BUF_SIZE (1544) -#define RX_BUFF_SIZE PKT_BUF_SIZE -#define TX_BUFF_SIZE PKT_BUF_SIZE - -/* Layout of the Lance's RAM Buffer */ - -struct lance_init_block { - unsigned short mode; /* Pre-set mode (reg. 15) */ - unsigned char phys_addr[6]; /* Physical ethernet address */ - unsigned filter[2]; /* Multicast filter. */ - - /* Receive and transmit ring base, along with extra bits. */ - unsigned short rx_ptr; /* receive descriptor addr */ - unsigned short rx_len; /* receive len and high addr */ - unsigned short tx_ptr; /* transmit descriptor addr */ - unsigned short tx_len; /* transmit len and high addr */ - - /* The Tx and Rx ring entries must aligned on 8-byte boundaries. */ - struct lance_rx_desc brx_ring[RX_RING_SIZE]; - struct lance_tx_desc btx_ring[TX_RING_SIZE]; - - char rx_buf[RX_RING_SIZE][RX_BUFF_SIZE]; - char tx_buf[TX_RING_SIZE][TX_BUFF_SIZE]; -}; - -/* Private Device Data */ - -struct lance_private { - char *name; - volatile struct lance_regs *ll; - volatile struct lance_init_block *init_block; /* Hosts view */ - volatile struct lance_init_block *lance_init_block; /* Lance view */ - - int rx_new, tx_new; - int rx_old, tx_old; - - int lance_log_rx_bufs, lance_log_tx_bufs; - int rx_ring_mod_mask, tx_ring_mod_mask; - - int tpe; /* cable-selection is TPE */ - int auto_select; /* cable-selection by carrier */ - unsigned short busmaster_regval; - -#ifdef CONFIG_SUNLANCE - struct Linux_SBus_DMA *ledma; /* if set this points to ledma and arch=4m */ - int burst_sizes; /* ledma SBus burst sizes */ -#endif - struct timer_list multicast_timer; -}; - -#define LANCE_ADDR(x) ((int)(x) & ~0xff000000) - -/* Load the CSR registers */ -static void load_csrs(struct lance_private *lp) -{ - volatile struct lance_regs *ll = lp->ll; - volatile struct lance_init_block *aib = lp->lance_init_block; - int leptr = LANCE_ADDR(aib); - - ll->rap = LE_CSR1; - ll->rdp = (leptr & 0xFFFF); - ll->rap = LE_CSR2; - ll->rdp = leptr >> 16; - ll->rap = LE_CSR3; - ll->rdp = lp->busmaster_regval; - - /* Point back to csr0 */ - ll->rap = LE_CSR0; -} - -/* Setup the Lance Rx and Tx rings */ -static void lance_init_ring(struct net_device *dev) -{ - struct lance_private *lp = netdev_priv(dev); - volatile struct lance_init_block *ib = lp->init_block; - volatile struct lance_init_block *aib = lp->lance_init_block; - /* for LANCE_ADDR computations */ - int leptr; - int i; - - /* Lock out other processes while setting up hardware */ - netif_stop_queue(dev); - lp->rx_new = lp->tx_new = 0; - lp->rx_old = lp->tx_old = 0; - - ib->mode = 0; - - /* Copy the ethernet address to the lance init block - * Note that on the sparc you need to swap the ethernet address. - */ - ib->phys_addr[0] = dev->dev_addr[1]; - ib->phys_addr[1] = dev->dev_addr[0]; - ib->phys_addr[2] = dev->dev_addr[3]; - ib->phys_addr[3] = dev->dev_addr[2]; - ib->phys_addr[4] = dev->dev_addr[5]; - ib->phys_addr[5] = dev->dev_addr[4]; - - /* Setup the Tx ring entries */ - netdev_dbg(dev, "TX rings:\n"); - for (i = 0; i <= 1 << lp->lance_log_tx_bufs; i++) { - leptr = LANCE_ADDR(&aib->tx_buf[i][0]); - ib->btx_ring[i].tmd0 = leptr; - ib->btx_ring[i].tmd1_hadr = leptr >> 16; - ib->btx_ring[i].tmd1_bits = 0; - ib->btx_ring[i].length = 0xf000; /* The ones required by tmd2 */ - ib->btx_ring[i].misc = 0; - if (i < 3) - netdev_dbg(dev, "%d: 0x%08x\n", i, leptr); - } - - /* Setup the Rx ring entries */ - netdev_dbg(dev, "RX rings:\n"); - for (i = 0; i < 1 << lp->lance_log_rx_bufs; i++) { - leptr = LANCE_ADDR(&aib->rx_buf[i][0]); - - ib->brx_ring[i].rmd0 = leptr; - ib->brx_ring[i].rmd1_hadr = leptr >> 16; - ib->brx_ring[i].rmd1_bits = LE_R1_OWN; - ib->brx_ring[i].length = -RX_BUFF_SIZE | 0xf000; - ib->brx_ring[i].mblength = 0; - if (i < 3) - netdev_dbg(dev, "%d: 0x%08x\n", i, leptr); - } - - /* Setup the initialization block */ - - /* Setup rx descriptor pointer */ - leptr = LANCE_ADDR(&aib->brx_ring); - ib->rx_len = (lp->lance_log_rx_bufs << 13) | (leptr >> 16); - ib->rx_ptr = leptr; - netdev_dbg(dev, "RX ptr: %08x\n", leptr); - - /* Setup tx descriptor pointer */ - leptr = LANCE_ADDR(&aib->btx_ring); - ib->tx_len = (lp->lance_log_tx_bufs << 13) | (leptr >> 16); - ib->tx_ptr = leptr; - netdev_dbg(dev, "TX ptr: %08x\n", leptr); - - /* Clear the multicast filter */ - ib->filter[0] = 0; - ib->filter[1] = 0; -} - -static int init_restart_lance(struct lance_private *lp) -{ - volatile struct lance_regs *ll = lp->ll; - int i; - - ll->rap = LE_CSR0; - ll->rdp = LE_C0_INIT; - - /* Wait for the lance to complete initialization */ - for (i = 0; (i < 100) && !(ll->rdp & (LE_C0_ERR | LE_C0_IDON)); i++) - barrier(); - if ((i == 100) || (ll->rdp & LE_C0_ERR)) { - pr_err("unopened after %d ticks, csr0=%04x\n", i, ll->rdp); - return -EIO; - } - - /* Clear IDON by writing a "1", enable interrupts and start lance */ - ll->rdp = LE_C0_IDON; - ll->rdp = LE_C0_INEA | LE_C0_STRT; - - return 0; -} - -static int lance_rx(struct net_device *dev) -{ - struct lance_private *lp = netdev_priv(dev); - volatile struct lance_init_block *ib = lp->init_block; - volatile struct lance_regs *ll = lp->ll; - volatile struct lance_rx_desc *rd; - unsigned char bits; - -#ifdef TEST_HITS - int i; - char buf[RX_RING_SIZE + 1]; - - for (i = 0; i < RX_RING_SIZE; i++) { - char r1_own = ib->brx_ring[i].rmd1_bits & LE_R1_OWN; - if (i == lp->rx_new) - buf[i] = r1_own ? '_' : 'X'; - else - buf[i] = r1_own ? '.' : '1'; - } - buf[RX_RING_SIZE] = 0; - - pr_debug("RxRing TestHits: [%s]\n", buf); -#endif - - ll->rdp = LE_C0_RINT | LE_C0_INEA; - for (rd = &ib->brx_ring[lp->rx_new]; - !((bits = rd->rmd1_bits) & LE_R1_OWN); - rd = &ib->brx_ring[lp->rx_new]) { - - /* We got an incomplete frame? */ - if ((bits & LE_R1_POK) != LE_R1_POK) { - dev->stats.rx_over_errors++; - dev->stats.rx_errors++; - continue; - } else if (bits & LE_R1_ERR) { - /* Count only the end frame as a rx error, - * not the beginning - */ - if (bits & LE_R1_BUF) - dev->stats.rx_fifo_errors++; - if (bits & LE_R1_CRC) - dev->stats.rx_crc_errors++; - if (bits & LE_R1_OFL) - dev->stats.rx_over_errors++; - if (bits & LE_R1_FRA) - dev->stats.rx_frame_errors++; - if (bits & LE_R1_EOP) - dev->stats.rx_errors++; - } else { - int len = (rd->mblength & 0xfff) - 4; - struct sk_buff *skb = dev_alloc_skb(len + 2); - - if (!skb) { - netdev_warn(dev, "Memory squeeze, deferring packet\n"); - dev->stats.rx_dropped++; - rd->mblength = 0; - rd->rmd1_bits = LE_R1_OWN; - lp->rx_new = (lp->rx_new + 1) & lp->rx_ring_mod_mask; - return 0; - } - - skb_reserve(skb, 2); /* 16 byte align */ - skb_put(skb, len); /* make room */ - skb_copy_to_linear_data(skb, - (unsigned char *)&ib->rx_buf[lp->rx_new][0], - len); - skb->protocol = eth_type_trans(skb, dev); - netif_rx(skb); - dev->stats.rx_packets++; - dev->stats.rx_bytes += len; - } - - /* Return the packet to the pool */ - rd->mblength = 0; - rd->rmd1_bits = LE_R1_OWN; - lp->rx_new = (lp->rx_new + 1) & lp->rx_ring_mod_mask; - } - return 0; -} - -static int lance_tx(struct net_device *dev) -{ - struct lance_private *lp = netdev_priv(dev); - volatile struct lance_init_block *ib = lp->init_block; - volatile struct lance_regs *ll = lp->ll; - volatile struct lance_tx_desc *td; - int i, j; - int status; - - /* csr0 is 2f3 */ - ll->rdp = LE_C0_TINT | LE_C0_INEA; - /* csr0 is 73 */ - - j = lp->tx_old; - for (i = j; i != lp->tx_new; i = j) { - td = &ib->btx_ring[i]; - - /* If we hit a packet not owned by us, stop */ - if (td->tmd1_bits & LE_T1_OWN) - break; - - if (td->tmd1_bits & LE_T1_ERR) { - status = td->misc; - - dev->stats.tx_errors++; - if (status & LE_T3_RTY) - dev->stats.tx_aborted_errors++; - if (status & LE_T3_LCOL) - dev->stats.tx_window_errors++; - - if (status & LE_T3_CLOS) { - dev->stats.tx_carrier_errors++; - if (lp->auto_select) { - lp->tpe = 1 - lp->tpe; - netdev_err(dev, "Carrier Lost, trying %s\n", - lp->tpe ? "TPE" : "AUI"); - /* Stop the lance */ - ll->rap = LE_CSR0; - ll->rdp = LE_C0_STOP; - lance_init_ring(dev); - load_csrs(lp); - init_restart_lance(lp); - return 0; - } - } - - /* buffer errors and underflows turn off - * the transmitter, so restart the adapter - */ - if (status & (LE_T3_BUF | LE_T3_UFL)) { - dev->stats.tx_fifo_errors++; - - netdev_err(dev, "Tx: ERR_BUF|ERR_UFL, restarting\n"); - /* Stop the lance */ - ll->rap = LE_CSR0; - ll->rdp = LE_C0_STOP; - lance_init_ring(dev); - load_csrs(lp); - init_restart_lance(lp); - return 0; - } - } else if ((td->tmd1_bits & LE_T1_POK) == LE_T1_POK) { - /* So we don't count the packet more than once. */ - td->tmd1_bits &= ~(LE_T1_POK); - - /* One collision before packet was sent. */ - if (td->tmd1_bits & LE_T1_EONE) - dev->stats.collisions++; - - /* More than one collision, be optimistic. */ - if (td->tmd1_bits & LE_T1_EMORE) - dev->stats.collisions += 2; - - dev->stats.tx_packets++; - } - - j = (j + 1) & lp->tx_ring_mod_mask; - } - lp->tx_old = j; - ll->rdp = LE_C0_TINT | LE_C0_INEA; - return 0; -} - -static int lance_tx_buffs_avail(struct lance_private *lp) -{ - if (lp->tx_old <= lp->tx_new) - return lp->tx_old + lp->tx_ring_mod_mask - lp->tx_new; - return lp->tx_old - lp->tx_new - 1; -} - -static irqreturn_t lance_interrupt(int irq, void *dev_id) -{ - struct net_device *dev = dev_id; - struct lance_private *lp = netdev_priv(dev); - volatile struct lance_regs *ll = lp->ll; - int csr0; - - ll->rap = LE_CSR0; /* LANCE Controller Status */ - csr0 = ll->rdp; - - if (!(csr0 & LE_C0_INTR)) /* Check if any interrupt has */ - return IRQ_NONE; /* been generated by the Lance. */ - - /* Acknowledge all the interrupt sources ASAP */ - ll->rdp = csr0 & ~(LE_C0_INEA | LE_C0_TDMD | LE_C0_STOP | LE_C0_STRT | - LE_C0_INIT); - - if (csr0 & LE_C0_ERR) { - /* Clear the error condition */ - ll->rdp = LE_C0_BABL | LE_C0_ERR | LE_C0_MISS | LE_C0_INEA; - } - - if (csr0 & LE_C0_RINT) - lance_rx(dev); - - if (csr0 & LE_C0_TINT) - lance_tx(dev); - - /* Log misc errors. */ - if (csr0 & LE_C0_BABL) - dev->stats.tx_errors++; /* Tx babble. */ - if (csr0 & LE_C0_MISS) - dev->stats.rx_errors++; /* Missed a Rx frame. */ - if (csr0 & LE_C0_MERR) { - netdev_err(dev, "Bus master arbitration failure, status %04x\n", - csr0); - /* Restart the chip. */ - ll->rdp = LE_C0_STRT; - } - - if (netif_queue_stopped(dev) && lance_tx_buffs_avail(lp) > 0) - netif_wake_queue(dev); - - ll->rap = LE_CSR0; - ll->rdp = (LE_C0_BABL | LE_C0_CERR | LE_C0_MISS | LE_C0_MERR | - LE_C0_IDON | LE_C0_INEA); - return IRQ_HANDLED; -} - -static int lance_open(struct net_device *dev) -{ - struct lance_private *lp = netdev_priv(dev); - volatile struct lance_regs *ll = lp->ll; - int ret; - - /* Stop the Lance */ - ll->rap = LE_CSR0; - ll->rdp = LE_C0_STOP; - - /* Install the Interrupt handler */ - ret = request_irq(IRQ_AMIGA_PORTS, lance_interrupt, IRQF_SHARED, - dev->name, dev); - if (ret) - return ret; - - load_csrs(lp); - lance_init_ring(dev); - - netif_start_queue(dev); - - return init_restart_lance(lp); -} - -static