[2871] in linux-net channel archive

home help back first fref pref prev next nref lref last post

ISA Lance cards in Alpha AXP boxes

daemon@ATHENA.MIT.EDU (Paul Gortmaker)
Sat May 11 18:08:58 1996

From: Paul Gortmaker <gpg109@rsphy6.anu.edu.au>
To: linux-alpha@vger.rutgers.edu
Date: 	Wed, 8 May 1996 19:34:56 +1000 (EST)
Cc: linux-net@vger.rutgers.edu, saw@shade.msu.ru, tsbogend@bigbug.franken.de

I noticed that somebody sprinkled a few #ifdef __alpha__ through the
lance driver, to avoid probing for ISA based lance cards. Unless there
is some fundamental reason why bus-master ISA lance cards don't work on
AXP boxes that I am not aware of, these architecture based #ifdef
are not needed (not to mention ugly ;-) and just needlessly stop AXP
people from using these ISA cards.

I would guess that they were added because someone noticed that
the ISA probe would cause the alpha to barf. Well, no wonder, with
lines like:

	if ( *((unsigned short *) 0x000f0102) == 0x5048)  {
and
	int hp_port = ( *((unsigned char *) 0x000f00f1) & 1) ? 0x499 : 0x99;

Rather than use #ifdef __alpha__ it makes more sense to do what I did for 
the 3c503 driver to make it alpha safe; that is use readl/readw/readb, i.e:

	if (readw(0x000f0102) == 0x5048)  {
and
	int hp_port = (readl(0x000f00f1) & 1) ? 0x499 : 0x99;

Anyway, assuming that my above analysis is correct, here is a patch.
Otherwise, feel free to ignore my babblings, as I don't have handfuls
of AXP boxes lying about to test my theory on...    :-)

Paul.

============================

--- /tmp/linux/drivers/net/lance.c	Wed May  8 18:20:01 1996
+++ linux/drivers/net/lance.c	Wed May  8 18:32:40 1996
@@ -165,6 +165,9 @@
  *	- added support for Linux/Alpha, but removed most of it, because
  *        it worked only for the PCI chip. 
  *      - added hook for the 32bit lance driver
+ *
+ *	Paul Gortmaker (gpg109@rsphy1.anu.edu.au):
+ *	- hopefully fix above so Linux/Alpha can use ISA cards too.
  */
 
 /* Set the number of Tx and Rx buffers, using Log_2(# buffers).
@@ -298,9 +301,7 @@
 
 int lance_init(void)
 {
-#ifndef __alpha__    
 	int *port;
-#endif    
 
 	if (high_memory <= 16*1024*1024)
 		lance_need_isa_bounce_buffers = 0;
@@ -344,8 +345,6 @@
 	}
 #endif  /* defined(CONFIG_PCI) */
 
-/* On the Alpha don't look for PCnet chips on the ISA bus */
-#ifndef __alpha__
 	for (port = lance_portlist; *port; port++) {
 		int ioaddr = *port;
 
@@ -359,8 +358,6 @@
 				lance_probe1(ioaddr);
 		}
 	}
-#endif
-
 	return 0;
 }
 
@@ -376,15 +373,14 @@
 	int hp_builtin = 0;					/* HP on-board ethernet. */
 	static int did_version = 0;			/* Already printed version info. */
 
-#ifndef __alpha__
 	/* First we look for special cases.
 	   Check for HP's on-board ethernet by looking for 'HP' in the BIOS.
 	   There are two HP versions, check the BIOS for the configuration port.
 	   This method provided by L. Julliard, Laurent_Julliard@grenoble.hp.com.
 	   */
-	if ( *((unsigned short *) 0x000f0102) == 0x5048)  {
+	if (readw(0x000f0102) == 0x5048)  {
 		static const short ioaddr_table[] = { 0x300, 0x320, 0x340, 0x360};
-		int hp_port = ( *((unsigned char *) 0x000f00f1) & 1)  ? 0x499 : 0x99;
+		int hp_port = (readl(0x000f00f1) & 1)  ? 0x499 : 0x99;
 		/* We can have boards other than the built-in!  Verify this is on-board. */
 		if ((inb(hp_port) & 0xc0) == 0x80
 			&& ioaddr_table[inb(hp_port) & 3] == ioaddr)
@@ -393,7 +389,6 @@
 	/* We also recognize the HP Vectra on-board here, but check below. */
 	hpJ2405A = (inb(ioaddr) == 0x08 && inb(ioaddr+1) == 0x00
 				&& inb(ioaddr+2) == 0x09);
-#endif
 
 	/* Reset the LANCE.	 */
 	reset_val = inw(ioaddr+LANCE_RESET); /* Reset the LANCE */


home help back first fref pref prev next nref lref last post