From 2fffb27c987d7c5af546c0171f7668a7351b61d6 Mon Sep 17 00:00:00 2001 From: Sander Vanheule Date: Thu, 19 Feb 2026 21:17:07 +0100 Subject: [PATCH] realtek: disable synchronous operation on RTL8231 It may be possible that the bootloader has left an RTL8231 expander configured for synchronous operation, which requires the user to signal that the new GPIO/LED states should be latched. As drivers typically perform one operation at a time for the higher level kernel framework, this would require a latch on every update, which is not very useful. Disable synchronous operation to keeps things simple. Signed-off-by: Sander Vanheule --- .../patches-6.12/802-mfd-Add-RTL8231-core-device.patch | 4 +++- ...-pinctrl-Add-RTL8231-pin-control-and-GPIO-support.patch | 7 ++++++- .../804-leds-Add-support-for-RTL8231-LED-scan-matrix.patch | 7 ++++++- .../patches-6.18/802-mfd-Add-RTL8231-core-device.patch | 4 +++- ...-pinctrl-Add-RTL8231-pin-control-and-GPIO-support.patch | 7 ++++++- .../804-leds-Add-support-for-RTL8231-LED-scan-matrix.patch | 7 ++++++- 6 files changed, 30 insertions(+), 6 deletions(-) diff --git a/target/linux/realtek/patches-6.12/802-mfd-Add-RTL8231-core-device.patch b/target/linux/realtek/patches-6.12/802-mfd-Add-RTL8231-core-device.patch index 2a6be8e456..95902ec5f8 100644 --- a/target/linux/realtek/patches-6.12/802-mfd-Add-RTL8231-core-device.patch +++ b/target/linux/realtek/patches-6.12/802-mfd-Add-RTL8231-core-device.patch @@ -256,7 +256,7 @@ Signed-off-by: Sander Vanheule +MODULE_LICENSE("GPL"); --- /dev/null +++ b/include/linux/mfd/rtl8231.h -@@ -0,0 +1,71 @@ +@@ -0,0 +1,73 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Register definitions the RTL8231 GPIO and LED expander chip @@ -280,6 +280,8 @@ Signed-off-by: Sander Vanheule +#define RTL8231_FUNC0_SCAN_MODE BIT(0) +#define RTL8231_FUNC0_SCAN_SINGLE 0 +#define RTL8231_FUNC0_SCAN_BICOLOR BIT(0) ++#define RTL8231_ENABLE_SYNC_LED BIT(14) ++#define RTL8231_ENABLE_SYNC_GPIO BIT(15) + +#define RTL8231_REG_FUNC1 0x01 +#define RTL8231_FUNC1_READY_CODE_VALUE 0x37 diff --git a/target/linux/realtek/patches-6.12/803-pinctrl-Add-RTL8231-pin-control-and-GPIO-support.patch b/target/linux/realtek/patches-6.12/803-pinctrl-Add-RTL8231-pin-control-and-GPIO-support.patch index 1b88dcd55c..c2fcadea0e 100644 --- a/target/linux/realtek/patches-6.12/803-pinctrl-Add-RTL8231-pin-control-and-GPIO-support.patch +++ b/target/linux/realtek/patches-6.12/803-pinctrl-Add-RTL8231-pin-control-and-GPIO-support.patch @@ -53,7 +53,7 @@ Signed-off-by: Sander Vanheule obj-$(CONFIG_PINCTRL_ST) += pinctrl-st.o --- /dev/null +++ b/drivers/pinctrl/pinctrl-rtl8231.c -@@ -0,0 +1,525 @@ +@@ -0,0 +1,530 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include @@ -432,6 +432,11 @@ Signed-off-by: Sander Vanheule + unsigned int dir; + int err; + ++ /* Enable immediate GPIO changes, otherwise we need to latch updates */ ++ err = regmap_update_bits(map, RTL8231_REG_FUNC0, RTL8231_ENABLE_SYNC_GPIO, 0); ++ if (err) ++ return err; ++ + for (unsigned int i = 0; i < ARRAY_SIZE(pin_fields); i++) { + field_data = devm_regmap_field_alloc(dev, map, pin_fields[i].gpio_data); + if (IS_ERR(field_data)) diff --git a/target/linux/realtek/patches-6.12/804-leds-Add-support-for-RTL8231-LED-scan-matrix.patch b/target/linux/realtek/patches-6.12/804-leds-Add-support-for-RTL8231-LED-scan-matrix.patch index 04eb36ddf7..c6527d04b1 100644 --- a/target/linux/realtek/patches-6.12/804-leds-Add-support-for-RTL8231-LED-scan-matrix.patch +++ b/target/linux/realtek/patches-6.12/804-leds-Add-support-for-RTL8231-LED-scan-matrix.patch @@ -50,7 +50,7 @@ Signed-off-by: Sander Vanheule obj-$(CONFIG_LEDS_SUN50I_A100) += leds-sun50i-a100.o --- /dev/null +++ b/drivers/leds/leds-rtl8231.c -@@ -0,0 +1,285 @@ +@@ -0,0 +1,290 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include @@ -309,6 +309,11 @@ Signed-off-by: Sander Vanheule + return -EINVAL; + } + ++ /* Enable immediate LED changes, otherwise we need to latch updates */ ++ err = regmap_update_bits(map, RTL8231_REG_FUNC0, RTL8231_ENABLE_SYNC_LED, 0); ++ if (err) ++ return err; ++ + fwnode_for_each_available_child_node(dev->fwnode, child) { + err = rtl8231_led_probe_single(dev, map, port_counts, child); + if (err) diff --git a/target/linux/realtek/patches-6.18/802-mfd-Add-RTL8231-core-device.patch b/target/linux/realtek/patches-6.18/802-mfd-Add-RTL8231-core-device.patch index b8e209024c..14e2bb8fd6 100644 --- a/target/linux/realtek/patches-6.18/802-mfd-Add-RTL8231-core-device.patch +++ b/target/linux/realtek/patches-6.18/802-mfd-Add-RTL8231-core-device.patch @@ -256,7 +256,7 @@ Signed-off-by: Sander Vanheule +MODULE_LICENSE("GPL"); --- /dev/null +++ b/include/linux/mfd/rtl8231.h -@@ -0,0 +1,71 @@ +@@ -0,0 +1,73 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Register definitions the RTL8231 GPIO and LED expander chip @@ -280,6 +280,8 @@ Signed-off-by: Sander Vanheule +#define RTL8231_FUNC0_SCAN_MODE BIT(0) +#define RTL8231_FUNC0_SCAN_SINGLE 0 +#define RTL8231_FUNC0_SCAN_BICOLOR BIT(0) ++#define RTL8231_ENABLE_SYNC_LED BIT(14) ++#define RTL8231_ENABLE_SYNC_GPIO BIT(15) + +#define RTL8231_REG_FUNC1 0x01 +#define RTL8231_FUNC1_READY_CODE_VALUE 0x37 diff --git a/target/linux/realtek/patches-6.18/803-pinctrl-Add-RTL8231-pin-control-and-GPIO-support.patch b/target/linux/realtek/patches-6.18/803-pinctrl-Add-RTL8231-pin-control-and-GPIO-support.patch index b33c0e4646..2133bf6ac1 100644 --- a/target/linux/realtek/patches-6.18/803-pinctrl-Add-RTL8231-pin-control-and-GPIO-support.patch +++ b/target/linux/realtek/patches-6.18/803-pinctrl-Add-RTL8231-pin-control-and-GPIO-support.patch @@ -53,7 +53,7 @@ Signed-off-by: Sander Vanheule obj-$(CONFIG_PINCTRL_ST) += pinctrl-st.o --- /dev/null +++ b/drivers/pinctrl/pinctrl-rtl8231.c -@@ -0,0 +1,525 @@ +@@ -0,0 +1,530 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include @@ -432,6 +432,11 @@ Signed-off-by: Sander Vanheule + unsigned int dir; + int err; + ++ /* Enable immediate GPIO changes, otherwise we need to latch updates */ ++ err = regmap_update_bits(map, RTL8231_REG_FUNC0, RTL8231_ENABLE_SYNC_GPIO, 0); ++ if (err) ++ return err; ++ + for (unsigned int i = 0; i < ARRAY_SIZE(pin_fields); i++) { + field_data = devm_regmap_field_alloc(dev, map, pin_fields[i].gpio_data); + if (IS_ERR(field_data)) diff --git a/target/linux/realtek/patches-6.18/804-leds-Add-support-for-RTL8231-LED-scan-matrix.patch b/target/linux/realtek/patches-6.18/804-leds-Add-support-for-RTL8231-LED-scan-matrix.patch index fe3c935387..946b64942e 100644 --- a/target/linux/realtek/patches-6.18/804-leds-Add-support-for-RTL8231-LED-scan-matrix.patch +++ b/target/linux/realtek/patches-6.18/804-leds-Add-support-for-RTL8231-LED-scan-matrix.patch @@ -50,7 +50,7 @@ Signed-off-by: Sander Vanheule obj-$(CONFIG_LEDS_SUN50I_A100) += leds-sun50i-a100.o --- /dev/null +++ b/drivers/leds/leds-rtl8231.c -@@ -0,0 +1,285 @@ +@@ -0,0 +1,290 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include @@ -309,6 +309,11 @@ Signed-off-by: Sander Vanheule + return -EINVAL; + } + ++ /* Enable immediate LED changes, otherwise we need to latch updates */ ++ err = regmap_update_bits(map, RTL8231_REG_FUNC0, RTL8231_ENABLE_SYNC_LED, 0); ++ if (err) ++ return err; ++ + fwnode_for_each_available_child_node(dev->fwnode, child) { + err = rtl8231_led_probe_single(dev, map, port_counts, child); + if (err)