mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/4] platform/x86: clevo-laptop: add initial Rust driver for keyboard backlight
@ 2026-11-22  4:35 Nick Dowsett via B4 Relay
  2026-11-22  4:35 ` [PATCH 1/4] platform/x86: clevo-laptop: add minimal WMI driver skeleton and Kbuild plumbing Nick Dowsett via B4 Relay
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Nick Dowsett via B4 Relay @ 2026-11-22  4:35 UTC (permalink / raw)
  To: Hans de Goede, Ilpo Järvinen, Miguel Ojeda, Boqun Feng,
	Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Alice Ryhl, Trevor Gross, Danilo Krummrich, Daniel Almeida,
	Tamir Duberstein, Alexandre Courbot, Onur Özkan
  Cc: Armin Wolf, Werner Sembach, linux-kernel, platform-driver-x86,
	rust-for-linux, Nick Dowsett

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/20261113-rust_leds-v28-0-b8cf2f74fa57@posteo.de/
- Rust WMI abstractions (change-id: 20261119-rust-wmi-c6b0e0fe97a7)
  https://lore.kernel.org/all/20261122-rust-wmi-v1-0-63111d9e824c@gmail.com/
- Rust DMI abstractions (change-id: 20261121-rust-dmi-c49d2041d7e2)
  https://lore.kernel.org/all/20261122-rust-dmi-v1-1-4ace9449f872@gmail.com/

Tested on a Clevo/Metabox NL57AU laptop.

Signed-off-by: Nick Dowsett <nick42d@gmail.com>
---
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 <nick42d@gmail.com>



^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/4] platform/x86: clevo-laptop: add minimal WMI driver skeleton and Kbuild plumbing
  2026-11-22  4:35 [PATCH 0/4] platform/x86: clevo-laptop: add initial Rust driver for keyboard backlight Nick Dowsett via B4 Relay
@ 2026-11-22  4:35 ` Nick Dowsett via B4 Relay
  2026-11-23 14:12   ` Werner Sembach
  2026-11-22  4:35 ` [PATCH 2/4] platform/x86: clevo-laptop: add EC WMI query interface and BIOS feature check Nick Dowsett via B4 Relay
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 9+ messages in thread
From: Nick Dowsett via B4 Relay @ 2026-11-22  4:35 UTC (permalink / raw)
  To: Hans de Goede, Ilpo Järvinen, Miguel Ojeda, Boqun Feng,
	Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Alice Ryhl, Trevor Gross, Danilo Krummrich, Daniel Almeida,
	Tamir Duberstein, Alexandre Courbot, Onur Özkan
  Cc: Armin Wolf, Werner Sembach, linux-kernel, platform-driver-x86,
	rust-for-linux, Nick Dowsett

From: Nick Dowsett <nick42d@gmail.com>

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

Signed-off-by: Nick Dowsett <nick42d@gmail.com>
---
 MAINTAINERS                          |  6 +++
 drivers/platform/x86/Kconfig         | 17 +++++++++
 drivers/platform/x86/Makefile        |  3 ++
 drivers/platform/x86/clevo-laptop.rs | 72 ++++++++++++++++++++++++++++++++++++
 4 files changed, 98 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 44540a1eb2b8..1130c293e84d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -6566,6 +6566,12 @@ F:	scripts/Makefile.clang
 F:	scripts/clang-tools/
 K:	\b(?i:clang|llvm)\b
 
+CLEVO LAPTOP DRIVER
+M:	Nick Dowsett <nick42d@gmail.com>
+L:	platform-driver-x86@vger.kernel.org
+S:	Maintained
+F:	drivers/platform/x86/clevo-laptop.rs
+
 CLK API
 M:	Russell King <linux@armlinux.org.uk>
 L:	linux-clk@vger.kernel.org
diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
index 9ce384e0475e..18aa4550c9f4 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -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
diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile
index 229057234d00..070af05a2064 100644
--- a/drivers/platform/x86/Makefile
+++ b/drivers/platform/x86/Makefile
@@ -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
 
diff --git a/drivers/platform/x86/clevo-laptop.rs b/drivers/platform/x86/clevo-laptop.rs
new file mode 100644
index 000000000000..1d862c57b3fe
--- /dev/null
+++ b/drivers/platform/x86/clevo-laptop.rs
@@ -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 <nick42d@gmail.com>.
+//!
+//! 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 <nick42d@gmail.com>"],
+    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 {})
+    }
+}

-- 
2.56.1



^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 2/4] platform/x86: clevo-laptop: add EC WMI query interface and BIOS feature check
  2026-11-22  4:35 [PATCH 0/4] platform/x86: clevo-laptop: add initial Rust driver for keyboard backlight Nick Dowsett via B4 Relay
  2026-11-22  4:35 ` [PATCH 1/4] platform/x86: clevo-laptop: add minimal WMI driver skeleton and Kbuild plumbing Nick Dowsett via B4 Relay
@ 2026-11-22  4:35 ` Nick Dowsett via B4 Relay
  2026-11-22  4:35 ` [PATCH 3/4] platform/x86: clevo-laptop: probe keyboard backlight type and detect 5-step white backlight Nick Dowsett via B4 Relay
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Nick Dowsett via B4 Relay @ 2026-11-22  4:35 UTC (permalink / raw)
  To: Hans de Goede, Ilpo Järvinen, Miguel Ojeda, Boqun Feng,
	Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Alice Ryhl, Trevor Gross, Danilo Krummrich, Daniel Almeida,
	Tamir Duberstein, Alexandre Courbot, Onur Özkan
  Cc: Armin Wolf, Werner Sembach, linux-kernel, platform-driver-x86,
	rust-for-linux, Nick Dowsett

From: Nick Dowsett <nick42d@gmail.com>

- 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.

Signed-off-by: Nick Dowsett <nick42d@gmail.com>
---
 drivers/platform/x86/clevo-laptop.rs | 104 ++++++++++++++++++++++++++++++++++-
 1 file changed, 102 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/x86/clevo-laptop.rs b/drivers/platform/x86/clevo-laptop.rs
index 1d862c57b3fe..289b30c478ec 100644
--- a/drivers/platform/x86/clevo-laptop.rs
+++ b/drivers/platform/x86/clevo-laptop.rs
@@ -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);
+}

-- 
2.56.1



^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 3/4] platform/x86: clevo-laptop: probe keyboard backlight type and detect 5-step white backlight
  2026-11-22  4:35 [PATCH 0/4] platform/x86: clevo-laptop: add initial Rust driver for keyboard backlight Nick Dowsett via B4 Relay
  2026-11-22  4:35 ` [PATCH 1/4] platform/x86: clevo-laptop: add minimal WMI driver skeleton and Kbuild plumbing Nick Dowsett via B4 Relay
  2026-11-22  4:35 ` [PATCH 2/4] platform/x86: clevo-laptop: add EC WMI query interface and BIOS feature check Nick Dowsett via B4 Relay
@ 2026-11-22  4:35 ` Nick Dowsett via B4 Relay
  2026-11-22  4:35 ` [PATCH 4/4] platform/x86: clevo-laptop: register 5-step white keyboard backlight LED device Nick Dowsett via B4 Relay
  2026-11-23 13:58 ` [PATCH 0/4] platform/x86: clevo-laptop: add initial Rust driver for keyboard backlight Werner Sembach
  4 siblings, 0 replies; 9+ messages in thread
From: Nick Dowsett via B4 Relay @ 2026-11-22  4:35 UTC (permalink / raw)
  To: Hans de Goede, Ilpo Järvinen, Miguel Ojeda, Boqun Feng,
	Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Alice Ryhl, Trevor Gross, Danilo Krummrich, Daniel Almeida,
	Tamir Duberstein, Alexandre Courbot, Onur Özkan
  Cc: Armin Wolf, Werner Sembach, linux-kernel, platform-driver-x86,
	rust-for-linux, Nick Dowsett

From: Nick Dowsett <nick42d@gmail.com>

- 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.

Signed-off-by: Nick Dowsett <nick42d@gmail.com>
---
 drivers/platform/x86/clevo-laptop.rs | 125 +++++++++++++++++++++++++++++++++++
 1 file changed, 125 insertions(+)

diff --git a/drivers/platform/x86/clevo-laptop.rs b/drivers/platform/x86/clevo-laptop.rs
index 289b30c478ec..6f08bf295c07 100644
--- a/drivers/platform/x86/clevo-laptop.rs
+++ b/drivers/platform/x86/clevo-laptop.rs
@@ -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])
+    }
 }

-- 
2.56.1



^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 4/4] platform/x86: clevo-laptop: register 5-step white keyboard backlight LED device
  2026-11-22  4:35 [PATCH 0/4] platform/x86: clevo-laptop: add initial Rust driver for keyboard backlight Nick Dowsett via B4 Relay
                   ` (2 preceding siblings ...)
  2026-11-22  4:35 ` [PATCH 3/4] platform/x86: clevo-laptop: probe keyboard backlight type and detect 5-step white backlight Nick Dowsett via B4 Relay
@ 2026-11-22  4:35 ` Nick Dowsett via B4 Relay
  2026-11-23 13:58 ` [PATCH 0/4] platform/x86: clevo-laptop: add initial Rust driver for keyboard backlight Werner Sembach
  4 siblings, 0 replies; 9+ messages in thread
From: Nick Dowsett via B4 Relay @ 2026-11-22  4:35 UTC (permalink / raw)
  To: Hans de Goede, Ilpo Järvinen, Miguel Ojeda, Boqun Feng,
	Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
	Alice Ryhl, Trevor Gross, Danilo Krummrich, Daniel Almeida,
	Tamir Duberstein, Alexandre Courbot, Onur Özkan
  Cc: Armin Wolf, Werner Sembach, linux-kernel, platform-driver-x86,
	rust-for-linux, Nick Dowsett

From: Nick Dowsett <nick42d@gmail.com>

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

Signed-off-by: Nick Dowsett <nick42d@gmail.com>
---
 drivers/platform/x86/clevo-laptop.rs | 100 +++++++++++++++++++++++++++++++++--
 1 file changed, 95 insertions(+), 5 deletions(-)

diff --git a/drivers/platform/x86/clevo-laptop.rs b/drivers/platform/x86/clevo-laptop.rs
index 6f08bf295c07..0a9cb96e7811 100644
--- a/drivers/platform/x86/clevo-laptop.rs
+++ b/drivers/platform/x86/clevo-laptop.rs
@@ -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 {

-- 
2.56.1



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/4] platform/x86: clevo-laptop: add initial Rust driver for keyboard backlight
  2026-11-22  4:35 [PATCH 0/4] platform/x86: clevo-laptop: add initial Rust driver for keyboard backlight Nick Dowsett via B4 Relay
                   ` (3 preceding siblings ...)
  2026-11-22  4:35 ` [PATCH 4/4] platform/x86: clevo-laptop: register 5-step white keyboard backlight LED device Nick Dowsett via B4 Relay
@ 2026-11-23 13:58 ` Werner Sembach
  2026-11-24  0:30   ` Nick Dowsett
  4 siblings, 1 reply; 9+ messages in thread
From: Werner Sembach @ 2026-11-23 13:58 UTC (permalink / raw)
  To: nick42d, Hans de Goede, Ilpo Järvinen, Miguel Ojeda,
	Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich,
	Daniel Almeida, Tamir Duberstein, Alexandre Courbot,
	Onur Özkan
  Cc: Armin Wolf, linux-kernel, platform-driver-x86, rust-for-linux

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:
> 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.

>
> 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

>
> Dependencies (not yet merged):
> - Markus Probst's Rust LED classdev abstractions (v28):
>    https://lore.kernel.org/all/20261113-rust_leds-v28-0-b8cf2f74fa57@posteo.de/
> - Rust WMI abstractions (change-id: 20261119-rust-wmi-c6b0e0fe97a7)
>    https://lore.kernel.org/all/20261122-rust-wmi-v1-0-63111d9e824c@gmail.com/
> - Rust DMI abstractions (change-id: 20261121-rust-dmi-c49d2041d7e2)
>    https://lore.kernel.org/all/20261122-rust-dmi-v1-1-4ace9449f872@gmail.com/
>
> Tested on a Clevo/Metabox NL57AU laptop.
>
> Signed-off-by: Nick Dowsett <nick42d@gmail.com>
> ---
> 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 <nick42d@gmail.com>
>
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/4] platform/x86: clevo-laptop: add minimal WMI driver skeleton and Kbuild plumbing
  2026-11-22  4:35 ` [PATCH 1/4] platform/x86: clevo-laptop: add minimal WMI driver skeleton and Kbuild plumbing Nick Dowsett via B4 Relay
@ 2026-11-23 14:12   ` Werner Sembach
  2026-11-24  8:50     ` Nick Dowsett
  0 siblings, 1 reply; 9+ messages in thread
From: Werner Sembach @ 2026-11-23 14:12 UTC (permalink / raw)
  To: nick42d, Hans de Goede, Ilpo Järvinen, Miguel Ojeda,
	Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich,
	Daniel Almeida, Tamir Duberstein, Alexandre Courbot,
	Onur Özkan
  Cc: Armin Wolf, linux-kernel, platform-driver-x86, rust-for-linux


Am 22.11.26 um 05:35 schrieb Nick Dowsett via B4 Relay:
> From: Nick Dowsett <nick42d@gmail.com>
>
> - Add `drivers/platform/x86/clevo-laptop.rs` with module implementation,
>    DMI board check, and Driver registration.
> - Add Kconfig and MAINTAINERS entries and Makefile wiring.
>
> Signed-off-by: Nick Dowsett <nick42d@gmail.com>
> ---
>   MAINTAINERS                          |  6 +++
>   drivers/platform/x86/Kconfig         | 17 +++++++++
>   drivers/platform/x86/Makefile        |  3 ++
>   drivers/platform/x86/clevo-laptop.rs | 72 ++++++++++++++++++++++++++++++++++++
>   4 files changed, 98 insertions(+)
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 44540a1eb2b8..1130c293e84d 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -6566,6 +6566,12 @@ F:	scripts/Makefile.clang
>   F:	scripts/clang-tools/
>   K:	\b(?i:clang|llvm)\b
>   
> +CLEVO LAPTOP DRIVER
> +M:	Nick Dowsett <nick42d@gmail.com>
> +L:	platform-driver-x86@vger.kernel.org
> +S:	Maintained
> +F:	drivers/platform/x86/clevo-laptop.rs
> +
>   CLK API
>   M:	Russell King <linux@armlinux.org.uk>
>   L:	linux-clk@vger.kernel.org
> diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
> index 9ce384e0475e..18aa4550c9f4 100644
> --- a/drivers/platform/x86/Kconfig
> +++ b/drivers/platform/x86/Kconfig
> @@ -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.
> +

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".

>   endif # X86_PLATFORM_DEVICES
>   
>   config P2SB
> diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile
> index 229057234d00..070af05a2064 100644
> --- a/drivers/platform/x86/Makefile
> +++ b/drivers/platform/x86/Makefile
> @@ -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
>   
> diff --git a/drivers/platform/x86/clevo-laptop.rs b/drivers/platform/x86/clevo-laptop.rs
> new file mode 100644
> index 000000000000..1d862c57b3fe
> --- /dev/null
> +++ b/drivers/platform/x86/clevo-laptop.rs
> @@ -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 <nick42d@gmail.com>.
> +//!
> +//! 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 <nick42d@gmail.com>"],
> +    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))

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

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

> +            {
> +                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 {})
> +    }
> +}
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/4] platform/x86: clevo-laptop: add initial Rust driver for keyboard backlight
  2026-11-23 13:58 ` [PATCH 0/4] platform/x86: clevo-laptop: add initial Rust driver for keyboard backlight Werner Sembach
@ 2026-11-24  0:30   ` Nick Dowsett
  0 siblings, 0 replies; 9+ messages in thread
From: Nick Dowsett @ 2026-11-24  0:30 UTC (permalink / raw)
  To: Werner Sembach, nick42d, Hans de Goede, Ilpo Järvinen,
	Miguel Ojeda, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
	Alexandre Courbot, Onur Özkan
  Cc: Armin Wolf, linux-kernel, platform-driver-x86, rust-for-linux

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.

On Mon Nov 23, 2026 at 9:58 PM AWST, Werner Sembach wrote:
> 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:
>> 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.

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.

>> 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?

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/4] platform/x86: clevo-laptop: add minimal WMI driver skeleton and Kbuild plumbing
  2026-11-23 14:12   ` Werner Sembach
@ 2026-11-24  8:50     ` Nick Dowsett
  0 siblings, 0 replies; 9+ messages in thread
From: Nick Dowsett @ 2026-11-24  8:50 UTC (permalink / raw)
  To: Werner Sembach, nick42d, Hans de Goede, Ilpo Järvinen,
	Miguel Ojeda, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
	Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
	Alexandre Courbot, Onur Özkan
  Cc: Armin Wolf, linux-kernel, platform-driver-x86, rust-for-linux

On Mon Nov 23, 2026 at 10:12 PM AWST, Werner Sembach wrote:
>> diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
>> index 9ce384e0475e..18aa4550c9f4 100644
>> --- a/drivers/platform/x86/Kconfig
>> +++ b/drivers/platform/x86/Kconfig
>> @@ -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.
>> +
> 
> 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".

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.

>> +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

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-11-24  8:50 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-22  4:35 [PATCH 0/4] platform/x86: clevo-laptop: add initial Rust driver for keyboard backlight Nick Dowsett via B4 Relay
2026-11-22  4:35 ` [PATCH 1/4] platform/x86: clevo-laptop: add minimal WMI driver skeleton and Kbuild plumbing Nick Dowsett via B4 Relay
2026-11-23 14:12   ` Werner Sembach
2026-11-24  8:50     ` Nick Dowsett
2026-11-22  4:35 ` [PATCH 2/4] platform/x86: clevo-laptop: add EC WMI query interface and BIOS feature check Nick Dowsett via B4 Relay
2026-11-22  4:35 ` [PATCH 3/4] platform/x86: clevo-laptop: probe keyboard backlight type and detect 5-step white backlight Nick Dowsett via B4 Relay
2026-11-22  4:35 ` [PATCH 4/4] platform/x86: clevo-laptop: register 5-step white keyboard backlight LED device Nick Dowsett via B4 Relay
2026-11-23 13:58 ` [PATCH 0/4] platform/x86: clevo-laptop: add initial Rust driver for keyboard backlight Werner Sembach
2026-11-24  0:30   ` Nick Dowsett

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®