From nobody Mon Jun 8 14:35:33 2026 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 03A7F32FA3C for ; Thu, 28 May 2026 18:57:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779994678; cv=none; b=sOEuQcJaN2vwW8D61Ym0X+/N5WKXB0aRJPAod0E7UPUj2NQlNBBMZ6XIv4WfdguphqVqacD9OP7va8PQF7N1vw5ZGIdYVYlZ+Di5hLsbzBBol4TeCbbSz1K+rrnLaw3r47+jHwdmSUZDepsEjs/OJJu/P1paY8hs3Guom+XfmzM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779994678; c=relaxed/simple; bh=MozaHNqyET9pV+QZs77p40YJfm2Dm3mE7Nd9L6TYFsI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=HFm/Fuk3DM8dnS6uQN9oxR1xT6YOWvedLPD84Kj4HWMo2wj9myeZA9BmYWeoWEb2oOmWEFDvb75IvotIw05jMNKX+bHpnNlQQdXg/Z7qj8Ux5VOF3JoyZlgcM57Z9EdUVncB3It8tROOBcJuOXrhOsZVtz3HZw9vdf1NP0n99nU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=bsliY4B9; arc=none smtp.client-ip=209.85.221.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bsliY4B9" Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-45eebccc346so644676f8f.0 for ; Thu, 28 May 2026 11:57:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779994675; x=1780599475; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=U6RwPcdJ3zNVONjocSGA28jC9qcgfm+AFsG+1ypMnpU=; b=bsliY4B9hXMyZPKAXZ/Zw6QDQ8Ox6JPKBlfd0p93jXbX76lpzmRIBrW2IBSLweNtiM 65MgXi0KRt5/Khybi5b5vAZn4/feBVhVxwoos1XCpKUVhYVL6DQjsKCpUicRDzCuxSu2 JPUYFGznGt7fEbqKhhvvqM7kFxQnIL5mXWLtw3e3F5fFQZU/1QbATuQVCYZlrixyYkqG uGRjddAbkGMBluMboZmH5/3dktpATFd6bOkZF/U8GXmEeJfjQkVJl45/lvMk/lNxL0wT 80Bzjdzgl3yi+/Hvh+db3jrHLg/qFyxVNXErtC1FL3PRkw53QPJ7lAGrwpoiUB00Pxha Rl/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779994675; x=1780599475; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=U6RwPcdJ3zNVONjocSGA28jC9qcgfm+AFsG+1ypMnpU=; b=l7da13PFZUKJA/xMGSSFcZZNXBlK7IrLOzjYoZLg4r6E0ZUxTgbBMSUwtaUlb4kpo+ jlGF04uEwrvK+5gdT8gmxaxxWC+vBgGfxpvYmM5aKorXqFHggdfi0gPKvvqeu3J1bmez 1Vg+JTo6HIWKCdq+Q+s3n9eK8MBmg7wLxRGqi+YXnArrMxTHUJnNothU4fNfFd9D5nLg PqobTNh2I9rhGnsOqhw7KAZjyXk6L3+YOY76J7N7tFEiF1BnChuOihMogG3edkkRT276 GW5ptMhyW9F2cQjX+dfec+WTMvLavJEWQi2cN5gJAqEroCZVUBskmzovrTA4gVl/L2cY nU2w== X-Forwarded-Encrypted: i=1; AFNElJ/ChajPHGFe+Ts79kgHK6YI3h+pbc6Y6qlEgST2FMrVr4ri8+hwx2nkt43KUXpfD7ynjz88HLNH9211AQs=@vger.kernel.org X-Gm-Message-State: AOJu0YwLLGMdSQKLlgm/dJwAwtDJLWaqNVdKwhqMsmaUP91u1V1Y8wrd AgcWrDovTlVq7cTPGoNRtYgcjZL92Q/BizLywWiNM9tRw+ZJ6/vzt877 X-Gm-Gg: Acq92OHr1VhqbKtgmQDcvePBGZtLt1WNd93dUmi8x53DqqcTndBiWBkU0xkchLARLKG 6c6sdO5ot7bPHq9YWq/3CG5CF7u1HnGRcunflsDOgb1aiguF0nxPFrMtFF2hHm4AhfvK2sdTh0J Xv1wtM41fSWfBPSacxdTGtaIyIkU3Q0J8zybrkl2Kb+Xab63ZeYeheg0HDX47u+BHSSO/nSpLW5 qZhThJkTABUJAIYYCcdykGZGw6rrqgT2d0y7JJlp/RPtUPTRR+qdH7m2lPEKIE9CoS7MnQPnZiP LIAQhHdyMEtPjVdZzrnucxh/30XbSyBvvIreia8lPIMGRh2mtQBA2Prq8Y/qwv1ChBqtr9dJ/J7 WIWh7JRP+2hvfsqp5ZLSXtbXpaiKnILlX4Q6OuUGBjPCRjeeYA2UTGKvMwcdC5qC5cnM9Bqzz1b zqYwxuwnD6MbSWCfX6VnanE7X6yAtus1hEHGbmT8IVhkJJtERhh9Q512xwyfiS8p899ExYVR7Wn TSp7AvW X-Received: by 2002:adf:f1cd:0:b0:45a:c97a:905e with SMTP id ffacd0b85a97d-45ef028c943mr515703f8f.1.1779994675355; Thu, 28 May 2026 11:57:55 -0700 (PDT) Received: from shiro (79.191.45.28.ipv4.supernova.orange.pl. [79.191.45.28]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45edb5a281dsm14737314f8f.24.2026.05.28.11.57.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 May 2026 11:57:54 -0700 (PDT) From: =?UTF-8?q?Dariusz=20Figza=C5=82?= To: platform-driver-x86@vger.kernel.org Cc: corentin.chary@gmail.com, luke@ljones.dev, denis.benato@linux.dev, hansg@kernel.org, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, =?UTF-8?q?Dariusz=20Figza=C5=82?= Subject: [PATCH v2] platform/x86: asus-wmi: add keystone dongle support Date: Thu, 28 May 2026 20:57:52 +0200 Message-ID: <20260528185752.81563-1-dariuszfigzal@gmail.com> X-Mailer: git-send-email 2.54.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The ASUS Keystone is a physical NFC-like dongle that slots into supported ASUS laptops. The EC fires WMI notify code 0xB4 on insert/remove events. Expose the current insert state via a sysfs attribute by querying WMI device ID 0x00120091 (DSTS). This devid does not follow the standard DSTS convention: PRESENCE_BIT (0x00010000) encodes the insert state rather than feature presence, and STATUS_BIT is never set. Presence of a keystone slot is detected by a successful DSTS call. Signed-off-by: Dariusz Figza=C5=82 Reviewed-by: Denis Benato --- Changes in v2: - Use .is_visible and platform_attributes[] instead of device_create_file/device_remove_file (Ilpo J=C3=A4rvinen) drivers/platform/x86/asus-wmi.c | 65 ++++++++++++++++++++++ include/linux/platform_data/x86/asus-wmi.h | 7 +++ 2 files changed, 72 insertions(+) diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wm= i.c index 80144c412b90..3c9ef826551d 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -70,6 +70,7 @@ module_param(fnlock_default, bool, 0444); #define NOTIFY_KBD_TTP 0xae #define NOTIFY_LID_FLIP 0xfa #define NOTIFY_LID_FLIP_ROG 0xbd +#define NOTIFY_KEYSTONE 0xb4 =20 #define ASUS_WMI_FNLOCK_BIOS_DISABLED BIT(0) =20 @@ -279,6 +280,8 @@ struct asus_wmi { u32 tablet_switch_dev_id; bool tablet_switch_inverted; =20 + bool keystone_available; + enum fan_type fan_type; enum fan_type gpu_fan_type; enum fan_type mid_fan_type; @@ -646,6 +649,55 @@ static bool asus_wmi_dev_is_present(struct asus_wmi *a= sus, u32 dev_id) return status =3D=3D 0 && (retval & ASUS_WMI_DSTS_PRESENCE_BIT); } =20 +/* Keystone **************************************************************= *****/ + +static int keystone_check_present(struct asus_wmi *asus) +{ + u32 retval; + int err; + + asus->keystone_available =3D false; + + /* + * Use a raw devstate call rather than asus_wmi_dev_is_present(). + * For this devid, PRESENCE_BIT encodes current insert state, not + * feature presence, so asus_wmi_dev_is_present() would return false + * whenever the dongle is absent at boot, even on machines that have + * a keystone slot. + * -ENODEV means the firmware doesn't know this devid at all. + * retval is not examined here, only the return code matters. + */ + err =3D asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_KEYSTONE, &retval); + if (err =3D=3D -ENODEV) + return 0; + if (err) + return err; + + asus->keystone_available =3D true; + return 0; +} + +static ssize_t keystone_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct asus_wmi *asus =3D dev_get_drvdata(dev); + u32 retval; + int err; + + err =3D asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_KEYSTONE, &retval); + if (err) + return err; + + return sysfs_emit(buf, "%d\n", !!(retval & ASUS_WMI_DSTS_PRESENCE_BIT)); +} + +static DEVICE_ATTR_RO(keystone); + +static void asus_wmi_keystone_notify(struct asus_wmi *asus) +{ + sysfs_notify(&asus->platform_device->dev.kobj, NULL, "keystone"); +} + /* Input *****************************************************************= *****/ static void asus_wmi_tablet_sw_report(struct asus_wmi *asus, bool value) { @@ -4575,6 +4627,12 @@ static void asus_wmi_handle_event_code(int code, str= uct asus_wmi *asus) return; } =20 + if (code =3D=3D NOTIFY_KEYSTONE) { + if (asus->keystone_available) + asus_wmi_keystone_notify(asus); + return; + } + if (code =3D=3D NOTIFY_KBD_FBM || code =3D=3D NOTIFY_KBD_TTP) { if (asus->fan_boost_mode_available) fan_boost_mode_switch_next(asus); @@ -4698,6 +4756,7 @@ static struct attribute *platform_attributes[] =3D { &dev_attr_lid_resume.attr, &dev_attr_als_enable.attr, &dev_attr_fan_boost_mode.attr, + &dev_attr_keystone.attr, #if IS_ENABLED(CONFIG_ASUS_WMI_DEPRECATED_ATTRS) &dev_attr_charge_mode.attr, &dev_attr_egpu_enable.attr, @@ -4741,6 +4800,8 @@ static umode_t asus_sysfs_is_visible(struct kobject *= kobj, devid =3D ASUS_WMI_DEVID_ALS_ENABLE; else if (attr =3D=3D &dev_attr_fan_boost_mode.attr) ok =3D asus->fan_boost_mode_available; + else if (attr =3D=3D &dev_attr_keystone.attr) + ok =3D asus->keystone_available; =20 #if IS_ENABLED(CONFIG_ASUS_WMI_DEPRECATED_ATTRS) if (attr =3D=3D &dev_attr_charge_mode.attr) @@ -5081,6 +5142,10 @@ static int asus_wmi_add(struct platform_device *pdev) if (err) goto fail_platform_profile_setup; =20 + err =3D keystone_check_present(asus); + if (err) + dev_warn(&pdev->dev, "Failed to check Keystone presence: %d\n", err); + err =3D asus_wmi_sysfs_init(asus->platform_device); if (err) goto fail_sysfs; diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/pla= tform_data/x86/asus-wmi.h index 554f41b827e1..c29962d5baac 100644 --- a/include/linux/platform_data/x86/asus-wmi.h +++ b/include/linux/platform_data/x86/asus-wmi.h @@ -147,6 +147,13 @@ #define ASUS_WMI_DEVID_GPU_MUX 0x00090016 #define ASUS_WMI_DEVID_GPU_MUX_VIVO 0x00090026 =20 +/* Keystone dongle insert/remove state. + * PRESENCE_BIT (0x00010000) encodes insert state: + * 0x00010000 =3D inserted, 0x00000000 =3D absent. STATUS_BIT is never set. + * 0xFFFFFFFE means no keystone slot on this machine. + */ +#define ASUS_WMI_DEVID_KEYSTONE 0x00120091 + /* TUF laptop RGB modes/colours */ #define ASUS_WMI_DEVID_TUF_RGB_MODE 0x00100056 #define ASUS_WMI_DEVID_TUF_RGB_MODE2 0x0010005A --=20 2.54.0