|
@@ -147,3 +147,28 @@ int mii_check_link ( struct mii_device *mii, struct net_device *netdev ) {
|
147
|
147
|
|
148
|
148
|
return 0;
|
149
|
149
|
}
|
|
150
|
+
|
|
151
|
+/**
|
|
152
|
+ * Find PHY address
|
|
153
|
+ *
|
|
154
|
+ * @v mii MII device
|
|
155
|
+ * @ret rc Return status code
|
|
156
|
+ */
|
|
157
|
+int mii_find ( struct mii_device *mii ) {
|
|
158
|
+ unsigned int address;
|
|
159
|
+ int id;
|
|
160
|
+
|
|
161
|
+ /* Try all possible PHY addresses */
|
|
162
|
+ for ( address = 0 ; address <= MII_MAX_PHY_ADDRESS ; address++ ) {
|
|
163
|
+ mii->address = address;
|
|
164
|
+ id = mii_read ( mii, MII_PHYSID1 );
|
|
165
|
+ if ( ( id > 0x0000 ) && ( id < 0xffff ) ) {
|
|
166
|
+ DBGC ( mii, "MII %p found PHY at address %d\n",
|
|
167
|
+ mii, address );
|
|
168
|
+ return 0;
|
|
169
|
+ }
|
|
170
|
+ }
|
|
171
|
+
|
|
172
|
+ DBGC ( mii, "MII %p failed to find an address\n", mii );
|
|
173
|
+ return -ENOENT;
|
|
174
|
+}
|