#define NOTIFY_KBD_TTP 0xae
#define NOTIFY_LID_FLIP 0xfa
#define NOTIFY_LID_FLIP_ROG 0xbd
+#define NOTIFY_KEYSTONE 0xb4
#define ASUS_WMI_FNLOCK_BIOS_DISABLED BIT(0)
u32 tablet_switch_dev_id;
bool tablet_switch_inverted;
+ bool keystone_available;
+
enum fan_type fan_type;
enum fan_type gpu_fan_type;
enum fan_type mid_fan_type;
return status == 0 && (retval & ASUS_WMI_DSTS_PRESENCE_BIT);
}
+/* Keystone *******************************************************************/
+
+static int keystone_check_present(struct asus_wmi *asus)
+{
+ u32 retval;
+ int err;
+
+ asus->keystone_available = 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 = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_KEYSTONE, &retval);
+ if (err == -ENODEV)
+ return 0;
+ if (err)
+ return err;
+
+ asus->keystone_available = true;
+ return 0;
+}
+
+static ssize_t keystone_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct asus_wmi *asus = dev_get_drvdata(dev);
+ u32 retval;
+ int err;
+
+ err = 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)
{
return;
}
+ if (code == NOTIFY_KEYSTONE) {
+ if (asus->keystone_available)
+ asus_wmi_keystone_notify(asus);
+ return;
+ }
+
if (code == NOTIFY_KBD_FBM || code == NOTIFY_KBD_TTP) {
if (asus->fan_boost_mode_available)
fan_boost_mode_switch_next(asus);
&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,
devid = ASUS_WMI_DEVID_ALS_ENABLE;
else if (attr == &dev_attr_fan_boost_mode.attr)
ok = asus->fan_boost_mode_available;
+ else if (attr == &dev_attr_keystone.attr)
+ ok = asus->keystone_available;
#if IS_ENABLED(CONFIG_ASUS_WMI_DEPRECATED_ATTRS)
if (attr == &dev_attr_charge_mode.attr)
if (err)
goto fail_platform_profile_setup;
+ err = keystone_check_present(asus);
+ if (err)
+ dev_warn(&pdev->dev, "Failed to check Keystone presence: %d\n", err);
+
err = asus_wmi_sysfs_init(asus->platform_device);
if (err)
goto fail_sysfs;