aboutsummaryrefslogtreecommitdiff
path: root/drivers/net/cpsw.c
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2017-06-03 18:05:28 -0400
committerTom Rini <trini@konsulko.com>2017-06-03 18:05:28 -0400
commit5cafcbab580bac6c7f44ca4a164c422b7e1ecf20 (patch)
tree40be1a1863c0cbf6bec128184076ac9857962178 /drivers/net/cpsw.c
parent541f538f4ca50082f77f7f34f05950d57804b1cc (diff)
parent2303bff7d55df47105740e5d635d50ef9f6856b6 (diff)
downloadu-boot-5cafcbab580bac6c7f44ca4a164c422b7e1ecf20.zip
u-boot-5cafcbab580bac6c7f44ca4a164c422b7e1ecf20.tar.gz
u-boot-5cafcbab580bac6c7f44ca4a164c422b7e1ecf20.tar.bz2
Merge git://git.denx.de/u-boot-net
Diffstat (limited to 'drivers/net/cpsw.c')
-rw-r--r--drivers/net/cpsw.c34
1 files changed, 22 insertions, 12 deletions
diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c
index 778d2f5..d7db0fc 100644
--- a/drivers/net/cpsw.c
+++ b/drivers/net/cpsw.c
@@ -612,21 +612,25 @@ static void cpsw_set_slave_mac(struct cpsw_slave *slave,
#endif
}
-static void cpsw_slave_update_link(struct cpsw_slave *slave,
+static int cpsw_slave_update_link(struct cpsw_slave *slave,
struct cpsw_priv *priv, int *link)
{
struct phy_device *phy;
u32 mac_control = 0;
+ int ret = -ENODEV;
phy = priv->phydev;
-
if (!phy)
- return;
+ goto out;
+
+ ret = phy_startup(phy);
+ if (ret)
+ goto out;
- phy_startup(phy);
- *link = phy->link;
+ if (link)
+ *link = phy->link;
- if (*link) { /* link up */
+ if (phy->link) { /* link up */
mac_control = priv->data.mac_control;
if (phy->speed == 1000)
mac_control |= GIGABITEN;
@@ -637,7 +641,7 @@ static void cpsw_slave_update_link(struct cpsw_slave *slave,
}
if (mac_control == slave->mac_control)
- return;
+ goto out;
if (mac_control) {
printf("link up on port %d, speed %d, %s duplex\n",
@@ -649,17 +653,20 @@ static void cpsw_slave_update_link(struct cpsw_slave *slave,
__raw_writel(mac_control, &slave->sliver->mac_control);
slave->mac_control = mac_control;
+
+out:
+ return ret;
}
static int cpsw_update_link(struct cpsw_priv *priv)
{
- int link = 0;
+ int ret = -ENODEV;
struct cpsw_slave *slave;
for_active_slave(slave, priv)
- cpsw_slave_update_link(slave, priv, &link);
+ ret = cpsw_slave_update_link(slave, priv, NULL);
- return link;
+ return ret;
}
static inline u32 cpsw_get_slave_port(struct cpsw_priv *priv, u32 slave_num)
@@ -822,7 +829,9 @@ static int _cpsw_init(struct cpsw_priv *priv, u8 *enetaddr)
for_active_slave(slave, priv)
cpsw_slave_init(slave, priv);
- cpsw_update_link(priv);
+ ret = cpsw_update_link(priv);
+ if (ret)
+ goto out;
/* init descriptor pool */
for (i = 0; i < NUM_DESCS; i++) {
@@ -897,7 +906,8 @@ static int _cpsw_init(struct cpsw_priv *priv, u8 *enetaddr)
}
}
- return 0;
+out:
+ return ret;
}
static void _cpsw_halt(struct cpsw_priv *priv)