From ea5a749311a5c1a5dce85915e0039b1db93f703e Mon Sep 17 00:00:00 2001 From: Sven Eckelmann Date: Wed, 20 Aug 2025 05:19:31 +0200 Subject: [PATCH] realtek: rtl931x: Add LED Sync configuration The pinmux-related registers on the RTL931X SoC family are spread across various non-consecutive registers. It might be tempting to modify them directly in a specific driver (SPI, LED, etc.), but this would cause issues with parallel, non-locked read-modify-write operations, which are required to update individual portions of these registers. Instead, it is better to use the devicetree pinctrl properties to define the correct configurations for the various operation modes. One important setting here is the LED Sync bit. This allows the LED controller to generate an additional positive edge on the `STCP` ("STore Clock Pin", also known as `RCLK`) of the LED shift register after the actual content has already been shifted in using the normal shift clock. The LED shift register is then expected to copy the content from the shift register section into the storage registers, which act as the actual LED output control. This functionality is available in, and commonly used with, the SNx4HC595 family of shift registers. To activate it, simply register it in the default state of the "realtek,rtl83xx-switch" node: &switch0 { pinctrl-names = "default"; pinctrl-0 = <&pinmux_enable_led_sync>; .... }; It would be nicer when this can be directly added to the led subnode. But for this to work, `realtek,rtl9300-leds` must first be an actual driver (known to the driver core). [1] https://www.ti.com/lit/ds/symlink/sn74hc595.pdf Suggested-by: Bevan Weiss Signed-off-by: Sven Eckelmann Link: https://github.com/openwrt/openwrt/pull/19815 Signed-off-by: Robert Marko --- target/linux/realtek/dts/rtl931x.dtsi | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/target/linux/realtek/dts/rtl931x.dtsi b/target/linux/realtek/dts/rtl931x.dtsi index 54a304019c..462c3ea9b0 100644 --- a/target/linux/realtek/dts/rtl931x.dtsi +++ b/target/linux/realtek/dts/rtl931x.dtsi @@ -231,6 +231,15 @@ pinctrl-single,function-mask = <0x1>; #pinctrl-cells = <2>; + /* Enable GPIO 31 */ + pinmux_disable_led_sync: disable-led-sync { + pinctrl-single,bits = <0x0 0x0 0x10000>; + }; + + pinmux_enable_led_sync: enable-led-sync { + pinctrl-single,bits = <0x0 0x10000 0x10000>; + }; + /* Enable GPIO6 and GPIO7, possibly unknown others */ pinmux_disable_jtag: disable_jtag { pinctrl-single,bits = <0x0 0x0 0x8000>; -- 2.30.2