[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <d70a1fa9b92c7b3e7ea09b5c3216d77a8fd35265.1768432653.git.daniel@makrotopia.org>
Date: Thu, 15 Jan 2026 23:40:38 +0000
From: Daniel Golle <daniel@...rotopia.org>
To: Andrew Lunn <andrew@...n.ch>, Heiner Kallweit <hkallweit1@...il.com>,
Russell King <linux@...linux.org.uk>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Cc: "Benny (Ying-Tsan) Weng" <yweng@...linear.com>,
Avinash Jayaraman <ajayaraman@...linear.com>,
Bing tao Xu <bxu@...linear.com>,
Juraj Povazanec <jpovazanec@...linear.com>,
"Fanni (Fang-Yi) Chan" <fchan@...linear.com>,
"Livia M. Rosu" <lrosu@...linear.com>,
John Crispin <john@...ozen.org>
Subject: [PATCH net-next] net: phy: intel-xway: workaround stale LEDs before
link-up
Due to a bug in some PHY internal firmware, manual control as well as
polarity configuration of the PHY LEDs has no effect until a link has
been detected at least once after reset. Apparently the LED control
thread is not started until then.
As a workaround, clear the BMCR_ANENABLE bit for 100ms to force the
firmware to start the LED thread, allowing manual LED control and
respecting LED polarity before the first link comes up.
In case the legacy default LED configuration is used the bug isn't
visible, so only apply the workaround in case LED configuration is
present in the device tree.
Signed-off-by: Daniel Golle <daniel@...rotopia.org>
---
drivers/net/phy/intel-xway.c | 28 +++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/drivers/net/phy/intel-xway.c b/drivers/net/phy/intel-xway.c
index 9766dd99afaa0..37150115c8edb 100644
--- a/drivers/net/phy/intel-xway.c
+++ b/drivers/net/phy/intel-xway.c
@@ -4,6 +4,7 @@
* Copyright (C) 2016 Hauke Mehrtens <hauke@...ke-m.de>
*/
+#include <linux/delay.h>
#include <linux/mdio.h>
#include <linux/module.h>
#include <linux/phy.h>
@@ -286,8 +287,33 @@ static int xway_gphy_config_init(struct phy_device *phydev)
return err;
/* Use default LED configuration if 'leds' node isn't defined */
- if (!of_get_child_by_name(np, "leds"))
+ if (!of_get_child_by_name(np, "leds")) {
xway_gphy_init_leds(phydev);
+ } else {
+ /* Due to a bug in some PHY internal firmware, manual control
+ * as well as polarity configuration of the PHY LEDs has no
+ * effect until a link has been detected at least once after
+ * reset. Apparently the LED control thread is not started
+ * until then.
+ *
+ * Workaround: clear the BMCR_ANENABLE bit to force the firmware
+ * to start the LED thread, allowing manual LED control and
+ * respecting LED polarity before the first link comes up.
+ *
+ * In case the default LED configuration is used the bug isn't
+ * visible, so only apply the workaround in case LED
+ * configuration is present in the device tree.
+ */
+ phy_clear_bits(phydev, MII_BMCR, BMCR_ANENABLE);
+ /* 100ms was found to be required by experimentation.
+ * A shorter delay causes other (serious) bugs...
+ */
+ msleep(100);
+ /* It turns out BMCR_ANENABLE *has* to be set when removing
+ * BMCR_PDOWN for not facing yet different bugs
+ */
+ phy_set_bits(phydev, MII_BMCR, BMCR_ANENABLE);
+ }
/* Clear all pending interrupts */
phy_read(phydev, XWAY_MDIO_ISTAT);
--
2.52.0
Powered by blists - more mailing lists