* [PATCH v4 0/2] platform/x86: alienware-wmi-wmax: Add support for GPIO methods
@ 2025-05-05 18:43 Kurt Borja via B4 Relay
2025-05-05 18:43 ` [PATCH v4 1/2] platform/x86: alienware-wmi-wmax: Expose GPIO debug methods Kurt Borja via B4 Relay
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Kurt Borja via B4 Relay @ 2025-05-05 18:43 UTC (permalink / raw)
To: Hans de Goede, Ilpo Järvinen, Armin Wolf
Cc: Gabriel Marcano, platform-driver-x86, Dell.Client.Kernel,
linux-kernel, Kurt Borja
Hi all,
I found a great blog post [1], which described the reverse engineering
process of the GPIO control methods present on this device.
In summary, these methods expose some debugging capabilities of the RGB
lighting controller present on Dell gaming laptops. See [Patch 2] for
more info.
Exposing these methods to DebugFS is useful for developers exploring
this RGB controllers (myself included).
Thanks for your feedback!
[1] https://gabriel.marcanobrady.family/blog/2024/12/16/dell-g5-5505-se-acpi-or-figuring-out-how-to-reset-the-rgb-controller/
Signed-off-by: Kurt Borja <kuurtb@gmail.com>
---
Changes in v4:
- Reuse name[] for all file a directory names in awcc_debugfs_init()
- Reword commit message to correctly reflect previous changes
- Link to v3: https://lore.kernel.org/r/20250502-awcc-gpio-v3-0-ea9a932d1124@gmail.com
Changes in v3:
- Create pinX files dynamically, based on GPIO pin count
- Added note on dummy input arguments in Documentation
- Link to v2: https://lore.kernel.org/r/20250427-awcc-gpio-v2-0-c731373b5d02@gmail.com
Changes in v2:
- Dropped module parameter
- Added ABI documentation to Patch 1
- Small improvements to documentation based on Armin's comments
- Improved Pin description table format
- Link to v1: https://lore.kernel.org/r/20250423-awcc-gpio-v1-0-160a11bc3f9a@gmail.com
---
Kurt Borja (2):
platform/x86: alienware-wmi-wmax: Expose GPIO debug methods
Documentation: wmi: alienware-wmi: Add GPIO control documentation
Documentation/ABI/testing/debugfs-alienware-wmi | 20 +++++
Documentation/wmi/devices/alienware-wmi.rst | 82 ++++++++++++++++++-
drivers/platform/x86/dell/alienware-wmi-wmax.c | 104 +++++++++++++++++++++++-
3 files changed, 201 insertions(+), 5 deletions(-)
---
base-commit: 67e2635fe0cca5f0383c0780db986d8237e83f0a
change-id: 20250413-awcc-gpio-24b1f5c546d2
Best regards,
--
~ Kurt
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v4 1/2] platform/x86: alienware-wmi-wmax: Expose GPIO debug methods
2025-05-05 18:43 [PATCH v4 0/2] platform/x86: alienware-wmi-wmax: Add support for GPIO methods Kurt Borja via B4 Relay
@ 2025-05-05 18:43 ` Kurt Borja via B4 Relay
2025-05-05 18:43 ` [PATCH v4 2/2] Documentation: wmi: alienware-wmi: Add GPIO control documentation Kurt Borja via B4 Relay
2025-05-07 10:36 ` [PATCH v4 0/2] platform/x86: alienware-wmi-wmax: Add support for GPIO methods Ilpo Järvinen
2 siblings, 0 replies; 4+ messages in thread
From: Kurt Borja via B4 Relay @ 2025-05-05 18:43 UTC (permalink / raw)
To: Hans de Goede, Ilpo Järvinen, Armin Wolf
Cc: Gabriel Marcano, platform-driver-x86, Dell.Client.Kernel,
linux-kernel, Kurt Borja
From: Kurt Borja <kuurtb@gmail.com>
Expose GPIO control methods present on the AWCC interface through
DebugFS.
These models come with an RGB lighting STM32 MCU, which usually has two
GPIO pins with debug capabilities:
- Pin 0: Device Firmware Update mode (DFU)
- Pin 1: Negative Reset (NRST)
Suggested-by: Gabriel Marcano <gabemarcano@yahoo.com>
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
Signed-off-by: Kurt Borja <kuurtb@gmail.com>
---
Documentation/ABI/testing/debugfs-alienware-wmi | 20 +++++
drivers/platform/x86/dell/alienware-wmi-wmax.c | 104 +++++++++++++++++++++++-
2 files changed, 123 insertions(+), 1 deletion(-)
diff --git a/Documentation/ABI/testing/debugfs-alienware-wmi b/Documentation/ABI/testing/debugfs-alienware-wmi
index 48cfd4d0b002efd7b68d9c1d3aa91a3a05f49db5..c7f525d6baac962be82780608f8da5c0368600cc 100644
--- a/Documentation/ABI/testing/debugfs-alienware-wmi
+++ b/Documentation/ABI/testing/debugfs-alienware-wmi
@@ -42,3 +42,23 @@ Description:
details.
RO
+
+What: /sys/kernel/debug/alienware-wmi-<wmi_device_name>/gpio_ctl/total_gpios
+Date: May 2025
+KernelVersion: 6.16
+Contact: Kurt Borja <kuurtb@gmail.com>
+Description:
+ Total number of GPIO pins reported by the device.
+
+ RO
+
+What: /sys/kernel/debug/alienware-wmi-<wmi_device_name>/gpio_ctl/pinX
+Date: May 2025
+KernelVersion: 6.16
+Contact: Kurt Borja <kuurtb@gmail.com>
+Description:
+ This file controls GPIO pin X status.
+
+ See Documentation/wmi/devices/alienware-wmi.rst for details.
+
+ RW
diff --git a/drivers/platform/x86/dell/alienware-wmi-wmax.c b/drivers/platform/x86/dell/alienware-wmi-wmax.c
index f3ad47c9edfac47fae181046acae2190e388306c..f0e6a36abc278d95059dfc007414894dee79b587 100644
--- a/drivers/platform/x86/dell/alienware-wmi-wmax.c
+++ b/drivers/platform/x86/dell/alienware-wmi-wmax.c
@@ -38,6 +38,9 @@
#define AWCC_METHOD_GET_FAN_SENSORS 0x13
#define AWCC_METHOD_THERMAL_INFORMATION 0x14
#define AWCC_METHOD_THERMAL_CONTROL 0x15
+#define AWCC_METHOD_FWUP_GPIO_CONTROL 0x20
+#define AWCC_METHOD_READ_TOTAL_GPIOS 0x21
+#define AWCC_METHOD_READ_GPIO_STATUS 0x22
#define AWCC_METHOD_GAME_SHIFT_STATUS 0x25
#define AWCC_FAILURE_CODE 0xFFFFFFFF
@@ -281,6 +284,8 @@ struct awcc_priv {
struct device *hwdev;
struct awcc_fan_data **fan_data;
unsigned long temp_sensors[AWCC_ID_BITMAP_LONGS];
+
+ u32 gpio_count;
};
static const enum platform_profile_option awcc_mode_to_platform_profile[AWCC_PROFILE_LAST] = {
@@ -571,6 +576,38 @@ static int awcc_thermal_information(struct wmi_device *wdev, u8 operation, u8 ar
return awcc_wmi_command(wdev, AWCC_METHOD_THERMAL_INFORMATION, &args, out);
}
+static int awcc_fwup_gpio_control(struct wmi_device *wdev, u8 pin, u8 status)
+{
+ struct wmax_u32_args args = {
+ .operation = pin,
+ .arg1 = status,
+ .arg2 = 0,
+ .arg3 = 0,
+ };
+ u32 out;
+
+ return awcc_wmi_command(wdev, AWCC_METHOD_FWUP_GPIO_CONTROL, &args, &out);
+}
+
+static int awcc_read_total_gpios(struct wmi_device *wdev, u32 *count)
+{
+ struct wmax_u32_args args = {};
+
+ return awcc_wmi_command(wdev, AWCC_METHOD_READ_TOTAL_GPIOS, &args, count);
+}
+
+static int awcc_read_gpio_status(struct wmi_device *wdev, u8 pin, u32 *status)
+{
+ struct wmax_u32_args args = {
+ .operation = pin,
+ .arg1 = 0,
+ .arg2 = 0,
+ .arg3 = 0,
+ };
+
+ return awcc_wmi_command(wdev, AWCC_METHOD_READ_GPIO_STATUS, &args, status);
+}
+
static int awcc_game_shift_status(struct wmi_device *wdev, u8 operation,
u32 *out)
{
@@ -1317,6 +1354,47 @@ static int awcc_debugfs_pprof_data_read(struct seq_file *seq, void *data)
return 0;
}
+static int awcc_gpio_pin_show(struct seq_file *seq, void *data)
+{
+ unsigned long pin = debugfs_get_aux_num(seq->file);
+ struct wmi_device *wdev = seq->private;
+ u32 status;
+ int ret;
+
+ ret = awcc_read_gpio_status(wdev, pin, &status);
+ if (ret)
+ return ret;
+
+ seq_printf(seq, "%u\n", status);
+
+ return 0;
+}
+
+static ssize_t awcc_gpio_pin_write(struct file *file, const char __user *buf,
+ size_t count, loff_t *ppos)
+{
+ unsigned long pin = debugfs_get_aux_num(file);
+ struct seq_file *seq = file->private_data;
+ struct wmi_device *wdev = seq->private;
+ bool status;
+ int ret;
+
+ if (!ppos || *ppos)
+ return -EINVAL;
+
+ ret = kstrtobool_from_user(buf, count, &status);
+ if (ret)
+ return ret;
+
+ ret = awcc_fwup_gpio_control(wdev, pin, status);
+ if (ret)
+ return ret;
+
+ return count;
+}
+
+DEFINE_SHOW_STORE_ATTRIBUTE(awcc_gpio_pin);
+
static void awcc_debugfs_remove(void *data)
{
struct dentry *root = data;
@@ -1326,8 +1404,11 @@ static void awcc_debugfs_remove(void *data)
static void awcc_debugfs_init(struct wmi_device *wdev)
{
- struct dentry *root;
+ struct awcc_priv *priv = dev_get_drvdata(&wdev->dev);
+ struct dentry *root, *gpio_ctl;
+ u32 gpio_count;
char name[64];
+ int ret;
scnprintf(name, sizeof(name), "%s-%s", "alienware-wmi", dev_name(&wdev->dev));
root = debugfs_create_dir(name, NULL);
@@ -1343,6 +1424,27 @@ static void awcc_debugfs_init(struct wmi_device *wdev)
debugfs_create_devm_seqfile(&wdev->dev, "pprof_data", root,
awcc_debugfs_pprof_data_read);
+ ret = awcc_read_total_gpios(wdev, &gpio_count);
+ if (ret) {
+ dev_dbg(&wdev->dev, "Failed to get total GPIO Pin count\n");
+ goto out_add_action;
+ } else if (gpio_count > AWCC_MAX_RES_COUNT) {
+ dev_dbg(&wdev->dev, "Reported GPIO Pin count may be incorrect: %u\n", gpio_count);
+ goto out_add_action;
+ }
+
+ gpio_ctl = debugfs_create_dir("gpio_ctl", root);
+
+ priv->gpio_count = gpio_count;
+ debugfs_create_u32("total_gpios", 0444, gpio_ctl, &priv->gpio_count);
+
+ for (unsigned int i = 0; i < gpio_count; i++) {
+ scnprintf(name, sizeof(name), "pin%u", i);
+ debugfs_create_file_aux_num(name, 0644, gpio_ctl, wdev, i,
+ &awcc_gpio_pin_fops);
+ }
+
+out_add_action:
devm_add_action_or_reset(&wdev->dev, awcc_debugfs_remove, root);
}
--
2.49.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v4 2/2] Documentation: wmi: alienware-wmi: Add GPIO control documentation
2025-05-05 18:43 [PATCH v4 0/2] platform/x86: alienware-wmi-wmax: Add support for GPIO methods Kurt Borja via B4 Relay
2025-05-05 18:43 ` [PATCH v4 1/2] platform/x86: alienware-wmi-wmax: Expose GPIO debug methods Kurt Borja via B4 Relay
@ 2025-05-05 18:43 ` Kurt Borja via B4 Relay
2025-05-07 10:36 ` [PATCH v4 0/2] platform/x86: alienware-wmi-wmax: Add support for GPIO methods Ilpo Järvinen
2 siblings, 0 replies; 4+ messages in thread
From: Kurt Borja via B4 Relay @ 2025-05-05 18:43 UTC (permalink / raw)
To: Hans de Goede, Ilpo Järvinen, Armin Wolf
Cc: Gabriel Marcano, platform-driver-x86, Dell.Client.Kernel,
linux-kernel, Kurt Borja
From: Kurt Borja <kuurtb@gmail.com>
Add documentation for the GPIO control methods.
Reviewed-by: Armin Wolf <W_Armin@gmx.de>
Signed-off-by: Kurt Borja <kuurtb@gmail.com>
---
Documentation/wmi/devices/alienware-wmi.rst | 82 +++++++++++++++++++++++++++--
1 file changed, 78 insertions(+), 4 deletions(-)
diff --git a/Documentation/wmi/devices/alienware-wmi.rst b/Documentation/wmi/devices/alienware-wmi.rst
index 79238051b18bc5de9b502325017cd5c5fcf41748..1d9d43e2e314b03c134e6c63a0f9124036939e32 100644
--- a/Documentation/wmi/devices/alienware-wmi.rst
+++ b/Documentation/wmi/devices/alienware-wmi.rst
@@ -231,6 +231,74 @@ WMI method MemoryOCControl([in] uint32 arg2, [out] uint32 argr)
AWCC supports memory overclocking, but this method is very intricate and has
not been deciphered yet.
+GPIO control Methods
+====================
+
+Alienware and Dell G Series devices with the AWCC interface usually have an
+embedded STM32 RGB lighting controller with USB/HID capabilities. It's vendor ID
+is ``187c`` while it's product ID may vary from model to model.
+
+The control of two GPIO pins of this MCU is exposed as WMI methods for debugging
+purposes.
+
++--------------+--------------------------------------------------------------+
+| Pin | Description |
++==============+===============================+==============================+
+| 0 | Device Firmware Update (DFU) | **HIGH**: Enables DFU mode |
+| | mode pin. | on next MCU boot. |
+| | +------------------------------+
+| | | **LOW**: Disables DFU mode |
+| | | on next MCU boot. |
++--------------+-------------------------------+------------------------------+
+| 1 | Negative Reset (NRST) pin. | **HIGH**: MCU is ON. |
+| | | |
+| | +------------------------------+
+| | | **LOW**: MCU is OFF. |
+| | | |
++--------------+-------------------------------+------------------------------+
+
+See :ref:`acknowledgements` for more information on this MCU.
+
+.. note::
+ Some GPIO control methods break the usual argument structure and take a
+ **Pin number** instead of an operation on the first byte.
+
+WMI method FWUpdateGPIOtoggle([in] uint32 arg2, [out] uint32 argr)
+------------------------------------------------------------------
+
++--------------------+------------------------------------+--------------------+
+| Operation (Byte 0) | Description | Arguments |
++====================+====================================+====================+
+| Pin number | Set the pin status | - Byte 1: Pin |
+| | | status |
++--------------------+------------------------------------+--------------------+
+
+WMI method ReadTotalofGPIOs([out] uint32 argr)
+----------------------------------------------
+
++--------------------+------------------------------------+--------------------+
+| Operation (Byte 0) | Description | Arguments |
++====================+====================================+====================+
+| N/A | Get the total number of GPIOs | - None |
++--------------------+------------------------------------+--------------------+
+
+.. note::
+ Due to how WMI methods are implemented on the firmware level, this method
+ requires a dummy uint32 input argument when invoked.
+
+WMI method ReadGPIOpPinStatus([in] uint32 arg2, [out] uint32 argr)
+------------------------------------------------------------------
+
++--------------------+------------------------------------+--------------------+
+| Operation (Byte 0) | Description | Arguments |
++====================+====================================+====================+
+| Pin number | Get the pin status | - None |
++--------------------+------------------------------------+--------------------+
+
+.. note::
+ There known firmware bug in some laptops where reading the status of a pin
+ also flips it.
+
Other information Methods
=========================
@@ -239,10 +307,16 @@ WMI method ReadChassisColor([out] uint32 argr)
Returns the chassis color internal ID.
+.. _acknowledgements:
+
Acknowledgements
================
-Kudos to `AlexIII <https://github.com/AlexIII/tcc-g15>`_ and
-`T-Troll <https://github.com/T-Troll/alienfx-tools/>`_ for documenting and
-testing some of this device's functionality, making it possible to generalize
-this driver.
+Kudos to
+
+* `AlexIII <https://github.com/AlexIII/tcc-g15>`_
+* `T-Troll <https://github.com/T-Troll/alienfx-tools/>`_
+* `Gabriel Marcano <https://gabriel.marcanobrady.family/blog/2024/12/16/dell-g5-5505-se-acpi-or-figuring-out-how-to-reset-the-rgb-controller/>`_
+
+for documenting and testing some of this device's functionality, making it
+possible to generalize this driver.
--
2.49.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v4 0/2] platform/x86: alienware-wmi-wmax: Add support for GPIO methods
2025-05-05 18:43 [PATCH v4 0/2] platform/x86: alienware-wmi-wmax: Add support for GPIO methods Kurt Borja via B4 Relay
2025-05-05 18:43 ` [PATCH v4 1/2] platform/x86: alienware-wmi-wmax: Expose GPIO debug methods Kurt Borja via B4 Relay
2025-05-05 18:43 ` [PATCH v4 2/2] Documentation: wmi: alienware-wmi: Add GPIO control documentation Kurt Borja via B4 Relay
@ 2025-05-07 10:36 ` Ilpo Järvinen
2 siblings, 0 replies; 4+ messages in thread
From: Ilpo Järvinen @ 2025-05-07 10:36 UTC (permalink / raw)
To: Hans de Goede, Armin Wolf, Kurt Borja
Cc: Gabriel Marcano, platform-driver-x86, Dell.Client.Kernel,
linux-kernel
On Mon, 05 May 2025 15:43:30 -0300, Kurt Borja wrote:
> I found a great blog post [1], which described the reverse engineering
> process of the GPIO control methods present on this device.
>
> In summary, these methods expose some debugging capabilities of the RGB
> lighting controller present on Dell gaming laptops. See [Patch 2] for
> more info.
>
> [...]
Thank you for your contribution, it has been applied to my local
review-ilpo-next branch. Note it will show up in the public
platform-drivers-x86/review-ilpo-next branch only once I've pushed my
local branch there, which might take a while.
The list of commits applied:
[1/2] platform/x86: alienware-wmi-wmax: Expose GPIO debug methods
commit: 8e27c47983c516a4d9e85199c0904e2da4c447df
[2/2] Documentation: wmi: alienware-wmi: Add GPIO control documentation
commit: c959bee66489a41555bd2be43a93da8be16b4acd
--
i.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-05-07 10:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-05 18:43 [PATCH v4 0/2] platform/x86: alienware-wmi-wmax: Add support for GPIO methods Kurt Borja via B4 Relay
2025-05-05 18:43 ` [PATCH v4 1/2] platform/x86: alienware-wmi-wmax: Expose GPIO debug methods Kurt Borja via B4 Relay
2025-05-05 18:43 ` [PATCH v4 2/2] Documentation: wmi: alienware-wmi: Add GPIO control documentation Kurt Borja via B4 Relay
2025-05-07 10:36 ` [PATCH v4 0/2] platform/x86: alienware-wmi-wmax: Add support for GPIO methods Ilpo Järvinen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).