Commit 27e0c31c authored by Finn Thain's avatar Finn Thain Committed by David S. Miller

net/sonic: Fix command register usage

There are several issues relating to command register usage during
chip initialization.

Firstly, the SONIC sometimes comes out of software reset with the
Start Timer bit set. This gets logged as,

    macsonic macsonic eth0: sonic_init: status=24, i=101

Avoid this by giving the Stop Timer command earlier than later.

Secondly, the loop that waits for the Read RRA command to complete has
the break condition inverted. That's why the for loop iterates until
its termination condition. Call the helper for this instead.

Finally, give the Receiver Enable command after clearing interrupts,
not before, to avoid the possibility of losing an interrupt.

Fixes: 1da177e4 ("Linux-2.6.12-rc2")
Tested-by: default avatarStan Johnson <userm57@yahoo.com>
Signed-off-by: default avatarFinn Thain <fthain@telegraphics.com.au>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3f4b7e6a
...@@ -664,7 +664,6 @@ static void sonic_multicast_list(struct net_device *dev) ...@@ -664,7 +664,6 @@ static void sonic_multicast_list(struct net_device *dev)
*/ */
static int sonic_init(struct net_device *dev) static int sonic_init(struct net_device *dev)
{ {
unsigned int cmd;
struct sonic_local *lp = netdev_priv(dev); struct sonic_local *lp = netdev_priv(dev);
int i; int i;
...@@ -681,7 +680,7 @@ static int sonic_init(struct net_device *dev) ...@@ -681,7 +680,7 @@ static int sonic_init(struct net_device *dev)
* enable interrupts, then completely initialize the SONIC * enable interrupts, then completely initialize the SONIC
*/ */
SONIC_WRITE(SONIC_CMD, 0); SONIC_WRITE(SONIC_CMD, 0);
SONIC_WRITE(SONIC_CMD, SONIC_CR_RXDIS); SONIC_WRITE(SONIC_CMD, SONIC_CR_RXDIS | SONIC_CR_STP);
sonic_quiesce(dev, SONIC_CR_ALL); sonic_quiesce(dev, SONIC_CR_ALL);
/* /*
...@@ -711,14 +710,7 @@ static int sonic_init(struct net_device *dev) ...@@ -711,14 +710,7 @@ static int sonic_init(struct net_device *dev)
netif_dbg(lp, ifup, dev, "%s: issuing RRRA command\n", __func__); netif_dbg(lp, ifup, dev, "%s: issuing RRRA command\n", __func__);
SONIC_WRITE(SONIC_CMD, SONIC_CR_RRRA); SONIC_WRITE(SONIC_CMD, SONIC_CR_RRRA);
i = 0; sonic_quiesce(dev, SONIC_CR_RRRA);
while (i++ < 100) {
if (SONIC_READ(SONIC_CMD) & SONIC_CR_RRRA)
break;
}
netif_dbg(lp, ifup, dev, "%s: status=%x, i=%d\n", __func__,
SONIC_READ(SONIC_CMD), i);
/* /*
* Initialize the receive descriptors so that they * Initialize the receive descriptors so that they
...@@ -806,15 +798,11 @@ static int sonic_init(struct net_device *dev) ...@@ -806,15 +798,11 @@ static int sonic_init(struct net_device *dev)
* enable receiver, disable loopback * enable receiver, disable loopback
* and enable all interrupts * and enable all interrupts
*/ */
SONIC_WRITE(SONIC_CMD, SONIC_CR_RXEN | SONIC_CR_STP);
SONIC_WRITE(SONIC_RCR, SONIC_RCR_DEFAULT); SONIC_WRITE(SONIC_RCR, SONIC_RCR_DEFAULT);
SONIC_WRITE(SONIC_TCR, SONIC_TCR_DEFAULT); SONIC_WRITE(SONIC_TCR, SONIC_TCR_DEFAULT);
SONIC_WRITE(SONIC_ISR, 0x7fff); SONIC_WRITE(SONIC_ISR, 0x7fff);
SONIC_WRITE(SONIC_IMR, SONIC_IMR_DEFAULT); SONIC_WRITE(SONIC_IMR, SONIC_IMR_DEFAULT);
SONIC_WRITE(SONIC_CMD, SONIC_CR_RXEN);
cmd = SONIC_READ(SONIC_CMD);
if ((cmd & SONIC_CR_RXEN) == 0 || (cmd & SONIC_CR_STP) == 0)
printk(KERN_ERR "sonic_init: failed, status=%x\n", cmd);
netif_dbg(lp, ifup, dev, "%s: new status=%x\n", __func__, netif_dbg(lp, ifup, dev, "%s: new status=%x\n", __func__,
SONIC_READ(SONIC_CMD)); SONIC_READ(SONIC_CMD));
......
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