Date: Mon, 15 Dec 1997 10:18:15 +0100
From: Alain Malek <Alain.Malek@dumbo.cryogen.ch>
To: linux68k <linux-m68k@phil.uni-sb.de>
Subject: L68K: APNE fix
Sender: owner-linux-m68k@phil.uni-sb.de

Hi,

 Here is a fix for the last patch I've send.
It fixes the 'MANUAL' config (thanks Kamil), and also another
small problem with interrupts which could lead to some
error messages from time to time.

Alain


diff -ruN linux.old/drivers/net/apne.c linux/drivers/net/apne.c
--- linux.old/drivers/net/apne.c	Thu Dec 11 23:04:25 1997
+++ linux/drivers/net/apne.c	Sat Dec 13 18:43:32 1997
@@ -99,6 +99,10 @@
 int ei_debug = 1;
 #endif
 
+/* IO base address used for nic */
+
+#define IOBASE 0x300
+
 /*
    use MANUAL_CONFIG and MANUAL_OFFSET for enabling IO by hand
    you can find the values to use by looking at the cnetdevice
@@ -108,6 +112,13 @@
 /*
 #define MANUAL_CONFIG 0x20
 #define MANUAL_OFFSET 0x3f8
+
+#define MANUAL_HWADDR0 0x00
+#define MANUAL_HWADDR1 0x12
+#define MANUAL_HWADDR2 0x34
+#define MANUAL_HWADDR3 0x56
+#define MANUAL_HWADDR4 0x78
+#define MANUAL_HWADDR5 0x9a
 */
 
 #define WORDSWAP(a) ( (((a)>>8)&0xff) | ((a)<<8) )
@@ -119,7 +130,9 @@
 
 int apne_probe(struct device *dev)
 {
+#ifndef MANUAL_CONFIG
 	char tuple[8];
+#endif
 
 	if ( !(MACH_IS_AMIGA && (boot_info.bi_un.bi_ami.model == AMI_1200)) )
 		return (ENODEV);
@@ -135,16 +148,18 @@
 	/* disable pcmcia irq for readtuple */
 	pcmcia_disable_irq();
 
+#ifndef MANUAL_CONFIG
 	if ((pcmcia_copy_tuple(CISTPL_FUNCID, tuple, 8) < 3) ||
 	     (tuple[2] != CISTPL_FUNCID_NETWORK)) {
 		printk("not an ethernet card\n");
 		return (ENODEV);
 	}
+#endif
 
 	printk("ethernet PCMCIA card inserted\n");
 
 	if (init_pcmcia())
-		return apne_probe1(dev, 0x300);
+		return apne_probe1(dev, IOBASE);
 	else
 		return (ENODEV);
 
@@ -252,7 +267,9 @@
     int wordlength = 2;
     const char *name = NULL;
     int start_page, stop_page;
+#ifndef MANUAL_HWADDR0
     int neX000, ctron;
+#endif
     static unsigned version_printed = 0;
 
     /* We should have a "dev" from Space.c or the static module table. */
@@ -280,6 +297,8 @@
 	gayle_outb(0xff, ioaddr + EN0_ISR);		/* Ack all intr. */
     }
 
+#ifndef MANUAL_HWADDR0
+
     /* Read the 16 bytes of station address PROM.
        We must first initialize registers, similar to apNS8390_init(eifdev, 0).
        We can't reliably read the SAPROM address without this.
@@ -347,6 +366,22 @@
 
     }
 
+#else
+    wordlength = 2;
+    /* We must set the 8390 for word mode. */
+    gayle_outb(0x49, ioaddr + EN0_DCFG);
+    start_page = NESM_START_PG;
+    stop_page = NESM_STOP_PG;
+
+    SA_prom[0] = MANUAL_HWADDR0;
+    SA_prom[1] = MANUAL_HWADDR1;
+    SA_prom[2] = MANUAL_HWADDR2;
+    SA_prom[3] = MANUAL_HWADDR3;
+    SA_prom[4] = MANUAL_HWADDR4;
+    SA_prom[5] = MANUAL_HWADDR5;
+    name = "NE2000";
+#endif
+
     dev->base_addr = ioaddr;
 
     /* Install the Interrupt handler */
@@ -1172,6 +1207,9 @@
 		return;
     }
 
+    if (!(gayle.inten & GAYLE_IRQ_IRQ))
+	return;
+
     pcmcia_intreq = pcmcia_get_intreq();
 
     if (!(pcmcia_intreq & GAYLE_IRQ_IRQ)) {
@@ -1298,7 +1336,9 @@
 static int init_pcmcia(void)
 {
 	unsigned char config;
+#ifndef MANUAL_CONFIG
 	unsigned char tuple[32];
+#endif
 	unsigned short offset;
 
 	pcmcia_reset();
@@ -1324,6 +1364,7 @@
 
 	offset = (tuple[5] << 8) | tuple[4];
 #endif
+
 	outb(config, GAYLE_ATTRIBUTE+offset);
 
 	return 1;
