From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.175 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796024416; b=xadXaZR1JVovGWZgiQN4an61rDUKEu7sfHSlCLHowCQ3pDD9TLPcxzgTwJWtcMkxkL5u BZQzOJafi5YNU2OfpFkZLqfRZD/9LBKC7cWev12JU4P+irGW98FVVdw0Wn0FTU6XvybFp +VzyRYbycljzM24VFh4zBvh7bVbmbHqroRQcbzs2/uUd6HTY3isr5qcVV4CGv6HbDJnS3 yrp6mEESX2RPcUtv2+EDhCPUlUWat1rV/9B6Gow/oifm+21Qz3AkmlwTZ+LkHEbe5coxx FIpF8WgELAVSdws/MekDNGhlYxF8K/gFt9xZ0aBqgR7CRaNym7a/qCqwvupduK0s5Sw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796024416; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Message-ID:Date:MIME-Version:User-Agent:From:Subject:To:Cc: Content-Language:Content-Type:Content-Transfer-Encoding; bh=vPmLiIsjDHy5VLZcbudFLtSD6hdSZDkTHS32i2kKVa0=; b=p3kC7bSJnOHl7OgsMCN0qMxeT+kDsZ3apbTOdg5Oc3HqUjSk0RNXjV1Go+xC9VOI58nl fpYxmEqmC+2R213qwJ0YqFG2nVNH8Otrmf3oAwSoT64TMuazt08/iU23Eb26cHCQp+KFM sCICTMYq3n4u+uH7auxidw+i0HtKe8E9MYBadOTRZ+Jxc92vRJl7TkilG2bNRUwnFWepV Q0UFvbRFE/d8Trh8UADRYA8f+URtPvmJ+EidVkQnsmd5Y3Zs8oXvmcnVvnyH7AgvBb1Fm aIsceSc3jJd8FeRV2oa70JTPF5hjuDui1iON+zd+TTeLF01wAfuPJo6wMejTgHyLflw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=PrHq4rgP; arc=none smtp.remote-ip=209.85.210.175 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 61039606A31C for ; Mon, 30 Nov 2026 07:40:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 61039606A31C 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.a=rsa-sha256 header.s=20260707 header.b=PrHq4rgP Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-8a06cc097c7so6030697b3a.0 for ; Sun, 29 Nov 2026 23:40:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796024416; x=1796629216; darn=vger.kernel.org; h=content-transfer-encoding:content-type:content-language:cc:to :subject:from:user-agent:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to:content-type; bh=vPmLiIsjDHy5VLZcbudFLtSD6hdSZDkTHS32i2kKVa0=; b=PrHq4rgPQwUCJAlubygMqanMEyBbRIkbDA5hRzXS7W8O19st8Cj/wJnMAY0XUnj6Kq 6dgeBRLQ0pamDyh8H05Ufm6tqh55D/rumXoXi75ml+UIfH58B+PsZG2LF59eaI+/E1Ph yXXnyZWaM3OKdPLlmwMQpnOdKdkDI5e0B6XaLCDYx33K/75bud012n5apGY5E/Ei+HlQ Mcf2YaoJR7dxlPajmxb4arUmOXg6hFHAMz4apFDk3gzgj+fuXikMQ/Q3z8UEVxELL2KO fZt5qgdHDslKenReCGIYCdDkA+YM9XYr7dTwm7MRT3DFmEobi24Aw6b3nfk+BhxqguTE bSAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796024416; x=1796629216; h=content-transfer-encoding:content-type:content-language:cc:to :subject:from:user-agent:mime-version:date:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=vPmLiIsjDHy5VLZcbudFLtSD6hdSZDkTHS32i2kKVa0=; b=OI91bzS4FIvlrE/FobQnkUm3dYCNX9hM1mmk6GXFu9VcQYVM4iZfnYhM07odMGG4op EC4b2NbBVAuDmEBssMVIE+wlfwgn9ECNoJHrHXfQ55PGjRO0sDgYJ3YE87Ui7LHaXIls tY+/+BjzbyYp9mwGPzfv4rYNzEvS+vRxlZEnhbmEsnjcNbv9ChGpxjju/+0rK/AmxnOE 8tpt/IG0WcygYMlIiP9MaW7uP0+2crkYFR0vC96Iee0pJt5OJJFV/eUII752Ck+riskE DHXEtEsbXY+0leqenu9Ltb88W1zcmxcYU15R9dmAC/mlDwJAh7HeTSs3vUR/SLlZUJp1 No9w== X-Forwarded-Encrypted: i=1; AL+hErGhHp8E1MW4y+NuX4WEoZCW63g++P9ArIk/9snJ5CiFTorGtz6lpa6uI6/huyh8/E884+z3M4hdsXu5jks=@vger.kernel.org X-Gm-Message-State: APuU4Z/xWyXykLMAiwtBnh3GaXQwgAwVGwEujmj4LWizk1al0PhaH3fN BXV7lZjAtghyfLdVuuHxhndHCCT2+4jiGJhSqQuilhP+tdVK5rcx9vQk X-Gm-Gg: AZFdTZctU1jYWqi8Hj4O6u6JlzBCH+JS7w+Dp8K8shF95iJ1mhLi1jzWQSK3XLkg9sr meiFUhxoXT7Em00qJ0decMU8PYKxGKg2le40NVBXqICUODkwRmz8VNB3asmICXVIUXJ4ZStaCR2 BBBmjkEZWO3/a4xYI4lF+fDZXGMZzTiL/gR7gNphrnuSKZk1kx05LPnn4UUpU8fKdPRHVhJ0aot zQgWwOxsJTflyb7xvNFAnESRV8DGTJ97iuCn+bj4S9a4WMDdog3qf1pK9e7ILN0ZbeK5p/9a6df Flrq4phFHRh1deJe73dcE9TI/4Pm/hkIpiRbacxMMaYTnUZytOe/+gXkAcKoxIrb6i3TulpLodP XFgqYe6T3s7demhg8J8/tLsB6QEetoUOfyt65tTXbxTmc0wceckdUuZFIPITwIRLqs7D8smh17v eQ2BFDwhI75fB1OnqTD6o19FGa3ypsJMS9DJFdfjFsa0tmJ0YX22AUo4zlYqPomMp4gKJTyG+mv qugZJJRkCuT2+1KJmXAw0DI7FjqJty2ZRNibZ8aHeApPWf6qcrymq++y5mi+H0baSZnjqrxJKob 8Sjgs7XPEgssR08nI+sLP18paFVnm+X90mEm+kLHnQbebEmEeCu3We+vfTKeO8nXbyIEbZf4db8 I5Fauxy2QrA== X-Received: by 2002:a05:6a00:138f:b0:8b3:ce6d:8481 with SMTP id d2e1a72fcca58-8c87b4eea9cmr35002018b3a.16.1796024415621; Sun, 29 Nov 2026 23:40:15 -0800 (PST) Received: from ?IPV6:2607:f598:b3da:290:d166:e547:104c:84c3? ([2607:f598:b3da:290:d166:e547:104c:84c3]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8c872e485f5sm17398334b3a.22.2026.11.29.23.40.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 29 Nov 2026 23:40:15 -0800 (PST) Message-ID: Date: Sun, 29 Nov 2026 23:40:11 -0800 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Bozhen Peng Subject: [PATCH v3] platform/x86: bitland-mifs-wmi: Support WUJIE15 PRO HPT To: Mingyou Chen , Ilya Gladyshev Cc: Hans de Goede , Ilpo Jarvinen , Armin Wolf , Randy Dunlap , Jonathan Corbet , platform-driver-x86@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit My WUJIE15 PRO HPT uses performance (0), balanced (1) and low-power (2), which differ from the default mapping. USB-C is its only external power input. I use the ACPI adapter's _PSR to check power because the USB-C supply's cached ONLINE value can be stale after unplugging during suspend. Failed or invalid queries return an error. HPT reports two fans, in Fan 2/Fan 1 order, and no CPU temperature. I hide the unsupported GPU mode, keyboard RGB mode and fan-boost controls, while keeping keyboard backlight brightness available. Link: https://lkml.iu.edu/hypermail/linux/kernel/2611.2/17183.html Signed-off-by: Bozhen Peng --- Thanks everyone for your work, and Mingyou for the reminder! I've ported the WUJIE15 PRO HPT support to the new quirks framework. Changes in v3: - Use the existing quirks table on the post-merge pdx86/for-next base, as Mingyou suggested. - Drop the redmi-wmi change now that the drivers have been merged. - Drop the model-specific documentation section. I built the x86-64 kernel and modules and booted the matching 7.4.0-rc2 kernel on my WUJIE15 PRO HPT. I checked that the Bitland profile choices are low-power, balanced and performance. I tested s2idle resume. It kept performance with the charger connected and restored balanced after I unplugged the charger during sleep. drivers/platform/x86/bitland-mifs-wmi.c | 134 +++++++++++++++++++++++++++++--- 1 file changed, 124 insertions(+), 10 deletions(-) diff --git a/drivers/platform/x86/bitland-mifs-wmi.c b/drivers/platform/x86/bitland-mifs-wmi.c index 7bad8942249d43bd378d7adf8da26261fd684df7..88b35afe02a3ce65d53433387e23b848e4e64d29 100644 --- a/drivers/platform/x86/bitland-mifs-wmi.c +++ b/drivers/platform/x86/bitland-mifs-wmi.c @@ -94,10 +94,24 @@ struct bitland_profile_entry { bool battery; /* Set in place of the AC entry while on battery */ }; +struct bitland_hwmon_config { + const struct hwmon_chip_info *chip_info; + const char * const *fan_labels; + size_t num_fans; +}; + +static const struct bitland_hwmon_config default_hwmon_config; +static const struct bitland_hwmon_config hpt_hwmon_config; + +static int bitland_hpt_check_performance_capability(void); + struct bitland_mifs_quirks { const struct bitland_profile_entry *profile_entries; size_t num_profile_entries; + int (*check_performance_capability)(void); + const struct bitland_hwmon_config *hwmon; + bool disable_extra_controls; bool return_code_at_end; bool skip_ac_type_check; }; @@ -140,6 +154,20 @@ static const struct bitland_mifs_quirks tm2424_quirks = { .skip_ac_type_check = true, }; +static const struct bitland_profile_entry hpt_profile_entries[] = { + { PLATFORM_PROFILE_LOW_POWER, 0x02 }, + { PLATFORM_PROFILE_BALANCED, 0x01 }, + { PLATFORM_PROFILE_PERFORMANCE, 0x00 }, +}; + +static const struct bitland_mifs_quirks hpt_quirks = { + .profile_entries = hpt_profile_entries, + .num_profile_entries = ARRAY_SIZE(hpt_profile_entries), + .check_performance_capability = bitland_hpt_check_performance_capability, + .hwmon = &hpt_hwmon_config, + .disable_extra_controls = true, +}; + static const struct dmi_system_id bitland_mifs_dmi_table[] = { { .matches = { @@ -155,6 +183,14 @@ static const struct dmi_system_id bitland_mifs_dmi_table[] = { }, .driver_data = (void *)&tm2424_quirks, }, + { + .matches = { + DMI_EXACT_MATCH(DMI_SYS_VENDOR, "MECHREVO"), + DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "WUJIE15 PRO"), + DMI_EXACT_MATCH(DMI_BOARD_NAME, "WUJIE15 Series-HPT"), + }, + .driver_data = (void *)&hpt_quirks, + }, {} }; @@ -344,6 +380,25 @@ static int laptop_profile_get(struct device *dev, return -EINVAL; } +static int bitland_hpt_check_performance_capability(void) +{ + struct acpi_device *adapter; + unsigned long long online; + acpi_status status; + + adapter = acpi_dev_get_first_match_dev("ACPI0003", NULL, -1); + if (!adapter) + return -ENODEV; + + /* USB-C ONLINE may be stale on resume; _PSR reads current EC state. */ + status = acpi_evaluate_integer(adapter->handle, "_PSR", NULL, &online); + acpi_dev_put(adapter); + if (ACPI_FAILURE(status) || online > 1) + return -EIO; + + return online ? 0 : -EOPNOTSUPP; +} + static int bitland_pp_check_capability(struct bitland_mifs_wmi_data *data) { struct bitland_mifs_input input = { @@ -353,6 +408,9 @@ static int bitland_pp_check_capability(struct bitland_mifs_wmi_data *data) struct bitland_mifs_output_head_rc output; int ret; + if (data->quirks->check_performance_capability) + return data->quirks->check_performance_capability(); + if (data->quirks->skip_ac_type_check) return power_supply_is_system_supplied() > 0 ? 0 : -EOPNOTSUPP; @@ -552,12 +610,21 @@ static const struct platform_profile_ops laptop_profile_ops = { .profile_set = laptop_profile_set, }; -static const char *const fan_labels[] = { +static const char * const default_fan_labels[] = { "CPU", /* 0 */ "GPU", /* 1 */ "SYS", /* 2 */ }; +/* The HPT firmware returns Fan 2 before Fan 1. */ +static const char * const hpt_fan_labels[] = { "Fan 2", "Fan 1" }; + +static const struct bitland_hwmon_config * +bitland_hwmon_config(const struct bitland_mifs_wmi_data *data) +{ + return data->quirks->hwmon ?: &default_hwmon_config; +} + static int laptop_hwmon_read(struct device *dev, enum hwmon_sensor_types type, u32 attr, int channel, long *val) { @@ -603,13 +670,15 @@ static int laptop_hwmon_read_string(struct device *dev, enum hwmon_sensor_types type, u32 attr, int channel, const char **str) { - if (type == hwmon_fan && attr == hwmon_fan_label) { - if (channel >= 0 && channel < ARRAY_SIZE(fan_labels)) { - *str = fan_labels[channel]; - return 0; - } - } - return -EINVAL; + struct bitland_mifs_wmi_data *data = dev_get_drvdata(dev); + const struct bitland_hwmon_config *config = bitland_hwmon_config(data); + + if (type != hwmon_fan || attr != hwmon_fan_label || + channel < 0 || channel >= config->num_fans) + return -EINVAL; + + *str = config->fan_labels[channel]; + return 0; } static const struct hwmon_channel_info *laptop_hwmon_info[] = { @@ -620,6 +689,12 @@ static const struct hwmon_channel_info *laptop_hwmon_info[] = { NULL }; +static const struct hwmon_channel_info *hpt_hwmon_info[] = { + HWMON_CHANNEL_INFO(fan, HWMON_F_INPUT | HWMON_F_LABEL, + HWMON_F_INPUT | HWMON_F_LABEL), + NULL +}; + static const struct hwmon_ops laptop_hwmon_ops = { .visible = 0444, .read = laptop_hwmon_read, @@ -631,6 +706,23 @@ static const struct hwmon_chip_info laptop_chip_info = { .info = laptop_hwmon_info, }; +static const struct hwmon_chip_info hpt_chip_info = { + .ops = &laptop_hwmon_ops, + .info = hpt_hwmon_info, +}; + +static const struct bitland_hwmon_config default_hwmon_config = { + .chip_info = &laptop_chip_info, + .fan_labels = default_fan_labels, + .num_fans = ARRAY_SIZE(default_fan_labels), +}; + +static const struct bitland_hwmon_config hpt_hwmon_config = { + .chip_info = &hpt_chip_info, + .fan_labels = hpt_fan_labels, + .num_fans = ARRAY_SIZE(hpt_fan_labels), +}; + static int laptop_kbd_led_set(struct led_classdev *led_cdev, enum led_brightness value) { @@ -809,7 +901,27 @@ static const struct attribute *const laptop_attrs[] = { &dev_attr_fan_boost.attr, NULL, }; -ATTRIBUTE_GROUPS(laptop); + +static umode_t laptop_attr_is_visible(struct kobject *kobj, + const struct attribute *attr, int n) +{ + struct bitland_mifs_wmi_data *data = dev_get_drvdata(kobj_to_dev(kobj)); + + if (data->quirks->disable_extra_controls) + return 0; + + return attr->mode; +} + +static const struct attribute_group laptop_group = { + .attrs_const = laptop_attrs, + .is_visible_const = laptop_attr_is_visible, +}; + +static const struct attribute_group *laptop_groups[] = { + &laptop_group, + NULL +}; static const struct key_entry bitland_mifs_wmi_keymap[] = { { KE_KEY, BI_HOTKEY_CODE(WMI_EVENT_OPEN_APP, 1, 0), { KEY_PROG1 } }, @@ -900,6 +1012,7 @@ static int bitland_notifier_callback(struct notifier_block *nb, static int bitland_mifs_wmi_probe(struct wmi_device *wdev, const void *context) { + const struct bitland_hwmon_config *hwmon; struct bitland_mifs_wmi_data *drv_data; enum bitland_wmi_device_type dev_type = (enum bitland_wmi_device_type)(unsigned long)context; @@ -971,10 +1084,11 @@ static int bitland_mifs_wmi_probe(struct wmi_device *wdev, const void *context) } /* Register hwmon */ + hwmon = bitland_hwmon_config(drv_data); drv_data->hwmon_dev = devm_hwmon_device_register_with_info(&wdev->dev, "bitland_mifs", drv_data, - &laptop_chip_info, + hwmon->chip_info, NULL); if (IS_ERR(drv_data->hwmon_dev)) return PTR_ERR(drv_data->hwmon_dev); base-commit: 9c82959c37bf69c2ace8a0f975cf2129ec1fd982