Re: [PATCH 1/1] net: phy: realtek: Add support for PHY LEDs on RTL8221B
From: Nicolai Buchwitz
Date: Wed Apr 01 2026 - 07:31:11 EST
On 1.4.2026 12:00, Chukun Pan wrote:
Realtek RTL8221B Ethernet PHY supports three LED pins which are used to
indicate link status and activity. Add netdev trigger support for them.
Signed-off-by: Chukun Pan <amadeus@xxxxxxxxxx>
---
drivers/net/phy/realtek/realtek_main.c | 146 +++++++++++++++++++++++++
1 file changed, 146 insertions(+)
diff --git a/drivers/net/phy/realtek/realtek_main.c b/drivers/net/phy/realtek/realtek_main.c
index 023e47ad605b..8a22e18e5c56 100644
--- a/drivers/net/phy/realtek/realtek_main.c
+++ b/drivers/net/phy/realtek/realtek_main.c
@@ -150,6 +150,15 @@
[...]
+static int rtl822xb_led_brightness_set(struct phy_device *phydev, u8 index,
+ enum led_brightness value)
+{
+ int ret;
+
+ if (index >= RTL8211x_LED_COUNT)
+ return -EINVAL;
+
+ /* clear HW LED setup */
+ ret = phy_write_mmd(phydev, MDIO_MMD_VEND2,
+ RTL822X_VND2_LED(index), 0);
+ if (ret < 0)
+ return ret;
+
+ /* clear HW LED blink */
+ return phy_clear_bits_mmd(phydev, MDIO_MMD_VEND2,
+ RTL822X_VND2_LCR6,
+ RTL822X_VND2_LED_ACT(index));
+}
This clears HW triggers but never actually turns the LED on when
value != LED_OFF. Both paths do the same thing: clear link and
activity config (value isn't used at all).
For LED_OFF that works (no triggers = LED off), but for LED_ON the
LED stays off too since there's no force-on written anywhere.
Compare with bcm_phy_led_brightness_set() which explicitly switches
between BCM_LED_SRC_ON and BCM_LED_SRC_OFF based on value.
If the RTL8221B has a software force-on register, it needs to be
programmed here. If it doesn't, brightness_set should not be
implemented at all. The framework handles its absence.
[...]
Thanks
Nicolai