Skip to content

Commit

Permalink
r6040: consolidate MAC reset to its own function
Browse files Browse the repository at this point in the history
The reset of the MAC is currently done identically from two places
and one place is not waiting for the MAC_SM bit to be set after reset.
Everytime the MAC is software resetted a state machine is also needed
so consolidate the reset to its own function.

Signed-off-by: Florian Fainelli <florian@openwrt.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
ffainelli authored and davem330 committed Apr 12, 2012
1 parent c1e6aaf commit 90f750a
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions drivers/net/ethernet/rdc/r6040.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,27 +358,35 @@ static int r6040_alloc_rxbufs(struct net_device *dev)
return rc;
}

static void r6040_init_mac_regs(struct net_device *dev)
static void r6040_reset_mac(struct r6040_private *lp)
{
struct r6040_private *lp = netdev_priv(dev);
void __iomem *ioaddr = lp->base;
int limit = 2048;
u16 cmd;

/* Mask Off Interrupt */
iowrite16(MSK_INT, ioaddr + MIER);

/* Reset RDC MAC */
iowrite16(MAC_RST, ioaddr + MCR1);
while (limit--) {
cmd = ioread16(ioaddr + MCR1);
if (cmd & MAC_RST)
break;
}

/* Reset internal state machine */
iowrite16(MAC_SM_RST, ioaddr + MAC_SM);
iowrite16(0, ioaddr + MAC_SM);
mdelay(5);
}

static void r6040_init_mac_regs(struct net_device *dev)
{
struct r6040_private *lp = netdev_priv(dev);
void __iomem *ioaddr = lp->base;

/* Mask Off Interrupt */
iowrite16(MSK_INT, ioaddr + MIER);

/* Reset RDC MAC */
r6040_reset_mac(lp);

/* MAC Bus Control Register */
iowrite16(MBCR_DEFAULT, ioaddr + MBCR);
Expand Down Expand Up @@ -445,18 +453,13 @@ static void r6040_down(struct net_device *dev)
{
struct r6040_private *lp = netdev_priv(dev);
void __iomem *ioaddr = lp->base;
int limit = 2048;
u16 *adrp;
u16 cmd;

/* Stop MAC */
iowrite16(MSK_INT, ioaddr + MIER); /* Mask Off Interrupt */
iowrite16(MAC_RST, ioaddr + MCR1); /* Reset RDC MAC */
while (limit--) {
cmd = ioread16(ioaddr + MCR1);
if (cmd & MAC_RST)
break;
}

/* Reset RDC MAC */
r6040_reset_mac(lp);

/* Restore MAC Address to MIDx */
adrp = (u16 *) dev->dev_addr;
Expand Down Expand Up @@ -736,11 +739,7 @@ static void r6040_mac_address(struct net_device *dev)
u16 *adrp;

/* Reset MAC */
iowrite16(MAC_RST, ioaddr + MCR1);
/* Reset internal state machine */
iowrite16(MAC_SM_RST, ioaddr + MAC_SM);
iowrite16(0, ioaddr + MAC_SM);
mdelay(5);
r6040_reset_mac(lp);

/* Restore MAC Address */
adrp = (u16 *) dev->dev_addr;
Expand Down

0 comments on commit 90f750a

Please sign in to comment.