ARM: rmobile: Merge prior-stage firmware DT fragment into U-Boot DT on Gen3
[oweals/u-boot.git] / net / eth-uclass.c
index 8bf2eabe9026df405825ddf3b78aedf5d417f94b..7f89f65c92a3ad4ac1bcc61b23044c050631b205 100644 (file)
@@ -6,13 +6,16 @@
  */
 
 #include <common.h>
+#include <bootstage.h>
 #include <dm.h>
 #include <env.h>
+#include <log.h>
 #include <net.h>
 #include <dm/device-internal.h>
 #include <dm/uclass-internal.h>
 #include <net/pcap.h>
 #include "eth_internal.h"
+#include <eth_phy.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -40,8 +43,12 @@ static int eth_errno;
 static struct eth_uclass_priv *eth_get_uclass_priv(void)
 {
        struct uclass *uc;
+       int ret;
+
+       ret = uclass_get(UCLASS_ETH, &uc);
+       if (ret)
+               return NULL;
 
-       uclass_get(UCLASS_ETH, &uc);
        assert(uc);
        return uc->priv;
 }
@@ -102,6 +109,7 @@ struct udevice *eth_get_dev_by_name(const char *devname)
        struct udevice *it;
        struct uclass *uc;
        int len = strlen("eth");
+       int ret;
 
        /* Must be longer than 3 to be an alias */
        if (!strncmp(devname, "eth", len) && strlen(devname) > len) {
@@ -109,7 +117,10 @@ struct udevice *eth_get_dev_by_name(const char *devname)
                seq = simple_strtoul(startp, &endp, 10);
        }
 
-       uclass_get(UCLASS_ETH, &uc);
+       ret = uclass_get(UCLASS_ETH, &uc);
+       if (ret)
+               return NULL;
+
        uclass_foreach_dev(it, uc) {
                /*
                 * We need the seq to be valid, so try to probe it.
@@ -453,6 +464,10 @@ static int eth_post_bind(struct udevice *dev)
                return -EINVAL;
        }
 
+#ifdef CONFIG_DM_ETH_PHY
+       eth_phy_binds_nodes(dev);
+#endif
+
        return 0;
 }