patch-1.3.39 linux/drivers/net/de620.c

Next file: linux/drivers/net/depca.c
Previous file: linux/drivers/net/de600.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.38/linux/drivers/net/de620.c linux/drivers/net/de620.c
@@ -1,5 +1,5 @@
 /*
- *	de620.c $Revision: 1.31 $ BETA
+ *	de620.c $Revision: 1.40 $ BETA
  *
  *
  *	Linux driver for the D-Link DE-620 Ethernet pocket adapter.
@@ -39,7 +39,7 @@
  *
  *****************************************************************************/
 static const char *version =
-	"de620.c: $Revision: 1.31 $,  Bjorn Ekwall <bj0rn@blox.se>\n";
+	"de620.c: $Revision: 1.40 $,  Bjorn Ekwall <bj0rn@blox.se>\n";
 
 /***********************************************************************
  *
@@ -57,6 +57,22 @@
  */
 
 /*
+ * This driver assumes that the printer port is a "normal",
+ * dumb, uni-directional port!
+ * If your port is "fancy" in any way, please try to set it to "normal"
+ * with your BIOS setup.  I have no access to machines with bi-directional
+ * ports, so I can't test such a driver :-(
+ * (Yes, I _know_ it is possible to use DE620 with bidirectional ports...)
+ *
+ * There are some clones of DE620 out there, with different names.
+ * If the current driver does not recognize a clone, try to change
+ * the following #define to:
+ *
+ * #define DE620_CLONE 1
+ */
+#define DE620_CLONE 0
+
+/*
  * If the adapter has problems with high speeds, enable this #define
  * otherwise full printerport speed will be attempted.
  *
@@ -100,18 +116,8 @@
 #define COUNT_LOOPS
  */
 #endif
-static int bnc = 0, utp = 0;
-/*
- * Force media with insmod:
- *	insmod de620.o bnc=1
- * or
- *	insmod de620.o utp=1
- */
 
-#ifdef MODULE
 #include <linux/module.h>
-#include <linux/version.h>
-#endif
 
 #include <linux/kernel.h>
 #include <linux/sched.h>
@@ -165,6 +171,27 @@
 #define PRINTK(x) /**/
 #endif
 
+
+/*
+ * Force media with insmod:
+ *	insmod de620.o bnc=1
+ * or
+ *	insmod de620.o utp=1
+ *
+ * Force io and/or irq with insmod:
+ *	insmod de620.o io=0x378 irq=7
+ *
+ * Make a clone skip the Ethernet-address range check:
+ *	insmod de620.o clone=1
+ */
+static int bnc = 0;
+static int utp = 0;
+static int io  = DE620_IO;
+static int irq = DE620_IRQ;
+static int clone = DE620_CLONE;
+
+static unsigned int de620_debug = DE620_DEBUG;
+
 /***********************************************
  *                                             *
  * Index to functions, as function prototypes. *
@@ -200,8 +227,6 @@
 #define DE620_RX_START_PAGE 12		/* 12 pages (=3k) reserved for tx */
 #define DEF_NIC_CMD IRQEN | ICEN | DS1
 
-unsigned int de620_debug = DE620_DEBUG;
-
 static volatile byte	NIC_Cmd;
 static volatile byte	next_rx_page;
 static byte		first_rx_page;
@@ -407,15 +432,13 @@
 static int
 de620_open(struct device *dev)
 {
-	if (request_irq(DE620_IRQ, de620_interrupt, 0, "de620")) {
-		printk ("%s: unable to get IRQ %d\n", dev->name, DE620_IRQ);
+	if (request_irq(dev->irq, de620_interrupt, 0, "de620")) {
+		printk ("%s: unable to get IRQ %d\n", dev->name, dev->irq);
 		return 1;
 	}
-	irq2dev_map[DE620_IRQ] = dev;
+	irq2dev_map[dev->irq] = dev;
 
-#ifdef MODULE
 	MOD_INC_USE_COUNT;
-#endif
 	if (adapter_init(dev)) {
 		return 1;
 	}
@@ -434,13 +457,11 @@
 	/* disable recv */
 	de620_set_register(dev, W_TCR, RXOFF);
 
-	free_irq(DE620_IRQ);
-	irq2dev_map[DE620_IRQ] = NULL;
+	free_irq(dev->irq);
+	irq2dev_map[dev->irq] = NULL;
 
 	dev->start = 0;
-#ifdef MODULE
 	MOD_DEC_USE_COUNT;
-#endif
 	return 0;
 }
 
@@ -580,16 +601,16 @@
  *
  */
 static void
-de620_interrupt(int irq, struct pt_regs *regs)
+de620_interrupt(int irq_in, struct pt_regs *regs)
 {
-	struct device *dev = irq2dev_map[irq];
+	struct device *dev = irq2dev_map[irq_in];
 	byte irq_status;
 	int bogus_count = 0;
 	int again = 0;
 
 	/* This might be deleted now, no crummy drivers present :-) Or..? */
-	if ((dev == NULL) || (DE620_IRQ != irq)) {
-		printk("%s: bogus interrupt %d\n", dev?dev->name:"DE620", irq);
+	if ((dev == NULL) || (irq != irq_in)) {
+		printk("%s: bogus interrupt %d\n", dev?dev->name:"de620", irq_in);
 		return;
 	}
 
@@ -817,6 +838,13 @@
 	int i;
 	byte checkbyte = 0xa5;
 
+	/*
+	 * This is where the base_addr and irq gets set.
+	 * Tunable at compile-time and insmod-time
+	 */
+	dev->base_addr = io;
+	dev->irq       = irq;
+
 	if (de620_debug)
 		printk(version);
 
@@ -836,12 +864,12 @@
 	}
 
 #if 0 /* Not yet */
-	if (check_region(DE620_IO, 3)) {
-		printk(", port 0x%x busy\n", DE620_IO);
+	if (check_region(dev->base_addr, 3)) {
+		printk(", port 0x%x busy\n", dev->base_addr);
 		return EBUSY;
 	}
 #endif
-	request_region(DE620_IO, 3, "de620");
+	request_region(dev->base_addr, 3, "de620");
 
 	/* else, got it! */
 	printk(", Ethernet Address: %2.2X",
@@ -869,8 +897,7 @@
 	dev->stop = de620_close;
 	dev->hard_start_xmit = &de620_start_xmit;
 	dev->set_multicast_list = &de620_set_multicast_list;
-	dev->base_addr = DE620_IO;
-	dev->irq = DE620_IRQ;
+	/* base_addr and irq are already set, see above! */
 
 	ether_setup(dev);
 	
@@ -948,13 +975,13 @@
 
 	/* D-Link Ethernet addresses are in the series  00:80:c8:7X:XX:XX:XX */
 	wrd = ReadAWord(dev, 0x1aa);	/* bytes 0 + 1 of NodeID */
-	if (wrd != htons(0x0080)) /* Valid D-Link ether sequence? */
+	if (!clone && (wrd != htons(0x0080))) /* Valid D-Link ether sequence? */
 		return -1; /* Nope, not a DE-620 */
 	nic_data.NodeID[0] = wrd & 0xff;
 	nic_data.NodeID[1] = wrd >> 8;
 
 	wrd = ReadAWord(dev, 0x1ab);	/* bytes 2 + 3 of NodeID */
-	if ((wrd & 0xff) != 0xc8) /* Valid D-Link ether sequence? */
+	if (!clone && ((wrd & 0xff) != 0xc8)) /* Valid D-Link ether sequence? */
 		return -1; /* Nope, not a DE-620 */
 	nic_data.NodeID[2] = wrd & 0xff;
 	nic_data.NodeID[3] = wrd >> 8;
@@ -984,19 +1011,13 @@
  *
  */
 #ifdef MODULE
-char kernel_version[] = UTS_RELEASE;
 static char nullname[8] = "";
 static struct device de620_dev = {
 	nullname, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, de620_probe };
 
-int de620_io  = DE620_IO;
-int de620_irq = DE620_IRQ;
-
 int
 init_module(void)
 {
-	de620_dev.base_addr = de620_io;
-	de620_dev.irq       = de620_irq;
 	if (register_netdev(&de620_dev) != 0)
 		return -EIO;
 	return 0;

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this