@@ -114,6 +114,35 @@ int of_mdio_parse_addr(struct device *dev, const struct device_node *np)
114
114
}
115
115
EXPORT_SYMBOL (of_mdio_parse_addr );
116
116
117
+ /*
118
+ * Return true if the child node is for a phy. It must either:
119
+ * o Compatible string of "ethernet-phy-idX.X"
120
+ * o Compatible string of "ethernet-phy-ieee802.3-c45"
121
+ * o Compatible string of "ethernet-phy-ieee802.3-c22"
122
+ * o No compatibility string
123
+ *
124
+ * A device which is not a phy is expected to have a compatible string
125
+ * indicating what sort of device it is.
126
+ */
127
+ static bool of_mdiobus_child_is_phy (struct device_node * child )
128
+ {
129
+ u32 phy_id ;
130
+
131
+ if (of_get_phy_id (child , & phy_id ) != - EINVAL )
132
+ return true;
133
+
134
+ if (of_device_is_compatible (child , "ethernet-phy-ieee802.3-c45" ))
135
+ return true;
136
+
137
+ if (of_device_is_compatible (child , "ethernet-phy-ieee802.3-c22" ))
138
+ return true;
139
+
140
+ if (!of_find_property (child , "compatible" , NULL ))
141
+ return true;
142
+
143
+ return false;
144
+ }
145
+
117
146
/**
118
147
* of_mdiobus_register - Register mii_bus and create PHYs from the device tree
119
148
* @mdio: pointer to mii_bus structure
@@ -140,17 +169,16 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
140
169
if (rc )
141
170
return rc ;
142
171
143
- /* Loop over the child nodes and register a phy_device for each one */
172
+ /* Loop over the child nodes and register a phy_device for each phy */
144
173
for_each_available_child_of_node (np , child ) {
145
174
addr = of_mdio_parse_addr (& mdio -> dev , child );
146
175
if (addr < 0 ) {
147
176
scanphys = true;
148
177
continue ;
149
178
}
150
179
151
- rc = of_mdiobus_register_phy (mdio , child , addr );
152
- if (rc )
153
- continue ;
180
+ if (of_mdiobus_child_is_phy (child ))
181
+ of_mdiobus_register_phy (mdio , child , addr );
154
182
}
155
183
156
184
if (!scanphys )
@@ -172,9 +200,8 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np)
172
200
dev_info (& mdio -> dev , "scan phy %s at address %i\n" ,
173
201
child -> name , addr );
174
202
175
- rc = of_mdiobus_register_phy (mdio , child , addr );
176
- if (rc )
177
- continue ;
203
+ if (of_mdiobus_child_is_phy (child ))
204
+ of_mdiobus_register_phy (mdio , child , addr );
178
205
}
179
206
}
180
207
0 commit comments