Commit ffb5fccf authored by Russell King's avatar Russell King

[ARM] Net: Convert ether1 and ether3 to use iomem accesses.

Signed-off-by: default avatarRussell King <rmk@arm.linux.org.uk>
parent fe12455c
...@@ -86,8 +86,8 @@ static char version[] __initdata = "ether1 ethernet driver (c) 2000 Russell King ...@@ -86,8 +86,8 @@ static char version[] __initdata = "ether1 ethernet driver (c) 2000 Russell King
#define DISABLEIRQS 1 #define DISABLEIRQS 1
#define NORMALIRQS 0 #define NORMALIRQS 0
#define ether1_inw(dev, addr, type, offset, svflgs) ether1_inw_p (dev, addr + (int)(&((type *)0)->offset), svflgs) #define ether1_readw(dev, addr, type, offset, svflgs) ether1_inw_p (dev, addr + (int)(&((type *)0)->offset), svflgs)
#define ether1_outw(dev, val, addr, type, offset, svflgs) ether1_outw_p (dev, val, addr + (int)(&((type *)0)->offset), svflgs) #define ether1_writew(dev, val, addr, type, offset, svflgs) ether1_outw_p (dev, val, addr + (int)(&((type *)0)->offset), svflgs)
static inline unsigned short static inline unsigned short
ether1_inw_p (struct net_device *dev, int addr, int svflgs) ether1_inw_p (struct net_device *dev, int addr, int svflgs)
...@@ -98,8 +98,8 @@ ether1_inw_p (struct net_device *dev, int addr, int svflgs) ...@@ -98,8 +98,8 @@ ether1_inw_p (struct net_device *dev, int addr, int svflgs)
if (svflgs) if (svflgs)
local_irq_save (flags); local_irq_save (flags);
outb (addr >> 12, REG_PAGE); writeb(addr >> 12, REG_PAGE);
ret = inw (ETHER1_RAM + ((addr & 4095) >> 1)); ret = readw(ETHER1_RAM + ((addr & 4095) << 1));
if (svflgs) if (svflgs)
local_irq_restore (flags); local_irq_restore (flags);
return ret; return ret;
...@@ -113,8 +113,8 @@ ether1_outw_p (struct net_device *dev, unsigned short val, int addr, int svflgs) ...@@ -113,8 +113,8 @@ ether1_outw_p (struct net_device *dev, unsigned short val, int addr, int svflgs)
if (svflgs) if (svflgs)
local_irq_save (flags); local_irq_save (flags);
outb (addr >> 12, REG_PAGE); writeb(addr >> 12, REG_PAGE);
outw (val, ETHER1_RAM + ((addr & 4095) >> 1)); writew(val, ETHER1_RAM + ((addr & 4095) << 1));
if (svflgs) if (svflgs)
local_irq_restore (flags); local_irq_restore (flags);
} }
...@@ -131,11 +131,12 @@ ether1_outw_p (struct net_device *dev, unsigned short val, int addr, int svflgs) ...@@ -131,11 +131,12 @@ ether1_outw_p (struct net_device *dev, unsigned short val, int addr, int svflgs)
static void static void
ether1_writebuffer (struct net_device *dev, void *data, unsigned int start, unsigned int length) ether1_writebuffer (struct net_device *dev, void *data, unsigned int start, unsigned int length)
{ {
unsigned int page, thislen, offset, addr; unsigned int page, thislen, offset;
void __iomem *addr;
offset = start & 4095; offset = start & 4095;
page = start >> 12; page = start >> 12;
addr = ioaddr(ETHER1_RAM + (offset >> 1)); addr = ETHER1_RAM + (offset << 1);
if (offset + length > 4096) if (offset + length > 4096)
thislen = 4096 - offset; thislen = 4096 - offset;
...@@ -145,7 +146,7 @@ ether1_writebuffer (struct net_device *dev, void *data, unsigned int start, unsi ...@@ -145,7 +146,7 @@ ether1_writebuffer (struct net_device *dev, void *data, unsigned int start, unsi
do { do {
int used; int used;
outb(page, REG_PAGE); writeb(page, REG_PAGE);
length -= thislen; length -= thislen;
__asm__ __volatile__( __asm__ __volatile__(
...@@ -181,7 +182,7 @@ ether1_writebuffer (struct net_device *dev, void *data, unsigned int start, unsi ...@@ -181,7 +182,7 @@ ether1_writebuffer (struct net_device *dev, void *data, unsigned int start, unsi
: "=&r" (used), "=&r" (data) : "=&r" (used), "=&r" (data)
: "r" (addr), "r" (thislen), "1" (data)); : "r" (addr), "r" (thislen), "1" (data));
addr = ioaddr(ETHER1_RAM); addr = ETHER1_RAM;
thislen = length; thislen = length;
if (thislen > 4096) if (thislen > 4096)
...@@ -193,11 +194,12 @@ ether1_writebuffer (struct net_device *dev, void *data, unsigned int start, unsi ...@@ -193,11 +194,12 @@ ether1_writebuffer (struct net_device *dev, void *data, unsigned int start, unsi
static void static void
ether1_readbuffer (struct net_device *dev, void *data, unsigned int start, unsigned int length) ether1_readbuffer (struct net_device *dev, void *data, unsigned int start, unsigned int length)
{ {
unsigned int page, thislen, offset, addr; unsigned int page, thislen, offset;
void __iomem *addr;
offset = start & 4095; offset = start & 4095;
page = start >> 12; page = start >> 12;
addr = ioaddr(ETHER1_RAM + (offset >> 1)); addr = ETHER1_RAM + (offset << 1);
if (offset + length > 4096) if (offset + length > 4096)
thislen = 4096 - offset; thislen = 4096 - offset;
...@@ -207,7 +209,7 @@ ether1_readbuffer (struct net_device *dev, void *data, unsigned int start, unsig ...@@ -207,7 +209,7 @@ ether1_readbuffer (struct net_device *dev, void *data, unsigned int start, unsig
do { do {
int used; int used;
outb(page, REG_PAGE); writeb(page, REG_PAGE);
length -= thislen; length -= thislen;
__asm__ __volatile__( __asm__ __volatile__(
...@@ -243,7 +245,7 @@ ether1_readbuffer (struct net_device *dev, void *data, unsigned int start, unsig ...@@ -243,7 +245,7 @@ ether1_readbuffer (struct net_device *dev, void *data, unsigned int start, unsig
: "=&r" (used), "=&r" (data) : "=&r" (used), "=&r" (data)
: "r" (addr), "r" (thislen), "1" (data)); : "r" (addr), "r" (thislen), "1" (data));
addr = ioaddr(ETHER1_RAM); addr = ETHER1_RAM;
thislen = length; thislen = length;
if (thislen > 4096) if (thislen > 4096)
...@@ -302,7 +304,7 @@ ether1_ramtest(struct net_device *dev, unsigned char byte) ...@@ -302,7 +304,7 @@ ether1_ramtest(struct net_device *dev, unsigned char byte)
static int static int
ether1_reset (struct net_device *dev) ether1_reset (struct net_device *dev)
{ {
outb (CTRL_RST|CTRL_ACK, REG_CONTROL); writeb(CTRL_RST|CTRL_ACK, REG_CONTROL);
return BUS_16; return BUS_16;
} }
...@@ -451,7 +453,7 @@ ether1_init_for_open (struct net_device *dev) ...@@ -451,7 +453,7 @@ ether1_init_for_open (struct net_device *dev)
int failures = 0; int failures = 0;
unsigned long timeout; unsigned long timeout;
outb (CTRL_RST|CTRL_ACK, REG_CONTROL); writeb(CTRL_RST|CTRL_ACK, REG_CONTROL);
for (i = 0; i < 6; i++) for (i = 0; i < 6; i++)
init_sa.sa_addr[i] = dev->dev_addr[i]; init_sa.sa_addr[i] = dev->dev_addr[i];
...@@ -466,7 +468,7 @@ ether1_init_for_open (struct net_device *dev) ...@@ -466,7 +468,7 @@ ether1_init_for_open (struct net_device *dev)
ether1_writebuffer (dev, &init_tdr, TDR_ADDR, TDR_SIZE); ether1_writebuffer (dev, &init_tdr, TDR_ADDR, TDR_SIZE);
ether1_writebuffer (dev, &init_nop, NOP_ADDR, NOP_SIZE); ether1_writebuffer (dev, &init_nop, NOP_ADDR, NOP_SIZE);
if (ether1_inw (dev, CFG_ADDR, cfg_t, cfg_command, NORMALIRQS) != CMD_CONFIG) { if (ether1_readw(dev, CFG_ADDR, cfg_t, cfg_command, NORMALIRQS) != CMD_CONFIG) {
printk (KERN_ERR "%s: detected either RAM fault or compiler bug\n", printk (KERN_ERR "%s: detected either RAM fault or compiler bug\n",
dev->name); dev->name);
return 1; return 1;
...@@ -510,13 +512,13 @@ ether1_init_for_open (struct net_device *dev) ...@@ -510,13 +512,13 @@ ether1_init_for_open (struct net_device *dev)
/* release reset & give 586 a prod */ /* release reset & give 586 a prod */
priv(dev)->resetting = 1; priv(dev)->resetting = 1;
priv(dev)->initialising = 1; priv(dev)->initialising = 1;
outb (CTRL_RST, REG_CONTROL); writeb(CTRL_RST, REG_CONTROL);
outb (0, REG_CONTROL); writeb(0, REG_CONTROL);
outb (CTRL_CA, REG_CONTROL); writeb(CTRL_CA, REG_CONTROL);
/* 586 should now unset iscp.busy */ /* 586 should now unset iscp.busy */
timeout = jiffies + HZ/2; timeout = jiffies + HZ/2;
while (ether1_inw (dev, ISCP_ADDR, iscp_t, iscp_busy, DISABLEIRQS) == 1) { while (ether1_readw(dev, ISCP_ADDR, iscp_t, iscp_busy, DISABLEIRQS) == 1) {
if (time_after(jiffies, timeout)) { if (time_after(jiffies, timeout)) {
printk (KERN_WARNING "%s: can't initialise 82586: iscp is busy\n", dev->name); printk (KERN_WARNING "%s: can't initialise 82586: iscp is busy\n", dev->name);
return 1; return 1;
...@@ -525,7 +527,7 @@ ether1_init_for_open (struct net_device *dev) ...@@ -525,7 +527,7 @@ ether1_init_for_open (struct net_device *dev)
/* check status of commands that we issued */ /* check status of commands that we issued */
timeout += HZ/10; timeout += HZ/10;
while (((status = ether1_inw (dev, CFG_ADDR, cfg_t, cfg_status, DISABLEIRQS)) while (((status = ether1_readw(dev, CFG_ADDR, cfg_t, cfg_status, DISABLEIRQS))
& STAT_COMPLETE) == 0) { & STAT_COMPLETE) == 0) {
if (time_after(jiffies, timeout)) if (time_after(jiffies, timeout))
break; break;
...@@ -534,15 +536,15 @@ ether1_init_for_open (struct net_device *dev) ...@@ -534,15 +536,15 @@ ether1_init_for_open (struct net_device *dev)
if ((status & (STAT_COMPLETE | STAT_OK)) != (STAT_COMPLETE | STAT_OK)) { if ((status & (STAT_COMPLETE | STAT_OK)) != (STAT_COMPLETE | STAT_OK)) {
printk (KERN_WARNING "%s: can't initialise 82586: config status %04X\n", dev->name, status); printk (KERN_WARNING "%s: can't initialise 82586: config status %04X\n", dev->name, status);
printk (KERN_DEBUG "%s: SCB=[STS=%04X CMD=%04X CBL=%04X RFA=%04X]\n", dev->name, printk (KERN_DEBUG "%s: SCB=[STS=%04X CMD=%04X CBL=%04X RFA=%04X]\n", dev->name,
ether1_inw (dev, SCB_ADDR, scb_t, scb_status, NORMALIRQS), ether1_readw(dev, SCB_ADDR, scb_t, scb_status, NORMALIRQS),
ether1_inw (dev, SCB_ADDR, scb_t, scb_command, NORMALIRQS), ether1_readw(dev, SCB_ADDR, scb_t, scb_command, NORMALIRQS),
ether1_inw (dev, SCB_ADDR, scb_t, scb_cbl_offset, NORMALIRQS), ether1_readw(dev, SCB_ADDR, scb_t, scb_cbl_offset, NORMALIRQS),
ether1_inw (dev, SCB_ADDR, scb_t, scb_rfa_offset, NORMALIRQS)); ether1_readw(dev, SCB_ADDR, scb_t, scb_rfa_offset, NORMALIRQS));
failures += 1; failures += 1;
} }
timeout += HZ/10; timeout += HZ/10;
while (((status = ether1_inw (dev, SA_ADDR, sa_t, sa_status, DISABLEIRQS)) while (((status = ether1_readw(dev, SA_ADDR, sa_t, sa_status, DISABLEIRQS))
& STAT_COMPLETE) == 0) { & STAT_COMPLETE) == 0) {
if (time_after(jiffies, timeout)) if (time_after(jiffies, timeout))
break; break;
...@@ -551,15 +553,15 @@ ether1_init_for_open (struct net_device *dev) ...@@ -551,15 +553,15 @@ ether1_init_for_open (struct net_device *dev)
if ((status & (STAT_COMPLETE | STAT_OK)) != (STAT_COMPLETE | STAT_OK)) { if ((status & (STAT_COMPLETE | STAT_OK)) != (STAT_COMPLETE | STAT_OK)) {
printk (KERN_WARNING "%s: can't initialise 82586: set address status %04X\n", dev->name, status); printk (KERN_WARNING "%s: can't initialise 82586: set address status %04X\n", dev->name, status);
printk (KERN_DEBUG "%s: SCB=[STS=%04X CMD=%04X CBL=%04X RFA=%04X]\n", dev->name, printk (KERN_DEBUG "%s: SCB=[STS=%04X CMD=%04X CBL=%04X RFA=%04X]\n", dev->name,
ether1_inw (dev, SCB_ADDR, scb_t, scb_status, NORMALIRQS), ether1_readw(dev, SCB_ADDR, scb_t, scb_status, NORMALIRQS),
ether1_inw (dev, SCB_ADDR, scb_t, scb_command, NORMALIRQS), ether1_readw(dev, SCB_ADDR, scb_t, scb_command, NORMALIRQS),
ether1_inw (dev, SCB_ADDR, scb_t, scb_cbl_offset, NORMALIRQS), ether1_readw(dev, SCB_ADDR, scb_t, scb_cbl_offset, NORMALIRQS),
ether1_inw (dev, SCB_ADDR, scb_t, scb_rfa_offset, NORMALIRQS)); ether1_readw(dev, SCB_ADDR, scb_t, scb_rfa_offset, NORMALIRQS));
failures += 1; failures += 1;
} }
timeout += HZ/10; timeout += HZ/10;
while (((status = ether1_inw (dev, MC_ADDR, mc_t, mc_status, DISABLEIRQS)) while (((status = ether1_readw(dev, MC_ADDR, mc_t, mc_status, DISABLEIRQS))
& STAT_COMPLETE) == 0) { & STAT_COMPLETE) == 0) {
if (time_after(jiffies, timeout)) if (time_after(jiffies, timeout))
break; break;
...@@ -568,15 +570,15 @@ ether1_init_for_open (struct net_device *dev) ...@@ -568,15 +570,15 @@ ether1_init_for_open (struct net_device *dev)
if ((status & (STAT_COMPLETE | STAT_OK)) != (STAT_COMPLETE | STAT_OK)) { if ((status & (STAT_COMPLETE | STAT_OK)) != (STAT_COMPLETE | STAT_OK)) {
printk (KERN_WARNING "%s: can't initialise 82586: set multicast status %04X\n", dev->name, status); printk (KERN_WARNING "%s: can't initialise 82586: set multicast status %04X\n", dev->name, status);
printk (KERN_DEBUG "%s: SCB=[STS=%04X CMD=%04X CBL=%04X RFA=%04X]\n", dev->name, printk (KERN_DEBUG "%s: SCB=[STS=%04X CMD=%04X CBL=%04X RFA=%04X]\n", dev->name,
ether1_inw (dev, SCB_ADDR, scb_t, scb_status, NORMALIRQS), ether1_readw(dev, SCB_ADDR, scb_t, scb_status, NORMALIRQS),
ether1_inw (dev, SCB_ADDR, scb_t, scb_command, NORMALIRQS), ether1_readw(dev, SCB_ADDR, scb_t, scb_command, NORMALIRQS),
ether1_inw (dev, SCB_ADDR, scb_t, scb_cbl_offset, NORMALIRQS), ether1_readw(dev, SCB_ADDR, scb_t, scb_cbl_offset, NORMALIRQS),
ether1_inw (dev, SCB_ADDR, scb_t, scb_rfa_offset, NORMALIRQS)); ether1_readw(dev, SCB_ADDR, scb_t, scb_rfa_offset, NORMALIRQS));
failures += 1; failures += 1;
} }
timeout += HZ; timeout += HZ;
while (((status = ether1_inw (dev, TDR_ADDR, tdr_t, tdr_status, DISABLEIRQS)) while (((status = ether1_readw(dev, TDR_ADDR, tdr_t, tdr_status, DISABLEIRQS))
& STAT_COMPLETE) == 0) { & STAT_COMPLETE) == 0) {
if (time_after(jiffies, timeout)) if (time_after(jiffies, timeout))
break; break;
...@@ -585,12 +587,12 @@ ether1_init_for_open (struct net_device *dev) ...@@ -585,12 +587,12 @@ ether1_init_for_open (struct net_device *dev)
if ((status & (STAT_COMPLETE | STAT_OK)) != (STAT_COMPLETE | STAT_OK)) { if ((status & (STAT_COMPLETE | STAT_OK)) != (STAT_COMPLETE | STAT_OK)) {
printk (KERN_WARNING "%s: can't tdr (ignored)\n", dev->name); printk (KERN_WARNING "%s: can't tdr (ignored)\n", dev->name);
printk (KERN_DEBUG "%s: SCB=[STS=%04X CMD=%04X CBL=%04X RFA=%04X]\n", dev->name, printk (KERN_DEBUG "%s: SCB=[STS=%04X CMD=%04X CBL=%04X RFA=%04X]\n", dev->name,
ether1_inw (dev, SCB_ADDR, scb_t, scb_status, NORMALIRQS), ether1_readw(dev, SCB_ADDR, scb_t, scb_status, NORMALIRQS),
ether1_inw (dev, SCB_ADDR, scb_t, scb_command, NORMALIRQS), ether1_readw(dev, SCB_ADDR, scb_t, scb_command, NORMALIRQS),
ether1_inw (dev, SCB_ADDR, scb_t, scb_cbl_offset, NORMALIRQS), ether1_readw(dev, SCB_ADDR, scb_t, scb_cbl_offset, NORMALIRQS),
ether1_inw (dev, SCB_ADDR, scb_t, scb_rfa_offset, NORMALIRQS)); ether1_readw(dev, SCB_ADDR, scb_t, scb_rfa_offset, NORMALIRQS));
} else { } else {
status = ether1_inw (dev, TDR_ADDR, tdr_t, tdr_result, DISABLEIRQS); status = ether1_readw(dev, TDR_ADDR, tdr_t, tdr_result, DISABLEIRQS);
if (status & TDR_XCVRPROB) if (status & TDR_XCVRPROB)
printk (KERN_WARNING "%s: i/f failed tdr: transceiver problem\n", dev->name); printk (KERN_WARNING "%s: i/f failed tdr: transceiver problem\n", dev->name);
else if ((status & (TDR_SHORT|TDR_OPEN)) && (status & TDR_TIME)) { else if ((status & (TDR_SHORT|TDR_OPEN)) && (status & TDR_TIME)) {
...@@ -732,7 +734,7 @@ ether1_sendpacket (struct sk_buff *skb, struct net_device *dev) ...@@ -732,7 +734,7 @@ ether1_sendpacket (struct sk_buff *skb, struct net_device *dev)
priv(dev)->tx_link = nopaddr; priv(dev)->tx_link = nopaddr;
/* now reset the previous nop pointer */ /* now reset the previous nop pointer */
ether1_outw (dev, txaddr, tmp, nop_t, nop_link, NORMALIRQS); ether1_writew(dev, txaddr, tmp, nop_t, nop_link, NORMALIRQS);
local_irq_restore(flags); local_irq_restore(flags);
...@@ -766,11 +768,11 @@ ether1_xmit_done (struct net_device *dev) ...@@ -766,11 +768,11 @@ ether1_xmit_done (struct net_device *dev)
switch (nop.nop_command & CMD_MASK) { switch (nop.nop_command & CMD_MASK) {
case CMD_TDR: case CMD_TDR:
/* special case */ /* special case */
if (ether1_inw (dev, SCB_ADDR, scb_t, scb_cbl_offset, NORMALIRQS) if (ether1_readw(dev, SCB_ADDR, scb_t, scb_cbl_offset, NORMALIRQS)
!= (unsigned short)I82586_NULL) { != (unsigned short)I82586_NULL) {
ether1_outw(dev, SCB_CMDCUCSTART | SCB_CMDRXSTART, SCB_ADDR, scb_t, ether1_outw(dev, SCB_CMDCUCSTART | SCB_CMDRXSTART, SCB_ADDR, scb_t,
scb_command, NORMALIRQS); scb_command, NORMALIRQS);
outb (CTRL_CA, REG_CONTROL); writeb(CTRL_CA, REG_CONTROL);
} }
priv(dev)->tx_tail = NOP_ADDR; priv(dev)->tx_tail = NOP_ADDR;
return; return;
...@@ -860,11 +862,11 @@ ether1_recv_done (struct net_device *dev) ...@@ -860,11 +862,11 @@ ether1_recv_done (struct net_device *dev)
rbd_t rbd; rbd_t rbd;
do { do {
status = ether1_inw (dev, priv(dev)->rx_head, rfd_t, rfd_status, NORMALIRQS); status = ether1_readw(dev, priv(dev)->rx_head, rfd_t, rfd_status, NORMALIRQS);
if ((status & RFD_COMPLETE) == 0) if ((status & RFD_COMPLETE) == 0)
break; break;
rbdaddr = ether1_inw (dev, priv(dev)->rx_head, rfd_t, rfd_rbdoffset, NORMALIRQS); rbdaddr = ether1_readw(dev, priv(dev)->rx_head, rfd_t, rfd_rbdoffset, NORMALIRQS);
ether1_readbuffer (dev, &rbd, rbdaddr, RBD_SIZE); ether1_readbuffer (dev, &rbd, rbdaddr, RBD_SIZE);
if ((rbd.rbd_status & (RBD_EOF | RBD_ACNTVALID)) == (RBD_EOF | RBD_ACNTVALID)) { if ((rbd.rbd_status & (RBD_EOF | RBD_ACNTVALID)) == (RBD_EOF | RBD_ACNTVALID)) {
...@@ -891,18 +893,18 @@ ether1_recv_done (struct net_device *dev) ...@@ -891,18 +893,18 @@ ether1_recv_done (struct net_device *dev)
priv(dev)->stats.rx_dropped ++; priv(dev)->stats.rx_dropped ++;
} }
nexttail = ether1_inw (dev, priv(dev)->rx_tail, rfd_t, rfd_link, NORMALIRQS); nexttail = ether1_readw(dev, priv(dev)->rx_tail, rfd_t, rfd_link, NORMALIRQS);
/* nexttail should be rx_head */ /* nexttail should be rx_head */
if (nexttail != priv(dev)->rx_head) if (nexttail != priv(dev)->rx_head)
printk(KERN_ERR "%s: receiver buffer chaining error (%04X != %04X)\n", printk(KERN_ERR "%s: receiver buffer chaining error (%04X != %04X)\n",
dev->name, nexttail, priv(dev)->rx_head); dev->name, nexttail, priv(dev)->rx_head);
ether1_outw (dev, RFD_CMDEL | RFD_CMDSUSPEND, nexttail, rfd_t, rfd_command, NORMALIRQS); ether1_writew(dev, RFD_CMDEL | RFD_CMDSUSPEND, nexttail, rfd_t, rfd_command, NORMALIRQS);
ether1_outw (dev, 0, priv(dev)->rx_tail, rfd_t, rfd_command, NORMALIRQS); ether1_writew(dev, 0, priv(dev)->rx_tail, rfd_t, rfd_command, NORMALIRQS);
ether1_outw (dev, 0, priv(dev)->rx_tail, rfd_t, rfd_status, NORMALIRQS); ether1_writew(dev, 0, priv(dev)->rx_tail, rfd_t, rfd_status, NORMALIRQS);
ether1_outw (dev, 0, priv(dev)->rx_tail, rfd_t, rfd_rbdoffset, NORMALIRQS); ether1_writew(dev, 0, priv(dev)->rx_tail, rfd_t, rfd_rbdoffset, NORMALIRQS);
priv(dev)->rx_tail = nexttail; priv(dev)->rx_tail = nexttail;
priv(dev)->rx_head = ether1_inw (dev, priv(dev)->rx_head, rfd_t, rfd_link, NORMALIRQS); priv(dev)->rx_head = ether1_readw(dev, priv(dev)->rx_head, rfd_t, rfd_link, NORMALIRQS);
} while (1); } while (1);
} }
...@@ -912,12 +914,12 @@ ether1_interrupt (int irq, void *dev_id, struct pt_regs *regs) ...@@ -912,12 +914,12 @@ ether1_interrupt (int irq, void *dev_id, struct pt_regs *regs)
struct net_device *dev = (struct net_device *)dev_id; struct net_device *dev = (struct net_device *)dev_id;
int status; int status;
status = ether1_inw (dev, SCB_ADDR, scb_t, scb_status, NORMALIRQS); status = ether1_readw(dev, SCB_ADDR, scb_t, scb_status, NORMALIRQS);
if (status) { if (status) {
ether1_outw(dev, status & (SCB_STRNR | SCB_STCNA | SCB_STFR | SCB_STCX), ether1_outw(dev, status & (SCB_STRNR | SCB_STCNA | SCB_STFR | SCB_STCX),
SCB_ADDR, scb_t, scb_command, NORMALIRQS); SCB_ADDR, scb_t, scb_command, NORMALIRQS);
outb (CTRL_CA | CTRL_ACK, REG_CONTROL); writeb(CTRL_CA | CTRL_ACK, REG_CONTROL);
if (status & SCB_STCX) { if (status & SCB_STCX) {
ether1_xmit_done (dev); ether1_xmit_done (dev);
} }
...@@ -926,10 +928,10 @@ ether1_interrupt (int irq, void *dev_id, struct pt_regs *regs) ...@@ -926,10 +928,10 @@ ether1_interrupt (int irq, void *dev_id, struct pt_regs *regs)
printk (KERN_WARNING "%s: CU went not ready ???\n", dev->name); printk (KERN_WARNING "%s: CU went not ready ???\n", dev->name);
else else
priv(dev)->resetting += 1; priv(dev)->resetting += 1;
if (ether1_inw (dev, SCB_ADDR, scb_t, scb_cbl_offset, NORMALIRQS) if (ether1_readw(dev, SCB_ADDR, scb_t, scb_cbl_offset, NORMALIRQS)
!= (unsigned short)I82586_NULL) { != (unsigned short)I82586_NULL) {
ether1_outw (dev, SCB_CMDCUCSTART, SCB_ADDR, scb_t, scb_command, NORMALIRQS); ether1_writew(dev, SCB_CMDCUCSTART, SCB_ADDR, scb_t, scb_command, NORMALIRQS);
outb (CTRL_CA, REG_CONTROL); writeb(CTRL_CA, REG_CONTROL);
} }
if (priv(dev)->resetting == 2) if (priv(dev)->resetting == 2)
priv(dev)->resetting = 0; priv(dev)->resetting = 0;
...@@ -938,19 +940,19 @@ ether1_interrupt (int irq, void *dev_id, struct pt_regs *regs) ...@@ -938,19 +940,19 @@ ether1_interrupt (int irq, void *dev_id, struct pt_regs *regs)
ether1_recv_done (dev); ether1_recv_done (dev);
} }
if (status & SCB_STRNR) { if (status & SCB_STRNR) {
if (ether1_inw (dev, SCB_ADDR, scb_t, scb_status, NORMALIRQS) & SCB_STRXSUSP) { if (ether1_readw(dev, SCB_ADDR, scb_t, scb_status, NORMALIRQS) & SCB_STRXSUSP) {
printk (KERN_WARNING "%s: RU went not ready: RU suspended\n", dev->name); printk (KERN_WARNING "%s: RU went not ready: RU suspended\n", dev->name);
ether1_outw (dev, SCB_CMDRXRESUME, SCB_ADDR, scb_t, scb_command, NORMALIRQS); ether1_writew(dev, SCB_CMDRXRESUME, SCB_ADDR, scb_t, scb_command, NORMALIRQS);
outb (CTRL_CA, REG_CONTROL); writeb(CTRL_CA, REG_CONTROL);
priv(dev)->stats.rx_dropped ++; /* we suspended due to lack of buffer space */ priv(dev)->stats.rx_dropped ++; /* we suspended due to lack of buffer space */
} else } else
printk(KERN_WARNING "%s: RU went not ready: %04X\n", dev->name, printk(KERN_WARNING "%s: RU went not ready: %04X\n", dev->name,
ether1_inw (dev, SCB_ADDR, scb_t, scb_status, NORMALIRQS)); ether1_readw(dev, SCB_ADDR, scb_t, scb_status, NORMALIRQS));
printk (KERN_WARNING "RU ptr = %04X\n", ether1_inw (dev, SCB_ADDR, scb_t, scb_rfa_offset, printk (KERN_WARNING "RU ptr = %04X\n", ether1_readw(dev, SCB_ADDR, scb_t, scb_rfa_offset,
NORMALIRQS)); NORMALIRQS));
} }
} else } else
outb (CTRL_ACK, REG_CONTROL); writeb(CTRL_ACK, REG_CONTROL);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -1012,9 +1014,15 @@ ether1_probe(struct expansion_card *ec, const struct ecard_id *id) ...@@ -1012,9 +1014,15 @@ ether1_probe(struct expansion_card *ec, const struct ecard_id *id)
} }
SET_MODULE_OWNER(dev); SET_MODULE_OWNER(dev);
SET_NETDEV_DEV(dev, &ec->dev);
dev->base_addr = ecard_address(ec, ECARD_IOC, ECARD_FAST); dev->irq = ec->irq;
dev->irq = ec->irq; priv(dev)->base = ioremap(ecard_resource_start(ec, ECARD_RES_IOCFAST),
ecard_resource_len(ec, ECARD_RES_IOCFAST));
if (!priv(dev)->base) {
ret = -ENOMEM;
goto free;
}
if ((priv(dev)->bus_type = ether1_reset(dev)) == 0) { if ((priv(dev)->bus_type = ether1_reset(dev)) == 0) {
ret = -ENODEV; ret = -ENODEV;
...@@ -1022,7 +1030,7 @@ ether1_probe(struct expansion_card *ec, const struct ecard_id *id) ...@@ -1022,7 +1030,7 @@ ether1_probe(struct expansion_card *ec, const struct ecard_id *id)
} }
for (i = 0; i < 6; i++) for (i = 0; i < 6; i++)
dev->dev_addr[i] = inb(IDPROM_ADDRESS + i); dev->dev_addr[i] = readb(IDPROM_ADDRESS + (i << 2));
if (ether1_init_2(dev)) { if (ether1_init_2(dev)) {
ret = -ENODEV; ret = -ENODEV;
...@@ -1051,6 +1059,8 @@ ether1_probe(struct expansion_card *ec, const struct ecard_id *id) ...@@ -1051,6 +1059,8 @@ ether1_probe(struct expansion_card *ec, const struct ecard_id *id)
return 0; return 0;
free: free:
if (priv(dev)->base)
iounmap(priv(dev)->base);
free_netdev(dev); free_netdev(dev);
release: release:
ecard_release_resources(ec); ecard_release_resources(ec);
...@@ -1065,6 +1075,7 @@ static void __devexit ether1_remove(struct expansion_card *ec) ...@@ -1065,6 +1075,7 @@ static void __devexit ether1_remove(struct expansion_card *ec)
ecard_set_drvdata(ec, NULL); ecard_set_drvdata(ec, NULL);
unregister_netdev(dev); unregister_netdev(dev);
iounmap(priv(dev)->base);
free_netdev(dev); free_netdev(dev);
ecard_release_resources(ec); ecard_release_resources(ec);
} }
......
...@@ -22,21 +22,22 @@ ...@@ -22,21 +22,22 @@
#define priv(dev) ((struct ether1_priv *)netdev_priv(dev)) #define priv(dev) ((struct ether1_priv *)netdev_priv(dev))
/* Page register */ /* Page register */
#define REG_PAGE (dev->base_addr + 0x00) #define REG_PAGE (priv(dev)->base + 0x0000)
/* Control register */ /* Control register */
#define REG_CONTROL (dev->base_addr + 0x01) #define REG_CONTROL (priv(dev)->base + 0x0004)
#define CTRL_RST 0x01 #define CTRL_RST 0x01
#define CTRL_LOOPBACK 0x02 #define CTRL_LOOPBACK 0x02
#define CTRL_CA 0x04 #define CTRL_CA 0x04
#define CTRL_ACK 0x08 #define CTRL_ACK 0x08
#define ETHER1_RAM (dev->base_addr + 0x800) #define ETHER1_RAM (priv(dev)->base + 0x2000)
/* HW address */ /* HW address */
#define IDPROM_ADDRESS (dev->base_addr + 0x09) #define IDPROM_ADDRESS (priv(dev)->base + 0x0024)
struct ether1_priv { struct ether1_priv {
void __iomem *base;
struct net_device_stats stats; struct net_device_stats stats;
unsigned int tx_link; unsigned int tx_link;
unsigned int tx_head; unsigned int tx_head;
......
...@@ -104,19 +104,19 @@ typedef enum { ...@@ -104,19 +104,19 @@ typedef enum {
* The SEEQ8005 doesn't like us writing to its registers * The SEEQ8005 doesn't like us writing to its registers
* too quickly. * too quickly.
*/ */
static inline void ether3_outb(int v, const int r) static inline void ether3_outb(int v, const void __iomem *r)
{ {
outb(v, r); writeb(v, r);
udelay(1); udelay(1);
} }
static inline void ether3_outw(int v, const int r) static inline void ether3_outw(int v, const void __iomem *r)
{ {
outw(v, r); writew(v, r);
udelay(1); udelay(1);
} }
#define ether3_inb(r) ({ unsigned int __v = inb((r)); udelay(1); __v; }) #define ether3_inb(r) ({ unsigned int __v = readb((r)); udelay(1); __v; })
#define ether3_inw(r) ({ unsigned int __v = inw((r)); udelay(1); __v; }) #define ether3_inw(r) ({ unsigned int __v = readw((r)); udelay(1); __v; })
static int static int
ether3_setbuffer(struct net_device *dev, buffer_rw_t read, int start) ether3_setbuffer(struct net_device *dev, buffer_rw_t read, int start)
...@@ -149,28 +149,28 @@ ether3_setbuffer(struct net_device *dev, buffer_rw_t read, int start) ...@@ -149,28 +149,28 @@ ether3_setbuffer(struct net_device *dev, buffer_rw_t read, int start)
* write data to the buffer memory * write data to the buffer memory
*/ */
#define ether3_writebuffer(dev,data,length) \ #define ether3_writebuffer(dev,data,length) \
outsw(REG_BUFWIN, (data), (length) >> 1) writesw(REG_BUFWIN, (data), (length) >> 1)
#define ether3_writeword(dev,data) \ #define ether3_writeword(dev,data) \
outw((data), REG_BUFWIN) writew((data), REG_BUFWIN)
#define ether3_writelong(dev,data) { \ #define ether3_writelong(dev,data) { \
unsigned long reg_bufwin = REG_BUFWIN; \ void __iomem *reg_bufwin = REG_BUFWIN; \
outw((data), reg_bufwin); \ writew((data), reg_bufwin); \
outw((data) >> 16, reg_bufwin); \ writew((data) >> 16, reg_bufwin); \
} }
/* /*
* read data from the buffer memory * read data from the buffer memory
*/ */
#define ether3_readbuffer(dev,data,length) \ #define ether3_readbuffer(dev,data,length) \
insw(REG_BUFWIN, (data), (length) >> 1) readsw(REG_BUFWIN, (data), (length) >> 1)
#define ether3_readword(dev) \ #define ether3_readword(dev) \
inw(REG_BUFWIN) readw(REG_BUFWIN)
#define ether3_readlong(dev) \ #define ether3_readlong(dev) \
inw(REG_BUFWIN) | (inw(REG_BUFWIN) << 16) readw(REG_BUFWIN) | (readw(REG_BUFWIN) << 16)
/* /*
* Switch LED off... * Switch LED off...
...@@ -371,10 +371,10 @@ ether3_probe_bus_8(struct net_device *dev, int val) ...@@ -371,10 +371,10 @@ ether3_probe_bus_8(struct net_device *dev, int val)
printk(KERN_DEBUG "ether3_probe: write8 [%02X:%02X]", write_high, write_low); printk(KERN_DEBUG "ether3_probe: write8 [%02X:%02X]", write_high, write_low);
ether3_outb(write_low, REG_RECVPTR); ether3_outb(write_low, REG_RECVPTR);
ether3_outb(write_high, REG_RECVPTR + 1); ether3_outb(write_high, REG_RECVPTR + 4);
read_low = ether3_inb(REG_RECVPTR); read_low = ether3_inb(REG_RECVPTR);
read_high = ether3_inb(REG_RECVPTR + 1); read_high = ether3_inb(REG_RECVPTR + 4);
printk(", read8 [%02X:%02X]\n", read_high, read_low); printk(", read8 [%02X:%02X]\n", read_high, read_low);
...@@ -434,7 +434,7 @@ ether3_close(struct net_device *dev) ...@@ -434,7 +434,7 @@ ether3_close(struct net_device *dev)
ether3_outw(CMD_RXOFF|CMD_TXOFF, REG_COMMAND); ether3_outw(CMD_RXOFF|CMD_TXOFF, REG_COMMAND);
priv(dev)->regs.command = 0; priv(dev)->regs.command = 0;
while (ether3_inw(REG_STATUS) & (STAT_RXON|STAT_TXON)); while (ether3_inw(REG_STATUS) & (STAT_RXON|STAT_TXON));
ether3_outb(0x80, REG_CONFIG2 + 1); ether3_outb(0x80, REG_CONFIG2 + 4);
ether3_outw(0, REG_COMMAND); ether3_outw(0, REG_COMMAND);
free_irq(dev->irq, dev); free_irq(dev->irq, dev);
...@@ -778,16 +778,16 @@ ether3_get_dev(struct net_device *dev, struct expansion_card *ec) ...@@ -778,16 +778,16 @@ ether3_get_dev(struct net_device *dev, struct expansion_card *ec)
{ {
const char *name = "ether3"; const char *name = "ether3";
dev->base_addr = ecard_address(ec, ECARD_MEMC, 0);
dev->irq = ec->irq; dev->irq = ec->irq;
priv(dev)->seeq = priv(dev)->base;
if (ec->cid.manufacturer == MANU_ANT && if (ec->cid.manufacturer == MANU_ANT &&
ec->cid.product == PROD_ANT_ETHERB) { ec->cid.product == PROD_ANT_ETHERB) {
dev->base_addr += 0x200; priv(dev)->seeq = priv(dev)->base + 0x800;
name = "etherb"; name = "etherb";
} }
ec->irqaddr = (volatile unsigned char *)ioaddr(dev->base_addr); ec->irqaddr = priv(dev)->seeq;
ec->irqmask = 0xf0; ec->irqmask = 0xf0;
ether3_addr(dev->dev_addr, ec); ether3_addr(dev->dev_addr, ec);
...@@ -815,6 +815,14 @@ ether3_probe(struct expansion_card *ec, const struct ecard_id *id) ...@@ -815,6 +815,14 @@ ether3_probe(struct expansion_card *ec, const struct ecard_id *id)
} }
SET_MODULE_OWNER(dev); SET_MODULE_OWNER(dev);
SET_NETDEV_DEV(dev, &ec->dev);
priv(dev)->base = ioremap(ecard_resource_start(ec, ECARD_RES_MEMC),
ecard_resource_len(ec, ECARD_RES_MEMC));
if (!priv(dev)->base) {
ret = -ENOMEM;
goto free;
}
name = ether3_get_dev(dev, ec); name = ether3_get_dev(dev, ec);
if (!name) { if (!name) {
...@@ -826,7 +834,7 @@ ether3_probe(struct expansion_card *ec, const struct ecard_id *id) ...@@ -826,7 +834,7 @@ ether3_probe(struct expansion_card *ec, const struct ecard_id *id)
/* Reset card... /* Reset card...
*/ */
ether3_outb(0x80, REG_CONFIG2 + 1); ether3_outb(0x80, REG_CONFIG2 + 4);
bus_type = BUS_UNKNOWN; bus_type = BUS_UNKNOWN;
udelay(4); udelay(4);
...@@ -883,6 +891,8 @@ ether3_probe(struct expansion_card *ec, const struct ecard_id *id) ...@@ -883,6 +891,8 @@ ether3_probe(struct expansion_card *ec, const struct ecard_id *id)
return 0; return 0;
free: free:
if (priv(dev)->base)
iounmap(priv(dev)->base);
free_netdev(dev); free_netdev(dev);
release: release:
ecard_release_resources(ec); ecard_release_resources(ec);
...@@ -897,6 +907,7 @@ static void __devexit ether3_remove(struct expansion_card *ec) ...@@ -897,6 +907,7 @@ static void __devexit ether3_remove(struct expansion_card *ec)
ecard_set_drvdata(ec, NULL); ecard_set_drvdata(ec, NULL);
unregister_netdev(dev); unregister_netdev(dev);
iounmap(priv(dev)->base);
free_netdev(dev); free_netdev(dev);
ecard_release_resources(ec); ecard_release_resources(ec);
} }
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#define priv(dev) ((struct dev_priv *)netdev_priv(dev)) #define priv(dev) ((struct dev_priv *)netdev_priv(dev))
/* Command register definitions & bits */ /* Command register definitions & bits */
#define REG_COMMAND (dev->base_addr + 0x00) #define REG_COMMAND (priv(dev)->seeq + 0x0000)
#define CMD_ENINTDMA 0x0001 #define CMD_ENINTDMA 0x0001
#define CMD_ENINTRX 0x0002 #define CMD_ENINTRX 0x0002
#define CMD_ENINTTX 0x0004 #define CMD_ENINTTX 0x0004
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
#define CMD_FIFOWRITE 0x8000 #define CMD_FIFOWRITE 0x8000
/* status register */ /* status register */
#define REG_STATUS (dev->base_addr + 0x00) #define REG_STATUS (priv(dev)->seeq + 0x0000)
#define STAT_ENINTSTAT 0x0001 #define STAT_ENINTSTAT 0x0001
#define STAT_ENINTRX 0x0002 #define STAT_ENINTRX 0x0002
#define STAT_ENINTTX 0x0004 #define STAT_ENINTTX 0x0004
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
#define STAT_FIFODIR 0x8000 #define STAT_FIFODIR 0x8000
/* configuration register 1 */ /* configuration register 1 */
#define REG_CONFIG1 (dev->base_addr + 0x10) #define REG_CONFIG1 (priv(dev)->seeq + 0x0040)
#define CFG1_BUFSELSTAT0 0x0000 #define CFG1_BUFSELSTAT0 0x0000
#define CFG1_BUFSELSTAT1 0x0001 #define CFG1_BUFSELSTAT1 0x0001
#define CFG1_BUFSELSTAT2 0x0002 #define CFG1_BUFSELSTAT2 0x0002
...@@ -94,7 +94,7 @@ ...@@ -94,7 +94,7 @@
#define CFG1_RECVCOMPSTAT5 0x2000 #define CFG1_RECVCOMPSTAT5 0x2000
/* configuration register 2 */ /* configuration register 2 */
#define REG_CONFIG2 (dev->base_addr + 0x20) #define REG_CONFIG2 (priv(dev)->seeq + 0x0080)
#define CFG2_BYTESWAP 0x0001 #define CFG2_BYTESWAP 0x0001
#define CFG2_ERRENCRC 0x0008 #define CFG2_ERRENCRC 0x0008
#define CFG2_ERRENDRIBBLE 0x0010 #define CFG2_ERRENDRIBBLE 0x0010
...@@ -108,15 +108,15 @@ ...@@ -108,15 +108,15 @@
#define CFG2_CTRLO 0x1000 #define CFG2_CTRLO 0x1000
#define CFG2_RESET 0x8000 #define CFG2_RESET 0x8000
#define REG_RECVEND (dev->base_addr + 0x30) #define REG_RECVEND (priv(dev)->seeq + 0x00c0)
#define REG_BUFWIN (dev->base_addr + 0x40) #define REG_BUFWIN (priv(dev)->seeq + 0x0100)
#define REG_RECVPTR (dev->base_addr + 0x50) #define REG_RECVPTR (priv(dev)->seeq + 0x0140)
#define REG_TRANSMITPTR (dev->base_addr + 0x60) #define REG_TRANSMITPTR (priv(dev)->seeq + 0x0180)
#define REG_DMAADDR (dev->base_addr + 0x70) #define REG_DMAADDR (priv(dev)->seeq + 0x01c0)
/* /*
* Cards transmit/receive headers * Cards transmit/receive headers
...@@ -154,6 +154,8 @@ ...@@ -154,6 +154,8 @@
#define MAX_TX_BUFFERED 10 #define MAX_TX_BUFFERED 10
struct dev_priv { struct dev_priv {
void __iomem *base;
void __iomem *seeq;
struct { struct {
unsigned int command; unsigned int command;
unsigned int config1; unsigned int config1;
......
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