patch-2.4.6 linux/drivers/net/am79c961a.c

Next file: linux/drivers/net/appletalk/ipddp.c
Previous file: linux/drivers/net/aironet4500_proc.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.5/linux/drivers/net/am79c961a.c linux/drivers/net/am79c961a.c
@@ -1,7 +1,7 @@
 /*
  *  linux/drivers/net/am79c961.c
  *
- *  by Russell King <rmk@arm.linux.org.uk> 1995-2000.
+ *  by Russell King <rmk@arm.linux.org.uk> 1995-2001.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -10,9 +10,9 @@
  * Derived from various things including skeleton.c
  *
  * This is a special driver for the am79c961A Lance chip used in the
- * Intel (formally Digital Equipment Corp) EBSA110 platform.
+ * Intel (formally Digital Equipment Corp) EBSA110 platform.  Please
+ * note that this can not be built as a module (it doesn't make sense).
  */
-#include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/types.h>
@@ -35,7 +35,6 @@
 #include <asm/irq.h>
 #include <asm/io.h>
 #include <asm/dma.h>
-#include <asm/ecard.h>
 
 #define TX_BUFFERS 15
 #define RX_BUFFERS 25
@@ -46,45 +45,42 @@
 
 static unsigned int net_debug = NET_DEBUG;
 
-static char *version = "am79c961 ethernet driver (c) 1995 R.M.King v0.02\n";
+static const char version[] =
+	"am79c961 ethernet driver (C) 1995-2001 Russell King v0.04\n";
 
 /* --------------------------------------------------------------------------- */
 
 #ifdef __arm__
-static void
-write_rreg (unsigned long base, unsigned int reg, unsigned short val)
+static void write_rreg(u_long base, u_int reg, u_int val)
 {
 	__asm__("str%?h	%1, [%2]	@ NET_RAP
 		str%?h	%0, [%2, #-4]	@ NET_RDP
-		" : : "r" (val), "r" (reg), "r" (0xf0000464));
+		" : : "r" (val), "r" (reg), "r" (ISAIO_BASE + 0x0464));
 }
 
-static inline unsigned short
-read_rreg (unsigned int base_addr, unsigned int reg)
+static inline unsigned short read_rreg(u_long base_addr, u_int reg)
 {
 	unsigned short v;
 	__asm__("str%?h	%1, [%2]	@ NET_RAP
 		ldr%?h	%0, [%2, #-4]	@ NET_RDP
-		" : "=r" (v): "r" (reg), "r" (0xf0000464));
+		" : "=r" (v): "r" (reg), "r" (ISAIO_BASE + 0x0464));
 	return v;
 }
 
-static inline void
-write_ireg (unsigned long base, unsigned int reg, unsigned short val)
+static inline void write_ireg(u_long base, u_int reg, u_int val)
 {
 	__asm__("str%?h	%1, [%2]	@ NET_RAP
 		str%?h	%0, [%2, #8]	@ NET_IDP
-		" : : "r" (val), "r" (reg), "r" (0xf0000464));
+		" : : "r" (val), "r" (reg), "r" (ISAIO_BASE + 0x0464));
 }
 
-#define am_writeword(dev,off,val)\
-	__asm__("str%?h	%0, [%1]" : : \
-		"r" ((val) & 0xffff), "r" (0xe0000000 + ((off) << 1)));
+#define am_writeword(dev,off,val) __raw_writew(val, ISAMEM_BASE + ((off) << 1))
+#define am_readword(dev,off)      __raw_readw(ISAMEM_BASE + ((off) << 1))
 
 static inline void
 am_writebuffer(struct net_device *dev, u_int offset, unsigned char *buf, unsigned int length)
 {
-	offset = 0xe0000000 + (offset << 1);
+	offset = ISAMEM_BASE + (offset << 1);
 	length = (length + 1) & ~1;
 	if ((int)buf & 2) {
 		__asm__ __volatile__("str%?h	%2, [%0], #4"
@@ -114,23 +110,10 @@
 	}
 }
 
-/*
- * This reads a 16-bit quantity in little-endian
- * mode from the am79c961 buffer.
- */
-static inline unsigned short am_readword(struct net_device *dev, u_int off)
-{
-	unsigned long address = 0xe0000000 + (off << 1);
-	unsigned short val;
-
-	__asm__("ldr%?h	%0, [%1]" : "=r" (val): "r" (address));
-	return val;
-}
-
 static inline void
 am_readbuffer(struct net_device *dev, u_int offset, unsigned char *buf, unsigned int length)
 {
-	offset = 0xe0000000 + (offset << 1);
+	offset = ISAMEM_BASE + (offset << 1);
 	length = (length + 1) & ~1;
 	if ((int)buf & 2) {
 		unsigned int tmp;
@@ -274,12 +257,7 @@
 }
 
 /*
- * Open/initialize the board.  This is called (in the current kernel)
- * sometime after booting when the 'ifconfig' program is run.
- *
- * This routine should set everything up anew at each open, even
- * registers that "should" only need to be set once at boot, so that
- * there is non-reboot way to recover if something goes wrong.
+ * Open/initialize the board.
  */
 static int
 am79c961_open(struct net_device *dev)
@@ -322,8 +300,7 @@
 }
 
 /*
- * Get the current statistics.	This may be called with the card open or
- * closed.
+ * Get the current statistics.
  */
 static struct net_device_stats *am79c961_getstats (struct net_device *dev)
 {
@@ -367,7 +344,7 @@
 }
 
 /*
- * Set or clear promiscuous/multicast mode filter for this adaptor.
+ * Set or clear promiscuous/multicast mode filter for this adapter.
  */
 static void am79c961_setmulticastlist (struct net_device *dev)
 {
@@ -478,10 +455,8 @@
 	 * then the tx ring is full and we can't add another
 	 * packet.
 	 */
-	if (am_readword(dev, priv->txhdr + (priv->txhead << 3) + 2) & TMD_OWN) {
-		printk(KERN_DEBUG"tx ring full, stopping queue\n");
+	if (am_readword(dev, priv->txhdr + (priv->txhead << 3) + 2) & TMD_OWN)
 		netif_stop_queue(dev);
-	}
 
 	dev_kfree_skb(skb);
 
@@ -557,9 +532,7 @@
 	do {
 		u_int hdraddr;
 		u_int status;
-int bufnum;
 
-bufnum = priv->txtail;
 		hdraddr = priv->txhdr + (priv->txtail << 3);
 		status = am_readword (dev, hdraddr + 2);
 		if (status & TMD_OWN)
@@ -654,7 +627,6 @@
 	if (!dev)
 		goto out;
 
-	SET_MODULE_OWNER(dev);
 	priv = dev->priv;
 
 	/*
@@ -668,7 +640,7 @@
 	/*
 	 * Reset the device.
 	 */
-	inb((dev->base_addr + NET_RESET) >> 1);
+	inb(dev->base_addr + NET_RESET);
 	udelay(5);
 
 	/*
@@ -676,21 +648,20 @@
 	 * ether address.
 	 */
     	ret = -ENODEV;
-	if (inb(dev->base_addr >> 1) != 0x08 ||
-	    inb((dev->base_addr >> 1) + 1) != 00 ||
-	    inb((dev->base_addr >> 1) + 2) != 0x2b)
+	if (inb(dev->base_addr) != 0x08 ||
+	    inb(dev->base_addr + 2) != 0x00 ||
+	    inb(dev->base_addr + 4) != 0x2b)
 	    	goto nodev;
 
 	if (!request_region(dev->base_addr, 0x18, dev->name))
 		goto nodev;
 
 	am79c961_banner();
-	printk(KERN_INFO "%s: am79c961 found at %08lx, IRQ%d, ether address ",
-		dev->name, dev->base_addr, dev->irq);
+	printk(KERN_INFO "%s: ether address ", dev->name);
 
 	/* Retrive and print the ethernet address. */
 	for (i = 0; i < 6; i++) {
-		dev->dev_addr[i] = inb((dev->base_addr >> 1) + i) & 0xff;
+		dev->dev_addr[i] = inb(dev->base_addr + i * 2) & 0xff;
 		printk (i == 5 ? "%02x\n" : "%02x:", dev->dev_addr[i]);
 	}
 
@@ -715,4 +686,4 @@
 	return ret;
 }
 
-module_init(am79c961_init);
+__initcall(am79c961_init);

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)