Merge tag 'u-boot-rockchip-20200501' of https://gitlab.denx.de/u-boot/custodians...
[oweals/u-boot.git] / common / miiphyutil.c
index d8ebb384dbfa82012284edea1999fd6ddc0c325f..2db067876e4b8f58263ddf2ceca8209f0f5e207d 100644 (file)
@@ -1,8 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * (C) Copyright 2001
  * Gerald Van Baren, Custom IDEAS, vanbaren@cideas.com.
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 /*
@@ -107,6 +106,18 @@ int mdio_register(struct mii_dev *bus)
        return 0;
 }
 
+int mdio_register_seq(struct mii_dev *bus, int seq)
+{
+       int ret;
+
+       /* Setup a unique name for each mdio bus */
+       ret = snprintf(bus->name, MDIO_NAME_LEN, "eth%d", seq);
+       if (ret < 0)
+               return ret;
+
+       return mdio_register(bus);
+}
+
 int mdio_unregister(struct mii_dev *bus)
 {
        if (!bus)
@@ -135,7 +146,7 @@ void mdio_list_devices(void)
                        struct phy_device *phydev = bus->phymap[i];
 
                        if (phydev) {
-                               printf("%d - %s", i, phydev->drv->name);
+                               printf("%x - %s", i, phydev->drv->name);
 
                                if (phydev->dev)
                                        printf(" <--> %s\n", phydev->dev->name);
@@ -166,6 +177,11 @@ struct mii_dev *mdio_get_current_dev(void)
        return current_mii;
 }
 
+struct list_head *mdio_get_list_head(void)
+{
+       return &mii_devs;
+}
+
 struct phy_device *mdio_phydev_for_ethname(const char *ethname)
 {
        struct list_head *entry;