airo.c patch for hppa
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
net/wireless/airo.c renamed from x/airo.c +20 -3
@@ -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 ; }
Quoted 2 lines · LaMont Jones
The first part (chage to
init_airo_cardand it's callers) allows us to callpci_enable_devicelike we need to.
We certainly do...
Quoted 4 lines
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.
Grant, I think this is a long-standing bug (Jan 2000!) in Dino's port IO macros. Look:
#define DINO_PORT_IN(type, size, mask) \
static u##size dino_in##size (struct pci_hba_data *d, u16 addr) \
{ \
/* tell HW which IO Port address */ \
gsc_writel((u32) addr & ~3, d->base_addr + DINO_PCI_ADDR); \
/* generate I/O PORT read cycle */ \
v = gsc_read##type(d->base_addr+DINO_IO_DATA+(addr&mask)); \That '& ~3' clears the bottom two bits of the address, so we always read from a 32-bit aligned address, even if we actually wanted to read the other 16-bit word or one of the other bytes. The PORT_OUT define doesn't mask that way:
#define DINO_PORT_OUT(type, size, mask) \
static void dino_out##size (struct pci_hba_data *d, u16 addr, u##size val) \
{ \
/* tell HW which CFG address */ \
gsc_writel((u32) addr, d->base_addr + DINO_PCI_ADDR); \
/* generate cfg write cycle */ \
gsc_write##type(cpu_to_le##size(val), d->base_addr+DINO_IO_DATA+(addr&mask)); \
(oops, looks like a comment wasn't updated ;-)
And HPUX doesn't mask addr that way either:
#define DINO_PRE_RD_IO(this, addr) \
WRITE_UINT32(this->base_addr + DINO_PCI_ADDR, addr);STATIC uint16_tdino_rd_io_w()
{
off += (uint32_t) phndl;
DINO_PRE_RD_IO(h2p, off);
data = READ_UINT16(h2p->base_addr + DINO_IO_DATA + (off & 2));LaMont's doing a rebuild now to check it works, but this seems fairly obvious to me. Thoughts? (Can _anyone_ remember what they were thinking when they wrote code nearly three years ago? ;-)
Signature · 3 lines
"It's not Hollywood. War is real, war is primarily not about defeat or victory, it is about death. I've seen thousands and thousands of dead bodies. Do you think I want to have an academic debate on this subject?" -- Robert Fisk
Quoted 2 lines · Matthew Wilcox
Grant, I think this is a long-standing bug (Jan 2000!) in Dino's port IO macros.
It sounds like there is...
...
Quoted 3 lines
That '& ~3' clears the bottom two bits of the address, so we always read from a 32-bit aligned address, even if we actually wanted to read the other 16-bit word or one of the other bytes.
The Dino ERS clearly says the AD[0:1] are used for IO Port space.
I gather IO_DATA behaves differently than MEM_DATA.MEM_DATA definitely uses byte enables to manage subword bytes and ignores the lower two bits of the address. The GSC byte enables are forwarded to the PCI bus when doing subword MMIO reads. Because MEM_DATA was added much later, it seems to have been implemented with more insight into how GSC/PCI can interact.
Quoted 1 line
The
PORT_OUTdefine doesn't mask that way:
Right.
...
Quoted 3 lines
LaMont's doing a rebuild now to check it works, but this seems fairly obvious to me. Thoughts? (Can _anyone_ remember what they were thinking when they wrote code nearly three years ago? ;-)
You are on the right track. And no, I don't remember.
thanks,
grant