From: Kenn H. <ke...@us...> - 2001-03-04 23:53:11
|
Update of /cvsroot/linux-vax/kernel-2.4/drivers/net In directory usw-pr-cvs1:/tmp/cvs-serv16107 Modified Files: vaxlance.c Log Message: Deal with KA43's DMA requirements Index: vaxlance.c =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.4/drivers/net/vaxlance.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- vaxlance.c 2001/02/27 22:05:26 1.8 +++ vaxlance.c 2001/03/04 23:54:44 1.9 @@ -14,10 +14,6 @@ * the lance pointed at the init block in the right address space. * - D.A. 14 Aug 2000 * - * THIS VERSION IS JUST A PLACE HOLDER, IT DOES LITTLE OR NOTHING - * IT READS THE CONTENTS OF THE PROM, - * - * will try and get some more working soon .. malloc would be nice :-) */ static char *version = @@ -49,6 +45,10 @@ #include <linux/etherdevice.h> #include <asm/vsa.h> +#include <asm/mv.h> +#include <asm/ka43.h> +extern struct vax_mv mv_ka43; + #ifndef CONFIG_TC unsigned long system_base = 0; unsigned long dmaptr; @@ -236,6 +236,9 @@ /* Pointers to the ring buffers as seen from the LANCE */ char *rx_buf_ptr_lnc[RX_RING_SIZE]; char *tx_buf_ptr_lnc[TX_RING_SIZE]; + + /* Virtual addr of buffer memory */ + char *buf_va; }; #define TX_BUFFS_AVAIL ((lp->tx_old<=lp->tx_new)?\ @@ -587,6 +590,7 @@ volatile struct lance_regs *ll = lp->ll; int csr0; +printk("lance_interrupt: entered\n"); writereg(&ll->rap, LE_CSR0); csr0 = ll->rdp; vsbus_clear_int(lp->vsbus_int); @@ -611,6 +615,7 @@ lp->stats.rx_errors++; if (csr0 & LE_C0_MERR) { + printk("%s: Memory error, status %04x", dev->name, csr0); #if 0 volatile unsigned long int_stat = *(unsigned long *) (system_base + IOCTL + SIR); @@ -651,6 +656,7 @@ printk("Lance: Can't get irq %d\n", dev->irq); return -EAGAIN; } + /* this is just a hack for now */ vsbus_enable_int(lp->vsbus_int); @@ -883,13 +889,14 @@ struct lance_private *lp; volatile struct lance_regs *ll; int i, ret; - unsigned long esar_base; unsigned char *esar; - unsigned long lance_phys_addr=0x200e0000; - unsigned long esar_phys_addr=0x20090000; + /* Could these base addresses be different on other CPUs? */ + unsigned long lance_phys_addr=KA43_LAN_BASE; + unsigned long esar_phys_addr=KA43_NWA_BASE; + base_addr=ioremap(lance_phys_addr, 0x8); - esar_base=ioremap(esar_phys_addr, 0x80); + esar=ioremap(esar_phys_addr, 0x80); if (vax_lance_debug && version_printed++ == 0) printk(version); #if 1 @@ -906,6 +913,7 @@ /* Make certain the data structures used by the LANCE are aligned. */ dev->priv = (void *) (((unsigned long) dev->priv + 7) & ~7); #else + /* If this is dead code, let's remove it... - KPH 2001-03-04 */ dev = init_etherdev(0, sizeof(struct lance_private)); if (!dev) return -ENOMEM; @@ -915,12 +923,40 @@ spin_lock_init(&lp->lock); /* Need to kmalloc a block of 64k */ - dev->mem_start=kmalloc(65536, GFP_KERNEL); - dev->mem_start = (((unsigned long) dev->mem_start + 7) & ~7); + lp->buf_va = kmalloc(65536 + 7, GFP_KERNEL); + if (lp->buf_va == NULL) { + /* Should be free dev->priv here if dev was non-NULL on entry? */ + return -ENOMEM; + } + /* Ensure alignment */ + lp->buf_va = (char *) (((unsigned long) lp->buf_va + 7) & ~7); + + if (mv == &mv_ka43) { + /* KA43 only. + * + * The KA43 seems to be nicely fscked up... All physical memory + * is accessible from 0x00000000 up (as normal) and also from + * 0x28000000 (KA43_DIAGMEM) in IO space. In order to reliably + * share memory with the LANCE, we _must_ read and write to this + * shared memory via the DIAGMEM region. Maybe this bypasses + * caches or something... If you don't do this you get evil + * "memory read parity error" machine checks. + * + * We really need a cleaner way to do this, for two reasons: + * + * 1. This is wasteful of SPTEs since the region ends up + * double-mapped + * 2. I think other drivers (SCSI?) will need this too + */ + dev->mem_start = (unsigned long) ioremap(virt_to_phys(lp->buf_va)|KA43_DIAGMEM, 65536); + } else { + /* other CPUs */ + dev->mem_start = (unsigned long) lp->buf_va; + } + + dev->mem_end = dev->mem_start + 65536; - /* dev->mem_start = base_addr;*/ - /* dev->base_addr = dev->mem_start + 0x100000;*/ - dev->base_addr=base_addr; + dev->base_addr=(unsigned long)base_addr; /* need something meaningful in here */ dev->irq = 0; @@ -948,9 +984,8 @@ } ll = (struct lance_regs *) base_addr; - esar = (unsigned char *)esar_base; #if DEBUG_VAX_DRIVER - printk("Hello %p\n",esar_base); + printk("Hello %p\n",esar); { unsigned int x; for (x=0x50; x<0x7E; x++) @@ -960,6 +995,7 @@ #endif /* prom checks */ #if 0 + /* If this is dead code, let's remove it... - KPH 2001-03-04 */ /* First, check for test pattern */ if (esar[0x60] != 0xff && esar[0x64] != 0x00 && esar[0x68] != 0x55 && esar[0x6c] != 0xaa) { @@ -988,6 +1024,7 @@ printk("%2.2x%c", dev->dev_addr[i], i == 5 ? ',' : ':'); } lp->vsbus_int=5; + #if 1 vsbus_enable_int(lp->vsbus_int); autoirq_setup(0); @@ -1000,13 +1037,16 @@ writereg(&ll->rdp, LE_C0_INEA|LE_C0_INIT); dev->irq = autoirq_report(100); + + /* maybe we should stop the LANCE here? */ + vsbus_clear_int(lp->vsbus_int); if (dev->irq) printk(" probed IRQ %d", dev->irq); else { - dev->irq=0x114; - printk(" failed to detect IRQ line.\n"); + dev->irq=0x94; + printk(" failed to detect IRQ line - assuming 0x94.\n"); } /* Fill the dev fields */ #else |