From 53f0321757b54b49e4e87211c63d994e8836b933 Mon Sep 17 00:00:00 2001
From: Jan Kiszka <jan.kiszka@siemens.com>
Date: Sat, 14 Jan 2023 19:48:15 +0100
Subject: [PATCH] net: ethernet: ti: icssg_prueth: Restore half-duplex support

This was lost during refactoring.

Fixes: 0a175a01189c ("net: ethernet: ti: icssg_prueth: move phy init in .ndo_open/close()")
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 drivers/net/ethernet/ti/icssg_prueth.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/ti/icssg_prueth.c b/drivers/net/ethernet/ti/icssg_prueth.c
index 7805603c9767..10ec9ebef867 100644
--- a/drivers/net/ethernet/ti/icssg_prueth.c
+++ b/drivers/net/ethernet/ti/icssg_prueth.c
@@ -1604,6 +1604,7 @@ const struct icss_iep_clockops prueth_iep_clockops = {
 static int emac_phy_connect(struct prueth_emac *emac)
 {
 	struct prueth *prueth = emac->prueth;
+	int slice = prueth_emac_slice(emac);
 
 	/* connect PHY */
 	emac->phydev = of_phy_connect(emac->ndev, emac->phy_node,
@@ -1614,9 +1615,14 @@ static int emac_phy_connect(struct prueth_emac *emac)
 		return -ENODEV;
 	}
 
+	emac->half_duplex = of_property_read_bool(prueth->eth_node[slice],
+						  "ti,half-duplex-capable");
+
 	/* remove unsupported modes */
-	phy_remove_link_mode(emac->phydev, ETHTOOL_LINK_MODE_10baseT_Half_BIT);
-	phy_remove_link_mode(emac->phydev, ETHTOOL_LINK_MODE_100baseT_Half_BIT);
+	if (!emac->half_duplex) {
+		phy_remove_link_mode(emac->phydev, ETHTOOL_LINK_MODE_10baseT_Half_BIT);
+		phy_remove_link_mode(emac->phydev, ETHTOOL_LINK_MODE_100baseT_Half_BIT);
+	}
 	phy_remove_link_mode(emac->phydev, ETHTOOL_LINK_MODE_1000baseT_Half_BIT);
 	phy_remove_link_mode(emac->phydev, ETHTOOL_LINK_MODE_Pause_BIT);
 	phy_remove_link_mode(emac->phydev, ETHTOOL_LINK_MODE_Asym_Pause_BIT);
