[PATCH net-next 2/4] net: stmmac: introduce PHY-less setup support

Ong Boon Leong boon.leong.ong at intel.com
Fri Apr 22 00:35:03 PDT 2022


Certain platform uses PHY-less configuration whereby the MAC controller
is connected to network switch chip directly over SGMII or 1000BASE-X.

This patch prepares the stmmac driver to support PHY-less configuration
described above.

Tested-by: Emilio Riva <emilio.riva at ericsson.com>
Signed-off-by: Ong Boon Leong <boon.leong.ong at intel.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 10 +++++++++-
 drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c |  2 +-
 include/linux/stmmac.h                            |  1 +
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 57cb11abec8..4d39387bc48 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1142,11 +1142,18 @@ static void stmmac_check_pcs_mode(struct stmmac_priv *priv)
 static int stmmac_init_phy(struct net_device *dev)
 {
 	struct stmmac_priv *priv = netdev_priv(dev);
+	struct stmmac_mdio_bus_data *mdio_bus_data;
 	struct device_node *node;
-	int ret;
+	int ret = 0;
 
+	mdio_bus_data = priv->plat->mdio_bus_data;
 	node = priv->plat->phylink_node;
 
+	if (mdio_bus_data->phyless) {
+		netdev_info(priv->dev, "using PHY-less setup\n");
+		goto phyless_setup;
+	}
+
 	if (node)
 		ret = phylink_of_phy_connect(priv->phylink, node, 0);
 
@@ -1166,6 +1173,7 @@ static int stmmac_init_phy(struct net_device *dev)
 		ret = phylink_connect_phy(priv->phylink, phydev);
 	}
 
+phyless_setup:
 	if (!priv->plat->pmt) {
 		struct ethtool_wolinfo wol = { .cmd = ETHTOOL_GWOL };
 
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
index 9bc625fccca..16ce188697e 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
@@ -490,7 +490,7 @@ int stmmac_mdio_register(struct net_device *ndev)
 	if (priv->plat->has_xgmac)
 		stmmac_xgmac2_mdio_read(new_bus, 0, MII_ADDR_C45);
 
-	if (priv->plat->phy_node || mdio_node)
+	if (priv->plat->phy_node || mdio_node || mdio_bus_data->phyless)
 		goto bus_register_done;
 
 	found = 0;
diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
index f8e8df25098..238d452ef43 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -82,6 +82,7 @@ struct stmmac_mdio_bus_data {
 	unsigned int phy_mask;
 	unsigned int has_xpcs;
 	unsigned int xpcs_an_inband;
+	unsigned int phyless;
 	int *irqs;
 	int probed_phy_irq;
 	bool needs_reset;
-- 
2.25.1




More information about the linux-arm-kernel mailing list