Commit 2bb50058 authored by Alexander Viro's avatar Alexander Viro Committed by Jeff Garzik

[PATCH] sk_mca - iomem and isa-ectomy

usual isa-ectomy and iomem annotations
Signed-off-by: default avatarAl Viro <viro@parcelfarce.linux.theplanet.co.uk>
Signed-off-by: default avatarJeff Garzik <jgarzik@pobox.com>
parent 28a0f7b5
...@@ -127,12 +127,13 @@ static unsigned char poly[] = ...@@ -127,12 +127,13 @@ static unsigned char poly[] =
#ifdef DEBUG #ifdef DEBUG
static void dumpmem(struct net_device *dev, u32 start, u32 len) static void dumpmem(struct net_device *dev, u32 start, u32 len)
{ {
skmca_priv *priv = netdev_priv(dev);
int z; int z;
for (z = 0; z < len; z++) { for (z = 0; z < len; z++) {
if ((z & 15) == 0) if ((z & 15) == 0)
printk("%04x:", z); printk("%04x:", z);
printk(" %02x", SKMCA_READB(dev->mem_start + start + z)); printk(" %02x", readb(priv->base + start + z));
if ((z & 15) == 15) if ((z & 15) == 15)
printk("\n"); printk("\n");
} }
...@@ -222,9 +223,9 @@ static void ResetBoard(struct net_device *dev) ...@@ -222,9 +223,9 @@ static void ResetBoard(struct net_device *dev)
{ {
skmca_priv *priv = netdev_priv(dev); skmca_priv *priv = netdev_priv(dev);
SKMCA_WRITEB(CTRL_RESET_ON, priv->ctrladdr); writeb(CTRL_RESET_ON, priv->ctrladdr);
udelay(10); udelay(10);
SKMCA_WRITEB(CTRL_RESET_OFF, priv->ctrladdr); writeb(CTRL_RESET_OFF, priv->ctrladdr);
} }
/* wait for LANCE interface to become not busy */ /* wait for LANCE interface to become not busy */
...@@ -234,7 +235,7 @@ static int WaitLANCE(struct net_device *dev) ...@@ -234,7 +235,7 @@ static int WaitLANCE(struct net_device *dev)
skmca_priv *priv = netdev_priv(dev); skmca_priv *priv = netdev_priv(dev);
int t = 0; int t = 0;
while ((SKMCA_READB(priv->ctrladdr) & STAT_IO_BUSY) == while ((readb(priv->ctrladdr) & STAT_IO_BUSY) ==
STAT_IO_BUSY) { STAT_IO_BUSY) {
udelay(1); udelay(1);
if (++t > 1000) { if (++t > 1000) {
...@@ -263,19 +264,17 @@ static void SetLANCE(struct net_device *dev, u16 addr, u16 value) ...@@ -263,19 +264,17 @@ static void SetLANCE(struct net_device *dev, u16 addr, u16 value)
/* transfer register address to RAP */ /* transfer register address to RAP */
SKMCA_WRITEB(CTRL_RESET_OFF | CTRL_RW_WRITE | CTRL_ADR_RAP, writeb(CTRL_RESET_OFF | CTRL_RW_WRITE | CTRL_ADR_RAP, priv->ctrladdr);
priv->ctrladdr); writew(addr, priv->ioregaddr);
SKMCA_WRITEW(addr, priv->ioregaddr); writeb(IOCMD_GO, priv->cmdaddr);
SKMCA_WRITEB(IOCMD_GO, priv->cmdaddr);
udelay(1); udelay(1);
WaitLANCE(dev); WaitLANCE(dev);
/* transfer data to register */ /* transfer data to register */
SKMCA_WRITEB(CTRL_RESET_OFF | CTRL_RW_WRITE | CTRL_ADR_DATA, writeb(CTRL_RESET_OFF | CTRL_RW_WRITE | CTRL_ADR_DATA, priv->ctrladdr);
priv->ctrladdr); writew(value, priv->ioregaddr);
SKMCA_WRITEW(value, priv->ioregaddr); writeb(IOCMD_GO, priv->cmdaddr);
SKMCA_WRITEB(IOCMD_GO, priv->cmdaddr);
udelay(1); udelay(1);
WaitLANCE(dev); WaitLANCE(dev);
...@@ -302,21 +301,19 @@ static u16 GetLANCE(struct net_device *dev, u16 addr) ...@@ -302,21 +301,19 @@ static u16 GetLANCE(struct net_device *dev, u16 addr)
/* transfer register address to RAP */ /* transfer register address to RAP */
SKMCA_WRITEB(CTRL_RESET_OFF | CTRL_RW_WRITE | CTRL_ADR_RAP, writeb(CTRL_RESET_OFF | CTRL_RW_WRITE | CTRL_ADR_RAP, priv->ctrladdr);
priv->ctrladdr); writew(addr, priv->ioregaddr);
SKMCA_WRITEW(addr, priv->ioregaddr); writeb(IOCMD_GO, priv->cmdaddr);
SKMCA_WRITEB(IOCMD_GO, priv->cmdaddr);
udelay(1); udelay(1);
WaitLANCE(dev); WaitLANCE(dev);
/* transfer data from register */ /* transfer data from register */
SKMCA_WRITEB(CTRL_RESET_OFF | CTRL_RW_READ | CTRL_ADR_DATA, writeb(CTRL_RESET_OFF | CTRL_RW_READ | CTRL_ADR_DATA, priv->ctrladdr);
priv->ctrladdr); writeb(IOCMD_GO, priv->cmdaddr);
SKMCA_WRITEB(IOCMD_GO, priv->cmdaddr);
udelay(1); udelay(1);
WaitLANCE(dev); WaitLANCE(dev);
res = SKMCA_READW(priv->ioregaddr); res = readw(priv->ioregaddr);
/* reenable interrupts */ /* reenable interrupts */
...@@ -329,6 +326,7 @@ static u16 GetLANCE(struct net_device *dev, u16 addr) ...@@ -329,6 +326,7 @@ static u16 GetLANCE(struct net_device *dev, u16 addr)
static void InitDscrs(struct net_device *dev) static void InitDscrs(struct net_device *dev)
{ {
skmca_priv *priv = netdev_priv(dev);
u32 bufaddr; u32 bufaddr;
/* Set up Tx descriptors. The board has only 16K RAM so bits 16..23 /* Set up Tx descriptors. The board has only 16K RAM so bits 16..23
...@@ -344,11 +342,10 @@ static void InitDscrs(struct net_device *dev) ...@@ -344,11 +342,10 @@ static void InitDscrs(struct net_device *dev)
descr.Flags = 0; descr.Flags = 0;
descr.Len = 0xf000; descr.Len = 0xf000;
descr.Status = 0; descr.Status = 0;
SKMCA_TOIO(dev->mem_start + RAM_TXBASE + memcpy_toio(priv->base + RAM_TXBASE +
(z * sizeof(LANCE_TxDescr)), &descr, (z * sizeof(LANCE_TxDescr)), &descr,
sizeof(LANCE_TxDescr)); sizeof(LANCE_TxDescr));
SKMCA_SETIO(dev->mem_start + bufaddr, 0, memset_io(priv->base + bufaddr, 0, RAM_BUFSIZE);
RAM_BUFSIZE);
bufaddr += RAM_BUFSIZE; bufaddr += RAM_BUFSIZE;
} }
} }
...@@ -364,11 +361,10 @@ static void InitDscrs(struct net_device *dev) ...@@ -364,11 +361,10 @@ static void InitDscrs(struct net_device *dev)
descr.Flags = RXDSCR_FLAGS_OWN; descr.Flags = RXDSCR_FLAGS_OWN;
descr.MaxLen = -RAM_BUFSIZE; descr.MaxLen = -RAM_BUFSIZE;
descr.Len = 0; descr.Len = 0;
SKMCA_TOIO(dev->mem_start + RAM_RXBASE + memcpy_toio(priv->base + RAM_RXBASE +
(z * sizeof(LANCE_RxDescr)), &descr, (z * sizeof(LANCE_RxDescr)), &descr,
sizeof(LANCE_RxDescr)); sizeof(LANCE_RxDescr));
SKMCA_SETIO(dev->mem_start + bufaddr, 0, memset_io(priv->base + bufaddr, 0, RAM_BUFSIZE);
RAM_BUFSIZE);
bufaddr += RAM_BUFSIZE; bufaddr += RAM_BUFSIZE;
} }
} }
...@@ -478,6 +474,7 @@ static void StopLANCE(struct net_device *dev) ...@@ -478,6 +474,7 @@ static void StopLANCE(struct net_device *dev)
static void InitBoard(struct net_device *dev) static void InitBoard(struct net_device *dev)
{ {
skmca_priv *priv = netdev_priv(dev);
LANCE_InitBlock block; LANCE_InitBlock block;
/* Lay out the shared RAM - first we create the init block for the LANCE. /* Lay out the shared RAM - first we create the init block for the LANCE.
...@@ -492,7 +489,7 @@ static void InitBoard(struct net_device *dev) ...@@ -492,7 +489,7 @@ static void InitBoard(struct net_device *dev)
block.RdrP = (RAM_RXBASE & 0xffffff) | (LRXCOUNT << 29); block.RdrP = (RAM_RXBASE & 0xffffff) | (LRXCOUNT << 29);
block.TdrP = (RAM_TXBASE & 0xffffff) | (LTXCOUNT << 29); block.TdrP = (RAM_TXBASE & 0xffffff) | (LTXCOUNT << 29);
SKMCA_TOIO(dev->mem_start + RAM_INITBASE, &block, sizeof(block)); memcpy_toio(priv->base + RAM_INITBASE, &block, sizeof(block));
/* initialize LANCE. Implicitly sets up other structures in RAM. */ /* initialize LANCE. Implicitly sets up other structures in RAM. */
...@@ -597,7 +594,7 @@ static u16 irqrx_handler(struct net_device *dev, u16 oldcsr0) ...@@ -597,7 +594,7 @@ static u16 irqrx_handler(struct net_device *dev, u16 oldcsr0)
descraddr = RAM_RXBASE + (priv->nextrx * sizeof(LANCE_RxDescr)); descraddr = RAM_RXBASE + (priv->nextrx * sizeof(LANCE_RxDescr));
while (1) { while (1) {
/* read descriptor */ /* read descriptor */
SKMCA_FROMIO(&descr, dev->mem_start + descraddr, memcpy_fromio(&descr, priv->base + descraddr,
sizeof(LANCE_RxDescr)); sizeof(LANCE_RxDescr));
/* if we reach a descriptor we do not own, we're done */ /* if we reach a descriptor we do not own, we're done */
...@@ -629,8 +626,8 @@ static u16 irqrx_handler(struct net_device *dev, u16 oldcsr0) ...@@ -629,8 +626,8 @@ static u16 irqrx_handler(struct net_device *dev, u16 oldcsr0)
if (skb == NULL) if (skb == NULL)
priv->stat.rx_dropped++; priv->stat.rx_dropped++;
else { else {
SKMCA_FROMIO(skb_put(skb, descr.Len), memcpy_fromio(skb_put(skb, descr.Len),
dev->mem_start + priv->base +
descr.LowAddr, descr.Len); descr.LowAddr, descr.Len);
skb->dev = dev; skb->dev = dev;
skb->protocol = eth_type_trans(skb, dev); skb->protocol = eth_type_trans(skb, dev);
...@@ -647,7 +644,7 @@ static u16 irqrx_handler(struct net_device *dev, u16 oldcsr0) ...@@ -647,7 +644,7 @@ static u16 irqrx_handler(struct net_device *dev, u16 oldcsr0)
descr.Flags |= RXDSCR_FLAGS_OWN; descr.Flags |= RXDSCR_FLAGS_OWN;
/* update descriptor in shared RAM */ /* update descriptor in shared RAM */
SKMCA_TOIO(dev->mem_start + descraddr, &descr, memcpy_toio(priv->base + descraddr, &descr,
sizeof(LANCE_RxDescr)); sizeof(LANCE_RxDescr));
/* go to next descriptor */ /* go to next descriptor */
...@@ -679,7 +676,7 @@ static u16 irqtx_handler(struct net_device *dev, u16 oldcsr0) ...@@ -679,7 +676,7 @@ static u16 irqtx_handler(struct net_device *dev, u16 oldcsr0)
RAM_TXBASE + (priv->nexttxdone * sizeof(LANCE_TxDescr)); RAM_TXBASE + (priv->nexttxdone * sizeof(LANCE_TxDescr));
while (priv->txbusy > 0) { while (priv->txbusy > 0) {
/* read descriptor */ /* read descriptor */
SKMCA_FROMIO(&descr, dev->mem_start + descraddr, memcpy_fromio(&descr, priv->base + descraddr,
sizeof(LANCE_TxDescr)); sizeof(LANCE_TxDescr));
/* if the LANCE still owns this one, we've worked out all sent packets */ /* if the LANCE still owns this one, we've worked out all sent packets */
...@@ -892,8 +889,7 @@ static int skmca_tx(struct sk_buff *skb, struct net_device *dev) ...@@ -892,8 +889,7 @@ static int skmca_tx(struct sk_buff *skb, struct net_device *dev)
/* get TX descriptor */ /* get TX descriptor */
address = RAM_TXBASE + (priv->nexttxput * sizeof(LANCE_TxDescr)); address = RAM_TXBASE + (priv->nexttxput * sizeof(LANCE_TxDescr));
SKMCA_FROMIO(&descr, dev->mem_start + address, memcpy_fromio(&descr, priv->base + address, sizeof(LANCE_TxDescr));
sizeof(LANCE_TxDescr));
/* enter packet length as 2s complement - assure minimum length */ /* enter packet length as 2s complement - assure minimum length */
tmplen = skb->len; tmplen = skb->len;
...@@ -909,14 +905,14 @@ static int skmca_tx(struct sk_buff *skb, struct net_device *dev) ...@@ -909,14 +905,14 @@ static int skmca_tx(struct sk_buff *skb, struct net_device *dev)
unsigned int destoffs = 0, l = strlen(fill); unsigned int destoffs = 0, l = strlen(fill);
while (destoffs < tmplen) { while (destoffs < tmplen) {
SKMCA_TOIO(dev->mem_start + descr.LowAddr + memcpy_toio(priv->base + descr.LowAddr +
destoffs, fill, l); destoffs, fill, l);
destoffs += l; destoffs += l;
} }
} }
/* do the real data copying */ /* do the real data copying */
SKMCA_TOIO(dev->mem_start + descr.LowAddr, skb->data, skb->len); memcpy_toio(priv->base + descr.LowAddr, skb->data, skb->len);
/* hand descriptor over to LANCE - this is the first and last chunk */ /* hand descriptor over to LANCE - this is the first and last chunk */
descr.Flags = descr.Flags =
...@@ -943,8 +939,7 @@ static int skmca_tx(struct sk_buff *skb, struct net_device *dev) ...@@ -943,8 +939,7 @@ static int skmca_tx(struct sk_buff *skb, struct net_device *dev)
netif_stop_queue(dev); netif_stop_queue(dev);
/* write descriptor back to RAM */ /* write descriptor back to RAM */
SKMCA_TOIO(dev->mem_start + address, &descr, memcpy_toio(priv->base + address, &descr, sizeof(LANCE_TxDescr));
sizeof(LANCE_TxDescr));
/* if no descriptors were active, give the LANCE a hint to read it /* if no descriptors were active, give the LANCE a hint to read it
immediately */ immediately */
...@@ -975,13 +970,14 @@ static struct net_device_stats *skmca_stats(struct net_device *dev) ...@@ -975,13 +970,14 @@ static struct net_device_stats *skmca_stats(struct net_device *dev)
static void skmca_set_multicast_list(struct net_device *dev) static void skmca_set_multicast_list(struct net_device *dev)
{ {
skmca_priv *priv = netdev_priv(dev);
LANCE_InitBlock block; LANCE_InitBlock block;
/* first stop the LANCE... */ /* first stop the LANCE... */
StopLANCE(dev); StopLANCE(dev);
/* ...then modify the initialization block... */ /* ...then modify the initialization block... */
SKMCA_FROMIO(&block, dev->mem_start + RAM_INITBASE, sizeof(block)); memcpy_fromio(&block, priv->base + RAM_INITBASE, sizeof(block));
if (dev->flags & IFF_PROMISC) if (dev->flags & IFF_PROMISC)
block.Mode |= LANCE_INIT_PROM; block.Mode |= LANCE_INIT_PROM;
else else
...@@ -1001,7 +997,7 @@ static void skmca_set_multicast_list(struct net_device *dev) ...@@ -1001,7 +997,7 @@ static void skmca_set_multicast_list(struct net_device *dev)
} }
} }
SKMCA_TOIO(dev->mem_start + RAM_INITBASE, &block, sizeof(block)); memcpy_toio(priv->base + RAM_INITBASE, &block, sizeof(block));
/* ...then reinit LANCE with the correct flags */ /* ...then reinit LANCE with the correct flags */
InitLANCE(dev); InitLANCE(dev);
...@@ -1019,6 +1015,7 @@ static void cleanup_card(struct net_device *dev) ...@@ -1019,6 +1015,7 @@ static void cleanup_card(struct net_device *dev)
DeinitBoard(dev); DeinitBoard(dev);
if (dev->irq != 0) if (dev->irq != 0)
free_irq(dev->irq, dev); free_irq(dev->irq, dev);
iounmap(priv->base);
mca_mark_as_unused(priv->slot); mca_mark_as_unused(priv->slot);
mca_set_adapter_procfn(priv->slot, NULL, NULL); mca_set_adapter_procfn(priv->slot, NULL, NULL);
} }
...@@ -1102,13 +1099,20 @@ struct net_device * __init skmca_probe(int unit) ...@@ -1102,13 +1099,20 @@ struct net_device * __init skmca_probe(int unit)
printk("%s: SKNet %s adapter found in slot %d\n", dev->name, printk("%s: SKNet %s adapter found in slot %d\n", dev->name,
junior ? "Junior MC2" : "MC2+", slot + 1); junior ? "Junior MC2" : "MC2+", slot + 1);
/* allocate structure */
priv = netdev_priv(dev); priv = netdev_priv(dev);
priv->base = ioremap(base, 0x4000);
if (!priv->base) {
mca_set_adapter_procfn(slot, NULL, NULL);
mca_mark_as_unused(slot);
free_netdev(dev);
return ERR_PTR(-ENOMEM);
}
priv->slot = slot; priv->slot = slot;
priv->macbase = base + 0x3fc0; priv->macbase = priv->base + 0x3fc0;
priv->ioregaddr = base + 0x3ff0; priv->ioregaddr = priv->base + 0x3ff0;
priv->ctrladdr = base + 0x3ff2; priv->ctrladdr = priv->base + 0x3ff2;
priv->cmdaddr = base + 0x3ff3; priv->cmdaddr = priv->base + 0x3ff3;
priv->medium = medium; priv->medium = medium;
memset(&priv->stat, 0, sizeof(struct net_device_stats)); memset(&priv->stat, 0, sizeof(struct net_device_stats));
spin_lock_init(&priv->lock); spin_lock_init(&priv->lock);
...@@ -1145,7 +1149,7 @@ struct net_device * __init skmca_probe(int unit) ...@@ -1145,7 +1149,7 @@ struct net_device * __init skmca_probe(int unit)
/* copy out MAC address */ /* copy out MAC address */
for (i = 0; i < 6; i++) for (i = 0; i < 6; i++)
dev->dev_addr[i] = SKMCA_READB(priv->macbase + (i << 1)); dev->dev_addr[i] = readb(priv->macbase + (i << 1));
/* print config */ /* print config */
printk("%s: IRQ %d, memory %#lx-%#lx, " printk("%s: IRQ %d, memory %#lx-%#lx, "
......
...@@ -5,16 +5,6 @@ ...@@ -5,16 +5,6 @@
#ifdef _SK_MCA_DRIVER_ #ifdef _SK_MCA_DRIVER_
/* version-dependent functions/structures */
#define SKMCA_READB(addr) isa_readb(addr)
#define SKMCA_READW(addr) isa_readw(addr)
#define SKMCA_WRITEB(data, addr) isa_writeb(data, addr)
#define SKMCA_WRITEW(data, addr) isa_writew(data, addr)
#define SKMCA_TOIO(dest, src, len) isa_memcpy_toio(dest, src, len)
#define SKMCA_FROMIO(dest, src, len) isa_memcpy_fromio(dest, src, len)
#define SKMCA_SETIO(dest, val, len) isa_memset_io(dest, val, len)
/* Adapter ID's */ /* Adapter ID's */
#define SKNET_MCA_ID 0x6afd #define SKNET_MCA_ID 0x6afd
#define SKNET_JUNIOR_MCA_ID 0x6be9 #define SKNET_JUNIOR_MCA_ID 0x6be9
...@@ -29,10 +19,11 @@ typedef enum { Media_10Base2, Media_10BaseT, ...@@ -29,10 +19,11 @@ typedef enum { Media_10Base2, Media_10BaseT,
/* private structure */ /* private structure */
typedef struct { typedef struct {
unsigned int slot; /* MCA-Slot-# */ unsigned int slot; /* MCA-Slot-# */
unsigned int macbase; /* base address of MAC address PROM */ void __iomem *base;
unsigned int ioregaddr; /* address of I/O-register (Lo) */ void __iomem *macbase; /* base address of MAC address PROM */
unsigned int ctrladdr; /* address of control/stat register */ void __iomem *ioregaddr;/* address of I/O-register (Lo) */
unsigned int cmdaddr; /* address of I/O-command register */ void __iomem *ctrladdr; /* address of control/stat register */
void __iomem *cmdaddr; /* address of I/O-command register */
int nextrx; /* index of next RX descriptor to int nextrx; /* index of next RX descriptor to
be read */ be read */
int nexttxput; /* index of next free TX descriptor */ int nexttxput; /* index of next free TX descriptor */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment