summaryrefslogtreecommitdiffstats
path: root/src/drivers/net/mii.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/drivers/net/mii.c')
-rw-r--r--src/drivers/net/mii.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/drivers/net/mii.c b/src/drivers/net/mii.c
index f6db3074..87605f0c 100644
--- a/src/drivers/net/mii.c
+++ b/src/drivers/net/mii.c
@@ -147,3 +147,28 @@ int mii_check_link ( struct mii_device *mii, struct net_device *netdev ) {
return 0;
}
+
+/**
+ * Find PHY address
+ *
+ * @v mii MII device
+ * @ret rc Return status code
+ */
+int mii_find ( struct mii_device *mii ) {
+ unsigned int address;
+ int id;
+
+ /* Try all possible PHY addresses */
+ for ( address = 0 ; address <= MII_MAX_PHY_ADDRESS ; address++ ) {
+ mii->address = address;
+ id = mii_read ( mii, MII_PHYSID1 );
+ if ( ( id > 0x0000 ) && ( id < 0xffff ) ) {
+ DBGC ( mii, "MII %p found PHY at address %d\n",
+ mii, address );
+ return 0;
+ }
+ }
+
+ DBGC ( mii, "MII %p failed to find an address\n", mii );
+ return -ENOENT;
+}