* [parisc-linux] airo.c patch for hppa
@ 2002-12-04 5:06 LaMont Jones
2002-12-04 14:44 ` Matthew Wilcox
0 siblings, 1 reply; 3+ messages in thread
From: LaMont Jones @ 2002-12-04 5:06 UTC (permalink / raw)
To: parisc-linux
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;
}
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [parisc-linux] airo.c patch for hppa
2002-12-04 5:06 [parisc-linux] airo.c patch for hppa LaMont Jones
@ 2002-12-04 14:44 ` Matthew Wilcox
2002-12-04 17:12 ` Grant Grundler
0 siblings, 1 reply; 3+ messages in thread
From: Matthew Wilcox @ 2002-12-04 14:44 UTC (permalink / raw)
To: LaMont Jones; +Cc: parisc-linux
On Tue, Dec 03, 2002 at 10:06:40PM -0700, LaMont Jones wrote:
> The first part (chage to init_airo_card and it's callers) allows us to call
> pci_enable_device like we need to.
We certainly do...
> 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&ma
sk)); \
(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_t
dino_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? ;-)
--
"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
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [parisc-linux] airo.c patch for hppa
2002-12-04 14:44 ` Matthew Wilcox
@ 2002-12-04 17:12 ` Grant Grundler
0 siblings, 0 replies; 3+ messages in thread
From: Grant Grundler @ 2002-12-04 17:12 UTC (permalink / raw)
To: Matthew Wilcox; +Cc: LaMont Jones, parisc-linux
On Wed, Dec 04, 2002 at 02:44:54PM +0000, Matthew Wilcox wrote:
> Grant, I think this is a long-standing bug (Jan 2000!) in
> Dino's port IO macros.
It sounds like there is...
...
> 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.
> The PORT_OUT define doesn't mask that way:
Right.
...
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-12-04 17:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-12-04 5:06 [parisc-linux] airo.c patch for hppa LaMont Jones
2002-12-04 14:44 ` Matthew Wilcox
2002-12-04 17:12 ` Grant Grundler
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.