@@ -241,6 +241,13 @@ static int ep93xx_mdiobus_write(struct mii_bus *bus, int phy_id, int reg, u16 da
static int ep93xx_mdiobus_reset(struct mii_bus *bus)
{
+ struct ep93xx_priv *ep = netdev_priv(bus->priv);
+
+ /*
+ * Make sure that the PHY clock divisor is valid before trying to
+ * access any of it's registers.
+ */
+ wrl(ep, REG_SELFCTL, ((ep->mdc_divisor - 1) << 9));
return 0;
}
@@ -631,10 +638,8 @@ err:
return 1;
}
-static int ep93xx_start_hw(struct net_device *dev)
+static void ep93xx_reset_hw(struct ep93xx_priv *ep)
{
- struct ep93xx_priv *ep = netdev_priv(dev);
- unsigned long addr;
int i;
wrl(ep, REG_SELFCTL, REG_SELFCTL_RESET);
@@ -644,12 +649,15 @@ static int ep93xx_start_hw(struct net_device *dev)
msleep(1);
}
- if (i == 10) {
+ if (i == 10)
pr_crit("hw failed to reset\n");
- return 1;
- }
+}
- wrl(ep, REG_SELFCTL, ((ep->mdc_divisor - 1) << 9));
+static int ep93xx_start_hw(struct net_device *dev)
+{
+ struct ep93xx_priv *ep = netdev_priv(dev);
+ unsigned long addr;
+ int i;
/* Does the PHY support preamble suppress? */
if ((ep93xx_mdiobus_read(ep->mii_bus, ep->phy_addr, MII_BMSR) & 0x0040) != 0)
@@ -715,18 +723,7 @@ static int ep93xx_start_hw(struct net_device *dev)
static void ep93xx_stop_hw(struct net_device *dev)
{
- struct ep93xx_priv *ep = netdev_priv(dev);
- int i;
-
- wrl(ep, REG_SELFCTL, REG_SELFCTL_RESET);
- for (i = 0; i < 10; i++) {
- if ((rdl(ep, REG_SELFCTL) & REG_SELFCTL_RESET) == 0)
- break;
- msleep(1);
- }
-
- if (i == 10)
- pr_crit("hw failed to reset\n");
+ ep93xx_reset_hw(netdev_priv(dev));
}
static int ep93xx_open(struct net_device *dev)
@@ -934,6 +931,8 @@ static int ep93xx_eth_probe(struct platform_device *pdev)
}
ep->irq = irq;
+ ep93xx_reset_hw(ep);
+
ep->mii_bus = mdiobus_alloc();
if (!ep->mii_bus) {
dev_err(&pdev->dev, "Failed to allocate mdiobus\n");