[PATCH v3 0/2] leds: Add support for CZ.NIC Turris 1.x LEDs
From: Josef Schlehofer
Date: Mon Sep 28 2026 - 07:19:23 EST
The CZ.NIC Turris 1.x routers have eight RGB LEDs on the front panel,
driven by the CZ.NIC CPLD firmware. arch/powerpc/boot/dts/turris1x.dts
already describes the LED controller, but there is no driver for it, so
Linux cannot control these LEDs.
Pali posted v1 and v2 in July 2022 [1][2] and a RESEND in December 2022
[3]. The RESEND did not address the review of v2, and Krzysztof NAKed
the binding [4] and objected to the driver [5] for that reason. Lee
asked Pavel whether he was happy with the user-space interface [6] and
later reviewed the driver [7]. Pali answered part of that review [8],
but no new version followed.
I am picking the series up. Most of the driver was reworked for v3;
authorship stays with Pali as the original author. The changelog of
each patch lists the changes and, for the review points that did not
lead to a change, the reason.
On the user-space interface: the global brightness follows the Turris
Omnia driver, which already has /sys/class/leds/<led>/device/brightness
[9]. The Turris 1.x uses the same attribute, documented in the same ABI
entry. Marek asked in the v1 review for the index of the selected level
[10], which is brightness_level, and Lee asked for one value per file
instead of the eight values in one brightness_values file [7], which
are now brightness_levels/<N>.
Marek, patch 2/2 extends the brightness entry in
Documentation/ABI/testing/sysfs-class-led-driver-turris-omnia and adds
that file to the new MAINTAINERS entry. Could you ack that part?
The series is based on leds/for-leds-next (05b4738b0078). The driver
implements hw_offloaded() for its private trigger and sets
hw_control_trigger, as the hardware control changes there require, so
it does not build on mainline yet.
Testing on a Turris 1.1:
- With OpenWrt's 6.18.44 kernel, the driver as it was before that
adaptation, built as a module: colour and brightness, the brightness
level attributes including invalid writes, the timer trigger, the
turris1x-cpld hardware trigger, unbind and bind, and rmmod while
triggers ran and a level file was held open, also watched at the
panel. After a reboot, the CPLD registers read at the U-Boot prompt
still had the WiFi LED's disable bit that the shutdown handler sets,
and after sysrq-b, which skips the shutdown, the bit was clear. With
linux,default-trigger set in the device tree, the driver took those
LEDs over from the CPLD, and the turris1x-cpld trigger gave them back.
- With a kernel built from leds/for-leds-next and this series, the
driver built in: the LEDs except the WiFi LED start under the
turris1x-cpld trigger, which trigger_may_offload_to_hw reports as
offloaded and under which reading brightness returns ENODATA. Writing
a brightness drops the trigger, writing multi_intensity keeps it, the
timer trigger works, and unbind and bind give the LEDs back to the
CPLD. The WiFi LED has no trigger_may_offload_to_hw. The panel showed
the same.
The lines were rewrapped at 100 columns after these runs, which changes
no object code (objdump -dr). Neither kernel had lock debugging.
dt_binding_check with dtschema 2026.9 is clean and rejects a bogus
property added to the example, dtbs_check reports no warning for the LED
controller in turris1x.dtb, and tools/docs/get_abi.py reports no new
warning. checkpatch --strict reports only the MAINTAINERS question on
1/2, answered in its changelog, and a macro argument reuse check on 2/2,
where the argument is always a literal. Built with W=1 and sparse on
leds/for-leds-next (05b4738b0078) for powerpc, as a module and built in
(vmlinux links), and with COMPILE_TEST for x86_64 and arm64 as a module.
[1] https://lore.kernel.org/r/20220705000448.14337-1-pali@xxxxxxxxxx/
[2] https://lore.kernel.org/r/20220705155929.25565-1-pali@xxxxxxxxxx/
[3] https://lore.kernel.org/r/20221226123630.6515-1-pali@xxxxxxxxxx/
[4] https://lore.kernel.org/r/8b829332-5cd7-2910-88db-513716e0919a@xxxxxxxxxx/
[5] https://lore.kernel.org/r/d8172c80-a3a0-07f6-97ea-9130c49fab18@xxxxxxxxxx/
[6] https://lore.kernel.org/r/Y9Ozg2O41a2iijMc@xxxxxxxxxx/
[7] https://lore.kernel.org/r/Y/iDVlodp9sBkX9D@xxxxxxxxxx/
[8] https://lore.kernel.org/r/20230309203526.5hcfa2w47vqzmny6@pali/
[9] https://lore.kernel.org/r/20230202234653.ukwpjntws3roacty@pali/
[10] https://lore.kernel.org/r/20220705143001.7371a256@thinkpad/
Pali Rohár (2):
dt-bindings: leds: Add CZ.NIC Turris 1.x LED controller
leds: Add support for Turris 1.x LEDs
.../sysfs-class-led-driver-turris-omnia | 13 +-
.../testing/sysfs-class-led-driver-turris1x | 23 +
.../bindings/leds/cznic,turris1x-leds.yaml | 132 ++++
MAINTAINERS | 10 +
drivers/leds/Kconfig | 13 +
drivers/leds/Makefile | 1 +
drivers/leds/leds-turris-1x.c | 609 ++++++++++++++++++
7 files changed, 798 insertions(+), 3 deletions(-)
create mode 100644 Documentation/ABI/testing/sysfs-class-led-driver-turris1x
create mode 100644 Documentation/devicetree/bindings/leds/cznic,turris1x-leds.yaml
create mode 100644 drivers/leds/leds-turris-1x.c
base-commit: 05b4738b0078f7d6f154f68068a11c8a0635e9df
--
2.54.0 (Apple Git-157)