realtek: rtl931x: Add support for active-low LEDs
authorSven Eckelmann <[email protected]>
Tue, 15 Jul 2025 17:53:07 +0000 (19:53 +0200)
committerHauke Mehrtens <[email protected]>
Mon, 6 Oct 2025 22:13:43 +0000 (00:13 +0200)
RTL930x received support for specifying active low/high LEDs in commit
bec9e79a99ad ("realtek: dsa: support active-high LEDs"). But this was
completely forgotten on RTL931x.

Signed-off-by: Sven Eckelmann <[email protected]>
Link: https://github.com/openwrt/openwrt/pull/20300
Signed-off-by: Hauke Mehrtens <[email protected]>
target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl838x.h
target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl931x.c

index 01f83d727156a45bb64a5545a35b8099fd2f9d51..66b761fdd51dbdc8e37e77adbb4771d91594ebe5 100644 (file)
@@ -582,6 +582,8 @@ typedef enum {
 #define RTL931X_LED_PORT_FIB_MASK_CTRL         (0x065c)
 #define RTL931X_LED_PORT_COMBO_MASK_CTRL       (0x0664)
 
+#define RTL931X_LED_GLB_ACTIVE_LOW BIT(21)
+
 #define MAX_VLANS 4096
 #define MAX_LAGS 16
 #define MAX_PRIOS 8
index 98c74cabf868bbde464f854bc4f53536653c1286..8ac9bcc17793d5190fc287cc309f5ee5fb475960 100644 (file)
@@ -1538,6 +1538,11 @@ static void rtldsa_931x_led_init(struct rtl838x_switch_priv *priv)
        /* Set LED mode to serial (0x1) */
        sw_w32_mask(0x3, 0x1, RTL931X_LED_GLB_CTRL);
 
+       if (of_property_read_bool(node, "active-low"))
+               sw_w32_mask(RTL931X_LED_GLB_ACTIVE_LOW, 0, RTL931X_LED_GLB_CTRL);
+       else
+               sw_w32_mask(0, RTL931X_LED_GLB_ACTIVE_LOW, RTL931X_LED_GLB_CTRL);
+
        rtl839x_set_port_reg_le(pm_copper, RTL931X_LED_PORT_COPR_MASK_CTRL);
        rtl839x_set_port_reg_le(pm_fiber, RTL931X_LED_PORT_FIB_MASK_CTRL);
        rtl839x_set_port_reg_le(pm_copper | pm_fiber, RTL931X_LED_PORT_COMBO_MASK_CTRL);