Commit a384a33b authored by Francois Romieu's avatar Francois Romieu

via-rhine: RHINE_WAIT_FOR macro removal.

Signed-off-by: default avatarFrancois Romieu <romieu@fr.zoreil.com>
parent 7ab87ff4
...@@ -501,15 +501,31 @@ static int rhine_vlan_rx_add_vid(struct net_device *dev, unsigned short vid); ...@@ -501,15 +501,31 @@ static int rhine_vlan_rx_add_vid(struct net_device *dev, unsigned short vid);
static int rhine_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid); static int rhine_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid);
static void rhine_restart_tx(struct net_device *dev); static void rhine_restart_tx(struct net_device *dev);
#define RHINE_WAIT_FOR(condition) \ static void rhine_wait_bit(struct rhine_private *rp, u8 reg, u8 mask, bool high)
do { \ {
int i = 1024; \ void __iomem *ioaddr = rp->base;
while (!(condition) && --i) \ int i;
; \
if (debug > 1 && i < 512) \ for (i = 0; i < 1024; i++) {
pr_info("%4d cycles used @ %s:%d\n", \ if (high ^ !!(ioread8(ioaddr + reg) & mask))
1024 - i, __func__, __LINE__); \ break;
} while (0) udelay(10);
}
if (i > 64) {
netdev_dbg(rp->dev, "%s bit wait (%02x/%02x) cycle "
"count: %04d\n", high ? "high" : "low", reg, mask, i);
}
}
static void rhine_wait_bit_high(struct rhine_private *rp, u8 reg, u8 mask)
{
rhine_wait_bit(rp, reg, mask, true);
}
static void rhine_wait_bit_low(struct rhine_private *rp, u8 reg, u8 mask)
{
rhine_wait_bit(rp, reg, mask, false);
}
static u32 rhine_get_events(struct rhine_private *rp) static u32 rhine_get_events(struct rhine_private *rp)
{ {
...@@ -609,7 +625,7 @@ static void rhine_chip_reset(struct net_device *dev) ...@@ -609,7 +625,7 @@ static void rhine_chip_reset(struct net_device *dev)
iowrite8(0x40, ioaddr + MiscCmd); iowrite8(0x40, ioaddr + MiscCmd);
/* Reset can take somewhat longer (rare) */ /* Reset can take somewhat longer (rare) */
RHINE_WAIT_FOR(!(ioread8(ioaddr + ChipCmd1) & Cmd1Reset)); rhine_wait_bit_low(rp, ChipCmd1, Cmd1Reset);
} }
if (debug > 1) if (debug > 1)
...@@ -641,9 +657,15 @@ static void __devinit rhine_reload_eeprom(long pioaddr, struct net_device *dev) ...@@ -641,9 +657,15 @@ static void __devinit rhine_reload_eeprom(long pioaddr, struct net_device *dev)
{ {
struct rhine_private *rp = netdev_priv(dev); struct rhine_private *rp = netdev_priv(dev);
void __iomem *ioaddr = rp->base; void __iomem *ioaddr = rp->base;
int i;
outb(0x20, pioaddr + MACRegEEcsr); outb(0x20, pioaddr + MACRegEEcsr);
RHINE_WAIT_FOR(!(inb(pioaddr + MACRegEEcsr) & 0x20)); for (i = 0; i < 1024; i++) {
if (!(inb(pioaddr + MACRegEEcsr) & 0x20))
break;
}
if (i > 512)
pr_info("%4d cycles used @ %s:%d\n", i, __func__, __LINE__);
#ifdef USE_MMIO #ifdef USE_MMIO
/* /*
...@@ -770,7 +792,7 @@ static int rhine_napipoll(struct napi_struct *napi, int budget) ...@@ -770,7 +792,7 @@ static int rhine_napipoll(struct napi_struct *napi, int budget)
u8 cmd; u8 cmd;
/* Avoid scavenging before Tx engine turned off */ /* Avoid scavenging before Tx engine turned off */
RHINE_WAIT_FOR(!(ioread8(ioaddr + ChipCmd) & CmdTxOn)); rhine_wait_bit_low(rp, ChipCmd, CmdTxOn);
cmd = ioread8(ioaddr + ChipCmd); cmd = ioread8(ioaddr + ChipCmd);
if ((cmd & CmdTxOn) && (debug > 2)) { if ((cmd & CmdTxOn) && (debug > 2)) {
netdev_warn(dev, "%s: Tx engine still on\n", netdev_warn(dev, "%s: Tx engine still on\n",
...@@ -1444,23 +1466,27 @@ static void init_registers(struct net_device *dev) ...@@ -1444,23 +1466,27 @@ static void init_registers(struct net_device *dev)
} }
/* Enable MII link status auto-polling (required for IntrLinkChange) */ /* Enable MII link status auto-polling (required for IntrLinkChange) */
static void rhine_enable_linkmon(void __iomem *ioaddr) static void rhine_enable_linkmon(struct rhine_private *rp)
{ {
void __iomem *ioaddr = rp->base;
iowrite8(0, ioaddr + MIICmd); iowrite8(0, ioaddr + MIICmd);
iowrite8(MII_BMSR, ioaddr + MIIRegAddr); iowrite8(MII_BMSR, ioaddr + MIIRegAddr);
iowrite8(0x80, ioaddr + MIICmd); iowrite8(0x80, ioaddr + MIICmd);
RHINE_WAIT_FOR((ioread8(ioaddr + MIIRegAddr) & 0x20)); rhine_wait_bit_high(rp, MIIRegAddr, 0x20);
iowrite8(MII_BMSR | 0x40, ioaddr + MIIRegAddr); iowrite8(MII_BMSR | 0x40, ioaddr + MIIRegAddr);
} }
/* Disable MII link status auto-polling (required for MDIO access) */ /* Disable MII link status auto-polling (required for MDIO access) */
static void rhine_disable_linkmon(void __iomem *ioaddr, u32 quirks) static void rhine_disable_linkmon(struct rhine_private *rp)
{ {
void __iomem *ioaddr = rp->base;
iowrite8(0, ioaddr + MIICmd); iowrite8(0, ioaddr + MIICmd);
if (quirks & rqRhineI) { if (rp->quirks & rqRhineI) {
iowrite8(0x01, ioaddr + MIIRegAddr); // MII_BMSR iowrite8(0x01, ioaddr + MIIRegAddr); // MII_BMSR
/* Can be called from ISR. Evil. */ /* Can be called from ISR. Evil. */
...@@ -1469,13 +1495,13 @@ static void rhine_disable_linkmon(void __iomem *ioaddr, u32 quirks) ...@@ -1469,13 +1495,13 @@ static void rhine_disable_linkmon(void __iomem *ioaddr, u32 quirks)
/* 0x80 must be set immediately before turning it off */ /* 0x80 must be set immediately before turning it off */
iowrite8(0x80, ioaddr + MIICmd); iowrite8(0x80, ioaddr + MIICmd);
RHINE_WAIT_FOR(ioread8(ioaddr + MIIRegAddr) & 0x20); rhine_wait_bit_high(rp, MIIRegAddr, 0x20);
/* Heh. Now clear 0x80 again. */ /* Heh. Now clear 0x80 again. */
iowrite8(0, ioaddr + MIICmd); iowrite8(0, ioaddr + MIICmd);
} }
else else
RHINE_WAIT_FOR(ioread8(ioaddr + MIIRegAddr) & 0x80); rhine_wait_bit_high(rp, MIIRegAddr, 0x80);
} }
/* Read and write over the MII Management Data I/O (MDIO) interface. */ /* Read and write over the MII Management Data I/O (MDIO) interface. */
...@@ -1486,16 +1512,16 @@ static int mdio_read(struct net_device *dev, int phy_id, int regnum) ...@@ -1486,16 +1512,16 @@ static int mdio_read(struct net_device *dev, int phy_id, int regnum)
void __iomem *ioaddr = rp->base; void __iomem *ioaddr = rp->base;
int result; int result;
rhine_disable_linkmon(ioaddr, rp->quirks); rhine_disable_linkmon(rp);
/* rhine_disable_linkmon already cleared MIICmd */ /* rhine_disable_linkmon already cleared MIICmd */
iowrite8(phy_id, ioaddr + MIIPhyAddr); iowrite8(phy_id, ioaddr + MIIPhyAddr);
iowrite8(regnum, ioaddr + MIIRegAddr); iowrite8(regnum, ioaddr + MIIRegAddr);
iowrite8(0x40, ioaddr + MIICmd); /* Trigger read */ iowrite8(0x40, ioaddr + MIICmd); /* Trigger read */
RHINE_WAIT_FOR(!(ioread8(ioaddr + MIICmd) & 0x40)); rhine_wait_bit_low(rp, MIICmd, 0x40);
result = ioread16(ioaddr + MIIData); result = ioread16(ioaddr + MIIData);
rhine_enable_linkmon(ioaddr); rhine_enable_linkmon(rp);
return result; return result;
} }
...@@ -1504,16 +1530,16 @@ static void mdio_write(struct net_device *dev, int phy_id, int regnum, int value ...@@ -1504,16 +1530,16 @@ static void mdio_write(struct net_device *dev, int phy_id, int regnum, int value
struct rhine_private *rp = netdev_priv(dev); struct rhine_private *rp = netdev_priv(dev);
void __iomem *ioaddr = rp->base; void __iomem *ioaddr = rp->base;
rhine_disable_linkmon(ioaddr, rp->quirks); rhine_disable_linkmon(rp);
/* rhine_disable_linkmon already cleared MIICmd */ /* rhine_disable_linkmon already cleared MIICmd */
iowrite8(phy_id, ioaddr + MIIPhyAddr); iowrite8(phy_id, ioaddr + MIIPhyAddr);
iowrite8(regnum, ioaddr + MIIRegAddr); iowrite8(regnum, ioaddr + MIIRegAddr);
iowrite16(value, ioaddr + MIIData); iowrite16(value, ioaddr + MIIData);
iowrite8(0x20, ioaddr + MIICmd); /* Trigger write */ iowrite8(0x20, ioaddr + MIICmd); /* Trigger write */
RHINE_WAIT_FOR(!(ioread8(ioaddr + MIICmd) & 0x20)); rhine_wait_bit_low(rp, MIICmd, 0x20);
rhine_enable_linkmon(ioaddr); rhine_enable_linkmon(rp);
} }
static void rhine_task_disable(struct rhine_private *rp) static void rhine_task_disable(struct rhine_private *rp)
......
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