[parisc-linux-cvs] 82596 cleanup

Matthew Wilcox willy@ldl.fc.hp.com
Mon, 27 Aug 2001 18:05:45 -0600


 * Simplify the ASP / LASI word swapping decision.
 * Merge drivers/gsc/lan.c into lasi_82596.c
 * Remove some dead code.

Index: drivers/net/lasi_82596.c
===================================================================
RCS file: /home/cvs/parisc/linux/drivers/net/lasi_82596.c,v
retrieving revision 1.21
diff -u -p -r1.21 lasi_82596.c
--- drivers/net/lasi_82596.c	2001/08/01 15:26:04	1.21
+++ drivers/net/lasi_82596.c	2001/08/27 21:02:12
@@ -84,6 +84,7 @@
 #include <linux/skbuff.h>
 #include <linux/init.h>
 #include <linux/pci.h>
+#include <linux/types.h>
 
 #include <asm/bitops.h>
 #include <asm/io.h>
@@ -95,6 +96,8 @@
 #include <asm/gsc.h>
 #include <asm/cache.h>
 
+#include "../gsc/busdevice.h" /* XXX */
+
 static char version[] __initdata =
 	"82596.c $Revision: 1.21 $\n";
 
@@ -411,7 +414,7 @@ static int max_cmd_backlog = TX_RING_SIZ
 
 static inline void CA(struct net_device *dev)
 {
-	gsc_writel(0, (void*)(dev->base_addr + PA_CHANNEL_ATTENTION));
+	gsc_writel(0, dev->base_addr + PA_CHANNEL_ATTENTION);
 }
 
 
@@ -420,13 +423,19 @@ static inline void MPU_PORT(struct net_d
 	struct i596_private *lp = (struct i596_private *) dev->priv;
 
 	u32 v = (u32) (c) | (u32) (x);
+	u16 a, b;
 
-	if (lp->options & OPT_SWAP_PORT)
-		v = ((u32) (v) << 16) | ((u32) (v) >> 16);
+	if (lp->options & OPT_SWAP_PORT) {
+		a = v >> 16;
+		b = v & 0xffff;
+	} else {
+		a = v & 0xffff;
+		b = v >> 16;
+	}
 
-	gsc_writel(v & 0xffff, (void*)(dev->base_addr + PA_CPU_PORT_L_ACCESS));
+	gsc_writel(a, dev->base_addr + PA_CPU_PORT_L_ACCESS);
 	udelay(1);
-	gsc_writel(v >> 16,    (void*)(dev->base_addr + PA_CPU_PORT_L_ACCESS));
+	gsc_writel(b, dev->base_addr + PA_CPU_PORT_L_ACCESS);
 }
 
 
@@ -1125,7 +1134,7 @@ static void print_eth(unsigned char *add
 
 #define LAN_PROM_ADDR	0xF0810000
 
-static int __init i82596_probe(struct net_device *dev, int options)
+static int __init i82596_probe(struct net_device *dev)
 {
 	int i;
 	struct i596_private *lp;
@@ -1159,11 +1168,6 @@ static int __init i82596_probe(struct ne
 	    return -ENODEV;
 	}
 
-	/* FIXME:
-	    Currently this works only, if set-up from lasi.c.
-	    This should be changed to use probing too !
-	*/
-
 	if (!dev->base_addr || !dev->irq)
 	    return -ENODEV;
 
@@ -1213,7 +1217,6 @@ static int __init i82596_probe(struct ne
 			sizeof(struct i596_private), (unsigned long)&lp->scb));
 	memset((void *) lp, 0, sizeof(struct i596_private));
 
-	lp->options = options;
 	lp->scb.command = 0;
 	lp->scb.cmd = I596_NULL;
 	lp->scb.rfd = I596_NULL;
@@ -1226,18 +1229,6 @@ static int __init i82596_probe(struct ne
 }
 
 
-int __init lasi_i82596_probe(struct net_device *dev)
-{
-	return i82596_probe(dev, 0);
-}
-
-
-int __init asp_i82596_probe(struct net_device *dev)
-{
-	return i82596_probe(dev, OPT_SWAP_PORT);
-}
-
-
 static void i596_interrupt(int irq, void *dev_id, struct pt_regs *regs)
 {
 	struct net_device *dev = dev_id;
@@ -1502,37 +1493,72 @@ static void set_multicast_list(struct ne
 	}
 }
 
-#ifdef HAVE_DEVLIST
-static unsigned int i596_portlist[] __initdata =
-{0x300, 0};
-struct netdev_entry i596_drv =
-{"lasi_i82596", lasi_i82596_probe, I596_TOTAL_SIZE, i596_portlist};
-#endif
+MODULE_PARM(debug, "i");
+MODULE_PARM_DESC(debug, "lasi_82596 debug mask");
+static int debug = -1;
 
-#ifdef MODULE
-static char devicename[9] =
-{0,};
-static struct net_device dev_82596 =
+static int __init
+lan_init_chip(struct parisc_device *dev)
 {
-	name: devicename,	/* device name inserted by drivers/net/net_init.c */
-	init: lasi_i82596_probe,
+	struct net_device *netdevice;
+	int	retval, irq;
+
+	irq = busdevice_alloc_irq(dev); 
+
+	if (!irq) {
+		printk(KERN_ERR __FILE__ ": IRQ not found for i82596 at 0x%lx\n", dev->hpa);
+		return -ENODEV;
+	}
+
+	printk(KERN_INFO "Found i82596 at 0x%lx, IRQ %d\n", dev->hpa, irq);
+
+	netdevice = alloc_etherdev(0);
+	if (!netdevice)
+		return -ENOMEM;
+
+	netdevice->base_addr = dev->hpa;
+	netdevice->irq = irq;
+	netdevice->init = i82596_probe;
+
+	retval = register_netdev(netdevice);
+	if (retval) {
+		printk(KERN_WARNING __FILE__ ": register_netdevice ret'd %d\n", retval);
+		kfree(netdevice);
+		return -ENODEV;
+	};
+	if (dev->id.sversion == 0x72) {
+		((struct i596_private *)netdevice->priv)->options = OPT_SWAP_PORT;
+	}
+
+	return retval;
+}
+
+
+static struct parisc_device_id lan_tbl[] = {
+	{ HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x0008a },
+	{ HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x00072 },
+	{ 0, }
 };
 
+MODULE_DEVICE_TABLE(parisc, lan_tbl);
 
-MODULE_PARM(debug, "i");
-MODULE_PARM_DESC(debug, "lasi_82596 debug mask");
-static int debug = -1;
+static struct parisc_driver lan_driver = {
+	name:		"Apricot",
+	id_table:	lan_tbl,
+	probe:		lan_init_chip,
+};
 
-int init_module(void)
+static int __init lasi_82596_init(void)
 {
 	if (debug >= 0)
 		i596_debug = debug;
-	if (register_netdev(&dev_82596) != 0)
-		return -EIO;
-	return 0;
+	return register_parisc_driver(&lan_driver);
 }
+
+module_init(lasi_82596_init);
 
-void cleanup_module(void)
+#if 0
+static void __exit lasi_82596_exit(void)
 {
 	unregister_netdev(&dev_82596);
 	lp = (struct i596_private *) dev_82596.priv;
@@ -1544,6 +1570,8 @@ void cleanup_module(void)
 		free_page ((u32)(dev_82596.mem_start));
 
 	dev_82596.priv = NULL;
+	unregister_parisc_driver(&lan_driver);
 }
 
-#endif				/* MODULE */
+module_exit(lasi_82596_exit);
+#endif