Message ID | 20230807193102.6374-3-brgl@bgdev.pl (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | net: stmmac: allow sharing MDIO lines | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Guessing tree name failed - patch did not apply |
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c index dd9e2fec5328..6a74b91595d0 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c @@ -543,6 +543,14 @@ int stmmac_mdio_register(struct net_device *ndev) if (!mdio_bus_data) return 0; + if (priv->plat->flags & STMMAC_FLAG_SHARED_MDIO) { + new_bus = of_mdio_find_bus(mdio_node); + if (!new_bus) + return -EPROBE_DEFER; + + goto bus_register_done; + } + new_bus = mdiobus_alloc(); if (!new_bus) return -ENOMEM; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index be8e79c7aa34..11a24b1c7beb 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c @@ -340,6 +340,12 @@ static int stmmac_dt_phy(struct plat_stmmacenet_data *plat, } } + if (!plat->mdio_node) { + plat->mdio_node = of_parse_phandle(np, "snps,shared-mdio", 0); + if (plat->mdio_node) + plat->flags |= STMMAC_FLAG_SHARED_MDIO; + } + if (plat->mdio_node) { dev_dbg(dev, "Found MDIO subnode\n"); mdio = true; diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h index 3d0702510224..892f61051002 100644 --- a/include/linux/stmmac.h +++ b/include/linux/stmmac.h @@ -218,6 +218,7 @@ struct dwmac4_addrs { #define STMMAC_FLAG_INT_SNAPSHOT_EN BIT(9) #define STMMAC_FLAG_RX_CLK_RUNS_IN_LPI BIT(10) #define STMMAC_FLAG_EN_TX_LPI_CLOCKGATING BIT(11) +#define STMMAC_FLAG_SHARED_MDIO BIT(12) struct plat_stmmacenet_data { int bus_id;