diff mbox series

net: fec: phy: Don't advertise Gbit on (R)MII

Message ID 20241212172530.2551014-1-alexander.sverdlin@siemens.com
State New
Headers show
Series net: fec: phy: Don't advertise Gbit on (R)MII | expand

Commit Message

A. Sverdlin Dec. 12, 2024, 5:25 p.m. UTC
From: Alexander Sverdlin <alexander.sverdlin@siemens.com>

Currently if a gigabit-capable PHY is connected to FEC via RMII or MII, it
will advertise 1000FULL and 1000HALF to a link partner.

Different problems may arise here:
- usually with (R)MII between MAC and PHY the PHY's connection to magnetics
would have only 2 pairs routed as well, otherwise a PHY can negotiate 1000
speed and there will be no traffic possible;
- but even if there is no way to negotiate 1000 speed in HW (only 2 signal
pairs routed), it may take a lot of time for PHY to figure this out; in
case of AD1300 it takes 17-20 seconds, which is waay longer than default
4s PHY_ANEG_TIMEOUT.

Use phy_set_supported() in such cases to disable gigabit advertised
options.

Signed-off-by: Alexander Sverdlin <alexander.sverdlin@siemens.com>
---
 drivers/net/fec_mxc.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
diff mbox series

Patch

diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index eca681b16d1..7d2170ae72c 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -1162,6 +1162,7 @@  static int fec_phy_init(struct fec_priv *priv, struct udevice *dev)
 {
 	struct phy_device *phydev = NULL;
 	int addr;
+	int ret;
 
 	addr = device_get_phy_addr(priv, dev);
 #ifdef CFG_FEC_MXC_PHYADDR
@@ -1175,6 +1176,17 @@  static int fec_phy_init(struct fec_priv *priv, struct udevice *dev)
 	if (!phydev)
 		return -ENODEV;
 
+	switch (priv->interface) {
+	case PHY_INTERFACE_MODE_MII:
+	case PHY_INTERFACE_MODE_RMII:
+		ret = phy_set_supported(phydev, SPEED_100);
+		if (ret)
+			return ret;
+		break;
+	default:
+		break;
+	}
+
 	priv->phydev = phydev;
 	priv->phydev->node = priv->phy_of_node;
 	phy_config(phydev);