realtek: rtl931x: Add support for active-low LEDs

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 <se@simonwunderlich.de>
Link: https://github.com/openwrt/openwrt/pull/20300
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
This commit is contained in:
Sven Eckelmann 2025-07-15 19:53:07 +02:00 committed by Hauke Mehrtens
parent 546722f95e
commit 38d35f413d
2 changed files with 7 additions and 0 deletions

View 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

View 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);