Skip to content

Commit

Permalink
net: stmmac: Use msleep rather then udelay for reset delay
Browse files Browse the repository at this point in the history
The reset delays used for stmmac are in the order of 10ms to 1 second,
which is far too long for udelay usage, so switch to using msleep.

Practically this fixes the PHY not being reliably detected in some cases
as udelay wouldn't actually delay for long enough to let the phy
reliably be reset.

Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
sjoerdsimons authored and davem330 committed Sep 15, 2015
1 parent d64f69b commit 892aa01
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,16 @@ int stmmac_mdio_reset(struct mii_bus *bus)

if (!gpio_request(reset_gpio, "mdio-reset")) {
gpio_direction_output(reset_gpio, active_low ? 1 : 0);
udelay(data->delays[0]);
if (data->delays[0])
msleep(DIV_ROUND_UP(data->delays[0], 1000));

gpio_set_value(reset_gpio, active_low ? 0 : 1);
udelay(data->delays[1]);
if (data->delays[1])
msleep(DIV_ROUND_UP(data->delays[1], 1000));

gpio_set_value(reset_gpio, active_low ? 1 : 0);
udelay(data->delays[2]);
if (data->delays[2])
msleep(DIV_ROUND_UP(data->delays[2], 1000));
}
}
#endif
Expand Down

0 comments on commit 892aa01

Please sign in to comment.