vserver 1.9.5.x5
[linux-2.6.git] / drivers / net / cs89x0.c
index 9745bf6..8171b10 100644 (file)
@@ -84,6 +84,9 @@
   Oskar Schirmer    : oskar@scara.com
                     : HiCO.SH4 (superh) support added (irq#1, cs89x0_media=)
 
+  Deepak Saxena     : dsaxena@plexity.net
+                    : Intel IXDP2x01 (XScale ixp2x00 NPU) platform support
+
 */
 
 /* Always include 'config.h' first in case the user wants to turn on
  * Note that even if DMA is turned off we still support the 'dma' and  'use_dma'
  * module options so we don't break any startup scripts.
  */
+#ifndef CONFIG_ARCH_IXDP2X01
+#define ALLOW_DMA      0
+#else
 #define ALLOW_DMA      1
+#endif
 
 /*
  * Set this to zero to remove all the debug statements via
 #include <linux/spinlock.h>
 #include <linux/string.h>
 #include <linux/init.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
-#include <asm/bitops.h>
 #include <asm/io.h>
 #if ALLOW_DMA
 #include <asm/dma.h>
 static char version[] __initdata =
 "cs89x0.c: v2.4.3-pre1 Russell Nelson <nelson@crynwr.com>, Andrew Morton <andrewm@uow.edu.au>\n";
 
+#define DRV_NAME "cs89x0"
+
 /* First, a few definitions that the brave might change.
    A zero-terminated list of I/O addresses to be probed. Some special flags..
       Addr & 1 = Read back the address port, look for signature and reset
@@ -160,6 +169,10 @@ static unsigned int cs8900_irq_map[] = {12,0,0,0};
 static unsigned int netcard_portlist[] __initdata =
    { 0x0300, 0};
 static unsigned int cs8900_irq_map[] = {1,0,0,0};
+#elif defined(CONFIG_ARCH_IXDP2X01)
+#include <asm/irq.h>
+static unsigned int netcard_portlist[] __initdata = {IXDP2X01_CS8900_VIRT_BASE, 0};
+static unsigned int cs8900_irq_map[] = {IRQ_IXDP2X01_CS8900, 0, 0, 0};
 #else
 static unsigned int netcard_portlist[] __initdata =
    { 0x300, 0x320, 0x340, 0x360, 0x200, 0x220, 0x240, 0x260, 0x280, 0x2a0, 0x2c0, 0x2e0, 0};
@@ -261,7 +274,6 @@ static int __init media_fn(char *str)
 }
 
 __setup("cs89x0_media=", media_fn);
-#endif
 
 \f
 /* Check for a network adaptor of this type, and return '0' iff one exists.
@@ -318,6 +330,7 @@ out:
        printk(KERN_WARNING "cs89x0: no cs8900 or cs8920 detected.  Be sure to disable PnP with SETUP\n");
        return ERR_PTR(err);
 }
+#endif
 
 static int
 readreg(struct net_device *dev, int portno)
@@ -425,9 +438,9 @@ cs89x0_probe1(struct net_device *dev, int ioaddr, int modular)
 
        /* Grab the region so we can find another board if autoIRQ fails. */
        /* WTF is going on here? */
-       if (!request_region(ioaddr & ~3, NETCARD_IO_EXTENT, dev->name)) {
+       if (!request_region(ioaddr & ~3, NETCARD_IO_EXTENT, DRV_NAME)) {
                printk(KERN_ERR "%s: request_region(0x%x, 0x%x) failed\n",
-                               dev->name, ioaddr, NETCARD_IO_EXTENT);
+                               DRV_NAME, ioaddr, NETCARD_IO_EXTENT);
                retval = -EBUSY;
                goto out1;
        }
@@ -452,11 +465,12 @@ cs89x0_probe1(struct net_device *dev, int ioaddr, int modular)
                                retval = -ENODEV;
                                goto out2;
                        }
-               ioaddr &= ~3;
-               outw(PP_ChipID, ioaddr + ADD_PORT);
        }
 printk("PP_addr=0x%x\n", inw(ioaddr + ADD_PORT));
 
+       ioaddr &= ~3;
+       outw(PP_ChipID, ioaddr + ADD_PORT);
+
        if (inw(ioaddr + DATA_PORT) != CHIP_EISA_ID_SIG) {
                printk(KERN_ERR "%s: incorrect signature 0x%x\n",
                        dev->name, inw(ioaddr + DATA_PORT));
@@ -663,6 +677,9 @@ printk("PP_addr=0x%x\n", inw(ioaddr + ADD_PORT));
        } else {
                i = lp->isa_config & INT_NO_MASK;
                if (lp->chip_type == CS8900) {
+#ifdef CONFIG_ARCH_IXDP2X01
+                       i = cs8900_irq_map[0];
+#else
                        /* Translate the IRQ using the IRQ mapping table. */
                        if (i >= sizeof(cs8900_irq_map)/sizeof(cs8900_irq_map[0]))
                                printk("\ncs89x0: invalid ISA interrupt number %d\n", i);
@@ -679,6 +696,7 @@ printk("PP_addr=0x%x\n", inw(ioaddr + ADD_PORT));
                                if ((irq_map_buff[0] & 0xff) == PNP_IRQ_FRMT)
                                        lp->irq_map = (irq_map_buff[0]>>8) | (irq_map_buff[1] << 8);
                        }
+#endif
                }
                if (!dev->irq)
                        dev->irq = i;
@@ -882,8 +900,10 @@ skip_this_frame:
 
 void  __init reset_chip(struct net_device *dev)
 {
+#ifndef CONFIG_ARCH_IXDP2X01
        struct net_local *lp = netdev_priv(dev);
        int ioaddr = dev->base_addr;
+#endif
        int reset_start_time;
 
        writereg(dev, PP_SelfCTL, readreg(dev, PP_SelfCTL) | POWER_ON_RESET);
@@ -892,6 +912,7 @@ void  __init reset_chip(struct net_device *dev)
        current->state = TASK_INTERRUPTIBLE;
        schedule_timeout(30*HZ/1000);
 
+#ifndef CONFIG_ARCH_IXDP2X01
        if (lp->chip_type != CS8900) {
                /* Hardware problem requires PNP registers to be reconfigured after a reset */
                outw(PP_CS8920_ISAINT, ioaddr + ADD_PORT);
@@ -902,6 +923,8 @@ void  __init reset_chip(struct net_device *dev)
                outb((dev->mem_start >> 16) & 0xff, ioaddr + DATA_PORT);
                outb((dev->mem_start >> 8) & 0xff,   ioaddr + DATA_PORT + 1);
        }
+#endif /* IXDP2x01 */
+
        /* Wait until the chip is reset */
        reset_start_time = jiffies;
        while( (readreg(dev, PP_SelfST) & INIT_DONE) == 0 && jiffies - reset_start_time < 2)
@@ -1153,12 +1176,14 @@ net_open(struct net_device *dev)
        else
 #endif
        {
+#ifndef CONFIG_ARCH_IXDP2X01
                if (((1 << dev->irq) & lp->irq_map) == 0) {
                        printk(KERN_ERR "%s: IRQ %d is not in our map of allowable IRQs, which is %x\n",
                                dev->name, dev->irq, lp->irq_map);
                        ret = -EAGAIN;
                        goto bad_out;
                }
+#endif
 /* FIXME: Cirrus' release had this: */
                writereg(dev, PP_BusCTL, readreg(dev, PP_BusCTL)|ENABLE_IRQ );
 /* And 2.3.47 had this: */
@@ -1564,7 +1589,7 @@ static void release_dma_buff(struct net_local *lp)
 {
        if (lp->dma_buff) {
                free_pages((unsigned long)(lp->dma_buff), get_order(lp->dmasize * 1024));
-               lp->dma_buff = 0;
+               lp->dma_buff = NULL;
        }
 }
 #endif
@@ -1573,7 +1598,9 @@ static void release_dma_buff(struct net_local *lp)
 static int
 net_close(struct net_device *dev)
 {
+#if ALLOW_DMA
        struct net_local *lp = netdev_priv(dev);
+#endif
 
        netif_stop_queue(dev);
        
@@ -1683,14 +1710,14 @@ static int use_dma;                     /* These generate unused var warnings if ALLOW_DMA = 0 */
 static int dma;
 static int dmasize=16;                 /* or 64 */
 
-MODULE_PARM(io, "i");
-MODULE_PARM(irq, "i");
-MODULE_PARM(debug, "i");
-MODULE_PARM(media, "c8");
-MODULE_PARM(duplex, "i");
-MODULE_PARM(dma , "i");
-MODULE_PARM(dmasize , "i");
-MODULE_PARM(use_dma , "i");
+module_param(io, int, 0);
+module_param(irq, int, 0);
+module_param(debug, int, 0);
+module_param_string(media, media, sizeof(media), 0);
+module_param(duplex, int, 0);
+module_param(dma , int, 0);
+module_param(dmasize , int, 0);
+module_param(use_dma , int, 0);
 MODULE_PARM_DESC(io, "cs89x0 I/O base address");
 MODULE_PARM_DESC(irq, "cs89x0 IRQ number");
 #if DEBUGGING