This commit was manufactured by cvs2svn to create tag
[linux-2.6.git] / drivers / net / tulip / winbond-840.c
index 5bf0549..cf72f17 100644 (file)
@@ -130,9 +130,9 @@ static int full_duplex[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1};
 #include <linux/mii.h>
 #include <linux/rtnetlink.h>
 #include <linux/crc32.h>
-#include <linux/bitops.h>
 #include <asm/uaccess.h>
 #include <asm/processor.h>             /* Processor type for cache alignment. */
+#include <asm/bitops.h>
 #include <asm/io.h>
 #include <asm/irq.h>
 
@@ -144,6 +144,7 @@ KERN_INFO "  http://www.scyld.com/network/drivers.html\n";
 MODULE_AUTHOR("Donald Becker <becker@scyld.com>");
 MODULE_DESCRIPTION("Winbond W89c840 Ethernet driver");
 MODULE_LICENSE("GPL");
+MODULE_VERSION(DRV_VERSION);
 
 MODULE_PARM(max_interrupt_work, "i");
 MODULE_PARM(debug, "i");
@@ -258,6 +259,21 @@ static struct pci_id_info pci_id_tbl[] = {
    work only with I/O space accesses.  Pass -DUSE_IO_OPS to use PCI I/O space
    accesses instead of memory space. */
 
+#ifdef USE_IO_OPS
+#undef readb
+#undef readw
+#undef readl
+#undef writeb
+#undef writew
+#undef writel
+#define readb inb
+#define readw inw
+#define readl inl
+#define writeb outb
+#define writew outw
+#define writel outl
+#endif
+
 /* Offsets to the Command and Status Registers, "CSRs".
    While similar to the Tulip, these registers are longword aligned.
    Note: It's not useful to define symbolic names for every register bit in
@@ -346,10 +362,9 @@ struct netdev_private {
        unsigned char phys[MII_CNT];            /* MII device addresses, but only the first is used */
        u32 mii;
        struct mii_if_info mii_if;
-       void __iomem *base_addr;
 };
 
-static int  eeprom_read(void __iomem *ioaddr, int location);
+static int  eeprom_read(long ioaddr, int location);
 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);
 static int  netdev_open(struct net_device *dev);
@@ -383,8 +398,7 @@ static int __devinit w840_probe1 (struct pci_dev *pdev,
        int chip_idx = ent->driver_data;
        int irq;
        int i, option = find_cnt < MAX_UNITS ? options[find_cnt] : 0;
-       void __iomem *ioaddr;
-       int bar = 1;
+       long ioaddr;
 
        i = pci_enable_device(pdev);
        if (i) return i;
@@ -406,24 +420,27 @@ static int __devinit w840_probe1 (struct pci_dev *pdev,
 
        if (pci_request_regions(pdev, DRV_NAME))
                goto err_out_netdev;
+
 #ifdef USE_IO_OPS
-       bar = 0;
-#endif
-       ioaddr = pci_iomap(pdev, bar, pci_id_tbl[chip_idx].io_size);
+       ioaddr = pci_resource_start(pdev, 0);
+#else
+       ioaddr = pci_resource_start(pdev, 1);
+       ioaddr = (long) ioremap (ioaddr, pci_id_tbl[chip_idx].io_size);
        if (!ioaddr)
                goto err_out_free_res;
+#endif
 
        for (i = 0; i < 3; i++)
                ((u16 *)dev->dev_addr)[i] = le16_to_cpu(eeprom_read(ioaddr, i));
 
        /* Reset the chip to erase previous misconfiguration.
           No hold time required! */
-       iowrite32(0x00000001, ioaddr + PCIBusCfg);
+       writel(0x00000001, ioaddr + PCIBusCfg);
 
-       dev->base_addr = (unsigned long)ioaddr;
+       dev->base_addr = ioaddr;
        dev->irq = irq;
 
-       np = netdev_priv(dev);
+       np = dev->priv;
        np->pci_dev = pdev;
        np->chip_id = chip_idx;
        np->drv_flags = pci_id_tbl[chip_idx].drv_flags;
@@ -431,7 +448,6 @@ static int __devinit w840_probe1 (struct pci_dev *pdev,
        np->mii_if.dev = dev;
        np->mii_if.mdio_read = mdio_read;
        np->mii_if.mdio_write = mdio_write;
-       np->base_addr = ioaddr;
        
        pci_set_drvdata(pdev, dev);
 
@@ -467,7 +483,7 @@ static int __devinit w840_probe1 (struct pci_dev *pdev,
        if (i)
                goto err_out_cleardev;
 
-       printk(KERN_INFO "%s: %s at %p, ",
+       printk(KERN_INFO "%s: %s at 0x%lx, ",
                   dev->name, pci_id_tbl[chip_idx].name, ioaddr);
        for (i = 0; i < 5; i++)
                        printk("%2.2x:", dev->dev_addr[i]);
@@ -500,8 +516,10 @@ static int __devinit w840_probe1 (struct pci_dev *pdev,
 
 err_out_cleardev:
        pci_set_drvdata(pdev, NULL);
-       pci_iounmap(pdev, ioaddr);
+#ifndef USE_IO_OPS
+       iounmap((void *)ioaddr);
 err_out_free_res:
+#endif
        pci_release_regions(pdev);
 err_out_netdev:
        free_netdev (dev);
@@ -520,7 +538,7 @@ err_out_netdev:
    The old method of using an ISA access as a delay, __SLOW_DOWN_IO__, is
    depricated.
 */
-#define eeprom_delay(ee_addr)  ioread32(ee_addr)
+#define eeprom_delay(ee_addr)  readl(ee_addr)
 
 enum EEPROM_Ctrl_Bits {
        EE_ShiftClk=0x02, EE_Write0=0x801, EE_Write1=0x805,
@@ -532,35 +550,35 @@ enum EEPROM_Cmds {
        EE_WriteCmd=(5 << 6), EE_ReadCmd=(6 << 6), EE_EraseCmd=(7 << 6),
 };
 
-static int eeprom_read(void __iomem *addr, int location)
+static int eeprom_read(long addr, int location)
 {
        int i;
        int retval = 0;
-       void __iomem *ee_addr = addr + EECtrl;
+       long ee_addr = addr + EECtrl;
        int read_cmd = location | EE_ReadCmd;
-       iowrite32(EE_ChipSelect, ee_addr);
+       writel(EE_ChipSelect, ee_addr);
 
        /* Shift the read command bits out. */
        for (i = 10; i >= 0; i--) {
                short dataval = (read_cmd & (1 << i)) ? EE_Write1 : EE_Write0;
-               iowrite32(dataval, ee_addr);
+               writel(dataval, ee_addr);
                eeprom_delay(ee_addr);
-               iowrite32(dataval | EE_ShiftClk, ee_addr);
+               writel(dataval | EE_ShiftClk, ee_addr);
                eeprom_delay(ee_addr);
        }
-       iowrite32(EE_ChipSelect, ee_addr);
+       writel(EE_ChipSelect, ee_addr);
        eeprom_delay(ee_addr);
 
        for (i = 16; i > 0; i--) {
-               iowrite32(EE_ChipSelect | EE_ShiftClk, ee_addr);
+               writel(EE_ChipSelect | EE_ShiftClk, ee_addr);
                eeprom_delay(ee_addr);
-               retval = (retval << 1) | ((ioread32(ee_addr) & EE_DataIn) ? 1 : 0);
-               iowrite32(EE_ChipSelect, ee_addr);
+               retval = (retval << 1) | ((readl(ee_addr) & EE_DataIn) ? 1 : 0);
+               writel(EE_ChipSelect, ee_addr);
                eeprom_delay(ee_addr);
        }
 
        /* Terminate the EEPROM access. */
-       iowrite32(0, ee_addr);
+       writel(0, ee_addr);
        return retval;
 }
 
@@ -571,7 +589,7 @@ static int eeprom_read(void __iomem *addr, int location)
 
        The maximum data clock rate is 2.5 Mhz.  The minimum timing is usually
        met by back-to-back 33Mhz PCI cycles. */
-#define mdio_delay(mdio_addr) ioread32(mdio_addr)
+#define mdio_delay(mdio_addr) readl(mdio_addr)
 
 /* Set iff a MII transceiver on any interface requires mdio preamble.
    This only set with older transceivers, so the extra
@@ -583,23 +601,22 @@ static char mii_preamble_required = 1;
 
 /* Generate the preamble required for initial synchronization and
    a few older transceivers. */
-static void mdio_sync(void __iomem *mdio_addr)
+static void mdio_sync(long mdio_addr)
 {
        int bits = 32;
 
        /* Establish sync by sending at least 32 logic ones. */
        while (--bits >= 0) {
-               iowrite32(MDIO_WRITE1, mdio_addr);
+               writel(MDIO_WRITE1, mdio_addr);
                mdio_delay(mdio_addr);
-               iowrite32(MDIO_WRITE1 | MDIO_ShiftClk, mdio_addr);
+               writel(MDIO_WRITE1 | MDIO_ShiftClk, mdio_addr);
                mdio_delay(mdio_addr);
        }
 }
 
 static int mdio_read(struct net_device *dev, int phy_id, int location)
 {
-       struct netdev_private *np = netdev_priv(dev);
-       void __iomem *mdio_addr = np->base_addr + MIICtrl;
+       long mdio_addr = dev->base_addr + MIICtrl;
        int mii_cmd = (0xf6 << 10) | (phy_id << 5) | location;
        int i, retval = 0;
 
@@ -610,17 +627,17 @@ static int mdio_read(struct net_device *dev, int phy_id, int location)
        for (i = 15; i >= 0; i--) {
                int dataval = (mii_cmd & (1 << i)) ? MDIO_WRITE1 : MDIO_WRITE0;
 
-               iowrite32(dataval, mdio_addr);
+               writel(dataval, mdio_addr);
                mdio_delay(mdio_addr);
-               iowrite32(dataval | MDIO_ShiftClk, mdio_addr);
+               writel(dataval | MDIO_ShiftClk, mdio_addr);
                mdio_delay(mdio_addr);
        }
        /* Read the two transition, 16 data, and wire-idle bits. */
        for (i = 20; i > 0; i--) {
-               iowrite32(MDIO_EnbIn, mdio_addr);
+               writel(MDIO_EnbIn, mdio_addr);
                mdio_delay(mdio_addr);
-               retval = (retval << 1) | ((ioread32(mdio_addr) & MDIO_DataIn) ? 1 : 0);
-               iowrite32(MDIO_EnbIn | MDIO_ShiftClk, mdio_addr);
+               retval = (retval << 1) | ((readl(mdio_addr) & MDIO_DataIn) ? 1 : 0);
+               writel(MDIO_EnbIn | MDIO_ShiftClk, mdio_addr);
                mdio_delay(mdio_addr);
        }
        return (retval>>1) & 0xffff;
@@ -628,8 +645,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)
 {
-       struct netdev_private *np = netdev_priv(dev);
-       void __iomem *mdio_addr = np->base_addr + MIICtrl;
+       struct netdev_private *np = dev->priv;
+       long mdio_addr = dev->base_addr + MIICtrl;
        int mii_cmd = (0x5002 << 16) | (phy_id << 23) | (location<<18) | value;
        int i;
 
@@ -643,16 +660,16 @@ static void mdio_write(struct net_device *dev, int phy_id, int location, int val
        for (i = 31; i >= 0; i--) {
                int dataval = (mii_cmd & (1 << i)) ? MDIO_WRITE1 : MDIO_WRITE0;
 
-               iowrite32(dataval, mdio_addr);
+               writel(dataval, mdio_addr);
                mdio_delay(mdio_addr);
-               iowrite32(dataval | MDIO_ShiftClk, mdio_addr);
+               writel(dataval | MDIO_ShiftClk, mdio_addr);
                mdio_delay(mdio_addr);
        }
        /* Clear out extra bits. */
        for (i = 2; i > 0; i--) {
-               iowrite32(MDIO_EnbIn, mdio_addr);
+               writel(MDIO_EnbIn, mdio_addr);
                mdio_delay(mdio_addr);
-               iowrite32(MDIO_EnbIn | MDIO_ShiftClk, mdio_addr);
+               writel(MDIO_EnbIn | MDIO_ShiftClk, mdio_addr);
                mdio_delay(mdio_addr);
        }
        return;
@@ -661,11 +678,11 @@ static void mdio_write(struct net_device *dev, int phy_id, int location, int val
 \f
 static int netdev_open(struct net_device *dev)
 {
-       struct netdev_private *np = netdev_priv(dev);
-       void __iomem *ioaddr = np->base_addr;
+       struct netdev_private *np = dev->priv;
+       long ioaddr = dev->base_addr;
        int i;
 
-       iowrite32(0x00000001, ioaddr + PCIBusCfg);              /* Reset */
+       writel(0x00000001, ioaddr + PCIBusCfg);         /* Reset */
 
        netif_device_detach(dev);
        i = request_irq(dev->irq, &intr_handler, SA_SHIRQ, dev->name, dev);
@@ -704,7 +721,7 @@ out_err:
 
 static int update_link(struct net_device *dev)
 {
-       struct netdev_private *np = netdev_priv(dev);
+       struct netdev_private *np = dev->priv;
        int duplex, fasteth, result, mii_reg;
 
        /* BSMR */
@@ -767,8 +784,8 @@ static int update_link(struct net_device *dev)
 #define RXTX_TIMEOUT   2000
 static inline void update_csr6(struct net_device *dev, int new)
 {
-       struct netdev_private *np = netdev_priv(dev);
-       void __iomem *ioaddr = np->base_addr;
+       struct netdev_private *np = dev->priv;
+       long ioaddr = dev->base_addr;
        int limit = RXTX_TIMEOUT;
 
        if (!netif_device_present(dev))
@@ -776,10 +793,10 @@ static inline void update_csr6(struct net_device *dev, int new)
        if (new==np->csr6)
                return;
        /* stop both Tx and Rx processes */
-       iowrite32(np->csr6 & ~0x2002, ioaddr + NetworkConfig);
+       writel(np->csr6 & ~0x2002, ioaddr + NetworkConfig);
        /* wait until they have really stopped */
        for (;;) {
-               int csr5 = ioread32(ioaddr + IntrStatus);
+               int csr5 = readl(ioaddr + IntrStatus);
                int t;
 
                t = (csr5 >> 17) & 0x07;
@@ -800,7 +817,7 @@ static inline void update_csr6(struct net_device *dev, int new)
        }
        np->csr6 = new;
        /* and restart them with the new configuration */
-       iowrite32(np->csr6, ioaddr + NetworkConfig);
+       writel(np->csr6, ioaddr + NetworkConfig);
        if (new & 0x200)
                np->mii_if.full_duplex = 1;
 }
@@ -808,14 +825,14 @@ static inline void update_csr6(struct net_device *dev, int new)
 static void netdev_timer(unsigned long data)
 {
        struct net_device *dev = (struct net_device *)data;
-       struct netdev_private *np = netdev_priv(dev);
-       void __iomem *ioaddr = np->base_addr;
+       struct netdev_private *np = dev->priv;
+       long ioaddr = dev->base_addr;
 
        if (debug > 2)
                printk(KERN_DEBUG "%s: Media selection timer tick, status %8.8x "
                           "config %8.8x.\n",
-                          dev->name, ioread32(ioaddr + IntrStatus),
-                          ioread32(ioaddr + NetworkConfig));
+                          dev->name, (int)readl(ioaddr + IntrStatus),
+                          (int)readl(ioaddr + NetworkConfig));
        spin_lock_irq(&np->lock);
        update_csr6(dev, update_link(dev));
        spin_unlock_irq(&np->lock);
@@ -825,7 +842,7 @@ static void netdev_timer(unsigned long data)
 
 static void init_rxtx_rings(struct net_device *dev)
 {
-       struct netdev_private *np = netdev_priv(dev);
+       struct netdev_private *np = dev->priv;
        int i;
 
        np->rx_head_desc = &np->rx_ring[0];
@@ -865,9 +882,9 @@ static void init_rxtx_rings(struct net_device *dev)
        np->tx_full = 0;
        np->tx_q_bytes = np->dirty_tx = np->cur_tx = 0;
 
-       iowrite32(np->ring_dma_addr, np->base_addr + RxRingPtr);
-       iowrite32(np->ring_dma_addr+sizeof(struct w840_rx_desc)*RX_RING_SIZE,
-               np->base_addr + TxRingPtr);
+       writel(np->ring_dma_addr, dev->base_addr + RxRingPtr);
+       writel(np->ring_dma_addr+sizeof(struct w840_rx_desc)*RX_RING_SIZE,
+               dev->base_addr + TxRingPtr);
 
 }
 
@@ -900,12 +917,12 @@ static void free_rxtx_rings(struct netdev_private* np)
 
 static void init_registers(struct net_device *dev)
 {
-       struct netdev_private *np = netdev_priv(dev);
-       void __iomem *ioaddr = np->base_addr;
+       struct netdev_private *np = dev->priv;
+       long ioaddr = dev->base_addr;
        int i;
 
        for (i = 0; i < 6; i++)
-               iowrite8(dev->dev_addr[i], ioaddr + StationAddr + i);
+               writeb(dev->dev_addr[i], ioaddr + StationAddr + i);
 
        /* Initialize other registers. */
 #ifdef __BIG_ENDIAN
@@ -942,7 +959,7 @@ static void init_registers(struct net_device *dev)
 #warning Processor architecture undefined
        i |= 0x4800;
 #endif
-       iowrite32(i, ioaddr + PCIBusCfg);
+       writel(i, ioaddr + PCIBusCfg);
 
        np->csr6 = 0;
        /* 128 byte Tx threshold; 
@@ -950,19 +967,19 @@ static void init_registers(struct net_device *dev)
        update_csr6(dev, 0x00022002 | update_link(dev) | __set_rx_mode(dev));
 
        /* Clear and Enable interrupts by setting the interrupt mask. */
-       iowrite32(0x1A0F5, ioaddr + IntrStatus);
-       iowrite32(0x1A0F5, ioaddr + IntrEnable);
+       writel(0x1A0F5, ioaddr + IntrStatus);
+       writel(0x1A0F5, ioaddr + IntrEnable);
 
-       iowrite32(0, ioaddr + RxStartDemand);
+       writel(0, ioaddr + RxStartDemand);
 }
 
 static void tx_timeout(struct net_device *dev)
 {
-       struct netdev_private *np = netdev_priv(dev);
-       void __iomem *ioaddr = np->base_addr;
+       struct netdev_private *np = dev->priv;
+       long ioaddr = dev->base_addr;
 
        printk(KERN_WARNING "%s: Transmit timed out, status %8.8x,"
-                  " resetting...\n", dev->name, ioread32(ioaddr + IntrStatus));
+                  " resetting...\n", dev->name, (int)readl(ioaddr + IntrStatus));
 
        {
                int i;
@@ -976,7 +993,7 @@ static void tx_timeout(struct net_device *dev)
        }
        printk(KERN_DEBUG "Tx cur %d Tx dirty %d Tx Full %d, q bytes %d.\n",
                                np->cur_tx, np->dirty_tx, np->tx_full, np->tx_q_bytes);
-       printk(KERN_DEBUG "Tx Descriptor addr %xh.\n",ioread32(ioaddr+0x4C));
+       printk(KERN_DEBUG "Tx Descriptor addr %xh.\n",readl(ioaddr+0x4C));
 
        disable_irq(dev->irq);
        spin_lock_irq(&np->lock);
@@ -986,7 +1003,7 @@ static void tx_timeout(struct net_device *dev)
         * everything.
         */
 
-       iowrite32(1, np->base_addr+PCIBusCfg);
+       writel(1, dev->base_addr+PCIBusCfg);
        udelay(1);
 
        free_rxtx_rings(np);
@@ -1004,7 +1021,7 @@ static void tx_timeout(struct net_device *dev)
 /* Initialize the Rx and Tx rings, along with various 'dev' bits. */
 static int alloc_ringdesc(struct net_device *dev)
 {
-       struct netdev_private *np = netdev_priv(dev);
+       struct netdev_private *np = dev->priv;
 
        np->rx_buf_sz = (dev->mtu <= 1500 ? PKT_BUF_SZ : dev->mtu + 32);
 
@@ -1029,7 +1046,7 @@ static void free_ringdesc(struct netdev_private *np)
 
 static int start_tx(struct sk_buff *skb, struct net_device *dev)
 {
-       struct netdev_private *np = netdev_priv(dev);
+       struct netdev_private *np = dev->priv;
        unsigned entry;
 
        /* Caution: the write order is important here, set the field
@@ -1070,7 +1087,7 @@ static int start_tx(struct sk_buff *skb, struct net_device *dev)
        wmb(); /* flush length, buffer1, buffer2 */
        np->tx_ring[entry].status = DescOwn;
        wmb(); /* flush status and kick the hardware */
-       iowrite32(0, np->base_addr + TxStartDemand);
+       writel(0, dev->base_addr + TxStartDemand);
        np->tx_q_bytes += skb->len;
        /* Work around horrible bug in the chip by marking the queue as full
           when we do not have FIFO room for a maximum sized packet. */
@@ -1093,7 +1110,7 @@ static int start_tx(struct sk_buff *skb, struct net_device *dev)
 
 static void netdev_tx_done(struct net_device *dev)
 {
-       struct netdev_private *np = netdev_priv(dev);
+       struct netdev_private *np = dev->priv;
        for (; np->cur_tx - np->dirty_tx > 0; np->dirty_tx++) {
                int entry = np->dirty_tx % TX_RING_SIZE;
                int tx_status = np->tx_ring[entry].status;
@@ -1146,18 +1163,18 @@ static void netdev_tx_done(struct net_device *dev)
 static irqreturn_t intr_handler(int irq, void *dev_instance, struct pt_regs *rgs)
 {
        struct net_device *dev = (struct net_device *)dev_instance;
-       struct netdev_private *np = netdev_priv(dev);
-       void __iomem *ioaddr = np->base_addr;
+       struct netdev_private *np = dev->priv;
+       long ioaddr = dev->base_addr;
        int work_limit = max_interrupt_work;
        int handled = 0;
 
        if (!netif_device_present(dev))
                return IRQ_NONE;
        do {
-               u32 intr_status = ioread32(ioaddr + IntrStatus);
+               u32 intr_status = readl(ioaddr + IntrStatus);
 
                /* Acknowledge all of the current interrupt sources ASAP. */
-               iowrite32(intr_status & 0x001ffff, ioaddr + IntrStatus);
+               writel(intr_status & 0x001ffff, ioaddr + IntrStatus);
 
                if (debug > 4)
                        printk(KERN_DEBUG "%s: Interrupt, status %4.4x.\n",
@@ -1171,7 +1188,7 @@ static irqreturn_t intr_handler(int irq, void *dev_instance, struct pt_regs *rgs
                if (intr_status & (IntrRxDone | RxNoBuf))
                        netdev_rx(dev);
                if (intr_status & RxNoBuf)
-                       iowrite32(0, ioaddr + RxStartDemand);
+                       writel(0, ioaddr + RxStartDemand);
 
                if (intr_status & (TxIdle | IntrTxDone) &&
                        np->cur_tx != np->dirty_tx) {
@@ -1192,8 +1209,8 @@ static irqreturn_t intr_handler(int irq, void *dev_instance, struct pt_regs *rgs
                           10*82usec ticks. */
                        spin_lock(&np->lock);
                        if (netif_device_present(dev)) {
-                               iowrite32(AbnormalIntr | TimerInt, ioaddr + IntrEnable);
-                               iowrite32(10, ioaddr + GPTimer);
+                               writel(AbnormalIntr | TimerInt, ioaddr + IntrEnable);
+                               writel(10, ioaddr + GPTimer);
                        }
                        spin_unlock(&np->lock);
                        break;
@@ -1202,7 +1219,7 @@ static irqreturn_t intr_handler(int irq, void *dev_instance, struct pt_regs *rgs
 
        if (debug > 3)
                printk(KERN_DEBUG "%s: exiting interrupt, status=%#4.4x.\n",
-                          dev->name, ioread32(ioaddr + IntrStatus));
+                          dev->name, (int)readl(ioaddr + IntrStatus));
        return IRQ_RETVAL(handled);
 }
 
@@ -1210,7 +1227,7 @@ static irqreturn_t intr_handler(int irq, void *dev_instance, struct pt_regs *rgs
    for clarity and better register allocation. */
 static int netdev_rx(struct net_device *dev)
 {
-       struct netdev_private *np = netdev_priv(dev);
+       struct netdev_private *np = dev->priv;
        int entry = np->cur_rx % RX_RING_SIZE;
        int work_limit = np->dirty_rx + RX_RING_SIZE - np->cur_rx;
 
@@ -1326,8 +1343,8 @@ static int netdev_rx(struct net_device *dev)
 
 static void netdev_error(struct net_device *dev, int intr_status)
 {
-       struct netdev_private *np = netdev_priv(dev);
-       void __iomem *ioaddr = np->base_addr;
+       long ioaddr = dev->base_addr;
+       struct netdev_private *np = dev->priv;
 
        if (debug > 2)
                printk(KERN_DEBUG "%s: Abnormal event, %8.8x.\n",
@@ -1361,22 +1378,22 @@ static void netdev_error(struct net_device *dev, int intr_status)
        if (intr_status & TimerInt) {
                /* Re-enable other interrupts. */
                if (netif_device_present(dev))
-                       iowrite32(0x1A0F5, ioaddr + IntrEnable);
+                       writel(0x1A0F5, ioaddr + IntrEnable);
        }
-       np->stats.rx_missed_errors += ioread32(ioaddr + RxMissed) & 0xffff;
-       iowrite32(0, ioaddr + RxStartDemand);
+       np->stats.rx_missed_errors += readl(ioaddr + RxMissed) & 0xffff;
+       writel(0, ioaddr + RxStartDemand);
        spin_unlock(&np->lock);
 }
 
 static struct net_device_stats *get_stats(struct net_device *dev)
 {
-       struct netdev_private *np = netdev_priv(dev);
-       void __iomem *ioaddr = np->base_addr;
+       long ioaddr = dev->base_addr;
+       struct netdev_private *np = dev->priv;
 
        /* The chip only need report frame silently dropped. */
        spin_lock_irq(&np->lock);
        if (netif_running(dev) && netif_device_present(dev))
-               np->stats.rx_missed_errors += ioread32(ioaddr + RxMissed) & 0xffff;
+               np->stats.rx_missed_errors += readl(ioaddr + RxMissed) & 0xffff;
        spin_unlock_irq(&np->lock);
 
        return &np->stats;
@@ -1385,8 +1402,7 @@ static struct net_device_stats *get_stats(struct net_device *dev)
 
 static u32 __set_rx_mode(struct net_device *dev)
 {
-       struct netdev_private *np = netdev_priv(dev);
-       void __iomem *ioaddr = np->base_addr;
+       long ioaddr = dev->base_addr;
        u32 mc_filter[2];                       /* Multicast hash filter */
        u32 rx_mode;
 
@@ -1413,14 +1429,14 @@ static u32 __set_rx_mode(struct net_device *dev)
                }
                rx_mode = AcceptBroadcast | AcceptMulticast | AcceptMyPhys;
        }
-       iowrite32(mc_filter[0], ioaddr + MulticastFilter0);
-       iowrite32(mc_filter[1], ioaddr + MulticastFilter1);
+       writel(mc_filter[0], ioaddr + MulticastFilter0);
+       writel(mc_filter[1], ioaddr + MulticastFilter1);
        return rx_mode;
 }
 
 static void set_rx_mode(struct net_device *dev)
 {
-       struct netdev_private *np = netdev_priv(dev);
+       struct netdev_private *np = dev->priv;
        u32 rx_mode = __set_rx_mode(dev);
        spin_lock_irq(&np->lock);
        update_csr6(dev, (np->csr6 & ~0x00F8) | rx_mode);
@@ -1429,7 +1445,7 @@ static void set_rx_mode(struct net_device *dev)
 
 static void netdev_get_drvinfo (struct net_device *dev, struct ethtool_drvinfo *info)
 {
-       struct netdev_private *np = netdev_priv(dev);
+       struct netdev_private *np = dev->priv;
 
        strcpy (info->driver, DRV_NAME);
        strcpy (info->version, DRV_VERSION);
@@ -1438,7 +1454,7 @@ static void netdev_get_drvinfo (struct net_device *dev, struct ethtool_drvinfo *
 
 static int netdev_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 {
-       struct netdev_private *np = netdev_priv(dev);
+       struct netdev_private *np = dev->priv;
        int rc;
 
        spin_lock_irq(&np->lock);
@@ -1450,7 +1466,7 @@ static int netdev_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 
 static int netdev_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 {
-       struct netdev_private *np = netdev_priv(dev);
+       struct netdev_private *np = dev->priv;
        int rc;
 
        spin_lock_irq(&np->lock);
@@ -1462,13 +1478,13 @@ static int netdev_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 
 static int netdev_nway_reset(struct net_device *dev)
 {
-       struct netdev_private *np = netdev_priv(dev);
+       struct netdev_private *np = dev->priv;
        return mii_nway_restart(&np->mii_if);
 }
 
 static u32 netdev_get_link(struct net_device *dev)
 {
-       struct netdev_private *np = netdev_priv(dev);
+       struct netdev_private *np = dev->priv;
        return mii_link_ok(&np->mii_if);
 }
 
@@ -1501,7 +1517,7 @@ static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 
        switch(cmd) {
        case SIOCGMIIPHY:               /* Get address of MII PHY in use. */
-               data->phy_id = ((struct netdev_private *)netdev_priv(dev))->phys[0] & 0x1f;
+               data->phy_id = ((struct netdev_private *)dev->priv)->phys[0] & 0x1f;
                /* Fall Through */
 
        case SIOCGMIIREG:               /* Read MII PHY register. */
@@ -1524,15 +1540,15 @@ static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 
 static int netdev_close(struct net_device *dev)
 {
-       struct netdev_private *np = netdev_priv(dev);
-       void __iomem *ioaddr = np->base_addr;
+       long ioaddr = dev->base_addr;
+       struct netdev_private *np = dev->priv;
 
        netif_stop_queue(dev);
 
        if (debug > 1) {
                printk(KERN_DEBUG "%s: Shutting down ethercard, status was %8.8x "
-                          "Config %8.8x.\n", dev->name, ioread32(ioaddr + IntrStatus),
-                          ioread32(ioaddr + NetworkConfig));
+                          "Config %8.8x.\n", dev->name, (int)readl(ioaddr + IntrStatus),
+                          (int)readl(ioaddr + NetworkConfig));
                printk(KERN_DEBUG "%s: Queue pointers were Tx %d / %d,  Rx %d / %d.\n",
                           dev->name, np->cur_tx, np->dirty_tx, np->cur_rx, np->dirty_rx);
        }
@@ -1541,15 +1557,15 @@ static int netdev_close(struct net_device *dev)
        spin_lock_irq(&np->lock);
        netif_device_detach(dev);
        update_csr6(dev, 0);
-       iowrite32(0x0000, ioaddr + IntrEnable);
+       writel(0x0000, ioaddr + IntrEnable);
        spin_unlock_irq(&np->lock);
 
        free_irq(dev->irq, dev);
        wmb();
        netif_device_attach(dev);
 
-       if (ioread32(ioaddr + NetworkConfig) != 0xffffffff)
-               np->stats.rx_missed_errors += ioread32(ioaddr + RxMissed) & 0xffff;
+       if (readl(ioaddr + NetworkConfig) != 0xffffffff)
+               np->stats.rx_missed_errors += readl(ioaddr + RxMissed) & 0xffff;
 
 #ifdef __i386__
        if (debug > 2) {
@@ -1584,10 +1600,11 @@ static void __devexit w840_remove1 (struct pci_dev *pdev)
        struct net_device *dev = pci_get_drvdata(pdev);
        
        if (dev) {
-               struct netdev_private *np = netdev_priv(dev);
                unregister_netdev(dev);
                pci_release_regions(pdev);
-               pci_iounmap(pdev, np->base_addr);
+#ifndef USE_IO_OPS
+               iounmap((char *)(dev->base_addr));
+#endif
                free_netdev(dev);
        }
 
@@ -1622,8 +1639,8 @@ static void __devexit w840_remove1 (struct pci_dev *pdev)
 static int w840_suspend (struct pci_dev *pdev, u32 state)
 {
        struct net_device *dev = pci_get_drvdata (pdev);
-       struct netdev_private *np = netdev_priv(dev);
-       void __iomem *ioaddr = np->base_addr;
+       struct netdev_private *np = dev->priv;
+       long ioaddr = dev->base_addr;
 
        rtnl_lock();
        if (netif_running (dev)) {
@@ -1632,19 +1649,19 @@ static int w840_suspend (struct pci_dev *pdev, u32 state)
                spin_lock_irq(&np->lock);
                netif_device_detach(dev);
                update_csr6(dev, 0);
-               iowrite32(0, ioaddr + IntrEnable);
+               writel(0, ioaddr + IntrEnable);
                netif_stop_queue(dev);
                spin_unlock_irq(&np->lock);
 
                spin_unlock_wait(&dev->xmit_lock);
                synchronize_irq(dev->irq);
        
-               np->stats.rx_missed_errors += ioread32(ioaddr + RxMissed) & 0xffff;
+               np->stats.rx_missed_errors += readl(ioaddr + RxMissed) & 0xffff;
 
                /* no more hardware accesses behind this line. */
 
                if (np->csr6) BUG();
-               if (ioread32(ioaddr + IntrEnable)) BUG();
+               if (readl(ioaddr + IntrEnable)) BUG();
 
                /* pci_power_off(pdev, -1); */
 
@@ -1659,7 +1676,7 @@ static int w840_suspend (struct pci_dev *pdev, u32 state)
 static int w840_resume (struct pci_dev *pdev)
 {
        struct net_device *dev = pci_get_drvdata (pdev);
-       struct netdev_private *np = netdev_priv(dev);
+       struct netdev_private *np = dev->priv;
 
        rtnl_lock();
        if (netif_device_present(dev))
@@ -1669,8 +1686,8 @@ static int w840_resume (struct pci_dev *pdev)
        /*      pci_power_on(pdev); */
 
                spin_lock_irq(&np->lock);
-               iowrite32(1, np->base_addr+PCIBusCfg);
-               ioread32(np->base_addr+PCIBusCfg);
+               writel(1, dev->base_addr+PCIBusCfg);
+               readl(dev->base_addr+PCIBusCfg);
                udelay(1);
                netif_device_attach(dev);
                init_rxtx_rings(dev);