[PATCH] net: usb: smsc95xx: configure external LEDs function for EVB-LAN8670-USB

From: Parthiban Veerasooran
Date: Wed May 22 2024 - 10:10:06 EST


By default, LAN9500A configures the external LEDs to the below function.
nSPD_LED -> Speed Indicator
nLNKA_LED -> Link and Activity Indicator
nFDX_LED -> Full Duplex Link Indicator

But, EVB-LAN8670-USB uses the below external LEDs function which can be
enabled by writing 1 to the LED Select (LED_SEL) bit in the LAN9500A.
nSPD_LED -> Speed Indicator
nLNKA_LED -> Link Indicator
nFDX_LED -> Activity Indicator

Signed-off-by: Parthiban Veerasooran <Parthiban.Veerasooran@xxxxxxxxxxxxx>
---
drivers/net/usb/smsc95xx.c | 12 ++++++++++++
drivers/net/usb/smsc95xx.h | 1 +
2 files changed, 13 insertions(+)

diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index cbea24666479..05975461bf10 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -1006,6 +1006,18 @@ static int smsc95xx_reset(struct usbnet *dev)
/* Configure GPIO pins as LED outputs */
write_buf = LED_GPIO_CFG_SPD_LED | LED_GPIO_CFG_LNK_LED |
LED_GPIO_CFG_FDX_LED;
+
+ /* Set LED Select (LED_SEL) bit for the external LED pins functionality
+ * in the Microchip's EVB-LAN8670-USB 10BASE-T1S Ethernet device which
+ * uses the below LED function.
+ * nSPD_LED -> Speed Indicator
+ * nLNKA_LED -> Link Indicator
+ * nFDX_LED -> Activity Indicator
+ */
+ if (dev->udev->descriptor.idVendor == 0x184F &&
+ dev->udev->descriptor.idProduct == 0x0051)
+ write_buf |= LED_GPIO_CFG_LED_SEL;
+
ret = smsc95xx_write_reg(dev, LED_GPIO_CFG, write_buf);
if (ret < 0)
return ret;
diff --git a/drivers/net/usb/smsc95xx.h b/drivers/net/usb/smsc95xx.h
index 013bf42e27f2..134f3c2fddd9 100644
--- a/drivers/net/usb/smsc95xx.h
+++ b/drivers/net/usb/smsc95xx.h
@@ -114,6 +114,7 @@

/* LED General Purpose IO Configuration Register */
#define LED_GPIO_CFG (0x24)
+#define LED_GPIO_CFG_LED_SEL BIT(31) /* Separate Link/Act LEDs */
#define LED_GPIO_CFG_SPD_LED (0x01000000) /* GPIOz as Speed LED */
#define LED_GPIO_CFG_LNK_LED (0x00100000) /* GPIOy as Link LED */
#define LED_GPIO_CFG_FDX_LED (0x00010000) /* GPIOx as Full Duplex LED */

base-commit: 4b377b4868ef17b040065bd468668c707d2477a5
--
2.34.1