Skip to content

Commit 88f8b1b

Browse files
Gabriel Fernandezdavem330
authored andcommitted
stmmac: Fix 'eth0: No PHY found' regression
This patch manages the case when you have an Ethernet MAC with a "fixed link", and not connected to a normal MDIO-managed PHY device. The test of phy_bus_name was not helpful because it was never affected and replaced by the mdio test node. Signed-off-by: Gabriel Fernandez <gabriel.fernandez@linaro.org> Acked-by: Giuseppe Cavallaro <peppe.cavallaro@st.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent ebc9780 commit 88f8b1b

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -199,21 +199,12 @@ int stmmac_mdio_register(struct net_device *ndev)
199199
struct stmmac_priv *priv = netdev_priv(ndev);
200200
struct stmmac_mdio_bus_data *mdio_bus_data = priv->plat->mdio_bus_data;
201201
int addr, found;
202-
struct device_node *mdio_node = NULL;
203-
struct device_node *child_node = NULL;
202+
struct device_node *mdio_node = priv->plat->mdio_node;
204203

205204
if (!mdio_bus_data)
206205
return 0;
207206

208207
if (IS_ENABLED(CONFIG_OF)) {
209-
for_each_child_of_node(priv->device->of_node, child_node) {
210-
if (of_device_is_compatible(child_node,
211-
"snps,dwmac-mdio")) {
212-
mdio_node = child_node;
213-
break;
214-
}
215-
}
216-
217208
if (mdio_node) {
218209
netdev_dbg(ndev, "FOUND MDIO subnode\n");
219210
} else {

drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
110110
struct device_node *np = pdev->dev.of_node;
111111
struct plat_stmmacenet_data *plat;
112112
struct stmmac_dma_cfg *dma_cfg;
113+
struct device_node *child_node = NULL;
113114

114115
plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL);
115116
if (!plat)
@@ -140,13 +141,19 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
140141
plat->phy_node = of_node_get(np);
141142
}
142143

144+
for_each_child_of_node(np, child_node)
145+
if (of_device_is_compatible(child_node, "snps,dwmac-mdio")) {
146+
plat->mdio_node = child_node;
147+
break;
148+
}
149+
143150
/* "snps,phy-addr" is not a standard property. Mark it as deprecated
144151
* and warn of its use. Remove this when phy node support is added.
145152
*/
146153
if (of_property_read_u32(np, "snps,phy-addr", &plat->phy_addr) == 0)
147154
dev_warn(&pdev->dev, "snps,phy-addr property is deprecated\n");
148155

149-
if ((plat->phy_node && !of_phy_is_fixed_link(np)) || plat->phy_bus_name)
156+
if ((plat->phy_node && !of_phy_is_fixed_link(np)) || !plat->mdio_node)
150157
plat->mdio_bus_data = NULL;
151158
else
152159
plat->mdio_bus_data =

include/linux/stmmac.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ struct plat_stmmacenet_data {
100100
int interface;
101101
struct stmmac_mdio_bus_data *mdio_bus_data;
102102
struct device_node *phy_node;
103+
struct device_node *mdio_node;
103104
struct stmmac_dma_cfg *dma_cfg;
104105
int clk_csr;
105106
int has_gmac;

0 commit comments

Comments
 (0)