mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] platform/x86: asus-wmi: Accept buffer result from DSTS
@ 2026-11-29 17:42 Lee Kindness
  0 siblings, 0 replies; only message in thread
From: Lee Kindness @ 2026-11-29 17:42 UTC (permalink / raw)
  To: platform-driver-x86
  Cc: Corentin Chary, Luke D . Jones, Denis Benato, Hans de Goede,
	Ilpo Järvinen, linux-kernel, Lee Kindness

On the ASUS Zenbook S14 UX5406AA (BIOS UX5406AA.310) the WMNB method
returns an 8-byte buffer instead of an integer when DSTS is called for
ASUS_WMI_DEVID_RSOC (0x00120057). The first dword holds the usual status
bits, including ASUS_WMI_DSTS_PRESENCE_BIT, and the second dword holds
the current charge limit:

    If ((IIA0 == 0x00120057))
    {
        Name (BCMV, Buffer (0x08) { ... })
        CreateDWordField (BCMV, Zero, BCML)
        CreateDWordField (BCMV, 0x04, BCMH)
        ...
        Local0 = 0x00010000
        ...
        BCML = Local0
        Return (BCMV)
    }

asus_wmi_evaluate_method3() only handles ACPI_TYPE_INTEGER results and
treats anything else as 0. asus_wmi_dev_is_present() therefore reports
RSOC as absent, the battery hook is never registered and
charge_control_end_threshold is not exposed, even though setting the
limit through DEVS works on this machine.

Accept a buffer of at least four bytes and use its first dword as the
result. Integer results are handled as before.

Tested on a UX5406AA: charge_control_end_threshold is now present and
upower/GNOME can set an 80% charge limit.

The firmware analysis and this patch were prepared with the help of an
AI coding assistant (Claude Opus 5.5, Anthropic); see the notes below.

Signed-off-by: Lee Kindness <lee@leekindness.com>
---
 drivers/platform/asus/asus-wmi.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/platform/asus/asus-wmi.c b/drivers/platform/asus/asus-wmi.c
index 1b75a2cbc372..257776373e83 100644
--- a/drivers/platform/asus/asus-wmi.c
+++ b/drivers/platform/asus/asus-wmi.c
@@ -41,6 +41,7 @@
 #include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/types.h>
+#include <linux/unaligned.h>
 #include <linux/units.h>
 
 #include <acpi/battery.h>
@@ -395,6 +396,14 @@ static int asus_wmi_evaluate_method3(u32 method_id,
 	obj = (union acpi_object *)output.pointer;
 	if (obj && obj->type == ACPI_TYPE_INTEGER)
 		tmp = (u32) obj->integer.value;
+	/*
+	 * Some firmware returns a buffer from DSTS instead of an integer, with
+	 * the status bits in the first dword, e.g. for ASUS_WMI_DEVID_RSOC on
+	 * the Zenbook S14 UX5406AA.
+	 */
+	else if (obj && obj->type == ACPI_TYPE_BUFFER &&
+		 obj->buffer.length >= sizeof(u32))
+		tmp = get_unaligned_le32(obj->buffer.pointer);
 
 	pr_debug("Result: 0x%08x\n", tmp);
 	if (retval)

base-commit: 61c0dac952b9308884936d05cce97565a5c89af4
-- 
2.55.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-29 17:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-29 17:42 [PATCH] platform/x86: asus-wmi: Accept buffer result from DSTS Lee Kindness

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®