]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - drivers/net/arcnet/com90xx.c
Merge remote-tracking branch 'ipsec/master'
[karo-tx-linux.git] / drivers / net / arcnet / com90xx.c
index 50c346b5d9073542e4105877c62f150600911ba3..0d9b45ff1bb21bc7878c251c63082a5400a7d93b 100644 (file)
@@ -36,7 +36,9 @@
 #include <linux/netdevice.h>
 #include <linux/slab.h>
 #include <linux/io.h>
-#include <linux/arcdevice.h>
+
+#include "arcdevice.h"
+#include "com9026.h"
 
 /* Define this to speed up the autoprobe by assuming if only one io port and
  * shmem are left in the list at Stage 5, they must correspond to each
@@ -60,8 +62,8 @@ static void com90xx_setmask(struct net_device *dev, int mask);
 static int com90xx_reset(struct net_device *dev, int really_reset);
 static void com90xx_copy_to_card(struct net_device *dev, int bufnum, int offset,
                                 void *buf, int count);
-static void com90xx_copy_from_card(struct net_device *dev, int bufnum, int offset,
-                                  void *buf, int count);
+static void com90xx_copy_from_card(struct net_device *dev, int bufnum,
+                                  int offset, void *buf, int count);
 
 /* Known ARCnet cards */
 
@@ -77,24 +79,6 @@ static int numcards;
 #define BUFFER_SIZE (512)
 #define MIRROR_SIZE (BUFFER_SIZE * 4)
 
-/* COM 9026 controller chip --> ARCnet register addresses */
-#define _INTMASK       (ioaddr + 0)    /* writable */
-#define _STATUS                (ioaddr + 0)    /* readable */
-#define _COMMAND       (ioaddr + 1)    /* writable, returns random vals on read (?) */
-#define _CONFIG                (ioaddr + 2)    /* Configuration register */
-#define _RESET         (ioaddr + 8)    /* software reset (on read) */
-#define _MEMDATA       (ioaddr + 12)   /* Data port for IO-mapped memory */
-#define _ADDR_HI       (ioaddr + 15)   /* Control registers for said */
-#define _ADDR_LO       (ioaddr + 14)
-
-#undef ASTATUS
-#undef ACOMMAND
-#undef AINTMASK
-
-#define ASTATUS()      inb(_STATUS)
-#define ACOMMAND(cmd)  outb((cmd), _COMMAND)
-#define AINTMASK(msk)  outb((msk), _INTMASK)
-
 static int com90xx_skip_probe __initdata = 0;
 
 /* Module parameters */
@@ -165,7 +149,8 @@ static void __init com90xx_probe(void)
 
                ioaddr = *port;
 
-               if (!request_region(*port, ARCNET_TOTAL_SIZE, "arcnet (90xx)")) {
+               if (!request_region(*port, ARCNET_TOTAL_SIZE,
+                                   "arcnet (90xx)")) {
                        arc_cont(D_INIT_REASONS, "(request_region)\n");
                        arc_cont(D_INIT_REASONS, "S1: ");
                        if (BUGLVL(D_INIT_REASONS))
@@ -173,7 +158,7 @@ static void __init com90xx_probe(void)
                        *port-- = ports[--numports];
                        continue;
                }
-               if (ASTATUS() == 0xFF) {
+               if (arcnet_inb(ioaddr, COM9026_REG_R_STATUS) == 0xFF) {
                        arc_cont(D_INIT_REASONS, "(empty)\n");
                        arc_cont(D_INIT_REASONS, "S1: ");
                        if (BUGLVL(D_INIT_REASONS))
@@ -182,7 +167,8 @@ static void __init com90xx_probe(void)
                        *port-- = ports[--numports];
                        continue;
                }
-               inb(_RESET);    /* begin resetting card */
+               /* begin resetting card */
+               arcnet_inb(ioaddr, COM9026_REG_R_RESET);
 
                arc_cont(D_INIT_REASONS, "\n");
                arc_cont(D_INIT_REASONS, "S1: ");
@@ -244,9 +230,10 @@ static void __init com90xx_probe(void)
                                numprint = 0;
                        goto out1;
                }
-               if (readb(base) != TESTvalue) {
+               if (arcnet_readb(base, COM9026_REG_R_STATUS) != TESTvalue) {
                        arc_cont(D_INIT_REASONS, "(%02Xh != %02Xh)\n",
-                                readb(base), TESTvalue);
+                                arcnet_readb(base, COM9026_REG_R_STATUS),
+                                TESTvalue);
                        arc_cont(D_INIT_REASONS, "S3: ");
                        if (BUGLVL(D_INIT_REASONS))
                                numprint = 0;
@@ -257,8 +244,8 @@ static void __init com90xx_probe(void)
                 * in another pass through this loop, they will be discarded
                 * because *cptr != TESTvalue.
                 */
-               writeb(0x42, base);
-               if (readb(base) != 0x42) {
+               arcnet_writeb(0x42, base, COM9026_REG_W_INTMASK);
+               if (arcnet_readb(base, COM9026_REG_R_STATUS) != 0x42) {
                        arc_cont(D_INIT_REASONS, "(read only)\n");
                        arc_cont(D_INIT_REASONS, "S3: ");
                        goto out2;
@@ -322,7 +309,7 @@ static void __init com90xx_probe(void)
                arc_cont(D_INIT, "%Xh ", *port);
 
                ioaddr = *port;
-               status = ASTATUS();
+               status = arcnet_inb(ioaddr, COM9026_REG_R_STATUS);
 
                if ((status & 0x9D)
                    != (NORXflag | RECONflag | TXFREEflag | RESETflag)) {
@@ -334,8 +321,9 @@ static void __init com90xx_probe(void)
                        *port-- = ports[--numports];
                        continue;
                }
-               ACOMMAND(CFLAGScmd | RESETclear | CONFIGclear);
-               status = ASTATUS();
+               arcnet_outb(CFLAGScmd | RESETclear | CONFIGclear,
+                           ioaddr, COM9026_REG_W_COMMAND);
+               status = arcnet_inb(ioaddr, COM9026_REG_R_STATUS);
                if (status & RESETflag) {
                        arc_cont(D_INIT_REASONS, " (eternal reset, status=%Xh)\n",
                                 status);
@@ -355,9 +343,9 @@ static void __init com90xx_probe(void)
                         * we tell it to start receiving.
                         */
                        airqmask = probe_irq_on();
-                       AINTMASK(NORXflag);
+                       arcnet_outb(NORXflag, ioaddr, COM9026_REG_W_INTMASK);
                        udelay(1);
-                       AINTMASK(0);
+                       arcnet_outb(0, ioaddr, COM9026_REG_W_INTMASK);
                        airq = probe_irq_off(airqmask);
 
                        if (airq <= 0) {
@@ -384,14 +372,15 @@ static void __init com90xx_probe(void)
                 */
 #ifdef FAST_PROBE
                if (numports > 1 || numshmems > 1) {
-                       inb(_RESET);
+                       arcnet_inb(ioaddr, COM9026_REG_R_RESET);
                        mdelay(RESETtime);
                } else {
                        /* just one shmem and port, assume they match */
-                       writeb(TESTvalue, iomem[0]);
+                       arcnet_writeb(TESTvalue, iomem[0],
+                                     COM9026_REG_W_INTMASK);
                }
 #else
-               inb(_RESET);
+               arcnet_inb(ioaddr, COM9026_REG_R_RESET);
                mdelay(RESETtime);
 #endif
 
@@ -399,7 +388,7 @@ static void __init com90xx_probe(void)
                        u_long ptr = shmems[index];
                        void __iomem *base = iomem[index];
 
-                       if (readb(base) == TESTvalue) { /* found one */
+                       if (arcnet_readb(base, COM9026_REG_R_STATUS) == TESTvalue) {    /* found one */
                                arc_cont(D_INIT, "%lXh)\n", *p);
                                openparen = 0;
 
@@ -413,7 +402,8 @@ static void __init com90xx_probe(void)
                                iomem[index] = iomem[numshmems];
                                break;  /* go to the next I/O port */
                        } else {
-                               arc_cont(D_INIT_REASONS, "%Xh-", readb(base));
+                               arc_cont(D_INIT_REASONS, "%Xh-",
+                                        arcnet_readb(base, COM9026_REG_R_STATUS));
                        }
                }
 
@@ -435,7 +425,7 @@ static void __init com90xx_probe(void)
 
        /* Now put back TESTvalue on all leftover shmems. */
        for (index = 0; index < numshmems; index++) {
-               writeb(TESTvalue, iomem[index]);
+               arcnet_writeb(TESTvalue, iomem[index], COM9026_REG_W_INTMASK);
                iounmap(iomem[index]);
                release_mem_region(shmems[index], MIRROR_SIZE);
        }
@@ -453,7 +443,7 @@ static int check_mirror(unsigned long addr, size_t size)
 
        p = ioremap(addr, size);
        if (p) {
-               if (readb(p) == TESTvalue)
+               if (arcnet_readb(p, COM9026_REG_R_STATUS) == TESTvalue)
                        res = 1;
                else
                        res = 0;
@@ -467,7 +457,8 @@ static int check_mirror(unsigned long addr, size_t size)
 /* Set up the struct net_device associated with this card.  Called after
  * probing succeeds.
  */
-static int __init com90xx_found(int ioaddr, int airq, u_long shmem, void __iomem *p)
+static int __init com90xx_found(int ioaddr, int airq, u_long shmem,
+                               void __iomem *p)
 {
        struct net_device *dev = NULL;
        struct arcnet_local *lp;
@@ -490,7 +481,7 @@ static int __init com90xx_found(int ioaddr, int airq, u_long shmem, void __iomem
         * 2k (or there are no mirrors at all) but on some, it's 4k.
         */
        mirror_size = MIRROR_SIZE;
-       if (readb(p) == TESTvalue &&
+       if (arcnet_readb(p, COM9026_REG_R_STATUS) == TESTvalue &&
            check_mirror(shmem - MIRROR_SIZE, MIRROR_SIZE) == 0 &&
            check_mirror(shmem - 2 * MIRROR_SIZE, MIRROR_SIZE) == 1)
                mirror_size = 2 * MIRROR_SIZE;
@@ -511,7 +502,9 @@ static int __init com90xx_found(int ioaddr, int airq, u_long shmem, void __iomem
        iounmap(p);
        release_mem_region(shmem, MIRROR_SIZE);
 
-       if (!request_mem_region(dev->mem_start, dev->mem_end - dev->mem_start + 1, "arcnet (90xx)"))
+       if (!request_mem_region(dev->mem_start,
+                               dev->mem_end - dev->mem_start + 1,
+                               "arcnet (90xx)"))
                goto err_free_dev;
 
        /* reserve the irq */
@@ -530,14 +523,15 @@ static int __init com90xx_found(int ioaddr, int airq, u_long shmem, void __iomem
        lp->hw.owner = THIS_MODULE;
        lp->hw.copy_to_card = com90xx_copy_to_card;
        lp->hw.copy_from_card = com90xx_copy_from_card;
-       lp->mem_start = ioremap(dev->mem_start, dev->mem_end - dev->mem_start + 1);
+       lp->mem_start = ioremap(dev->mem_start,
+                               dev->mem_end - dev->mem_start + 1);
        if (!lp->mem_start) {
                arc_printk(D_NORMAL, dev, "Can't remap device memory!\n");
                goto err_free_irq;
        }
 
        /* get and check the station ID from offset 1 in shmem */
-       dev->dev_addr[0] = readb(lp->mem_start + 1);
+       dev->dev_addr[0] = arcnet_readb(lp->mem_start, COM9026_REG_R_STATION);
 
        dev->base_addr = ioaddr;
 
@@ -568,21 +562,21 @@ static void com90xx_command(struct net_device *dev, int cmd)
 {
        short ioaddr = dev->base_addr;
 
-       ACOMMAND(cmd);
+       arcnet_outb(cmd, ioaddr, COM9026_REG_W_COMMAND);
 }
 
 static int com90xx_status(struct net_device *dev)
 {
        short ioaddr = dev->base_addr;
 
-       return ASTATUS();
+       return arcnet_inb(ioaddr, COM9026_REG_R_STATUS);
 }
 
 static void com90xx_setmask(struct net_device *dev, int mask)
 {
        short ioaddr = dev->base_addr;
 
-       AINTMASK(mask);
+       arcnet_outb(mask, ioaddr, COM9026_REG_W_INTMASK);
 }
 
 /* Do a hardware reset on the card, and set up necessary registers.
@@ -597,27 +591,32 @@ static int com90xx_reset(struct net_device *dev, int really_reset)
        struct arcnet_local *lp = netdev_priv(dev);
        short ioaddr = dev->base_addr;
 
-       arc_printk(D_INIT, dev, "Resetting (status=%02Xh)\n", ASTATUS());
+       arc_printk(D_INIT, dev, "Resetting (status=%02Xh)\n",
+                  arcnet_inb(ioaddr, COM9026_REG_R_STATUS));
 
        if (really_reset) {
                /* reset the card */
-               inb(_RESET);
+               arcnet_inb(ioaddr, COM9026_REG_R_RESET);
                mdelay(RESETtime);
        }
-       ACOMMAND(CFLAGScmd | RESETclear);       /* clear flags & end reset */
-       ACOMMAND(CFLAGScmd | CONFIGclear);
+       /* clear flags & end reset */
+       arcnet_outb(CFLAGScmd | RESETclear, ioaddr, COM9026_REG_W_COMMAND);
+       arcnet_outb(CFLAGScmd | CONFIGclear, ioaddr, COM9026_REG_W_COMMAND);
 
+#if 0
        /* don't do this until we verify that it doesn't hurt older cards! */
-       /* outb(inb(_CONFIG) | ENABLE16flag, _CONFIG); */
+       arcnet_outb(arcnet_inb(ioaddr, COM9026_REG_RW_CONFIG) | ENABLE16flag,
+                   ioaddr, COM9026_REG_RW_CONFIG);
+#endif
 
        /* verify that the ARCnet signature byte is present */
-       if (readb(lp->mem_start) != TESTvalue) {
+       if (arcnet_readb(lp->mem_start, COM9026_REG_R_STATUS) != TESTvalue) {
                if (really_reset)
                        arc_printk(D_NORMAL, dev, "reset failed: TESTvalue not present.\n");
                return 1;
        }
        /* enable extended (512-byte) packets */
-       ACOMMAND(CONFIGcmd | EXTconf);
+       arcnet_outb(CONFIGcmd | EXTconf, ioaddr, COM9026_REG_W_COMMAND);
 
        /* clean out all the memory to make debugging make more sense :) */
        if (BUGLVL(D_DURING))
@@ -627,8 +626,8 @@ static int com90xx_reset(struct net_device *dev, int really_reset)
        return 0;
 }
 
-static void com90xx_copy_to_card(struct net_device *dev, int bufnum, int offset,
-                                void *buf, int count)
+static void com90xx_copy_to_card(struct net_device *dev, int bufnum,
+                                int offset, void *buf, int count)
 {
        struct arcnet_local *lp = netdev_priv(dev);
        void __iomem *memaddr = lp->mem_start + bufnum * 512 + offset;
@@ -636,8 +635,8 @@ static void com90xx_copy_to_card(struct net_device *dev, int bufnum, int offset,
        TIME(dev, "memcpy_toio", count, memcpy_toio(memaddr, buf, count));
 }
 
-static void com90xx_copy_from_card(struct net_device *dev, int bufnum, int offset,
-                                  void *buf, int count)
+static void com90xx_copy_from_card(struct net_device *dev, int bufnum,
+                                  int offset, void *buf, int count)
 {
        struct arcnet_local *lp = netdev_priv(dev);
        void __iomem *memaddr = lp->mem_start + bufnum * 512 + offset;
@@ -671,7 +670,8 @@ static void __exit com90xx_exit(void)
                free_irq(dev->irq, dev);
                iounmap(lp->mem_start);
                release_region(dev->base_addr, ARCNET_TOTAL_SIZE);
-               release_mem_region(dev->mem_start, dev->mem_end - dev->mem_start + 1);
+               release_mem_region(dev->mem_start,
+                                  dev->mem_end - dev->mem_start + 1);
                free_netdev(dev);
        }
 }