[parisc-linux] airo.c patch for hppa

LaMont Jones lamont@b180.mmjgroup.com
Tue, 3 Dec 2002 22:06:40 -0700


The patch below gets airo.c working on hppa.  Diff is vs 2.4.20 source.

The first part (chage to init_airo_card and it's callers) allows us to call
pci_enable_device like we need to.

The other part (the stuff inside #ifdef __hppa__) is a gross hack that works
around some issues between dino and the card during initialization where the
card fails to ack reads of several 2-byte aligned addresses.  With these
changes, I have a working PCI4800 in my B180.

It would, of course, be nice if at least part of this made it into the CVS
tree...

thoughts?
lamont

--- ../x/airo.c	2002-12-03 18:55:31.000000000 -0700
+++ drivers/net/wireless/airo.c	2002-12-03 21:20:32.000000000 -0700
@@ -1649,7 +1649,7 @@
 	return dev;
 }
 
-struct net_device *init_airo_card( unsigned short irq, int port, int is_pcmcia )
+struct net_device *init_airo_card( unsigned short irq, int port, int is_pcmcia , struct pci_dev *pdev )
 {
 	struct net_device *dev;
 	struct airo_info *ai;
@@ -1696,6 +1696,12 @@
 	dev->irq = irq;
 	dev->base_addr = port;
 
+	if ( !is_pcmcia && pdev ) {
+		if (pci_enable_device(pdev))
+			goto err_out_free;
+		pci_set_master(pdev);
+	}
+
 	rc = request_irq( dev->irq, airo_interrupt, SA_SHIRQ, dev->name, dev );
 	if (rc) {
 		printk(KERN_ERR "airo: register interrupt %d failed, rc %d\n", irq, rc );
@@ -2163,12 +2169,22 @@
 static u16 IN4500( struct airo_info *ai, u16 reg ) {
 	unsigned short rc;
 
+#ifdef __hppa__
+	if ((reg&3) && reg!=DATA0) {
+		unsigned int ri;
+		ri=inl(ai->dev->base_addr + (reg&~3));
+		rc=(ri>>(8*(reg&3)))&0xffff;
+	} else {
+		rc = inw( ai->dev->base_addr + reg );
+	}
+#else
 	if ( !do8bitIO )
 		rc = inw( ai->dev->base_addr + reg );
 	else {
 		rc = inb( ai->dev->base_addr + reg );
 		rc += ((int)inb( ai->dev->base_addr + reg + 1 )) << 8;
 	}
+#endif
 	return rc;
 }
 
@@ -2266,6 +2282,7 @@
 		printk(KERN_ERR "airo: Error checking for AUX port\n");
 		return ERROR;
 	}
+	
 	if (!aux_bap || rsp.status & 0xff00) {
 		ai->bap_read = fast_bap_read;
 		printk(KERN_DEBUG "airo: Doing fast bap_reads\n");
@@ -4008,7 +4025,7 @@
 {
 	struct net_device *dev;
 
-	dev = init_airo_card(pdev->irq,	pdev->resource[2].start, 0);
+	dev = init_airo_card(pdev->irq,	pdev->resource[2].start, 0, pdev);
 	if (!dev)
 		return -ENODEV;
 
@@ -4036,7 +4053,7 @@
 		printk( KERN_INFO
 			"airo:  Trying to configure ISA adapter at irq=%d io=0x%x\n",
 			irq[i], io[i] );
-		if (init_airo_card( irq[i], io[i], 0 ))
+		if (init_airo_card( irq[i], io[i], 0, 0 ))
 			have_isa_dev = 1;
 	}