- patches.fixes/patch-2.6.11-rc1: 2.6.11-rc1.
[linux-flexiantxendom0-3.2.10.git] / drivers / net / starfire.c
index f87ff13..236bdd3 100644 (file)
@@ -372,15 +372,15 @@ MODULE_AUTHOR("Donald Becker <becker@scyld.com>");
 MODULE_DESCRIPTION("Adaptec Starfire Ethernet driver");
 MODULE_LICENSE("GPL");
 
-MODULE_PARM(max_interrupt_work, "i");
-MODULE_PARM(mtu, "i");
-MODULE_PARM(debug, "i");
-MODULE_PARM(rx_copybreak, "i");
-MODULE_PARM(intr_latency, "i");
-MODULE_PARM(small_frames, "i");
-MODULE_PARM(options, "1-" __MODULE_STRING(MAX_UNITS) "i");
-MODULE_PARM(full_duplex, "1-" __MODULE_STRING(MAX_UNITS) "i");
-MODULE_PARM(enable_hw_cksum, "i");
+module_param(max_interrupt_work, int, 0);
+module_param(mtu, int, 0);
+module_param(debug, int, 0);
+module_param(rx_copybreak, int, 0);
+module_param(intr_latency, int, 0);
+module_param(small_frames, int, 0);
+module_param_array(options, int, NULL, 0);
+module_param_array(full_duplex, int, NULL, 0);
+module_param(enable_hw_cksum, int, 0);
 MODULE_PARM_DESC(max_interrupt_work, "Maximum events handled per interrupt");
 MODULE_PARM_DESC(mtu, "MTU (all boards)");
 MODULE_PARM_DESC(debug, "Debug level (0-6)");
@@ -776,6 +776,7 @@ struct netdev_private {
        struct mii_if_info mii_if;              /* MII lib hooks/info */
        int phy_cnt;                    /* MII device addresses. */
        unsigned char phys[PHY_CNT];    /* MII device addresses. */
+       void __iomem *base;
 };
 
 
@@ -846,6 +847,7 @@ static int __devinit starfire_init_one(struct pci_dev *pdev,
        struct net_device *dev;
        static int card_idx = -1;
        long ioaddr;
+       void __iomem *base;
        int drv_flags, io_size;
        int boguscnt;
 
@@ -884,14 +886,12 @@ static int __devinit starfire_init_one(struct pci_dev *pdev,
        }
 
        /* ioremap is borken in Linux-2.2.x/sparc64 */
-#if !defined(CONFIG_SPARC64) || LINUX_VERSION_CODE > 0x20300
-       ioaddr = (long) ioremap(ioaddr, io_size);
-       if (!ioaddr) {
+       base = ioremap(ioaddr, io_size);
+       if (!base) {
                printk(KERN_ERR DRV_NAME " %d: cannot remap %#x @ %#lx, aborting\n",
                        card_idx, io_size, ioaddr);
                goto err_out_free_res;
        }
-#endif /* !CONFIG_SPARC64 || Linux 2.3.0+ */
 
        pci_set_master(pdev);
 
@@ -918,27 +918,27 @@ static int __devinit starfire_init_one(struct pci_dev *pdev,
 
        /* Serial EEPROM reads are hidden by the hardware. */
        for (i = 0; i < 6; i++)
-               dev->dev_addr[i] = readb(ioaddr + EEPROMCtrl + 20 - i);
+               dev->dev_addr[i] = readb(base + EEPROMCtrl + 20 - i);
 
 #if ! defined(final_version) /* Dump the EEPROM contents during development. */
        if (debug > 4)
                for (i = 0; i < 0x20; i++)
                        printk("%2.2x%s",
-                              (unsigned int)readb(ioaddr + EEPROMCtrl + i),
+                              (unsigned int)readb(base + EEPROMCtrl + i),
                               i % 16 != 15 ? " " : "\n");
 #endif
 
        /* Issue soft reset */
-       writel(MiiSoftReset, ioaddr + TxMode);
+       writel(MiiSoftReset, base + TxMode);
        udelay(1000);
-       writel(0, ioaddr + TxMode);
+       writel(0, base + TxMode);
 
        /* Reset the chip to erase previous misconfiguration. */
-       writel(1, ioaddr + PCIDeviceConfig);
+       writel(1, base + PCIDeviceConfig);
        boguscnt = 1000;
        while (--boguscnt > 0) {
                udelay(10);
-               if ((readl(ioaddr + PCIDeviceConfig) & 1) == 0)
+               if ((readl(base + PCIDeviceConfig) & 1) == 0)
                        break;
        }
        if (boguscnt == 0)
@@ -946,10 +946,11 @@ static int __devinit starfire_init_one(struct pci_dev *pdev,
        /* wait a little longer */
        udelay(1000);
 
-       dev->base_addr = ioaddr;
+       dev->base_addr = (unsigned long)base;
        dev->irq = irq;
 
        np = netdev_priv(dev);
+       np->base = base;
        spin_lock_init(&np->lock);
        pci_set_drvdata(pdev, dev);
 
@@ -1021,8 +1022,8 @@ static int __devinit starfire_init_one(struct pci_dev *pdev,
        if (register_netdev(dev))
                goto err_out_cleardev;
 
-       printk(KERN_INFO "%s: %s at %#lx, ",
-                  dev->name, netdrv_tbl[chip_idx].name, ioaddr);
+       printk(KERN_INFO "%s: %s at %p, ",
+                  dev->name, netdrv_tbl[chip_idx].name, base);
        for (i = 0; i < 5; i++)
                printk("%2.2x:", dev->dev_addr[i]);
        printk("%2.2x, IRQ %d.\n", dev->dev_addr[i], irq);
@@ -1065,7 +1066,7 @@ static int __devinit starfire_init_one(struct pci_dev *pdev,
 
 err_out_cleardev:
        pci_set_drvdata(pdev, NULL);
-       iounmap((void *)ioaddr);
+       iounmap(base);
 err_out_free_res:
        pci_release_regions (pdev);
 err_out_free_netdev:
@@ -1077,7 +1078,8 @@ err_out_free_netdev:
 /* Read the MII Management Data I/O (MDIO) interfaces. */
 static int mdio_read(struct net_device *dev, int phy_id, int location)
 {
-       long mdio_addr = dev->base_addr + MIICtrl + (phy_id<<7) + (location<<2);
+       struct netdev_private *np = netdev_priv(dev);
+       void __iomem *mdio_addr = np->base + MIICtrl + (phy_id<<7) + (location<<2);
        int result, boguscnt=1000;
        /* ??? Should we add a busy-wait here? */
        do
@@ -1093,7 +1095,8 @@ static int mdio_read(struct net_device *dev, int phy_id, int location)
 
 static void mdio_write(struct net_device *dev, int phy_id, int location, int value)
 {
-       long mdio_addr = dev->base_addr + MIICtrl + (phy_id<<7) + (location<<2);
+       struct netdev_private *np = netdev_priv(dev);
+       void __iomem *mdio_addr = np->base + MIICtrl + (phy_id<<7) + (location<<2);
        writel(value, mdio_addr);
        /* The busy-wait will occur before a read. */
 }
@@ -1102,7 +1105,7 @@ static void mdio_write(struct net_device *dev, int phy_id, int location, int val
 static int netdev_open(struct net_device *dev)
 {
        struct netdev_private *np = netdev_priv(dev);
-       long ioaddr = dev->base_addr;
+       void __iomem *ioaddr = np->base;
        int i, retval;
        size_t tx_done_q_size, rx_done_q_size, tx_ring_size, rx_ring_size;
 
@@ -1191,7 +1194,7 @@ static int netdev_open(struct net_device *dev)
        writew(0, ioaddr + PerfFilterTable + 8);
        for (i = 1; i < 16; i++) {
                u16 *eaddrs = (u16 *)dev->dev_addr;
-               long setup_frm = ioaddr + PerfFilterTable + i * 16;
+               void __iomem *setup_frm = ioaddr + PerfFilterTable + i * 16;
                writew(cpu_to_be16(eaddrs[2]), setup_frm); setup_frm += 4;
                writew(cpu_to_be16(eaddrs[1]), setup_frm); setup_frm += 4;
                writew(cpu_to_be16(eaddrs[0]), setup_frm); setup_frm += 8;
@@ -1295,7 +1298,7 @@ static void check_duplex(struct net_device *dev)
 static void tx_timeout(struct net_device *dev)
 {
        struct netdev_private *np = netdev_priv(dev);
-       long ioaddr = dev->base_addr;
+       void __iomem *ioaddr = np->base;
        int old_debug;
 
        printk(KERN_WARNING "%s: Transmit timed out, status %#8.8x, "
@@ -1343,7 +1346,7 @@ static void init_ring(struct net_device *dev)
                /* Grrr, we cannot offset to correctly align the IP header. */
                np->rx_ring[i].rxaddr = cpu_to_dma(np->rx_info[i].mapping | RxDescValid);
        }
-       writew(i - 1, dev->base_addr + RxDescQIdx);
+       writew(i - 1, np->base + RxDescQIdx);
        np->dirty_rx = (unsigned int)(i - RX_RING_SIZE);
 
        /* Clear the remainder of the Rx buffer ring. */
@@ -1464,7 +1467,7 @@ static int start_tx(struct sk_buff *skb, struct net_device *dev)
        wmb();
 
        /* Update the producer index. */
-       writel(entry * (sizeof(starfire_tx_desc) / 8), dev->base_addr + TxProducerIdx);
+       writel(entry * (sizeof(starfire_tx_desc) / 8), np->base + TxProducerIdx);
 
        /* 4 is arbitrary, but should be ok */
        if ((np->cur_tx - np->dirty_tx) + 4 > TX_RING_SIZE)
@@ -1481,16 +1484,13 @@ static int start_tx(struct sk_buff *skb, struct net_device *dev)
 static irqreturn_t intr_handler(int irq, void *dev_instance, struct pt_regs *rgs)
 {
        struct net_device *dev = dev_instance;
-       struct netdev_private *np;
-       long ioaddr;
+       struct netdev_private *np = netdev_priv(dev);
+       void __iomem *ioaddr = np->base;
        int boguscnt = max_interrupt_work;
        int consumer;
        int tx_status;
        int handled = 0;
 
-       ioaddr = dev->base_addr;
-       np = netdev_priv(dev);
-
        do {
                u32 intr_status = readl(ioaddr + IntrClear);
 
@@ -1697,7 +1697,7 @@ static int __netdev_rx(struct net_device *dev, int *quota)
                desc->status = 0;
                np->rx_done = (np->rx_done + 1) % DONE_Q_SIZE;
        }
-       writew(np->rx_done, dev->base_addr + CompletionQConsumerIdx);
+       writew(np->rx_done, np->base + CompletionQConsumerIdx);
 
  out:
        refill_rx_ring(dev);
@@ -1712,7 +1712,8 @@ static int __netdev_rx(struct net_device *dev, int *quota)
 static int netdev_poll(struct net_device *dev, int *budget)
 {
        u32 intr_status;
-       long ioaddr = dev->base_addr;
+       struct netdev_private *np = netdev_priv(dev);
+       void __iomem *ioaddr = np->base;
        int retcode = 0, quota = dev->quota;
 
        do {
@@ -1766,14 +1767,14 @@ static void refill_rx_ring(struct net_device *dev)
                        np->rx_ring[entry].rxaddr |= cpu_to_dma(RxDescEndRing);
        }
        if (entry >= 0)
-               writew(entry, dev->base_addr + RxDescQIdx);
+               writew(entry, np->base + RxDescQIdx);
 }
 
 
 static void netdev_media_change(struct net_device *dev)
 {
        struct netdev_private *np = netdev_priv(dev);
-       long ioaddr = dev->base_addr;
+       void __iomem *ioaddr = np->base;
        u16 reg0, reg1, reg4, reg5;
        u32 new_tx_mode;
        u32 new_intr_timer_ctrl;
@@ -1852,7 +1853,7 @@ static void netdev_error(struct net_device *dev, int intr_status)
        /* Came close to underrunning the Tx FIFO, increase threshold. */
        if (intr_status & IntrTxDataLow) {
                if (np->tx_threshold <= PKT_BUF_SZ / 16) {
-                       writel(++np->tx_threshold, dev->base_addr + TxThreshold);
+                       writel(++np->tx_threshold, np->base + TxThreshold);
                        printk(KERN_NOTICE "%s: PCI bus congestion, increasing Tx FIFO threshold to %d bytes\n",
                               dev->name, np->tx_threshold * 16);
                } else
@@ -1874,8 +1875,8 @@ static void netdev_error(struct net_device *dev, int intr_status)
 
 static struct net_device_stats *get_stats(struct net_device *dev)
 {
-       long ioaddr = dev->base_addr;
        struct netdev_private *np = netdev_priv(dev);
+       void __iomem *ioaddr = np->base;
 
        /* This adapter architecture needs no SMP locks. */
        np->stats.tx_bytes = readl(ioaddr + 0x57010);
@@ -1904,17 +1905,17 @@ static struct net_device_stats *get_stats(struct net_device *dev)
 */
 static void set_rx_mode(struct net_device *dev)
 {
-       long ioaddr = dev->base_addr;
+       struct netdev_private *np = netdev_priv(dev);
+       void __iomem *ioaddr = np->base;
        u32 rx_mode = MinVLANPrio;
        struct dev_mc_list *mclist;
        int i;
 #ifdef VLAN_SUPPORT
-       struct netdev_private *np = netdev_priv(dev);
 
        rx_mode |= VlanMode;
        if (np->vlgrp) {
                int vlan_count = 0;
-               long filter_addr = ioaddr + HashTable + 8;
+               void __iomem *filter_addr = ioaddr + HashTable + 8;
                for (i = 0; i < VLAN_VID_MASK; i++) {
                        if (np->vlgrp->vlan_devices[i]) {
                                if (vlan_count >= 32)
@@ -1943,7 +1944,7 @@ static void set_rx_mode(struct net_device *dev)
                rx_mode |= AcceptBroadcast|AcceptAllMulticast|PerfectFilter;
        } else if (dev->mc_count <= 14) {
                /* Use the 16 element perfect filter, skip first two entries. */
-               long filter_addr = ioaddr + PerfFilterTable + 2 * 16;
+               void __iomem *filter_addr = ioaddr + PerfFilterTable + 2 * 16;
                u16 *eaddrs;
                for (i = 2, mclist = dev->mc_list; mclist && i < dev->mc_count + 2;
                     i++, mclist = mclist->next) {
@@ -1961,7 +1962,7 @@ static void set_rx_mode(struct net_device *dev)
                rx_mode |= AcceptBroadcast|PerfectFilter;
        } else {
                /* Must use a multicast hash table. */
-               long filter_addr;
+               void __iomem *filter_addr;
                u16 *eaddrs;
                u16 mc_filter[32] __attribute__ ((aligned(sizeof(long))));      /* Multicast hash filter */
 
@@ -2077,8 +2078,8 @@ static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 
 static int netdev_close(struct net_device *dev)
 {
-       long ioaddr = dev->base_addr;
        struct netdev_private *np = netdev_priv(dev);
+       void __iomem *ioaddr = np->base;
        int i;
 
        netif_stop_queue(dev);
@@ -2159,10 +2160,10 @@ static void __devexit starfire_remove_one (struct pci_dev *pdev)
 
 
        /* XXX: add wakeup code -- requires firmware for MagicPacket */
-       pci_set_power_state(pdev, 3);   /* go to sleep in D3 mode */
+       pci_set_power_state(pdev, PCI_D3hot);   /* go to sleep in D3 mode */
        pci_disable_device(pdev);
 
-       iounmap((char *)dev->base_addr);
+       iounmap(np->base);
        pci_release_regions(pdev);
 
        pci_set_drvdata(pdev, NULL);