[PATCH v2 0/5] Rust LED Driver Abstractions and Lenovo SE10 Driver with DMI and I/O Port Support

From: Fiona Behrens
Date: Mon Jan 13 2025 - 07:24:29 EST


This patch series introduces Rust LED abstractions and provides a driver for the Lenovo ThinkEdge SE10 using those abstractions.

1. DMI Abstraction:
- Introduced Rust macros and types for DMI-based system matching, providing functionality similar to the `MODULE_DEVICE_TABLE(dmi, x)` macro in C. This abstraction allows system-specific matching using DMI fields.

2. LED Abstractions:
- Introduced a generic LED abstraction that supports on/off control, brightness levels, and hardware blinking.
- The abstraction is implemented using a vtable, with a struct that holds the generic driver data and is pinned for direct LED registration.

3. I/O Port Abstractions:
- Added abstractions for hardware I/O port memory access, enabling the driver to interact with hardware ports.

4. LED Driver for Lenovo ThinkEdge SE10:
- A driver is implemented for the red LED on the front panel of the Lenovo ThinkEdge SE10, utilizing the previously introduced LED abstractions, I/O port abstractions, and DMI matching.
- The driver supports on/off control and a WWAN hardware trigger.

Additionally, the LED abstraction has been prepared to support multicolor LEDs in the future. While this functionality is planned, it has not yet been implemented, as I do not have a consumer for it at this time.

Would it make sense to add the Rust DMI abstractions to the existing DMI/SMBIOS SUPPORT entry in the MAINTAINERS file?

This series depends on `rust: time: Introduce Delta type` by FUJITA Tomonori[1].

I send this previously without the SE10 driver as an RFC[2], and now have a driver to consume the APIs.

[1]: https://lore.kernel.org/rust-for-linux/20241220061853.2782878-3-fujita.tomonori@xxxxxxxxx/
[2]: https://lore.kernel.org/rust-for-linux/20241009105759.579579-1-me@xxxxxxxxxx/

Fiona Behrens (5):
rust: dmi: Add abstractions for DMI
rust: leds: Add Rust bindings for LED subsystem
rust: leds: Add hardware trigger support for hardware-controlled LEDs
rust: add I/O port abstractions with resource management
leds: leds_lenovo_se10: LED driver for Lenovo SE10 platform

MAINTAINERS | 2 +
drivers/leds/Kconfig | 10 +
drivers/leds/Makefile | 1 +
drivers/leds/leds_lenovo_se10.rs | 132 ++++++++
rust/bindings/bindings_helper.h | 1 +
rust/helpers/helpers.c | 1 +
rust/helpers/ioport.c | 42 +++
rust/kernel/dmi.rs | 533 +++++++++++++++++++++++++++++++
rust/kernel/ioport.rs | 169 ++++++++++
rust/kernel/leds.rs | 416 ++++++++++++++++++++++++
rust/kernel/leds/triggers.rs | 128 ++++++++
rust/kernel/lib.rs | 6 +
rust/kernel/time.rs | 7 +
13 files changed, 1448 insertions(+)
create mode 100644 drivers/leds/leds_lenovo_se10.rs
create mode 100644 rust/helpers/ioport.c
create mode 100644 rust/kernel/dmi.rs
create mode 100644 rust/kernel/ioport.rs
create mode 100644 rust/kernel/leds.rs
create mode 100644 rust/kernel/leds/triggers.rs

--
2.47.0