summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorSimon Kagstrom <simon.kagstrom@netinsight.net>2009-08-20 10:13:06 +0200
committerBen Warren <biggerbadderben@gmail.com>2009-08-21 09:57:33 -0700
commitcad713bf7548b9e90433dac8270165402a6c9cc3 (patch)
treea0e8607d951a0efff50ccb68420daf0cc2efabf2 /drivers
parentbb1ca3b27f7fba8c73cb10279a6a8b8b69a308ff (diff)
downloadbootable_bootloader_goldelico_gta04-cad713bf7548b9e90433dac8270165402a6c9cc3.zip
bootable_bootloader_goldelico_gta04-cad713bf7548b9e90433dac8270165402a6c9cc3.tar.gz
bootable_bootloader_goldelico_gta04-cad713bf7548b9e90433dac8270165402a6c9cc3.tar.bz2
Wait for the link to come up on kirkwood network init
This patch makes the device wait for up to 5 seconds for the link to come up, similar to what many of the other network drivers do. This avoids confusing situations where, e.g., a tftp fails when initiated early after U-boot has started (before the link has come up). Signed-off-by: Simon Kagstrom <simon.kagstrom@netinsight.net> Signed-off-by: Ben Warren <biggerbadderben@gmail.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/kirkwood_egiga.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/drivers/net/kirkwood_egiga.c b/drivers/net/kirkwood_egiga.c
index 065e335..9f36633 100644
--- a/drivers/net/kirkwood_egiga.c
+++ b/drivers/net/kirkwood_egiga.c
@@ -400,6 +400,7 @@ static int kwgbe_init(struct eth_device *dev)
{
struct kwgbe_device *dkwgbe = to_dkwgbe(dev);
struct kwgbe_registers *regs = dkwgbe->regs;
+ int i;
/* setup RX rings */
kwgbe_init_rx_desc_ring(dkwgbe);
@@ -447,13 +448,20 @@ static int kwgbe_init(struct eth_device *dev)
#if (defined (CONFIG_MII) || defined (CONFIG_CMD_MII)) \
&& defined (CONFIG_SYS_FAULT_ECHO_LINK_DOWN)
- u16 phyadr;
- miiphy_read(dev->name, KIRKWOOD_PHY_ADR_REQUEST,
- KIRKWOOD_PHY_ADR_REQUEST, &phyadr);
- if (!miiphy_link(dev->name, phyadr)) {
- printf("%s: No link on %s\n", __FUNCTION__, dev->name);
- return -1;
+ /* Wait up to 5s for the link status */
+ for (i = 0; i < 5; i++) {
+ u16 phyadr;
+
+ miiphy_read(dev->name, KIRKWOOD_PHY_ADR_REQUEST,
+ KIRKWOOD_PHY_ADR_REQUEST, &phyadr);
+ /* Return if we get link up */
+ if (miiphy_link(dev->name, phyadr))
+ return 0;
+ udelay(1000000);
}
+
+ printf("No link on %s\n", dev->name);
+ return -1;
#endif
return 0;
}