Skip to contentSkip to conversation

platform/x86: clevo-laptop: add initial Rust driver for keyboard backlight

PATCH In review Nick Dowsett 4 participants 12 messages Nov 22 – Nov 30

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover platform/x86: clevo-laptop: add initial Rust driver for keyboard backlight

This series adds a new Rust platform driver MVP (clevo-laptop) for Clevo barebones and rebranded laptops (Metabox, Tuxedo, Sager, XMG, etc.), starting with 5-step white keyboard backlight control.

It is intended as the first in-tree user of the Rust WMI abstractions, and a starting point to be extended to additional Clevo models and EC features.

What's included:
- Minimal driver skeleton, Kconfig/Makefile plumbing, and MAINTAINERS entry.
- Type-safe EC WMI query interface.
- Driver registration and backlight type detection following tuxedo-drivers business rules.

Dependencies (not yet merged):
- Markus Probst's Rust LED classdev abstractions (v28):
https://lore.kernel.org/all/[email protected]/
- Rust WMI abstractions (change-id: 20261119-rust-wmi-c6b0e0fe97a7)
https://lore.kernel.org/all/[email protected]/
- Rust DMI abstractions (change-id: 20261121-rust-dmi-c49d2041d7e2)
https://lore.kernel.org/all/[email protected]/

Tested on a Clevo/Metabox NL57AU laptop.

---
Nick Dowsett (4):
platform/x86: clevo-laptop: add minimal WMI driver skeleton and Kbuild plumbing platform/x86: clevo-laptop: add EC WMI query interface and BIOS feature check platform/x86: clevo-laptop: probe keyboard backlight type and detect 5-step white backlight platform/x86: clevo-laptop: register 5-step white keyboard backlight LED device

 MAINTAINERS                          |   6 +
 drivers/platform/x86/Kconfig         |  17 ++
 drivers/platform/x86/Makefile        |   3 +
 drivers/platform/x86/clevo-laptop.rs | 387 +++++++++++++++++++++++++++++++++++
 4 files changed, 413 insertions(+)

---
base-commit: 4843f6873f7c4835e62f2c73ba0fd538e57a2f22
change-id: 20261120-clevo-laptop-170d658cd678

Best regards,

Signature · 1 line
Nick Dowsett <[email protected]>
#1 lore raw

PATCH 1/4 platform/x86: clevo-laptop: add minimal WMI driver skeleton and Kbuild plumbing

- Add drivers/platform/x86/clevo-laptop.rs with module implementation, DMI board check, and Driver registration.
- Add Kconfig and MAINTAINERS entries and Makefile wiring.

---
 MAINTAINERS                          |  6 +++
 drivers/platform/x86/Kconfig         | 17 +++++++++
 drivers/platform/x86/Makefile        |  3 ++
 drivers/platform/x86/clevo-laptop.rs | 72 ++++++++++++++++++++++++++++++++++++
 4 files changed, 98 insertions(+)
MAINTAINERS +6 -0
index 44540a1eb2b8..1130c293e84d 100644
@@ -6566,6 +6566,12 @@ F:	scripts/Makefile.clang
 F:	scripts/clang-tools/
 K:	\b(?i:clang|llvm)\b
 
+CLEVO LAPTOP DRIVER
+M:	Nick Dowsett <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	drivers/platform/x86/clevo-laptop.rs
+
 CLK API
 M:	Russell King <[email protected]>
 L:	[email protected]
drivers/platform/x86/Kconfig +17 -0
index 9ce384e0475e..18aa4550c9f4 100644
@@ -1059,6 +1059,23 @@ config OXP_EC
 
 source "drivers/platform/x86/tuxedo/Kconfig"
 
+config CLEVO_LAPTOP
+	tristate "Clevo Laptop Platform Driver"
+	depends on RUST
+	depends on ACPI_WMI=y
+	depends on DMI
+	depends on LEDS_CLASS
+	help
+	  This driver provides platform support for Clevo barebones and
+	  rebranded laptops (Tuxedo, Metabox, Sager, XMG, etc.).
+	  Currently only Clevo NLx0AU boards (e.g. Metabox Edge NL57AU)
+	  with a 5-step white keyboard backlight are supported over WMI.
+	  It is intended to be extended with additional Clevo models and
+	  EC features over time.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called clevo-laptop.
+
 endif # X86_PLATFORM_DEVICES
 
 config P2SB
drivers/platform/x86/Makefile +3 -0
index 229057234d00..070af05a2064 100644
@@ -158,6 +158,9 @@ obj-$(CONFIG_SILICOM_PLATFORM)		+= silicom-platform.o
 # TUXEDO
 obj-y					+= tuxedo/
 
+# Clevo
+obj-$(CONFIG_CLEVO_LAPTOP)		+= clevo-laptop.o
+
 # Winmate
 obj-$(CONFIG_WINMATE_FM07_KEYS)		+= winmate-fm07-keys.o
 
drivers/platform/x86/clevo-laptop.rs new file +72 -0

72 lines not on this page · raw message

Signature · 1 line
2.56.1
#2 lore raw

Re: [PATCH 1/4] platform/x86: clevo-laptop: add minimal WMI driver skeleton and Kbuild plumbing

Am 22.11.26 um 05:35 schrieb Nick Dowsett via B4 Relay:

Quoted 46 lines

From: Nick Dowsett <[email protected]>

- Add drivers/platform/x86/clevo-laptop.rs with module implementation, DMI board check, and Driver registration.
- Add Kconfig and MAINTAINERS entries and Makefile wiring.

---
  MAINTAINERS                          |  6 +++
  drivers/platform/x86/Kconfig         | 17 +++++++++
  drivers/platform/x86/Makefile        |  3 ++
  drivers/platform/x86/clevo-laptop.rs | 72 ++++++++++++++++++++++++++++++++++++
  4 files changed, 98 insertions(+)
MAINTAINERS +6 -0
index 44540a1eb2b8..1130c293e84d 100644
@@ -6566,6 +6566,12 @@ F:	scripts/Makefile.clang
  F:	scripts/clang-tools/
  K:	\b(?i:clang|llvm)\b
 
+CLEVO LAPTOP DRIVER
+M:	Nick Dowsett <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	drivers/platform/x86/clevo-laptop.rs
+
  CLK API
  M:	Russell King <[email protected]>
  L:	[email protected]
drivers/platform/x86/Kconfig +7 -0
index 9ce384e0475e..18aa4550c9f4 100644
@@ -1059,6 +1059,23 @@ config OXP_EC
 
  source "drivers/platform/x86/tuxedo/Kconfig"
 
+config CLEVO_LAPTOP
+	tristate "Clevo Laptop Platform Driver"
+	depends on RUST
+	depends on ACPI_WMI=y
+	depends on DMI
+	depends on LEDS_CLASS
+	help

drivers/platform/x86/Kconfig config OXP_EC · line 1078

Quoted 10 lines
drivers/platform/x86/Kconfig +10 -0
+	  This driver provides platform support for Clevo barebones and
+	  rebranded laptops (Tuxedo, Metabox, Sager, XMG, etc.).
+	  Currently only Clevo NLx0AU boards (e.g. Metabox Edge NL57AU)
+	  with a 5-step white keyboard backlight are supported over WMI.
+	  It is intended to be extended with additional Clevo models and
+	  EC features over time.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called clevo-laptop.
+

TUXEDO is officially all caps.

Technically all clevo barebones are rebranded and it is sometimes more then just rebranding.

Maybe just drop everything behind the "and".

Quoted 60 lines
drivers/platform/x86/Kconfig +0 -0
  endif # X86_PLATFORM_DEVICES
 
  config P2SB
drivers/platform/x86/Makefile +3 -0
index 229057234d00..070af05a2064 100644
@@ -158,6 +158,9 @@ obj-$(CONFIG_SILICOM_PLATFORM)		+= silicom-platform.o
  # TUXEDO
  obj-y					+= tuxedo/
 
+# Clevo
+obj-$(CONFIG_CLEVO_LAPTOP)		+= clevo-laptop.o
+
  # Winmate
  obj-$(CONFIG_WINMATE_FM07_KEYS)		+= winmate-fm07-keys.o
 
drivers/platform/x86/clevo-laptop.rs new file +37 -0
new file mode 100644
index 000000000000..1d862c57b3fe
@@ -0,0 +1,72 @@
+// SPDX-License-Identifier: GPL-2.0
+
+//! Clevo Laptop Driver.
+//!
+//! Currently supports only the 5-step white keyboard backlight on Clevo
+//! NLx0AU boards (e.g., Metabox Edge NL57AU).
+//!
+//! Copyright (C) 2026 Nick Dowsett <[email protected]>.
+//!
+//! Inspired by Tuxedo Computers' drivers.
+
+use kernel::{
+    device,
+    dmi,
+    prelude::*,
+    wmi, //
+};
+
+/// # Note
+///
+/// This GUID is non-unique (shared by Uniwill for example) and cannot be trusted
+/// to uniquely identify a Clevo device.
+const CLEVO_WMI_METHOD_GUID: &CStr = c"ABBC0F6D-8EA1-11D1-00A0-C90629100000";
+/// DMI board name allowlist, restricted to tested boards since the WMI GUID is not
+/// unique.
+const SUPPORTED_BOARDS: &[&CStr] = &[c"NLx0AU"];
+
+module! {
+    type: ClevoLaptopModule,
+    name: "clevo-laptop",
+    authors: ["Nick Dowsett <[email protected]>"],
+    description: "Clevo Laptop Driver (Keyboard Backlight)",
+    license: "GPL",
+}
+
+/// RAII guard for Clevo Laptop Module holding all subsystem drivers e.g WMI.
+#[pin_data]

drivers/platform/x86/clevo-laptop.rs line 47

Quoted 10 lines
drivers/platform/x86/clevo-laptop.rs new file +10 -0
+struct ClevoLaptopModule {
+    #[pin]
+    _wmi_driver: wmi::Registration<WmiDriver>,
+}
+
+impl kernel::InPlaceModule for ClevoLaptopModule {
+    fn init(module: &'static ThisModule) -> impl PinInit<Self, Error> {
+        pin_init::pin_init_scope(move || {
+            if dmi::get_system_info(dmi::Field::BoardName)
+                .is_none_or(|board| !SUPPORTED_BOARDS.contains(&board))

We most likely need more complex matching here in the future.

Is dmi_system_id table matching available in rust for the linux kernel?

Quoted 26 lines
drivers/platform/x86/clevo-laptop.rs new file +25 -0
+            {
+                return Err(ENODEV);
+            }
+            Ok(try_pin_init!(Self {
+                _wmi_driver <- wmi::Registration::new(c"clevo-laptop", module),
+            }))
+        })
+    }
+}
+
+/// RAII guard for Clevo WMI driver holding all subsystem devices e.g LED device.
+#[pin_data]
+struct WmiDriver {}
+
+kernel::wmi_device_table!(WMI_TABLE, [wmi::DeviceId::new(CLEVO_WMI_METHOD_GUID)]);
+
+impl wmi::Driver for WmiDriver {
+    type Data<'bound> = WmiDriver;
+    const ID_TABLE: wmi::IdTable = &WMI_TABLE;
+    fn probe<'bound>(
+        _dev: &'bound wmi::Device<device::Core<'_>>,
+    ) -> impl PinInit<Self::Data<'bound>, Error> + 'bound {
+        try_pin_init!(WmiDriver {})
+    }
+}
#3 lore raw

Re: [PATCH 1/4] platform/x86: clevo-laptop: add minimal WMI driver skeleton and Kbuild plumbing

Quoted 28 lines · Werner Sembach
Quoted 15 lines
drivers/platform/x86/Kconfig +0 -0
index 9ce384e0475e..18aa4550c9f4 100644
@@ -1059,6 +1059,23 @@ config OXP_EC


  source "drivers/platform/x86/tuxedo/Kconfig"

drivers/platform/x86/Kconfig +7 -0
+config CLEVO_LAPTOP
+   tristate "Clevo Laptop Platform Driver"
+   depends on RUST
+   depends on ACPI_WMI=y
+   depends on DMI
+   depends on LEDS_CLASS
+   help

drivers/platform/x86/Kconfig config OXP_EC · line 1078

Quoted 10 lines
drivers/platform/x86/Kconfig +10 -0
+     This driver provides platform support for Clevo barebones and
+     rebranded laptops (Tuxedo, Metabox, Sager, XMG, etc.).
+     Currently only Clevo NLx0AU boards (e.g. Metabox Edge NL57AU)
+     with a 5-step white keyboard backlight are supported over WMI.
+     It is intended to be extended with additional Clevo models and
+     EC features over time.
+
+     To compile this driver as a module, choose M here: the module
+     will be called clevo-laptop.
+

TUXEDO is officially all caps.

Quoted 4 lines

Technically all clevo barebones are rebranded and it is sometimes more then just rebranding.

Maybe just drop everything behind the "and".

No concerns from my side, happy to amend this in v2. Please have a think also about how you would like code license attributed to TUXEDO.

Quoted 9 lines
Quoted 5 lines

+impl kernel::InPlaceModule for ClevoLaptopModule {
+    fn init(module: &'static ThisModule) -> impl PinInit<Self, Error> { +        pin_init::pin_init_scope(move || {
+            if dmi::get_system_info(dmi::Field::BoardName) +                .is_none_or(|board| !SUPPORTED_BOARDS.contains(&board))

We most likely need more complex matching here in the future.

Is dmi_system_id table matching available in rust for the linux kernel?

Not currently, but I believe this would be a relatively straightforward binding to write if needed, or it may even be idiomatic to write the complex matching directly in this driver since Rust makes iteration and string matching simpler. I'd consider this out-of-scope for the MVP unless you have some other tested boards with the same requirements as the NLx0AU.

Cheers Nick

maintainer
#4 lore raw

Re: [PATCH 1/4] platform/x86: clevo-laptop: add minimal WMI driver skeleton and Kbuild plumbing

In reply to Nick Dowsett
Quoted 4 lines · On Sun, 22 Nov 2026, Nick Dowsett via B4 Relay wrote:

From: Nick Dowsett <[email protected]>

- Add drivers/platform/x86/clevo-laptop.rs with module implementation, DMI board check, and Driver registration.

Mostly, don't use bullet lists to describe kernel changes. Only if there's a small part of the change that clearly is a list bullets may be warranted. LLMs in particular tend to overuse bullet lists for things that clearly aren't lists so don't fall into that trap.

And definitely do not to describe algoritms using bullets like you do in the subsequent patches.

Quoted 1 line

- Add Kconfig and MAINTAINERS entries and Makefile wiring.

You're expected to add Kconfig and MAINTAINERS so mentioning those seems useless detail for experienced kernel developers. We can see that you do from the diff so stating the same adds zero value.

--
i.

Quoted 147 lines
---
 MAINTAINERS                          |  6 +++
 drivers/platform/x86/Kconfig         | 17 +++++++++
 drivers/platform/x86/Makefile        |  3 ++
 drivers/platform/x86/clevo-laptop.rs | 72 ++++++++++++++++++++++++++++++++++++
 4 files changed, 98 insertions(+)
MAINTAINERS +6 -0
index 44540a1eb2b8..1130c293e84d 100644
@@ -6566,6 +6566,12 @@ F:	scripts/Makefile.clang
 F:	scripts/clang-tools/
 K:	\b(?i:clang|llvm)\b
 
+CLEVO LAPTOP DRIVER
+M:	Nick Dowsett <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	drivers/platform/x86/clevo-laptop.rs
+
 CLK API
 M:	Russell King <[email protected]>
 L:	[email protected]
drivers/platform/x86/Kconfig +17 -0
index 9ce384e0475e..18aa4550c9f4 100644
@@ -1059,6 +1059,23 @@ config OXP_EC
 
 source "drivers/platform/x86/tuxedo/Kconfig"
 
+config CLEVO_LAPTOP
+	tristate "Clevo Laptop Platform Driver"
+	depends on RUST
+	depends on ACPI_WMI=y
+	depends on DMI
+	depends on LEDS_CLASS
+	help
+	  This driver provides platform support for Clevo barebones and
+	  rebranded laptops (Tuxedo, Metabox, Sager, XMG, etc.).
+	  Currently only Clevo NLx0AU boards (e.g. Metabox Edge NL57AU)
+	  with a 5-step white keyboard backlight are supported over WMI.
+	  It is intended to be extended with additional Clevo models and
+	  EC features over time.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called clevo-laptop.
+
 endif # X86_PLATFORM_DEVICES
 
 config P2SB
drivers/platform/x86/Makefile +3 -0
index 229057234d00..070af05a2064 100644
@@ -158,6 +158,9 @@ obj-$(CONFIG_SILICOM_PLATFORM)		+= silicom-platform.o
 # TUXEDO
 obj-y					+= tuxedo/
 
+# Clevo
+obj-$(CONFIG_CLEVO_LAPTOP)		+= clevo-laptop.o
+
 # Winmate
 obj-$(CONFIG_WINMATE_FM07_KEYS)		+= winmate-fm07-keys.o
 
drivers/platform/x86/clevo-laptop.rs new file +72 -0
new file mode 100644
index 000000000000..1d862c57b3fe
@@ -0,0 +1,72 @@
+// SPDX-License-Identifier: GPL-2.0
+
+//! Clevo Laptop Driver.
+//!
+//! Currently supports only the 5-step white keyboard backlight on Clevo
+//! NLx0AU boards (e.g., Metabox Edge NL57AU).
+//!
+//! Copyright (C) 2026 Nick Dowsett <[email protected]>.
+//!
+//! Inspired by Tuxedo Computers' drivers.
+
+use kernel::{
+    device,
+    dmi,
+    prelude::*,
+    wmi, //
+};
+
+/// # Note
+///
+/// This GUID is non-unique (shared by Uniwill for example) and cannot be trusted
+/// to uniquely identify a Clevo device.
+const CLEVO_WMI_METHOD_GUID: &CStr = c"ABBC0F6D-8EA1-11D1-00A0-C90629100000";
+/// DMI board name allowlist, restricted to tested boards since the WMI GUID is not
+/// unique.
+const SUPPORTED_BOARDS: &[&CStr] = &[c"NLx0AU"];
+
+module! {
+    type: ClevoLaptopModule,
+    name: "clevo-laptop",
+    authors: ["Nick Dowsett <[email protected]>"],
+    description: "Clevo Laptop Driver (Keyboard Backlight)",
+    license: "GPL",
+}
+
+/// RAII guard for Clevo Laptop Module holding all subsystem drivers e.g WMI.
+#[pin_data]
+struct ClevoLaptopModule {
+    #[pin]
+    _wmi_driver: wmi::Registration<WmiDriver>,
+}
+
+impl kernel::InPlaceModule for ClevoLaptopModule {
+    fn init(module: &'static ThisModule) -> impl PinInit<Self, Error> {
+        pin_init::pin_init_scope(move || {
+            if dmi::get_system_info(dmi::Field::BoardName)
+                .is_none_or(|board| !SUPPORTED_BOARDS.contains(&board))
+            {
+                return Err(ENODEV);
+            }
+            Ok(try_pin_init!(Self {
+                _wmi_driver <- wmi::Registration::new(c"clevo-laptop", module),
+            }))
+        })
+    }
+}
+
+/// RAII guard for Clevo WMI driver holding all subsystem devices e.g LED device.
+#[pin_data]
+struct WmiDriver {}
+
+kernel::wmi_device_table!(WMI_TABLE, [wmi::DeviceId::new(CLEVO_WMI_METHOD_GUID)]);
+
+impl wmi::Driver for WmiDriver {
+    type Data<'bound> = WmiDriver;
+    const ID_TABLE: wmi::IdTable = &WMI_TABLE;
+    fn probe<'bound>(
+        _dev: &'bound wmi::Device<device::Core<'_>>,
+    ) -> impl PinInit<Self::Data<'bound>, Error> + 'bound {
+        try_pin_init!(WmiDriver {})
+    }
+}
#5 lore raw

Re: [PATCH 1/4] platform/x86: clevo-laptop: add minimal WMI driver skeleton and Kbuild plumbing

Quoted 12 lines · Ilpo Järvinen
Quoted 4 lines · On Sun, 22 Nov 2026, Nick Dowsett via B4 Relay wrote:

From: Nick Dowsett <[email protected]>

- Add drivers/platform/x86/clevo-laptop.rs with module implementation, DMI board check, and Driver registration.

Mostly, don't use bullet lists to describe kernel changes. Only if there's a small part of the change that clearly is a list bullets may be warranted. LLMs in particular tend to overuse bullet lists for things that clearly aren't lists so don't fall into that trap.

Quoted 8 lines

And definitely do not to describe algoritms using bullets like you do in the subsequent patches.

Quoted 1 line

- Add Kconfig and MAINTAINERS entries and Makefile wiring.

You're expected to add Kconfig and MAINTAINERS so mentioning those seems useless detail for experienced kernel developers. We can see that you do from the diff so stating the same adds zero value.

Hi Ilpo,

Thanks for the feedback, its much appreciated. I'll improve on these for v2, which I'm aiming to send in a couple of days to reflect a change to the Rust bindings.

Note on LLM use - I do use LLMs as a tool but I take all responsibility for any poor quality code or comments, and unlike an LLM, I will learn from my experiences :-).

Cheers Nick

#6 lore raw

PATCH 2/4 platform/x86: clevo-laptop: add EC WMI query interface and BIOS feature check

In reply to Nick Dowsett

- Add EcQuery trait and implement EcInterface for sending commands to the Clevo EC over WMI.
- Add GetBiosFeatures1 query to verify the EC responds during probe.

---
 drivers/platform/x86/clevo-laptop.rs | 104 ++++++++++++++++++++++++++++++++++-
 1 file changed, 102 insertions(+), 2 deletions(-)
drivers/platform/x86/clevo-laptop.rs +102 -2
index 1d862c57b3fe..289b30c478ec 100644
@@ -24,6 +24,8 @@
 /// DMI board name allowlist, restricted to tested boards since the WMI GUID is not
 /// unique.
 const SUPPORTED_BOARDS: &[&CStr] = &[c"NLx0AU"];
+const CLEVO_EC_CMD_GET_BIOS_FEATURES_1: u8 = 0x52;
+const CLEVO_EC_WMI_INSTANCE: u8 = 0;
 
 module! {
     type: ClevoLaptopModule,
@@ -33,6 +35,21 @@
     license: "GPL",
 }
 
+/// Represents a query that can run on the Clevo Embedded Controller (EC).
+///
+/// # Endianness note
+/// Clevo EC sends and receives little endian data.
+/// As this is a `platform/x86` driver, no conversion is required.
+trait EcQuery {
+    type Output;
+    /// EC method code.
+    fn cmd(&self) -> u8;
+    /// EC method args.
+    fn args(&self) -> EcMethodArgs;
+    /// Each command must know how to deserialize itself from the raw EC output.
+    fn deserialize_output(output: &[u8]) -> Result<Self::Output>;
+}
+
 /// RAII guard for Clevo Laptop Module holding all subsystem drivers e.g WMI.
 #[pin_data]
 struct ClevoLaptopModule {
@@ -65,8 +82,91 @@ impl wmi::Driver for WmiDriver {
     type Data<'bound> = WmiDriver;
     const ID_TABLE: wmi::IdTable = &WMI_TABLE;
     fn probe<'bound>(
-        _dev: &'bound wmi::Device<device::Core<'_>>,
+        dev: &'bound wmi::Device<device::Core<'_>>,
     ) -> impl PinInit<Self::Data<'bound>, Error> + 'bound {
-        try_pin_init!(WmiDriver {})
+        pin_init::pin_init_scope(move || {
+            let backend = EcInterface::Wmi(dev);
+
+            backend.query(GetBiosFeatures1).map_err(|_| ENODEV)?;
+
+            Ok(try_pin_init!(WmiDriver {}))
+        })
+    }
+}
+
+/// Interface to Clevo Embedded Controller.
+enum EcInterface<'a> {
+    Wmi(&'a wmi::Device<device::Bound>),
+}
+impl<'a> EcInterface<'a> {
+    /// Send a query to the EC, receiving a response.
+    fn query<Q>(&self, query: Q) -> Result<Q::Output>
+    where
+        Q: EcQuery + core::fmt::Debug,
+        Q::Output: core::fmt::Debug,
+    {
+        let cmd = query.cmd();
+        let arg = query.args();
+
+        match self {
+            Self::Wmi(wdev) => {
+                dev_dbg!(
+                    wdev.as_ref(),
+                    "ec cmd {query:?} method_id 0x{cmd:02x} arg {arg:x?}\n"
+                );
+                let buf = wdev.invoke_method(
+                    CLEVO_EC_WMI_INSTANCE,
+                    cmd.into(),
+                    arg.as_bytes(),
+                    core::mem::size_of::<Q::Output>(),
+                )?;
+
+                let res = Q::deserialize_output(&buf)?;
+                dev_dbg!(wdev.as_ref(), "ec cmd {query:?} -> {res:?}\n");
+                Ok(res)
+            }
+        }
     }
 }
+
+/// Args for a command sent to the EC.
+#[derive(Debug)]
+enum EcMethodArgs {
+    Scalar(u32),
+}
+impl EcMethodArgs {
+    /// Convert to the type expected by the EC.
+    fn as_bytes(&self) -> &[u8] {
+        match self {
+            // Clevo EC expects little-endian integers; x86 is always little-endian.
+            Self::Scalar(val) => val.as_bytes(),
+        }
+    }
+}
+
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+struct GetBiosFeatures1;
+
+impl EcQuery for GetBiosFeatures1 {
+    type Output = BiosFeatures1;
+    fn cmd(&self) -> u8 {
+        CLEVO_EC_CMD_GET_BIOS_FEATURES_1
+    }
+    fn args(&self) -> EcMethodArgs {
+        EcMethodArgs::Scalar(0)
+    }
+    fn deserialize_output(output: &[u8]) -> Result<Self::Output> {
+        let (feat, _) = BiosFeatures1::read_from_prefix(output).map_err(|_| ENODATA)?;
+        if feat == BiosFeatures1::INVALID {
+            return Err(ENODEV);
+        }
+        Ok(feat)
+    }
+}
+
+#[derive(Debug, Clone, Copy, PartialEq, Eq, FromBytes)]
+struct BiosFeatures1(u32);
+
+impl BiosFeatures1 {
+    const INVALID: Self = Self(0xFFFF_FFFF);
+}
Signature · 1 line
2.56.1
#7 lore raw

PATCH 3/4 platform/x86: clevo-laptop: probe keyboard backlight type and detect 5-step white backlight

In reply to Nick Dowsett

- Add GetSpecs and GetBiosFeatures2 EC queries and KbBacklightType detection (with retries and BIOS features fallback for older devices).
- Restrict probe to the supported 5-step white keyboard backlight.

---
 drivers/platform/x86/clevo-laptop.rs | 125 +++++++++++++++++++++++++++++++++++
 1 file changed, 125 insertions(+)
drivers/platform/x86/clevo-laptop.rs +125 -0
index 289b30c478ec..6f08bf295c07 100644
@@ -13,6 +13,10 @@
     device,
     dmi,
     prelude::*,
+    time::{
+        delay::fsleep,
+        Delta, //
+    },
     wmi, //
 };
 
@@ -24,7 +28,12 @@
 /// DMI board name allowlist, restricted to tested boards since the WMI GUID is not
 /// unique.
 const SUPPORTED_BOARDS: &[&CStr] = &[c"NLx0AU"];
+const CLEVO_EC_CMD_GET_SPECS: u8 = 0x0D;
 const CLEVO_EC_CMD_GET_BIOS_FEATURES_1: u8 = 0x52;
+const CLEVO_EC_CMD_GET_BIOS_FEATURES_2: u8 = 0x7A;
+const CLEVO_BIOS_FEATURE_CODE_WHITE_ONLY_KB: u32 = 0x4000_0000;
+const CLEVO_BIOS_FEATURE_CODE_3_ZONE_RGB_KB: u32 = 0x0040_0000;
+const CLEVO_BIOS_FEATURE_CODE_WHITE_ONLY_KB_MAX_5: u32 = 0x4000;
 const CLEVO_EC_WMI_INSTANCE: u8 = 0;
 
 module! {
@@ -89,6 +98,17 @@ fn probe<'bound>(
 
             backend.query(GetBiosFeatures1).map_err(|_| ENODEV)?;
 
+            // MVP: Only the NL57AU 5-step white backlight is supported.
+            if backend.detect_backlight_type()? != Some(KbBacklightType::FixedColor) {
+                return Err(ENODEV);
+            }
+            let has_white_5 = backend
+                .query(GetBiosFeatures2)
+                .is_ok_and(|feat2| feat2.has_white_only_kb_max_5());
+            if !has_white_5 {
+                return Err(ENODEV);
+            }
+
             Ok(try_pin_init!(WmiDriver {}))
         })
     }
@@ -127,6 +147,61 @@ fn query<Q>(&self, query: Q) -> Result<Q::Output>
             }
         }
     }
+    /// Detect backlight type e.g white.
+    fn detect_backlight_type(&self) -> Result<Option<KbBacklightType>> {
+        const MAX_RETRIES: usize = 3;
+        const RETRY_SLEEP_DURATION: Delta = Delta::from_millis(50);
+
+        for attempt in 0..MAX_RETRIES {
+            if attempt != 0 {
+                pr_debug!(
+                    "KbBacklightType::None probably wrong, retrying - attempt {} of {}\n",
+                    attempt,
+                    MAX_RETRIES - 1
+                );
+                fsleep(RETRY_SLEEP_DURATION);
+            }
+            if let Ok(specs) = self.query(GetSpecs) {
+                let backlight_type = specs.kb_backlight_type();
+                if backlight_type != Ok(None) {
+                    return backlight_type.map_err(|_| ENODEV);
+                }
+            }
+        }
+
+        // Check for devices <= Intel 8th gen (only white only, 3 zone RGB,
+        // or no backlight on these devices)
+        let feat1 = self.query(GetBiosFeatures1).map_err(|_| ENODEV)?;
+        if feat1.has_3_zone_rgb_kb() {
+            Ok(Some(KbBacklightType::ThreeZoneRgb))
+        } else if feat1.has_white_only_kb() {
+            Ok(Some(KbBacklightType::FixedColor))
+        } else {
+            Ok(None)
+        }
+    }
+}
+
+/// Keyboard backlight type - e.g Fixed Color
+#[derive(PartialEq)]
+#[repr(u8)]
+enum KbBacklightType {
+    FixedColor = 0x01,
+    ThreeZoneRgb = 0x02,
+    OneZoneRgb = 0x06,
+    PerKeyRgb = 0xF3,
+}
+impl KbBacklightType {
+    const fn from_raw(raw: u8) -> Result<Option<Self>, u8> {
+        match raw {
+            0x01 => Ok(Some(KbBacklightType::FixedColor)),
+            0x02 => Ok(Some(KbBacklightType::ThreeZoneRgb)),
+            0x06 => Ok(Some(KbBacklightType::OneZoneRgb)),
+            0xF3 => Ok(Some(KbBacklightType::PerKeyRgb)),
+            0x00 => Ok(None),
+            other => Err(other),
+        }
+    }
 }
 
 /// Args for a command sent to the EC.
@@ -144,8 +219,12 @@ fn as_bytes(&self) -> &[u8] {
     }
 }
 
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+struct GetSpecs;
 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
 struct GetBiosFeatures1;
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+struct GetBiosFeatures2;
 
 impl EcQuery for GetBiosFeatures1 {
     type Output = BiosFeatures1;
@@ -163,10 +242,56 @@ fn deserialize_output(output: &[u8]) -> Result<Self::Output> {
         Ok(feat)
     }
 }
+impl EcQuery for GetBiosFeatures2 {
+    type Output = BiosFeatures2;
+    fn cmd(&self) -> u8 {
+        CLEVO_EC_CMD_GET_BIOS_FEATURES_2
+    }
+    fn args(&self) -> EcMethodArgs {
+        EcMethodArgs::Scalar(0)
+    }
+    fn deserialize_output(output: &[u8]) -> Result<Self::Output> {
+        let (feat, _) = BiosFeatures2::read_from_prefix(output).map_err(|_| ENODATA)?;
+        Ok(feat)
+    }
+}
+impl EcQuery for GetSpecs {
+    type Output = Specs;
+    fn cmd(&self) -> u8 {
+        CLEVO_EC_CMD_GET_SPECS
+    }
+    fn args(&self) -> EcMethodArgs {
+        EcMethodArgs::Scalar(0)
+    }
+    fn deserialize_output(output: &[u8]) -> Result<Self::Output> {
+        let (specs, _) = Specs::read_from_prefix(output).map_err(|_| ENODATA)?;
+        Ok(specs)
+    }
+}
 
 #[derive(Debug, Clone, Copy, PartialEq, Eq, FromBytes)]
 struct BiosFeatures1(u32);
+#[derive(Debug, Clone, Copy, PartialEq, Eq, FromBytes)]
+struct BiosFeatures2(u32);
+#[derive(Debug, Clone, Copy, PartialEq, Eq, FromBytes)]
+struct Specs([u8; 16]);
 
 impl BiosFeatures1 {
     const INVALID: Self = Self(0xFFFF_FFFF);
+    const fn has_white_only_kb(self) -> bool {
+        (self.0 & CLEVO_BIOS_FEATURE_CODE_WHITE_ONLY_KB) != 0
+    }
+    const fn has_3_zone_rgb_kb(self) -> bool {
+        (self.0 & CLEVO_BIOS_FEATURE_CODE_3_ZONE_RGB_KB) != 0
+    }
+}
+impl BiosFeatures2 {
+    const fn has_white_only_kb_max_5(self) -> bool {
+        (self.0 & CLEVO_BIOS_FEATURE_CODE_WHITE_ONLY_KB_MAX_5) != 0
+    }
+}
+impl Specs {
+    const fn kb_backlight_type(&self) -> Result<Option<KbBacklightType>, u8> {
+        KbBacklightType::from_raw(self.0[0x0F])
+    }
 }
Signature · 1 line
2.56.1
#8 lore raw

PATCH 4/4 platform/x86: clevo-laptop: register 5-step white keyboard backlight LED device

In reply to Nick Dowsett

- Add SetWhiteBrightness EC command and Brightness wrapper.
- Implement LedOps (FixedColorLedOperations) and register a white:kbd_backlight LED class device during WMI probe.

---
 drivers/platform/x86/clevo-laptop.rs | 100 +++++++++++++++++++++++++++++++++--
 1 file changed, 95 insertions(+), 5 deletions(-)
drivers/platform/x86/clevo-laptop.rs +95 -5
index 6f08bf295c07..0a9cb96e7811 100644
@@ -10,8 +10,14 @@
 //! Inspired by Tuxedo Computers' drivers.
 
 use kernel::{
+    self,
     device,
     dmi,
+    led::{
+        self,
+        LedOps,
+        Normal, //
+    },
     prelude::*,
     time::{
         delay::fsleep,
@@ -31,6 +37,7 @@
 const CLEVO_EC_CMD_GET_SPECS: u8 = 0x0D;
 const CLEVO_EC_CMD_GET_BIOS_FEATURES_1: u8 = 0x52;
 const CLEVO_EC_CMD_GET_BIOS_FEATURES_2: u8 = 0x7A;
+const CLEVO_EC_CMD_SET_KB_WHITE_LEDS: u8 = 0x27;
 const CLEVO_BIOS_FEATURE_CODE_WHITE_ONLY_KB: u32 = 0x4000_0000;
 const CLEVO_BIOS_FEATURE_CODE_3_ZONE_RGB_KB: u32 = 0x0040_0000;
 const CLEVO_BIOS_FEATURE_CODE_WHITE_ONLY_KB_MAX_5: u32 = 0x4000;
@@ -63,7 +70,7 @@ trait EcQuery {
 #[pin_data]
 struct ClevoLaptopModule {
     #[pin]
-    _wmi_driver: wmi::Registration<WmiDriver>,
+    _wmi_driver: wmi::Registration<WmiDriver<'static>>,
 }
 
 impl kernel::InPlaceModule for ClevoLaptopModule {
@@ -83,12 +90,14 @@ fn init(module: &'static ThisModule) -> impl PinInit<Self, Error> {
 
 /// RAII guard for Clevo WMI driver holding all subsystem devices e.g LED device.
 #[pin_data]
-struct WmiDriver {}
+struct WmiDriver<'a> {
+    _led: LedRegistration<'a>,
+}
 
 kernel::wmi_device_table!(WMI_TABLE, [wmi::DeviceId::new(CLEVO_WMI_METHOD_GUID)]);
 
-impl wmi::Driver for WmiDriver {
-    type Data<'bound> = WmiDriver;
+impl wmi::Driver for WmiDriver<'_> {
+    type Data<'bound> = WmiDriver<'bound>;
     const ID_TABLE: wmi::IdTable = &WMI_TABLE;
     fn probe<'bound>(
         dev: &'bound wmi::Device<device::Core<'_>>,
@@ -109,11 +118,64 @@ fn probe<'bound>(
                 return Err(ENODEV);
             }
 
-            Ok(try_pin_init!(WmiDriver {}))
+            if let Err(e) = backend.query(SetWhiteBrightness(Brightness::OFF)) {
+                dev_dbg!(
+                    dev,
+                    "Error {e:?} setting keyboard brightness on initialization.\n"
+                );
+            }
+
+            let led_dev = KBox::pin_init(
+                led::DeviceBuilder::new()
+                    .name(c"white:kbd_backlight")
+                    .color(led::Color::White)
+                    .build(
+                        dev.as_ref(),
+                        try_pin_init!(FixedColorLedOperations { backend }),
+                    ),
+                GFP_KERNEL,
+            )?;
+
+            Ok(try_pin_init!(WmiDriver {
+                _led: LedRegistration::White5Step { _dev: led_dev },
+            }))
         })
     }
 }
 
+/// RAII guard for Clevo LED device holding the appropriate sysfs device for the backlight type.
+enum LedRegistration<'a> {
+    White5Step {
+        _dev: Pin<
+            KBox<led::Device<'a, FixedColorLedOperations<'a, { Brightness::MAX_WHITE_5.raw() }>>>,
+        >,
+    },
+}
+
+/// Represents how to perform LED operations for a Clevo single-color LED keyboard, generic over
+/// `MAX_BRIGHTNESS`.
+#[pin_data]
+struct FixedColorLedOperations<'a, const MAX_BRIGHTNESS: u8> {
+    backend: EcInterface<'a>,
+}
+#[vtable]
+impl<'a, const MAX_BRIGHTNESS: u8> LedOps for FixedColorLedOperations<'a, MAX_BRIGHTNESS> {
+    const BLOCKING: bool = true;
+    const MAX_BRIGHTNESS: u32 = MAX_BRIGHTNESS as u32;
+    type Mode = Normal;
+
+    fn brightness_set<'bound>(
+        self: &<Self::Mode as led::Mode>::Device<'bound, Self>,
+        brightness: u32,
+    ) -> Result<()> {
+        let clamped = u8::try_from(brightness)
+            .unwrap_or(MAX_BRIGHTNESS)
+            .min(MAX_BRIGHTNESS);
+        self.backend
+            .query(SetWhiteBrightness(Brightness::new(clamped)))
+    }
+}
+
 /// Interface to Clevo Embedded Controller.
 enum EcInterface<'a> {
     Wmi(&'a wmi::Device<device::Bound>),
@@ -182,6 +244,20 @@ fn detect_backlight_type(&self) -> Result<Option<KbBacklightType>> {
     }
 }
 
+/// Keyboard backlight brightness level.
+#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Copy, Clone)]
+struct Brightness(u8);
+impl Brightness {
+    const OFF: Self = Self(0);
+    const MAX_WHITE_5: Self = Self(5);
+    const fn new(val: u8) -> Self {
+        Self(val)
+    }
+    const fn raw(self) -> u8 {
+        self.0
+    }
+}
+
 /// Keyboard backlight type - e.g Fixed Color
 #[derive(PartialEq)]
 #[repr(u8)]
@@ -219,6 +295,8 @@ fn as_bytes(&self) -> &[u8] {
     }
 }
 
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+struct SetWhiteBrightness(Brightness);
 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
 struct GetSpecs;
 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
@@ -226,6 +304,18 @@ fn as_bytes(&self) -> &[u8] {
 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
 struct GetBiosFeatures2;
 
+impl EcQuery for SetWhiteBrightness {
+    type Output = ();
+    fn cmd(&self) -> u8 {
+        CLEVO_EC_CMD_SET_KB_WHITE_LEDS
+    }
+    fn args(&self) -> EcMethodArgs {
+        EcMethodArgs::Scalar(self.0.raw().into())
+    }
+    fn deserialize_output(_output: &[u8]) -> Result<Self::Output> {
+        Ok(())
+    }
+}
 impl EcQuery for GetBiosFeatures1 {
     type Output = BiosFeatures1;
     fn cmd(&self) -> u8 {
Signature · 1 line
2.56.1
#9 lore raw

Re: [PATCH 4/4] platform/x86: clevo-laptop: register 5-step white keyboard backlight LED device

kernel test robot noticed the following build errors:

Hi Nick,

kernel test robot noticed the following build errors:

[auto build test ERROR on 4843f6873f7c4835e62f2c73ba0fd538e57a2f22]

url:    https://github.com/intel-lab-lkp/linux/commits/Nick-Dowsett-via-B4-Relay/platform-x86-clevo-laptop-add-minimal-WMI-driver-skeleton-and-Kbuild-plumbing/20261122-123538
base:   4843f6873f7c4835e62f2c73ba0fd538e57a2f22
patch link:    https://lore.kernel.org/r/20261122-clevo-laptop-v1-4-881debf4d4b0%40gmail.com
patch subject: [PATCH 4/4] platform/x86: clevo-laptop: register 5-step white keyboard backlight LED device
config: x86_64-allyesconfig (https://download.01.org/0day-ci/archive/20261125/[email protected]/config)
compiler: clang version 22.1.8 (https://github.com/llvm/llvm-project ca7933e47d3a3451d81e72ac174dcb5aa28b59d1)
rustc: rustc 1.96.0 (ac68faa20 2026-05-25)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261125/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

>> error[E0223]: ambiguous associated type

--> drivers/platform/x86/clevo-laptop.rs:168:17
|
168 | self: &<Self::Mode as led::Mode>::Device<'bound, Self>,
| ^^^^^^^^^^
|
help: if there were a trait named Example with associated type Mode implemented for FixedColorLedOperations<'a, MAX_BRIGHTNESS>, you could use the fully-qualified path |
168 - self: &<Self::Mode as led::Mode>::Device<'bound, Self>,
168 + self: &<<FixedColorLedOperations<'a, MAX_BRIGHTNESS> as Example>::Mode as led::Mode>::Device<'bound, Self>,
|

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#10 lore raw
In reply to Nick Dowsett

Hi,

First: I never have touched rust code, but I'm not opposed to it in principle. Just to excuse a little bit of knowledge gap.

Am 22.11.26 um 05:35 schrieb Nick Dowsett via B4 Relay:

Quoted 3 lines

This series adds a new Rust platform driver MVP (clevo-laptop) for Clevo barebones and rebranded laptops (Metabox, Tuxedo, Sager, XMG, etc.), starting with 5-step white keyboard backlight control.

The driver will have to interact at least with these subsystems when finished (If I haven't forgotten any):

- Platform/ACPI
- WMI
- Power Supply/Battery
- LEDs
- Input
- HWMon

And maybe:

- Thermal
- HID
- Component

I don't know how much this influences the feasibility of doing it in rust.

Quoted 11 lines

It is intended as the first in-tree user of the Rust WMI abstractions, and a starting point to be extended to additional Clevo models and EC features.

What's included:
- Minimal driver skeleton, Kconfig/Makefile plumbing, and MAINTAINERS entry.
- Type-safe EC WMI query interface.
- Driver registration and backlight type detection following tuxedo-drivers business rules.

Just wanna make sure what you are referring to here exactly?

Best regards,

Werner

Quoted 33 lines

Dependencies (not yet merged):
- Markus Probst's Rust LED classdev abstractions (v28):

   https://lore.kernel.org/all/[email protected]/

- Rust WMI abstractions (change-id: 20261119-rust-wmi-c6b0e0fe97a7)
https://lore.kernel.org/all/[email protected]/
- Rust DMI abstractions (change-id: 20261121-rust-dmi-c49d2041d7e2)
https://lore.kernel.org/all/[email protected]/

Tested on a Clevo/Metabox NL57AU laptop.

---
Nick Dowsett (4):
platform/x86: clevo-laptop: add minimal WMI driver skeleton and Kbuild plumbing platform/x86: clevo-laptop: add EC WMI query interface and BIOS feature check platform/x86: clevo-laptop: probe keyboard backlight type and detect 5-step white backlight platform/x86: clevo-laptop: register 5-step white keyboard backlight LED device

  MAINTAINERS                          |   6 +
  drivers/platform/x86/Kconfig         |  17 ++
  drivers/platform/x86/Makefile        |   3 +
  drivers/platform/x86/clevo-laptop.rs | 387 +++++++++++++++++++++++++++++++++++
  4 files changed, 413 insertions(+)

---
base-commit: 4843f6873f7c4835e62f2c73ba0fd538e57a2f22
change-id: 20261120-clevo-laptop-170d658cd678

Best regards,
--
Nick Dowsett <[email protected]>

#11 lore raw

Hi Werner,

Thanks for the reply. I guess for some context for those that aren't aware, Werner/TUXEDO maintain an out-of-tree driver (tuxedo-drivers) that includes support for TUXEDO-branded Clevo drivers. This driver was influenced by their work, and I reached out to Werner briefly by email before submitting this series to the mailing list.

Quoted 20 lines · Werner Sembach

Hi,

First: I never have touched rust code, but I'm not opposed to it in principle. Just to excuse a little bit of knowledge gap.

Am 22.11.26 um 05:35 schrieb Nick Dowsett via B4 Relay:

Quoted 3 lines

This series adds a new Rust platform driver MVP (clevo-laptop) for Clevo barebones and rebranded laptops (Metabox, Tuxedo, Sager, XMG, etc.), starting with 5-step white keyboard backlight control.

The driver will have to interact at least with these subsystems when finished (If I haven't forgotten any):

- Platform/ACPI
- WMI
- Power Supply/Battery
- LEDs
- Input
- HWMon

Quoted 7 lines

And maybe:

- Thermal
- HID
- Component

I don't know how much this influences the feasibility of doing it in rust.

I understand this is referring to the feasibility of rewriting the entire tuxedo-drivers package in Rust. Perhaps someone more experienced on the RFL front could jump in here in terms of the feasibility of writing the mentioned bindings (from what I can see, workable patches exist already for LEDs and WMI), but I'll give my perspective:
- This is a beneficial effort regardless of full compatibility for now; even this MVP solves a real problem for users with this specific non-TUXEDO branded, Clevo laptop.
- Some modularity between C and Rust may still be able to exist, for example, perhaps the existing HID keyboard backlight drivers may be better to remain in C.
- In terms of feasibilty, whilst some waiting for bindings to reach full parity with tuxedo-drivers may be required, this is still more feasible for myself than writing and maintaining significant amounts of C.

Quoted 4 lines
Quoted 4 lines

It is intended as the first in-tree user of the Rust WMI abstractions, and a starting point to be extended to additional Clevo models and EC features.

Quoted 8 lines
Quoted 6 lines

What's included:
- Minimal driver skeleton, Kconfig/Makefile plumbing, and MAINTAINERS entry.
- Type-safe EC WMI query interface.
- Driver registration and backlight type detection following tuxedo-drivers business rules.

Just wanna make sure what you are referring to here exactly?

Specifically, I am referring to the logic used for board capability detection; ie how to determine if a device supports fixed colour vs. RGB backlight etc. TUXEDO has already done a significant volume of work here.

Any questions or concerns please shout out.

Cheers Nick