linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: phy: micrel: ksz9131 led errata workaround
@ 2021-10-06  7:37 Francesco Dolcini
  2021-10-06  9:39 ` Francesco Dolcini
  2021-10-06 21:57 ` Andrew Lunn
  0 siblings, 2 replies; 3+ messages in thread
From: Francesco Dolcini @ 2021-10-06  7:37 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit, Russell King, David S. Miller,
	Jakub Kicinski
  Cc: philippe.schenker, Francesco Dolcini, netdev, linux-kernel

Micrel KSZ9131 PHY LED behavior is not correct when configured in
Individual Mode, LED1 (Activity LED) is in the ON state when there is
no-link.

Workaround this by setting bit 9 of register 0x1e after verifying that
the LED configuration is Individual Mode.

This issue is described in KSZ9131RNX Silicon Errata DS80000693B
(http://ww1.microchip.com/downloads/en/DeviceDoc/80000863A.pdf) and
according to that it will not be corrected in a future silicon revision.

Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com>
---
 drivers/net/phy/micrel.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index c330a5a9f665..661dedec84c4 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -1003,6 +1003,23 @@ static int ksz9131_config_rgmii_delay(struct phy_device *phydev)
 			      txcdll_val);
 }
 
+/* Silicon Errata DS80000693B
+ *
+ * When LEDs are configured in Individual Mode, LED1 is ON in a no-link
+ * condition. Workaround is to set register 0x1e, bit 9, this way LED1 behaves
+ * according to the datasheet (off if there is no link).
+ */
+
+static int ksz9131_led_errata(struct phy_device *phydev)
+{
+	int ret = 0;
+
+	if (phy_read_mmd(phydev, 2, 0) & BIT(4))
+		ret = phy_set_bits(phydev, 0x1e, BIT(9));
+
+	return ret;
+}
+
 static int ksz9131_config_init(struct phy_device *phydev)
 {
 	struct device_node *of_node;
@@ -1058,6 +1075,10 @@ static int ksz9131_config_init(struct phy_device *phydev)
 	if (ret < 0)
 		return ret;
 
+	ret = ksz9131_led_errata(phydev);
+	if (ret < 0)
+		return ret;
+
 	return 0;
 }
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-10-06 21:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-06  7:37 [PATCH] net: phy: micrel: ksz9131 led errata workaround Francesco Dolcini
2021-10-06  9:39 ` Francesco Dolcini
2021-10-06 21:57 ` Andrew Lunn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).