From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.182 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796024417; b=HAtamfGl0ZcbCyhZwiQxCeT8KQ6csd8dC7KVw+AMMUOTkdILtGPuJeqe9qROiFqlaqIl CO2XeKhniYONrN4U3IkHU54EMJi2sguzwfzjXybWbfFLSi6FIMS3NDWdGEErt4/T4GQQt wcpnNI2TXgnuzFn21FWVyfa19owvYlgs1yJb8Q5bFXs7pLrW+fds+Cwlisx931kJMOrj9 DXJTUTp4LEKA7atz3sa2BGAJqIj4jeXGAj9JFe9kR1kttq0XsAR3uCMf0Ke4LBeJtL9d+ uoPmImdD7eLs2dFsntrGHQev3vP/Rpx71uV2hLs+vARkdi+hhh/PU6/P8YlXZ5jOwSQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796024417; 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=Rpfw6JHnGuN4WZXQi3/5MRASell/inuhXF6bzNQnvlDWb5wu3LHu43I0A7afsdWo24CL 1C46Dub5FeHR4hBrt2n+9evTV2UGBpR4VecXqhzQ5B1E+abgZ9E2t99lNsLEXGYyvGXcW ZERaM1/RO01skYPYIetBU55M09x+V0P/O/CyRiw72IMUkNOycjRwLN6g2JDkcpEv8+pvo ClloiEIBIJ6G+GFSDwPD9CmHtHmTP0eZpTuI70A8lrTmfGNOs9Ih+cGf+lFgQNpefz2Ay IvgKNMEzYjT4NlWPoOnLp8STQ5qpsg6ATRFoqgmcQ/AgZWy544kztfTgNpYxsd3hhow== 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.182 Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) (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 70E38606A320 for ; Mon, 30 Nov 2026 07:40:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 70E38606A320 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-f182.google.com with SMTP id d2e1a72fcca58-8b68e59ab33so7358723b3a.2 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=lDhfy3CKW8KbchxdBafZTWwgk7SfTnCanMxcCPx9gdqkEZeAxPBI9WE0Jv49xIJQlA StHtCOr8isvgRh2cJ+QDzCJOQfwxIozPGejuBuLG0atO+pbRtX//NX9XSk64VXIoYQk3 0JwiTeFi1s5LHFjEGZCzD+Txm0+X9hZADpO7MvU2LfbXx5bAdbulm1V9iNWROb03ZqhV OUxzk0hLrO3Ao+tsOOmsWOPFTH0U5bwMvnIjEER7I3uTsGzo7IbVXiOkSdbHUNgG2a7y 7PUmHu5c2mvWe5ZlO00xcZJDp6HsfwPfcbKLJjIGwqt5UhhmW1vwhszA8By/z8BlbRnf 7uwA== X-Forwarded-Encrypted: i=1; AL+hErFhuRCbMeNv+Epk8SbHiPxniysJ8NIUJFnOHx0Cju6pK4dN34YLTJj0VWw34NaH+jU5twIRkGdGXJ7XiKxNZTpsu837@vger.kernel.org X-Gm-Message-State: APuU4Z+A+OwaGWglloV/8YNyB08jv2xJ4y/23+n2XCWzJvRAt3RI/bWz Z9uuMJ5gaHG3JSXqkeMMUyHEcWBB3NXOMTpuo3Y5Vx8B9bSw+Sm9mJVe X-Gm-Gg: AZFdTZf87yK7wbc9guc4JJqQ6dSD2cx/9XwSNJpZbW7JOsQf6vjZuYxtiP8IwoPa/vr 5xurBV10e8x3gqDgtEKAq0seeO0F8c2pkpnzuLVymNCmwvwdmRgFVKct9Nw0oOFF90qLOVoqIxO kJ9tas/IpGKdHkp7ZzN3oobhui5MM924CMRt2pTEzGvrQNZin6ShgKJmAiK/HG+8yqNUVa5QysJ qoYukd+pprQdl1FWNJkiGCTBlG8GMCJkwBo9dmchk7UsxNnP+J8R3kmjynTLCLzkHfSxzj2ktgU 564cpEcddhDgQ8zliHzJ6Qg8MtMVYd3fih7paTWeogPlSFM1Hx9YhOxB6f0EDKLa5QmKgOwasry yunHAe+jmngfKk/iKwpphMqJqGXAtIo2KfXpz81h664ljg3g8X+0to4tnNRCqo/tNdKk8j9bPA6 qSm+UyBUUL7Xh/vhGXrNkt3IFxT+A6XtK2CAANb90uGvr8wggxB6PENdcx3JdI0MPaZR1SUeFuq 92uxi/OMxUxLK+Xw7CUPIAqGhxFse+3vvfMFZuqxKkOdsPZqYjFqrnUDrniMuF4aZ5Lr0W0ZVho /AX/6nfn6tDCQjXP2RxLknIDnS1Z9aGj5fS3GoDPN6hJDMB8ywyPKhU70JkOQzngRXi0XWFAOuP WfTHEG3yYSw== 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: platform-driver-x86@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