Thread (11 messages) 11 messages, 3 authors, 14d ago

RE: [PATCH net-next 3/3] net: phy: realtek: add LED support for RTL8261C/D

flat view

From: Javen <hidden>
Date: 2026-09-28 07:24:28
Also in: linux-devicetree, lkml

quoted hunk ↗ jump to hunk
The RTL8261C/D use the same LED register block as the RTL8221B: one control
register per LED at VEND2 0xd032 + 2 * index selecting the link speeds that light
it, activity blink bits in LCR6 and per-LED polarity and enable bits in LCR7.
Compared to the RTL8221B there are four LEDs instead of three, and two more
speed bits for 5G and 10G.

Reuse the existing RTL822X_VND2_* definitions and add the two speed bits
and the enable bit. The callbacks follow rtl822xb_led_*() closely, with two
additions:

- led_polarity_set() honours active-low LEDs. The polarity bit in LCR7
  doubles as the manual on/off level in led_brightness_set(), so the
  configured polarity is cached in the private data and restored by
  led_hw_control_set().

- led_hw_control_set() and led_brightness_set() set the output enable
  bit, which firmware normally leaves set already.

The callbacks duplicate most of rtl822xb_led_*(), differing only in the LED
count, the speed mask and the LCR7 handling. Making the RTL8221B code
table-driven and sharing it would be the right end state, but that touches a
working driver and wants testing on an RTL8221B, so it is left for a follow-up
series.

The callbacks are wired to the RTL8261C_CG and RTL8261CE_CG entries, which
between them cover the parts this was tested on. RTL8261D_VM is left out for
lack of hardware.

Tested on a Gemtek W1700K (Airoha AN7581) with an RTL8261CE: index 2
drives a yellow and index 3 a green LED on each 10G port. Under hardware
control the link speed bits, the activity blink and the combined
TRIGGER_NETDEV_LINK all take effect and offloading is confirmed through the
netdev trigger. The polarity bit was verified to be active-high when clear on that
board. Also tested on AN7581 and MT7988A boards with an RTL8261C and
RTL8261D.

Signed-off-by: Chad Monroe <redacted>
Co-developed-by: Simon Polack <redacted>
Signed-off-by: Simon Polack <redacted>
Assisted-by: LLM
---
drivers/net/phy/realtek/realtek_main.c | 228
+++++++++++++++++++++++++
1 file changed, 228 insertions(+)
diff --git a/drivers/net/phy/realtek/realtek_main.c
b/drivers/net/phy/realtek/realtek_main.c
index 04d397f0a2d8..b1f020aa7760 100644
--- a/drivers/net/phy/realtek/realtek_main.c
+++ b/drivers/net/phy/realtek/realtek_main.c
@@ -183,12 +183,15 @@
#define RTL822X_VND2_LCR_LINK_100              BIT(1)
#define RTL822X_VND2_LCR_LINK_1000             BIT(2)
#define RTL822X_VND2_LCR_LINK_2500             BIT(5)
+#define RTL822X_VND2_LCR_LINK_5000             BIT(6)
+#define RTL822X_VND2_LCR_LINK_10000            BIT(4)

#define RTL822X_VND2_LCR6                      0xd040
#define RTL822X_VND2_LED_ACT(x)                        BIT(x)

#define RTL822X_VND2_LCR7                      0xd044
#define RTL822X_VND2_LED_POLAR(x)              BIT(x)
+#define RTL822X_VND2_LED_EN(x)                 BIT((x) + 4)

#define RTL8224_MII_RTCT                       0x11
#define RTL8224_MII_RTCT_ENABLE                        BIT(0)
@@ -305,6 +308,7 @@
#define FW_SUB_MAGIC_8261D             0x32363144
#define RTL8261X_POLL_TIMEOUT_MS       100
#define RTL8261X_MAX_MMD_DEV           31
+#define RTL8261X_LED_COUNT             4
Hi,

We kindly suggest dropping this patch for the same reason as in Patch 2/3.

LED config is related to HW config and will be configured via firmware.

BRs,
Javen
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help