From nobody Mon Feb 9 19:26:46 2026 Received: from wfout3-smtp.messagingengine.com (wfout3-smtp.messagingengine.com [64.147.123.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E15EA1119B; Tue, 2 Apr 2024 02:26:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.146 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712024785; cv=none; b=YJeRJQgxIY3xg2HtfhE9ynZ2cw/XOzzkRJC/ohomAhoi7LLcnW9ZUKz+iHdWPQ+ta9SClVMGY0NLVtEys3bIrozoGeaqL0MkDTHH/NqGt/DDfwmWUew6wI1AldMUm55OD6fg8aCKkt6FItJg6zGZfQ//CCcRILPJxufuTzwLLxs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712024785; c=relaxed/simple; bh=qSmsh9/IR3rOAqrNHFgQnDe/gM7dkXYBsU0kaq+U+2U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jtQL0wrfZXrLqYTO5HY8g+0nojqpwtYHMn2yqIYH+p5oERGaD03sOj9mbKcgbwplKw8okrLqgYbU7zo2bNw4jjget47KV3j40paGqCXSbm/IkbDMVIwYHIEWK8hDJ4Hqrtzi+4JNllbBCZgKGKkmGppQ2GaRd/RRRJ2xfsr85E8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ljones.dev; spf=none smtp.mailfrom=ljones.dev; dkim=pass (2048-bit key) header.d=ljones.dev header.i=@ljones.dev header.b=iysiQSDl; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=TJhtFYqM; arc=none smtp.client-ip=64.147.123.146 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ljones.dev Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ljones.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ljones.dev header.i=@ljones.dev header.b="iysiQSDl"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="TJhtFYqM" Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailfout.west.internal (Postfix) with ESMTP id B3A7D1C000A6; Mon, 1 Apr 2024 22:26:21 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Mon, 01 Apr 2024 22:26:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ljones.dev; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm3; t=1712024781; x= 1712111181; bh=PWlttQ05zh32ghVePLcr881KF2PLwTz0eDgDhUTn+EM=; b=i ysiQSDloWLEXALkhjpmHK5zE3u5zd3Yvr/1pYxoC13y8QAcr9gzyUxUIeqnCjxTY 0Kl7WfiE3I7UU5zuPVw6uXGgbu355AUJ1eJkBo8l6/UobYlR+AnHRwOQKmH9sAH5 FXNtTahLUUHBZPDpS0gjrHAZXrwO6nnX/fW0XhA9MGTJUCJ0qjAtZYgg75vlc+Ii fGT68f1ksIHc3AW3fYVMi+jTTU73cqrY0qDj6t2vLnkZQs8nXiAhIn9v9MZDNGZG xIW60jDS2c1OyKQdOFZOK92z3KxtwEcy5A5FBQ9DLXvevSVQwnO/4tAGOAkrLuZU tBtf3+jH30v4bcFuwNTGA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1712024781; x= 1712111181; bh=PWlttQ05zh32ghVePLcr881KF2PLwTz0eDgDhUTn+EM=; b=T JhtFYqMUxWSXzByx1MKryF/0WR27Rey9oxe1ATzoPwgzcbmBgiGFS4wUFw3H7YEF Lp+/pawgqtSPT3sh/QWwfmHKQ+9Q8ZX+AlKcNfZo5Vn/GDZ64nWGmw5gIanOo+79 WMq95Dy4ILlgIQdgdEO8NG7S3bz8P9gCLuf0qFplZzHTaHmnspcp2+k0sf3HADJy FI/6oIq3ff5mdh33CyZrJ70BmZWHlzl8qztxq9VpEJ+sGqUPEjKrxx4iY5NStv1x lKDYufX2y5v8jS8Brd1uFmJ55tJNy/vzIleYDYGRnGOWFIB1nPetB+EWiNQxLzhi SqioRvMfLFTcSRCKhM+Tg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudefuddgheekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpedfnfhukhgvucffrdculfhonhgvshdfuceolhhukhgvsehl jhhonhgvshdruggvvheqnecuggftrfgrthhtvghrnhepgfetfedugfetudeuheetjefhue fggfelleetvdevtefhueeujeefvdegleevhefgnecuvehluhhsthgvrhfuihiivgeptden ucfrrghrrghmpehmrghilhhfrhhomheplhhukhgvsehljhhonhgvshdruggvvh X-ME-Proxy: Feedback-ID: i5ec1447f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 1 Apr 2024 22:26:18 -0400 (EDT) From: "Luke D. Jones" To: hdegoede@redhat.com Cc: corentin.chary@gmail.com, ilpo.jarvinen@linux.intel.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, "Luke D. Jones" Subject: [PATCH v2 1/9] platform/x86: asus-wmi: add support for 2024 ROG Mini-LED Date: Tue, 2 Apr 2024 15:25:59 +1300 Message-ID: <20240402022607.34625-2-luke@ljones.dev> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240402022607.34625-1-luke@ljones.dev> References: <20240402022607.34625-1-luke@ljones.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Support the 2024 mini-led backlight and adjust the related functions to select the relevant dev-id. Also add `available_mini_led_mode` to the platform sysfs since the available mini-led levels can be different. Signed-off-by: Luke D. Jones --- .../ABI/testing/sysfs-platform-asus-wmi | 8 ++ drivers/platform/x86/asus-wmi.c | 80 ++++++++++++++++--- include/linux/platform_data/x86/asus-wmi.h | 1 + 3 files changed, 78 insertions(+), 11 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-platform-asus-wmi b/Documentat= ion/ABI/testing/sysfs-platform-asus-wmi index 8a7e25bde085..ef1ac1a20a71 100644 --- a/Documentation/ABI/testing/sysfs-platform-asus-wmi +++ b/Documentation/ABI/testing/sysfs-platform-asus-wmi @@ -126,6 +126,14 @@ Description: Change the mini-LED mode: * 0 - Single-zone, * 1 - Multi-zone + * 2 - Multi-zone strong (available on newer generation mini-led) + +What: /sys/devices/platform//available_mini_led_mode +Date: Apr 2024 +KernelVersion: 6.10 +Contact: "Luke Jones" +Description: + List the available mini-led modes. =20 What: /sys/devices/platform//ppt_pl1_spl Date: Jun 2023 diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wm= i.c index 3f07bbf809ef..2330f02ff76f 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -288,7 +288,7 @@ struct asus_wmi { bool battery_rsoc_available; =20 bool panel_overdrive_available; - bool mini_led_mode_available; + u32 mini_led_dev_id; =20 struct hotplug_slot hotplug_slot; struct mutex hotplug_lock; @@ -2108,13 +2108,30 @@ static ssize_t mini_led_mode_show(struct device *de= v, struct device_attribute *attr, char *buf) { struct asus_wmi *asus =3D dev_get_drvdata(dev); - int result; + u32 value; =20 - result =3D asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_MINI_LED_MOD= E); - if (result < 0) - return result; + asus_wmi_get_devstate(asus, asus->mini_led_dev_id, &value); + value =3D value & 0x03; // only 3 modes on 2024 version =20 - return sysfs_emit(buf, "%d\n", result); + /* Remap the mode values to match previous generation mini-led. + * Some BIOSes return -19 instead of 2, which is "mini-LED off", this + * appears to be a BIOS bug. + */ + if (asus->mini_led_dev_id =3D=3D ASUS_WMI_DEVID_MINI_LED_MODE2) { + switch (value) { + case 0: + value =3D 1; + break; + case 1: + value =3D 2; + break; + case 2: + value =3D 0; + } + } else if (value < 0) { + return value; + } + return sysfs_emit(buf, "%d\n", value); } =20 static ssize_t mini_led_mode_store(struct device *dev, @@ -2130,11 +2147,28 @@ static ssize_t mini_led_mode_store(struct device *d= ev, if (result) return result; =20 - if (mode > 1) + if (mode > 1 && asus->mini_led_dev_id =3D=3D ASUS_WMI_DEVID_MINI_LED_MODE) return -EINVAL; + if (mode > 2 && asus->mini_led_dev_id =3D=3D ASUS_WMI_DEVID_MINI_LED_MODE= 2) + return -EINVAL; + /* + * Remap the mode values so expected behaviour is the same as the last + * generation of mini-LED + */ + if (asus->mini_led_dev_id =3D=3D ASUS_WMI_DEVID_MINI_LED_MODE2) { + switch (mode) { + case 0: + mode =3D 2; + break; + case 1: + mode =3D 0; + break; + case 2: + mode =3D 1; + } + } =20 - err =3D asus_wmi_set_devstate(ASUS_WMI_DEVID_MINI_LED_MODE, mode, &result= ); - + err =3D asus_wmi_set_devstate(asus->mini_led_dev_id, mode, &result); if (err) { pr_warn("Failed to set mini-LED: %d\n", err); return err; @@ -2151,6 +2185,23 @@ static ssize_t mini_led_mode_store(struct device *de= v, } static DEVICE_ATTR_RW(mini_led_mode); =20 +static ssize_t available_mini_led_mode_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct asus_wmi *asus =3D dev_get_drvdata(dev); + + switch (asus->mini_led_dev_id) { + case ASUS_WMI_DEVID_MINI_LED_MODE: + return sysfs_emit(buf, "0 1\n"); + case ASUS_WMI_DEVID_MINI_LED_MODE2: + return sysfs_emit(buf, "0 1 2\n"); + } + + return sysfs_emit(buf, "0\n"); +} + +static DEVICE_ATTR_RO(available_mini_led_mode); + /* Quirks ****************************************************************= *****/ =20 static void asus_wmi_set_xusb2pr(struct asus_wmi *asus) @@ -4139,6 +4190,7 @@ static struct attribute *platform_attributes[] =3D { &dev_attr_nv_temp_target.attr, &dev_attr_panel_od.attr, &dev_attr_mini_led_mode.attr, + &dev_attr_available_mini_led_mode.attr, NULL }; =20 @@ -4191,7 +4243,9 @@ static umode_t asus_sysfs_is_visible(struct kobject *= kobj, else if (attr =3D=3D &dev_attr_panel_od.attr) ok =3D asus->panel_overdrive_available; else if (attr =3D=3D &dev_attr_mini_led_mode.attr) - ok =3D asus->mini_led_mode_available; + ok =3D asus->mini_led_dev_id !=3D 0; + else if (attr =3D=3D &dev_attr_available_mini_led_mode.attr) + ok =3D asus->mini_led_dev_id !=3D 0; =20 if (devid !=3D -1) ok =3D !(asus_wmi_get_devstate_simple(asus, devid) < 0); @@ -4444,10 +4498,14 @@ static int asus_wmi_add(struct platform_device *pde= v) asus->nv_dyn_boost_available =3D asus_wmi_dev_is_present(asus, ASUS_WMI_D= EVID_NV_DYN_BOOST); asus->nv_temp_tgt_available =3D asus_wmi_dev_is_present(asus, ASUS_WMI_DE= VID_NV_THERM_TARGET); asus->panel_overdrive_available =3D asus_wmi_dev_is_present(asus, ASUS_WM= I_DEVID_PANEL_OD); - asus->mini_led_mode_available =3D asus_wmi_dev_is_present(asus, ASUS_WMI_= DEVID_MINI_LED_MODE); asus->ally_mcu_usb_switch =3D acpi_has_method(NULL, ASUS_USB0_PWR_EC0_CSE= E) && dmi_match(DMI_BOARD_NAME, "RC71L"); =20 + if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_MINI_LED_MODE)) + asus->mini_led_dev_id =3D ASUS_WMI_DEVID_MINI_LED_MODE; + else if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_MINI_LED_MODE2)) + asus->mini_led_dev_id =3D ASUS_WMI_DEVID_MINI_LED_MODE2; + err =3D fan_boost_mode_check_present(asus); if (err) goto fail_fan_boost_mode; diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/pla= tform_data/x86/asus-wmi.h index ab1c7deff118..9cadce10ad9a 100644 --- a/include/linux/platform_data/x86/asus-wmi.h +++ b/include/linux/platform_data/x86/asus-wmi.h @@ -71,6 +71,7 @@ #define ASUS_WMI_DEVID_LID_FLIP 0x00060062 #define ASUS_WMI_DEVID_LID_FLIP_ROG 0x00060077 #define ASUS_WMI_DEVID_MINI_LED_MODE 0x0005001E +#define ASUS_WMI_DEVID_MINI_LED_MODE2 0x0005002E =20 /* Storage */ #define ASUS_WMI_DEVID_CARDREADER 0x00080013 --=20 2.44.0 From nobody Mon Feb 9 19:26:46 2026 Received: from wfout3-smtp.messagingengine.com (wfout3-smtp.messagingengine.com [64.147.123.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 57A4D14003; Tue, 2 Apr 2024 02:26:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.146 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712024789; cv=none; b=I/xaQ1beifhD5wf4c3EbZKIDQPKQSz6oSaOsC2yadU+cUbKewx6MT9cP8XLCpjiSVTFqYnYaJSMcta+a8MyL1Ln59QYQMY82iMqQSvX6KYAop0lyjqEaEx834UWTwtosjgpl47N5v5TGzyKamNCCEKT07LAtqB0HLBVjeBqftm0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712024789; c=relaxed/simple; bh=Yx+3WmSsz+NPr8WZNCY2nTQdyVHc18JH0+8Yquj71ec=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tDk6JJdyr5CYtAi+aJKlbaQ7HQDtF+/RYRjEVt2NMm8oGDDLSlBMgdTp4G4x6wLZJXTL2KGjeCtjZEEFzcVOhUaXiqwQJgR1Ja80omZ2S85scLRCS7z4i2XF+B/AlQ2M7/Ree6JI/aYGB8QQeSs8rJU+pqc/1nfeCO2pFnb2yqk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ljones.dev; spf=none smtp.mailfrom=ljones.dev; dkim=pass (2048-bit key) header.d=ljones.dev header.i=@ljones.dev header.b=bDG3MInv; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=nC7FM6pX; arc=none smtp.client-ip=64.147.123.146 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ljones.dev Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ljones.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ljones.dev header.i=@ljones.dev header.b="bDG3MInv"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="nC7FM6pX" Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailfout.west.internal (Postfix) with ESMTP id F0AFC1C000D0; Mon, 1 Apr 2024 22:26:25 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Mon, 01 Apr 2024 22:26:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ljones.dev; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm3; t=1712024785; x= 1712111185; bh=erdmGTaD3HvDZKlB15DdC5j7W9Wro6lcol+amycaFKI=; b=b DG3MInvtcx7G5L8hjCI2jJTA6d2zLl1eAZyevCqxFZ7omZf9UQwmPAlE+X0x7oOW kS5dl9VAF0ZdspmCagGz8XOkMbPtB9QJCyf5oluFvmf6fKgs7Hl7G8gVw1PVtj0Z YCl6X5SBwEL9N/uDvtqw1tpeSmEQNi7H+nIoaFR25UpxGtTA8ouBk2CvBfcCaqLu SeD625/MmS40+aODQAeUuraNh2BkzDORhZDLxjyZ14Iunaj651sLUssJsh6EFO+9 XYceAYne9t+dawx5PWov/Sz+wYzokXcZ0zHpKkqh0H3MORENlIWGoFkgzrjKmnce Rq/Y6gouhEbnqs1RPC0BQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1712024785; x= 1712111185; bh=erdmGTaD3HvDZKlB15DdC5j7W9Wro6lcol+amycaFKI=; b=n C7FM6pX5HYcxLplsISXjB8M9ThSqLaBlzw+Xx+cvbcJBSEmuQpROKA1Vz4ICALox mWuccOERtI6ei04YhyBAP4JT3KIYgutkeS8ctRMWR+2s9ECW+zSIoSeXtgQBHi8J l6xzmHgaAzsUS8JpydLEp/VuoaYIJj15ny7N/MqeFPNH1pQeyBaFlsWYkZ2h5TZs rnU4uvFDH3r8rii26VDOENhTWAZDUkkmdaRnKa1vFOoNnqbsFMppWB9DY2smqLme 4zVntqDbgCjFQe4XCcrmRfHsneZEdPcoV8ycE0M/aU5bd0eAMM2WR0qw8WCy1NZY aOTERxljU1XKa7bQL9veg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudefuddgheekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpedfnfhukhgvucffrdculfhonhgvshdfuceolhhukhgvsehl jhhonhgvshdruggvvheqnecuggftrfgrthhtvghrnhepgfetfedugfetudeuheetjefhue fggfelleetvdevtefhueeujeefvdegleevhefgnecuvehluhhsthgvrhfuihiivgeptden ucfrrghrrghmpehmrghilhhfrhhomheplhhukhgvsehljhhonhgvshdruggvvh X-ME-Proxy: Feedback-ID: i5ec1447f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 1 Apr 2024 22:26:22 -0400 (EDT) From: "Luke D. Jones" To: hdegoede@redhat.com Cc: corentin.chary@gmail.com, ilpo.jarvinen@linux.intel.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, "Luke D. Jones" Subject: [PATCH v2 2/9] platform/x86: asus-wmi: add support for Vivobook GPU MUX Date: Tue, 2 Apr 2024 15:26:00 +1300 Message-ID: <20240402022607.34625-3-luke@ljones.dev> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240402022607.34625-1-luke@ljones.dev> References: <20240402022607.34625-1-luke@ljones.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add support for the Vivobook dgpu MUX available on the ASUS Viviobook and some of the other ranges (Zen). This MUX functions exactly the same as the existing ROG MUX support so the existing functionality now detects which MUX is available and uses that for control. Signed-off-by: Luke D. Jones Reviewed-by: Ilpo J=C3=A4rvinen --- drivers/platform/x86/asus-wmi.c | 22 +++++++++++++--------- include/linux/platform_data/x86/asus-wmi.h | 1 + 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wm= i.c index 2330f02ff76f..797531300138 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -259,7 +259,7 @@ struct asus_wmi { bool egpu_enable_available; bool egpu_connect_available; bool dgpu_disable_available; - bool gpu_mux_mode_available; + u32 gpu_mux_dev; =20 /* Tunables provided by ASUS for gaming laptops */ bool ppt_pl2_sppt_available; @@ -682,8 +682,8 @@ static ssize_t dgpu_disable_store(struct device *dev, if (disable > 1) return -EINVAL; =20 - if (asus->gpu_mux_mode_available) { - result =3D asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_GPU_MUX); + if (asus->gpu_mux_dev) { + result =3D asus_wmi_get_devstate_simple(asus, asus->gpu_mux_dev); if (result < 0) /* An error here may signal greater failure of GPU handling */ return result; @@ -748,8 +748,8 @@ static ssize_t egpu_enable_store(struct device *dev, return err; } =20 - if (asus->gpu_mux_mode_available) { - result =3D asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_GPU_MUX); + if (asus->gpu_mux_dev) { + result =3D asus_wmi_get_devstate_simple(asus, asus->gpu_mux_dev); if (result < 0) { /* An error here may signal greater failure of GPU handling */ pr_warn("Failed to get gpu mux status: %d\n", result); @@ -802,7 +802,7 @@ static ssize_t gpu_mux_mode_show(struct device *dev, struct asus_wmi *asus =3D dev_get_drvdata(dev); int result; =20 - result =3D asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_GPU_MUX); + result =3D asus_wmi_get_devstate_simple(asus, asus->gpu_mux_dev); if (result < 0) return result; =20 @@ -848,7 +848,7 @@ static ssize_t gpu_mux_mode_store(struct device *dev, } } =20 - err =3D asus_wmi_set_devstate(ASUS_WMI_DEVID_GPU_MUX, optimus, &result); + err =3D asus_wmi_set_devstate(asus->gpu_mux_dev, optimus, &result); if (err) { dev_err(dev, "Failed to set GPU MUX mode: %d\n", err); return err; @@ -4221,7 +4221,7 @@ static umode_t asus_sysfs_is_visible(struct kobject *= kobj, else if (attr =3D=3D &dev_attr_dgpu_disable.attr) ok =3D asus->dgpu_disable_available; else if (attr =3D=3D &dev_attr_gpu_mux_mode.attr) - ok =3D asus->gpu_mux_mode_available; + ok =3D asus->gpu_mux_dev !=3D 0; 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_throttle_thermal_policy.attr) @@ -4487,7 +4487,6 @@ static int asus_wmi_add(struct platform_device *pdev) asus->egpu_enable_available =3D asus_wmi_dev_is_present(asus, ASUS_WMI_DE= VID_EGPU); asus->egpu_connect_available =3D asus_wmi_dev_is_present(asus, ASUS_WMI_D= EVID_EGPU_CONNECTED); asus->dgpu_disable_available =3D asus_wmi_dev_is_present(asus, ASUS_WMI_D= EVID_DGPU); - asus->gpu_mux_mode_available =3D asus_wmi_dev_is_present(asus, ASUS_WMI_D= EVID_GPU_MUX); asus->kbd_rgb_mode_available =3D asus_wmi_dev_is_present(asus, ASUS_WMI_D= EVID_TUF_RGB_MODE); asus->kbd_rgb_state_available =3D asus_wmi_dev_is_present(asus, ASUS_WMI_= DEVID_TUF_RGB_STATE); asus->ppt_pl2_sppt_available =3D asus_wmi_dev_is_present(asus, ASUS_WMI_D= EVID_PPT_PL2_SPPT); @@ -4506,6 +4505,11 @@ static int asus_wmi_add(struct platform_device *pdev) else if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_MINI_LED_MODE2)) asus->mini_led_dev_id =3D ASUS_WMI_DEVID_MINI_LED_MODE2; =20 + if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_GPU_MUX)) + asus->gpu_mux_dev =3D ASUS_WMI_DEVID_GPU_MUX; + else if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_GPU_MUX_VIVO)) + asus->gpu_mux_dev =3D ASUS_WMI_DEVID_GPU_MUX_VIVO; + err =3D fan_boost_mode_check_present(asus); if (err) goto fail_fan_boost_mode; diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/pla= tform_data/x86/asus-wmi.h index 9cadce10ad9a..b48b024dd844 100644 --- a/include/linux/platform_data/x86/asus-wmi.h +++ b/include/linux/platform_data/x86/asus-wmi.h @@ -128,6 +128,7 @@ =20 /* gpu mux switch, 0 =3D dGPU, 1 =3D Optimus */ #define ASUS_WMI_DEVID_GPU_MUX 0x00090016 +#define ASUS_WMI_DEVID_GPU_MUX_VIVO 0x00090026 =20 /* TUF laptop RGB modes/colours */ #define ASUS_WMI_DEVID_TUF_RGB_MODE 0x00100056 --=20 2.44.0 From nobody Mon Feb 9 19:26:46 2026 Received: from wfhigh3-smtp.messagingengine.com (wfhigh3-smtp.messagingengine.com [64.147.123.154]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2467014F61; Tue, 2 Apr 2024 02:26:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.154 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712024792; cv=none; b=LNBC8uGy2cY2YEzfAxIYeLslmmQToDc57th4gMV1KTD84kD5opml9gZ0l64dKH7K8HTDs9nhCxFHsmqMOY8d/lrVSCjR6+LaecRO6bHrM2hNXn+yee5wiZ6r1mDOxibxOYw4HjJm/0qQ5Z53KZ4sN0XMANEarqIolYk0E5U7sZM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712024792; c=relaxed/simple; bh=XrDifZLBnt4fCjvKUzd9ltht3O/1IZaK2plN2UfMYnU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QVsqEdaFHv05P0yvW6oZAsT0rFmwTwrCjdWSBnpGLr/vRoTvDsAWW3Vi30QcSqWSaSP0tjNGsAR2Pvs+r3vls4TpHbTgIHPXurHZCaq91MUD3LdxJkr1kb2t8qD/L/mfM0LdVHU9AvQUTiJtbIKLd184ZS1F0oxp19UsCPs5jpo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ljones.dev; spf=none smtp.mailfrom=ljones.dev; dkim=pass (2048-bit key) header.d=ljones.dev header.i=@ljones.dev header.b=pKbxvHiA; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=sTrQVriB; arc=none smtp.client-ip=64.147.123.154 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ljones.dev Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ljones.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ljones.dev header.i=@ljones.dev header.b="pKbxvHiA"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="sTrQVriB" Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailfhigh.west.internal (Postfix) with ESMTP id 0352218000D8; Mon, 1 Apr 2024 22:26:29 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Mon, 01 Apr 2024 22:26:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ljones.dev; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm3; t=1712024789; x= 1712111189; bh=xGYXj3+OYpZ/y0v09IWuHlu1qJrw9PujBX8roj5cEGs=; b=p KbxvHiA/dJd22WzuhQOZ7TVmuD+TnBMr21QqmBYyoH8WNfNS2K5cPqZtvftTsZzn jUZ6Lc1oEsX/Yo1s6Ngd8z8Ej3MZGfRW/cUBNP8kYGUcwsfuPNY37vfzaQOz4IBf I3JJMbOskN6TKuoy4psHKEJ60t87kzfWCRNhezPJibXiC09m+t0fQOGHhi/FGgcY p55FfTkgHjE/6vs+/yQqI0IYIhEW+M0pLQUBsHApyxfgAyam1XE8BxbnujO6RPHe jeMx8jwGhEHZJHyz7j9njuvkj4QnJZK58JgW5XUQwXoxstjps1f90rPFRnCnMcO/ ZVUlkKcHlIMaRja4ZiQJQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1712024789; x= 1712111189; bh=xGYXj3+OYpZ/y0v09IWuHlu1qJrw9PujBX8roj5cEGs=; b=s TrQVriBCu/Ob/99ijq0EQlqzdwSRhi/SPfnRgwr7ZogGaKAOldQVKwcIewfxGzuL 6Z9B6wKbJt15FRRpvD8Y19oJqOtMM2qgx1xfAajIvUVdOvP1lhhShPZGyS0DigqC f5Xn/YHICAGIxyK1gWBlq1M6U+/WmpxUQf8OjE6eYuNljfrtbG8wY/QZEhtTEVC6 MhK2+vCCFpJ+qYOzg63QsTeStwdpBdZCnxt0zds785aHez8DTSXEg3D2o5lPion6 dGzI+Qit2Maufo/VbE7k4DP/ic1y+wF3gFHA5S5WHDxrjbPZNZrebrb/KHiXnUzH 1vJCoEHHkfC/FeakWYdGA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudefuddgheekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpedfnfhukhgvucffrdculfhonhgvshdfuceolhhukhgvsehl jhhonhgvshdruggvvheqnecuggftrfgrthhtvghrnhepgfetfedugfetudeuheetjefhue fggfelleetvdevtefhueeujeefvdegleevhefgnecuvehluhhsthgvrhfuihiivgeptden ucfrrghrrghmpehmrghilhhfrhhomheplhhukhgvsehljhhonhgvshdruggvvh X-ME-Proxy: Feedback-ID: i5ec1447f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 1 Apr 2024 22:26:26 -0400 (EDT) From: "Luke D. Jones" To: hdegoede@redhat.com Cc: corentin.chary@gmail.com, ilpo.jarvinen@linux.intel.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, "Luke D. Jones" Subject: [PATCH v2 3/9] platform/x86: asus-wmi: add support variant of TUF RGB Date: Tue, 2 Apr 2024 15:26:01 +1300 Message-ID: <20240402022607.34625-4-luke@ljones.dev> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240402022607.34625-1-luke@ljones.dev> References: <20240402022607.34625-1-luke@ljones.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Adds support for a second TUF RGB wmi call that some versions of the TUF laptop come with. Also adjusts existing support to select whichever is available. Signed-off-by: Luke D. Jones Reviewed-by: Ilpo J=C3=A4rvinen --- drivers/platform/x86/asus-wmi.c | 13 +++++++++---- include/linux/platform_data/x86/asus-wmi.h | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wm= i.c index 797531300138..b5bd42e5f4ef 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -270,7 +270,7 @@ struct asus_wmi { bool nv_dyn_boost_available; bool nv_temp_tgt_available; =20 - bool kbd_rgb_mode_available; + u32 kbd_rgb_dev; bool kbd_rgb_state_available; =20 bool throttle_thermal_policy_available; @@ -870,6 +870,7 @@ static ssize_t kbd_rgb_mode_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { + struct asus_wmi *asus =3D dev_get_drvdata(dev); u32 cmd, mode, r, g, b, speed; int err; =20 @@ -906,7 +907,7 @@ static ssize_t kbd_rgb_mode_store(struct device *dev, speed =3D 0xeb; } =20 - err =3D asus_wmi_evaluate_method3(ASUS_WMI_METHODID_DEVS, ASUS_WMI_DEVID_= TUF_RGB_MODE, + err =3D asus_wmi_evaluate_method3(ASUS_WMI_METHODID_DEVS, asus->kbd_rgb_d= ev, cmd | (mode << 8) | (r << 16) | (g << 24), b | (speed << 8), NULL); if (err) return err; @@ -1549,7 +1550,7 @@ static int asus_wmi_led_init(struct asus_wmi *asus) { int rv =3D 0, num_rgb_groups =3D 0, led_val; =20 - if (asus->kbd_rgb_mode_available) + if (asus->kbd_rgb_dev) kbd_rgb_mode_groups[num_rgb_groups++] =3D &kbd_rgb_mode_group; if (asus->kbd_rgb_state_available) kbd_rgb_mode_groups[num_rgb_groups++] =3D &kbd_rgb_state_group; @@ -4487,7 +4488,6 @@ static int asus_wmi_add(struct platform_device *pdev) asus->egpu_enable_available =3D asus_wmi_dev_is_present(asus, ASUS_WMI_DE= VID_EGPU); asus->egpu_connect_available =3D asus_wmi_dev_is_present(asus, ASUS_WMI_D= EVID_EGPU_CONNECTED); asus->dgpu_disable_available =3D asus_wmi_dev_is_present(asus, ASUS_WMI_D= EVID_DGPU); - asus->kbd_rgb_mode_available =3D asus_wmi_dev_is_present(asus, ASUS_WMI_D= EVID_TUF_RGB_MODE); asus->kbd_rgb_state_available =3D asus_wmi_dev_is_present(asus, ASUS_WMI_= DEVID_TUF_RGB_STATE); asus->ppt_pl2_sppt_available =3D asus_wmi_dev_is_present(asus, ASUS_WMI_D= EVID_PPT_PL2_SPPT); asus->ppt_pl1_spl_available =3D asus_wmi_dev_is_present(asus, ASUS_WMI_DE= VID_PPT_PL1_SPL); @@ -4510,6 +4510,11 @@ static int asus_wmi_add(struct platform_device *pdev) else if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_GPU_MUX_VIVO)) asus->gpu_mux_dev =3D ASUS_WMI_DEVID_GPU_MUX_VIVO; =20 + if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_TUF_RGB_MODE)) + asus->kbd_rgb_dev =3D ASUS_WMI_DEVID_TUF_RGB_MODE; + else if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_TUF_RGB_MODE2)) + asus->kbd_rgb_dev =3D ASUS_WMI_DEVID_TUF_RGB_MODE2; + err =3D fan_boost_mode_check_present(asus); if (err) goto fail_fan_boost_mode; diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/pla= tform_data/x86/asus-wmi.h index b48b024dd844..3e9a01467c67 100644 --- a/include/linux/platform_data/x86/asus-wmi.h +++ b/include/linux/platform_data/x86/asus-wmi.h @@ -132,6 +132,7 @@ =20 /* TUF laptop RGB modes/colours */ #define ASUS_WMI_DEVID_TUF_RGB_MODE 0x00100056 +#define ASUS_WMI_DEVID_TUF_RGB_MODE2 0x0010005A =20 /* TUF laptop RGB power/state */ #define ASUS_WMI_DEVID_TUF_RGB_STATE 0x00100057 --=20 2.44.0 From nobody Mon Feb 9 19:26:46 2026 Received: from wfhigh3-smtp.messagingengine.com (wfhigh3-smtp.messagingengine.com [64.147.123.154]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E4A8817559; Tue, 2 Apr 2024 02:26:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.154 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712024797; cv=none; b=mZtvFSn0uQHJxDme98c8EmwzSo/wi7AMF0aItsnQ20stdruZBA/GEPlohuKDMt0XTkCoLWxqaS18KlfSINMqDii3a6lqFOhw9W1Hr+X3AYULPRtbEGtzlBhoUI2KG1g+leR1WztQ/UkvFL7MW5Y8WMZ/oaDazYTaDt9Vy7XBXa0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712024797; c=relaxed/simple; bh=xykdxOfz2jEm1yIquNvZ1gKBij8yxhYzNxLswTnbRfk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OBrHNEjoYSrnX+vwFtUlJXDhPSi6rzaTxIMAOSiO2iR5ASve+0pZPrb3IXf+rveUVDB/6dIEQE8zGP84rI6nhu5nW/EtWSsfrRkOwBkuDpNfJKSnJIwZ9lBziyPEfoDgmeuI0/adZztoNS4x+M9wmd7Twl1ebgPu5sRP2aAjkt0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ljones.dev; spf=none smtp.mailfrom=ljones.dev; dkim=pass (2048-bit key) header.d=ljones.dev header.i=@ljones.dev header.b=GES26GoJ; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=tg9+1ajy; arc=none smtp.client-ip=64.147.123.154 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ljones.dev Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ljones.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ljones.dev header.i=@ljones.dev header.b="GES26GoJ"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="tg9+1ajy" Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfhigh.west.internal (Postfix) with ESMTP id A308418000D8; Mon, 1 Apr 2024 22:26:34 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Mon, 01 Apr 2024 22:26:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ljones.dev; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm3; t=1712024794; x= 1712111194; bh=OCy0b+3c9e5ebi4YdsSvBDHKTUpcvrfM5ZhA2KWSXkY=; b=G ES26GoJ2x3kIUm5Np4B7by/gHKRWvbwJ7qkNFeEY+0+SJ5j7+q8/2EBSGH2zhD3W mUbyumKGvaTRWDkIvqLKwCIxZyQZriAGEceSBRwuMTtXjYdgdsoGEiP9TI80qjaP 01uLBzTXbypCmWXJxR7x/uCwBH3Ktt3/62U9FN6CX3dQMtBPbqnzHVJk5Gy8htEj cOU2A1OTW4oXOdpOhce+AUAYj46aqatlNVsHK80c8PACh1Or/DOhHLoilyJkNQDW Q+nG0ljw2pg3bP0bfVvxoZKTpRC/OvydZhLjNYFw1u/xD7tcoJdRskJ0AfTTshiz +BfwFFsyLujpiez9GHN+Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1712024794; x= 1712111194; bh=OCy0b+3c9e5ebi4YdsSvBDHKTUpcvrfM5ZhA2KWSXkY=; b=t g9+1ajyJBfo+Ns2QJkn8pYnsabZ+7rWrvq9JztaldMWRaPYDSjlTMcVDYHzIZDTQ vF7Bm4r3I/K3RC6ojDMpsy6nFx4OJSWY/9ty4Gj4wAeMhgaIKTwT+qaPzUjtRMG4 ORozdDDIn/PfE8rV7riJ9HCP3hiNIEgufeQTQ2ubMJkGXj3ArVUTW5ocqYq5+8RU T/g3N19SAWy9tOrMBZGHjATa6vbeM8fm7GdPjkxr6FlxPY26euyYemjdGVPNhY52 r7Gitu1rUsrW8ZAmNoa7I9BjUNNXm5tXH0LRRF/IU76KxQb3WCUMxJKGs/IEdZZD qB9tH9L54apupVbsl21+w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudefuddgheekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpedfnfhukhgvucffrdculfhonhgvshdfuceolhhukhgvsehl jhhonhgvshdruggvvheqnecuggftrfgrthhtvghrnhepgfetfedugfetudeuheetjefhue fggfelleetvdevtefhueeujeefvdegleevhefgnecuvehluhhsthgvrhfuihiivgeptden ucfrrghrrghmpehmrghilhhfrhhomheplhhukhgvsehljhhonhgvshdruggvvh X-ME-Proxy: Feedback-ID: i5ec1447f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 1 Apr 2024 22:26:30 -0400 (EDT) From: "Luke D. Jones" To: hdegoede@redhat.com Cc: corentin.chary@gmail.com, ilpo.jarvinen@linux.intel.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, "Luke D. Jones" Subject: [PATCH v2 4/9] platform/x86: asus-wmi: support toggling POST sound Date: Tue, 2 Apr 2024 15:26:02 +1300 Message-ID: <20240402022607.34625-5-luke@ljones.dev> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240402022607.34625-1-luke@ljones.dev> References: <20240402022607.34625-1-luke@ljones.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add support for toggling the BIOS POST sound on some ASUS laptops. Signed-off-by: Luke D. Jones Reviewed-by: Ilpo J=C3=A4rvinen --- .../ABI/testing/sysfs-platform-asus-wmi | 9 ++++ drivers/platform/x86/asus-wmi.c | 51 +++++++++++++++++++ include/linux/platform_data/x86/asus-wmi.h | 3 ++ 3 files changed, 63 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-platform-asus-wmi b/Documentat= ion/ABI/testing/sysfs-platform-asus-wmi index ef1ac1a20a71..41b92e53e88a 100644 --- a/Documentation/ABI/testing/sysfs-platform-asus-wmi +++ b/Documentation/ABI/testing/sysfs-platform-asus-wmi @@ -194,3 +194,12 @@ Contact: "Luke Jones" Description: Set the target temperature limit of the Nvidia dGPU: * min=3D75, max=3D87 + +What: /sys/devices/platform//boot_sound +Date: Apr 2024 +KernelVersion: 6.10 +Contact: "Luke Jones" +Description: + Set if the BIOS POST sound is played on boot. + * 0 - False, + * 1 - True \ No newline at end of file diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wm= i.c index b5bd42e5f4ef..b795f9c1941f 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -2104,6 +2104,54 @@ static ssize_t panel_od_store(struct device *dev, } static DEVICE_ATTR_RW(panel_od); =20 +/* Bootup sound **********************************************************= *****/ + +static ssize_t boot_sound_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct asus_wmi *asus =3D dev_get_drvdata(dev); + int result; + + result =3D asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_BOOT_SOUND); + if (result < 0) + return result; + + return sysfs_emit(buf, "%d\n", result); +} + +static ssize_t boot_sound_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + int result, err; + u32 snd; + + struct asus_wmi *asus =3D dev_get_drvdata(dev); + + result =3D kstrtou32(buf, 10, &snd); + if (result) + return result; + + if (snd > 1) + return -EINVAL; + + err =3D asus_wmi_set_devstate(ASUS_WMI_DEVID_BOOT_SOUND, snd, &result); + if (err) { + pr_warn("Failed to set boot sound: %d\n", err); + return err; + } + + if (result > 1) { + pr_warn("Failed to set panel boot sound (result): 0x%x\n", result); + return -EIO; + } + + sysfs_notify(&asus->platform_device->dev.kobj, NULL, "boot_sound"); + + return count; +} +static DEVICE_ATTR_RW(boot_sound); + /* Mini-LED mode *********************************************************= *****/ static ssize_t mini_led_mode_show(struct device *dev, struct device_attribute *attr, char *buf) @@ -4189,6 +4237,7 @@ static struct attribute *platform_attributes[] =3D { &dev_attr_ppt_platform_sppt.attr, &dev_attr_nv_dynamic_boost.attr, &dev_attr_nv_temp_target.attr, + &dev_attr_boot_sound.attr, &dev_attr_panel_od.attr, &dev_attr_mini_led_mode.attr, &dev_attr_available_mini_led_mode.attr, @@ -4241,6 +4290,8 @@ static umode_t asus_sysfs_is_visible(struct kobject *= kobj, ok =3D asus->nv_dyn_boost_available; else if (attr =3D=3D &dev_attr_nv_temp_target.attr) ok =3D asus->nv_temp_tgt_available; + else if (attr =3D=3D &dev_attr_boot_sound.attr) + devid =3D ASUS_WMI_DEVID_BOOT_SOUND; else if (attr =3D=3D &dev_attr_panel_od.attr) ok =3D asus->panel_overdrive_available; else if (attr =3D=3D &dev_attr_mini_led_mode.attr) diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/pla= tform_data/x86/asus-wmi.h index 3e9a01467c67..3eb5cd6773ad 100644 --- a/include/linux/platform_data/x86/asus-wmi.h +++ b/include/linux/platform_data/x86/asus-wmi.h @@ -137,6 +137,9 @@ /* TUF laptop RGB power/state */ #define ASUS_WMI_DEVID_TUF_RGB_STATE 0x00100057 =20 +/* Bootup sound control */ +#define ASUS_WMI_DEVID_BOOT_SOUND 0x00130022 + /* DSTS masks */ #define ASUS_WMI_DSTS_STATUS_BIT 0x00000001 #define ASUS_WMI_DSTS_UNKNOWN_BIT 0x00000002 --=20 2.44.0 From nobody Mon Feb 9 19:26:46 2026 Received: from wfout3-smtp.messagingengine.com (wfout3-smtp.messagingengine.com [64.147.123.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5EEEA175A9; Tue, 2 Apr 2024 02:26:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.146 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712024802; cv=none; b=mEpVMj/sQmA1oZpFIctnu9wdXknoi09tpNalXlV7eBGEVL1Hr/Sxo/cAbAAGqWmgTDXefgu7FwbgUCl0+to7YwBstH/BzqI0adsitJ1OrZMvwQLEBCBQ1hfl+eIuYTgXtPARwgKk7+8OQCzTntG/DbFnhyI2S8ttVfG9ci043WU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712024802; c=relaxed/simple; bh=6Nbg7HJanlxSp+EVpawDpDIMndRCVKMPWk+fTGgikQA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=r0Sm7qZVhH63rE2w4C1nfEcZShMDveRCJjDjDgXO3955HhblxeqcOcEh4VwrHIBSDHw4ZdXBwg7By+2+VB6fAdVQWd2LR+67+p/yoXr8kWvw86Je9LtdKtRCF8AaJcw666X21iPMWDwT3flCFLFK/kaX7nPxKmf+7qKpwEWKkpQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ljones.dev; spf=none smtp.mailfrom=ljones.dev; dkim=pass (2048-bit key) header.d=ljones.dev header.i=@ljones.dev header.b=IIg2wY8T; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=gyOFG4MR; arc=none smtp.client-ip=64.147.123.146 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ljones.dev Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ljones.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ljones.dev header.i=@ljones.dev header.b="IIg2wY8T"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="gyOFG4MR" Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailfout.west.internal (Postfix) with ESMTP id 35B331C000B2; Mon, 1 Apr 2024 22:26:39 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Mon, 01 Apr 2024 22:26:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ljones.dev; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm3; t=1712024798; x= 1712111198; bh=8vCreOtmdp1HVovlQHQZwFGuVhfQqWoudJkCsID7108=; b=I Ig2wY8TIT+nz5WjK4gh4wXz0eBvHCx6aX4B5LV8ZUvf8A2zs0V/pgryTA90YDOC9 YAzhr7w/ANtTC8jMAuwdsfx9aMrp8Osy0Gn6at+Tbon0wvBwyLio0zoZ5CMlOOtU a1tsBM1IrMxER8BpMn0J/Glotx08JZGUB6B0G96GpGw1oQfa0ugsTobJcvjK2PCJ s/LEYc+odI6dhsgk1G6AS6gmFsGexGL+KB+ogB/0AVGZzQdvh16JEuVl5VL4rEUM ZUbFP4jcPbS9tsfFQtjMgSbNrlB4Uu98ggCKP3qIuxSMNfhq4/APdu2ufTuMujig VvmfTLohunx+UVVgojhpg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1712024798; x= 1712111198; bh=8vCreOtmdp1HVovlQHQZwFGuVhfQqWoudJkCsID7108=; b=g yOFG4MR+UcOyrRZFmTG1gRrTHaRvopQA5rOEVjvQi3kSXo1GDUvJaWIE2xTpNXhq fdfaPCkALZYJt9tKv3Z3LcRE9LdnVHq0l2fI3DZ5nmHSLNykUClpKa2O0c67ppnv mppLgGZRaNCbb8Kqe+AvLGQTglLXSK3GUcXYQAflOxAAHoU4VEq3zVknVwMX+7DP CUwqp+UpOPoG5vQ2HZ0qojbiMvv1QM9xbCK/zdqcxO4wt6pV/jfhk4Eb1ye7COkH x/23Kv++2RvfszFCDuCUCXLys/KX1M0KqpUcBwsuoyqXmua2cSMhRNfCNqXefjBs 5M+YPjHdZQnhpRRgZE1cQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudefuddgheekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpedfnfhukhgvucffrdculfhonhgvshdfuceolhhukhgvsehl jhhonhgvshdruggvvheqnecuggftrfgrthhtvghrnhepgfetfedugfetudeuheetjefhue fggfelleetvdevtefhueeujeefvdegleevhefgnecuvehluhhsthgvrhfuihiivgepuden ucfrrghrrghmpehmrghilhhfrhhomheplhhukhgvsehljhhonhgvshdruggvvh X-ME-Proxy: Feedback-ID: i5ec1447f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 1 Apr 2024 22:26:35 -0400 (EDT) From: "Luke D. Jones" To: hdegoede@redhat.com Cc: corentin.chary@gmail.com, ilpo.jarvinen@linux.intel.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, "Luke D. Jones" Subject: [PATCH v2 5/9] platform/x86: asus-wmi: store a min default for ppt options Date: Tue, 2 Apr 2024 15:26:03 +1300 Message-ID: <20240402022607.34625-6-luke@ljones.dev> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240402022607.34625-1-luke@ljones.dev> References: <20240402022607.34625-1-luke@ljones.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Laptops with any of the ppt or nv tunables default to the minimum setting on boot so we can safely assume a stored value is correct. This patch adds storing of those values in the local struct, and enables reading of those values back. To prevent creating a series of byte holes in the struct the "_available" bool is removed and `asus_sysfs_is_visible()` uses the `ASUS_WMI_DEVID_` directly. Signed-off-by: Luke D. Jones --- drivers/platform/x86/asus-wmi.c | 127 +++++++++++++++++++++++++------- 1 file changed, 99 insertions(+), 28 deletions(-) diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wm= i.c index b795f9c1941f..c80afa385532 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -262,13 +262,13 @@ struct asus_wmi { u32 gpu_mux_dev; =20 /* Tunables provided by ASUS for gaming laptops */ - bool ppt_pl2_sppt_available; - bool ppt_pl1_spl_available; - bool ppt_apu_sppt_available; - bool ppt_plat_sppt_available; - bool ppt_fppt_available; - bool nv_dyn_boost_available; - bool nv_temp_tgt_available; + u32 ppt_pl2_sppt; + u32 ppt_pl1_spl; + u32 ppt_apu_sppt; + u32 ppt_platform_sppt; + u32 ppt_fppt; + u32 nv_dynamic_boost; + u32 nv_temp_target; =20 u32 kbd_rgb_dev; bool kbd_rgb_state_available; @@ -1020,11 +1020,21 @@ static ssize_t ppt_pl2_sppt_store(struct device *de= v, return -EIO; } =20 + asus->ppt_pl2_sppt =3D value; sysfs_notify(&asus->platform_device->dev.kobj, NULL, "ppt_pl2_sppt"); =20 return count; } -static DEVICE_ATTR_WO(ppt_pl2_sppt); + +static ssize_t ppt_pl2_sppt_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct asus_wmi *asus =3D dev_get_drvdata(dev); + + return sysfs_emit(buf, "%d\n", asus->ppt_pl2_sppt); +} +static DEVICE_ATTR_RW(ppt_pl2_sppt); =20 /* Tunable: PPT, Intel=3DPL1, AMD=3DSPL **********************************= ********/ static ssize_t ppt_pl1_spl_store(struct device *dev, @@ -1054,11 +1064,20 @@ static ssize_t ppt_pl1_spl_store(struct device *dev, return -EIO; } =20 + asus->ppt_pl1_spl =3D value; sysfs_notify(&asus->platform_device->dev.kobj, NULL, "ppt_pl1_spl"); =20 return count; } -static DEVICE_ATTR_WO(ppt_pl1_spl); +static ssize_t ppt_pl1_spl_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct asus_wmi *asus =3D dev_get_drvdata(dev); + + return sysfs_emit(buf, "%d\n", asus->ppt_pl1_spl); +} +static DEVICE_ATTR_RW(ppt_pl1_spl); =20 /* Tunable: PPT APU FPPT *************************************************= *****/ static ssize_t ppt_fppt_store(struct device *dev, @@ -1088,11 +1107,21 @@ static ssize_t ppt_fppt_store(struct device *dev, return -EIO; } =20 + asus->ppt_fppt =3D value; sysfs_notify(&asus->platform_device->dev.kobj, NULL, "ppt_fpu_sppt"); =20 return count; } -static DEVICE_ATTR_WO(ppt_fppt); + +static ssize_t ppt_fppt_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct asus_wmi *asus =3D dev_get_drvdata(dev); + + return sysfs_emit(buf, "%d\n", asus->ppt_fppt); +} +static DEVICE_ATTR_RW(ppt_fppt); =20 /* Tunable: PPT APU SPPT *************************************************= ****/ static ssize_t ppt_apu_sppt_store(struct device *dev, @@ -1122,11 +1151,21 @@ static ssize_t ppt_apu_sppt_store(struct device *de= v, return -EIO; } =20 + asus->ppt_apu_sppt =3D value; sysfs_notify(&asus->platform_device->dev.kobj, NULL, "ppt_apu_sppt"); =20 return count; } -static DEVICE_ATTR_WO(ppt_apu_sppt); + +static ssize_t ppt_apu_sppt_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct asus_wmi *asus =3D dev_get_drvdata(dev); + + return sysfs_emit(buf, "%d\n", asus->ppt_apu_sppt); +} +static DEVICE_ATTR_RW(ppt_apu_sppt); =20 /* Tunable: PPT platform SPPT ********************************************= ****/ static ssize_t ppt_platform_sppt_store(struct device *dev, @@ -1156,11 +1195,21 @@ static ssize_t ppt_platform_sppt_store(struct devic= e *dev, return -EIO; } =20 + asus->ppt_platform_sppt =3D value; sysfs_notify(&asus->platform_device->dev.kobj, NULL, "ppt_platform_sppt"); =20 return count; } -static DEVICE_ATTR_WO(ppt_platform_sppt); + +static ssize_t ppt_platform_sppt_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct asus_wmi *asus =3D dev_get_drvdata(dev); + + return sysfs_emit(buf, "%d\n", asus->ppt_platform_sppt); +} +static DEVICE_ATTR_RW(ppt_platform_sppt); =20 /* Tunable: NVIDIA dynamic boost *****************************************= ****/ static ssize_t nv_dynamic_boost_store(struct device *dev, @@ -1190,11 +1239,21 @@ static ssize_t nv_dynamic_boost_store(struct device= *dev, return -EIO; } =20 + asus->nv_dynamic_boost =3D value; sysfs_notify(&asus->platform_device->dev.kobj, NULL, "nv_dynamic_boost"); =20 return count; } -static DEVICE_ATTR_WO(nv_dynamic_boost); + +static ssize_t nv_dynamic_boost_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct asus_wmi *asus =3D dev_get_drvdata(dev); + + return sysfs_emit(buf, "%d\n", asus->nv_dynamic_boost); +} +static DEVICE_ATTR_RW(nv_dynamic_boost); =20 /* Tunable: NVIDIA temperature target ************************************= ****/ static ssize_t nv_temp_target_store(struct device *dev, @@ -1224,11 +1283,21 @@ static ssize_t nv_temp_target_store(struct device *= dev, return -EIO; } =20 + asus->nv_temp_target =3D value; sysfs_notify(&asus->platform_device->dev.kobj, NULL, "nv_temp_target"); =20 return count; } -static DEVICE_ATTR_WO(nv_temp_target); + +static ssize_t nv_temp_target_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct asus_wmi *asus =3D dev_get_drvdata(dev); + + return sysfs_emit(buf, "%d\n", asus->nv_temp_target); +} +static DEVICE_ATTR_RW(nv_temp_target); =20 /* Battery ***************************************************************= *****/ =20 @@ -4277,19 +4346,19 @@ static umode_t asus_sysfs_is_visible(struct kobject= *kobj, else if (attr =3D=3D &dev_attr_throttle_thermal_policy.attr) ok =3D asus->throttle_thermal_policy_available; else if (attr =3D=3D &dev_attr_ppt_pl2_sppt.attr) - ok =3D asus->ppt_pl2_sppt_available; + devid =3D ASUS_WMI_DEVID_PPT_PL2_SPPT; else if (attr =3D=3D &dev_attr_ppt_pl1_spl.attr) - ok =3D asus->ppt_pl1_spl_available; + devid =3D ASUS_WMI_DEVID_PPT_PL1_SPL; else if (attr =3D=3D &dev_attr_ppt_fppt.attr) - ok =3D asus->ppt_fppt_available; + devid =3D ASUS_WMI_DEVID_PPT_FPPT; else if (attr =3D=3D &dev_attr_ppt_apu_sppt.attr) - ok =3D asus->ppt_apu_sppt_available; + devid =3D ASUS_WMI_DEVID_PPT_APU_SPPT; else if (attr =3D=3D &dev_attr_ppt_platform_sppt.attr) - ok =3D asus->ppt_plat_sppt_available; + devid =3D ASUS_WMI_DEVID_PPT_PLAT_SPPT; else if (attr =3D=3D &dev_attr_nv_dynamic_boost.attr) - ok =3D asus->nv_dyn_boost_available; + devid =3D ASUS_WMI_DEVID_NV_DYN_BOOST; else if (attr =3D=3D &dev_attr_nv_temp_target.attr) - ok =3D asus->nv_temp_tgt_available; + devid =3D ASUS_WMI_DEVID_NV_THERM_TARGET; else if (attr =3D=3D &dev_attr_boot_sound.attr) devid =3D ASUS_WMI_DEVID_BOOT_SOUND; else if (attr =3D=3D &dev_attr_panel_od.attr) @@ -4535,18 +4604,20 @@ static int asus_wmi_add(struct platform_device *pde= v) if (err) goto fail_platform; =20 + /* ensure defaults for tunables */ + asus->ppt_pl2_sppt =3D 5; + asus->ppt_pl1_spl =3D 5; + asus->ppt_apu_sppt =3D 5; + asus->ppt_platform_sppt =3D 5; + asus->ppt_fppt =3D 5; + asus->nv_dynamic_boost =3D 5; + asus->nv_temp_target =3D 75; + asus->charge_mode_available =3D asus_wmi_dev_is_present(asus, ASUS_WMI_DE= VID_CHARGE_MODE); asus->egpu_enable_available =3D asus_wmi_dev_is_present(asus, ASUS_WMI_DE= VID_EGPU); asus->egpu_connect_available =3D asus_wmi_dev_is_present(asus, ASUS_WMI_D= EVID_EGPU_CONNECTED); asus->dgpu_disable_available =3D asus_wmi_dev_is_present(asus, ASUS_WMI_D= EVID_DGPU); asus->kbd_rgb_state_available =3D asus_wmi_dev_is_present(asus, ASUS_WMI_= DEVID_TUF_RGB_STATE); - asus->ppt_pl2_sppt_available =3D asus_wmi_dev_is_present(asus, ASUS_WMI_D= EVID_PPT_PL2_SPPT); - asus->ppt_pl1_spl_available =3D asus_wmi_dev_is_present(asus, ASUS_WMI_DE= VID_PPT_PL1_SPL); - asus->ppt_fppt_available =3D asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID= _PPT_FPPT); - asus->ppt_apu_sppt_available =3D asus_wmi_dev_is_present(asus, ASUS_WMI_D= EVID_PPT_APU_SPPT); - asus->ppt_plat_sppt_available =3D asus_wmi_dev_is_present(asus, ASUS_WMI_= DEVID_PPT_PLAT_SPPT); - asus->nv_dyn_boost_available =3D asus_wmi_dev_is_present(asus, ASUS_WMI_D= EVID_NV_DYN_BOOST); - asus->nv_temp_tgt_available =3D asus_wmi_dev_is_present(asus, ASUS_WMI_DE= VID_NV_THERM_TARGET); asus->panel_overdrive_available =3D asus_wmi_dev_is_present(asus, ASUS_WM= I_DEVID_PANEL_OD); asus->ally_mcu_usb_switch =3D acpi_has_method(NULL, ASUS_USB0_PWR_EC0_CSE= E) && dmi_match(DMI_BOARD_NAME, "RC71L"); --=20 2.44.0 From nobody Mon Feb 9 19:26:46 2026 Received: from wfout3-smtp.messagingengine.com (wfout3-smtp.messagingengine.com [64.147.123.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C7EE9179BC; Tue, 2 Apr 2024 02:26:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.146 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712024806; cv=none; b=VjJ2o1bt30UgP8694P0fstSqlvYwmcF71u33b6wLzIl92RLx2rE5rwEg7/JPvxI4dVYF7AnRRVRD+IQjst7EMeFq4NrePTok1Gp1/3junwNW/D4blo/6RoA+SVIo6wRhgLrTWeKNStiGENtFTHoKKVEp7ktBs1QBOpLR9Y18oOc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712024806; c=relaxed/simple; bh=+nJ1i4zjhw6QYZq9p+edmZbpJx6SUFFReBlnsuUMOXk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FfXszV85MivtvJX0qfGnTkyLwaF7/08pL+s60viWZDzYHnOPwn6DBPl9LM9MbcQy8XPIB7EYBNSfAW2bOJDEZVY1NHiTRYwOIrsHGBnqspdd+vTIzaiDoP6o5AYY/jcKzqxtqq7FWdeE4xonciXV9AddrNPprvJsaCm9PhZr2rU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ljones.dev; spf=none smtp.mailfrom=ljones.dev; dkim=pass (2048-bit key) header.d=ljones.dev header.i=@ljones.dev header.b=jFTKq/Tz; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=wUmjbMvL; arc=none smtp.client-ip=64.147.123.146 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ljones.dev Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ljones.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ljones.dev header.i=@ljones.dev header.b="jFTKq/Tz"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="wUmjbMvL" Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailfout.west.internal (Postfix) with ESMTP id C52CF1C000CC; Mon, 1 Apr 2024 22:26:43 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Mon, 01 Apr 2024 22:26:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ljones.dev; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm3; t=1712024803; x= 1712111203; bh=341GqYNK58gKj+Y+aZKsOtylg69391aSNxN3HwJLYqw=; b=j FTKq/TzUhPo+lRB0gcwn6iedHIHXrxIo8vwddX3btt2qZEQJTcHZQVWUSjTNygaH S5GbxcwJn/Wo8GH1OrvqqS9wPRDbkqXTXCBniwl1B5OgOyn8dBdNd2a+sVkLTdUw 4lMqSDm/1C+zDkhTWyqKVLhRaI8Tj4yipvs5Q3QfryQCiwR9YnPAO3DaZeb23Cxm 3PuGtKO9xkVHRIkj8AJij21GD4e5N4mbiRcxfaGrn5+izFrbn3nzfjxquU5/XJAZ +gF46/bqwmxYOzPg0IQG6tM0GH7V3ouuHQwYFlrtYMl4CGwsD966YM9X+gXgEMfm vwkL7/7LKlj8heoHt37hQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1712024803; x= 1712111203; bh=341GqYNK58gKj+Y+aZKsOtylg69391aSNxN3HwJLYqw=; b=w UmjbMvLJSTQu2PS8qbOrpN6c2ytiZFlvBNB/qPPklPl6ywKj2Q9ETrSenrhDvZsi 9Mnp5GqKYZNqHzoxqOZTOp+gYYIoTc6gv4jLOCYCI+0awHV3Bzgv8YWU0DURgvRB 9geAqVU6GI27T4ZAIeFTwyJK11wx9Hqqnk09lDw/IvIU8wLNzvYb1F5K6Nq7tsTy VNSi70NgeNwkhMzyd+ykMaODm1cWimV/33itjPCY9vGfWR39fsrqMF2NcxIv9Fx8 QtyvRUmVsIPPTaH4r3DZ5GHcYtgHxbONmpcBgg6J2MfInhEXtNEkpluzSQm1sSJ/ O+RVB9yMKys3+F9mpT3MQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudefuddgheekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpedfnfhukhgvucffrdculfhonhgvshdfuceolhhukhgvsehl jhhonhgvshdruggvvheqnecuggftrfgrthhtvghrnhepgfetfedugfetudeuheetjefhue fggfelleetvdevtefhueeujeefvdegleevhefgnecuvehluhhsthgvrhfuihiivgeptden ucfrrghrrghmpehmrghilhhfrhhomheplhhukhgvsehljhhonhgvshdruggvvh X-ME-Proxy: Feedback-ID: i5ec1447f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 1 Apr 2024 22:26:40 -0400 (EDT) From: "Luke D. Jones" To: hdegoede@redhat.com Cc: corentin.chary@gmail.com, ilpo.jarvinen@linux.intel.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, "Luke D. Jones" Subject: [PATCH v2 6/9] platform/x86: asus-wmi: adjust formatting of ppt-() functions Date: Tue, 2 Apr 2024 15:26:04 +1300 Message-ID: <20240402022607.34625-7-luke@ljones.dev> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240402022607.34625-1-luke@ljones.dev> References: <20240402022607.34625-1-luke@ljones.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Shift the call to dev_get_drvdata() up to top of the function block in all of the ppt_() functions as part of a minor cleanup. Signed-off-by: Luke D. Jones Reviewed-by: Ilpo J=C3=A4rvinen --- drivers/platform/x86/asus-wmi.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wm= i.c index c80afa385532..1743ff1eb0ac 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -997,11 +997,10 @@ static ssize_t ppt_pl2_sppt_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { + struct asus_wmi *asus =3D dev_get_drvdata(dev); int result, err; u32 value; =20 - struct asus_wmi *asus =3D dev_get_drvdata(dev); - result =3D kstrtou32(buf, 10, &value); if (result) return result; @@ -1041,11 +1040,10 @@ static ssize_t ppt_pl1_spl_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { + struct asus_wmi *asus =3D dev_get_drvdata(dev); int result, err; u32 value; =20 - struct asus_wmi *asus =3D dev_get_drvdata(dev); - result =3D kstrtou32(buf, 10, &value); if (result) return result; @@ -1084,11 +1082,10 @@ static ssize_t ppt_fppt_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { + struct asus_wmi *asus =3D dev_get_drvdata(dev); int result, err; u32 value; =20 - struct asus_wmi *asus =3D dev_get_drvdata(dev); - result =3D kstrtou32(buf, 10, &value); if (result) return result; @@ -1128,11 +1125,10 @@ static ssize_t ppt_apu_sppt_store(struct device *de= v, struct device_attribute *attr, const char *buf, size_t count) { + struct asus_wmi *asus =3D dev_get_drvdata(dev); int result, err; u32 value; =20 - struct asus_wmi *asus =3D dev_get_drvdata(dev); - result =3D kstrtou32(buf, 10, &value); if (result) return result; @@ -1172,11 +1168,10 @@ static ssize_t ppt_platform_sppt_store(struct devic= e *dev, struct device_attribute *attr, const char *buf, size_t count) { + struct asus_wmi *asus =3D dev_get_drvdata(dev); int result, err; u32 value; =20 - struct asus_wmi *asus =3D dev_get_drvdata(dev); - result =3D kstrtou32(buf, 10, &value); if (result) return result; @@ -1216,11 +1211,10 @@ static ssize_t nv_dynamic_boost_store(struct device= *dev, struct device_attribute *attr, const char *buf, size_t count) { + struct asus_wmi *asus =3D dev_get_drvdata(dev); int result, err; u32 value; =20 - struct asus_wmi *asus =3D dev_get_drvdata(dev); - result =3D kstrtou32(buf, 10, &value); if (result) return result; @@ -1260,11 +1254,10 @@ static ssize_t nv_temp_target_store(struct device *= dev, struct device_attribute *attr, const char *buf, size_t count) { + struct asus_wmi *asus =3D dev_get_drvdata(dev); int result, err; u32 value; =20 - struct asus_wmi *asus =3D dev_get_drvdata(dev); - result =3D kstrtou32(buf, 10, &value); if (result) return result; --=20 2.44.0 From nobody Mon Feb 9 19:26:46 2026 Received: from wfout3-smtp.messagingengine.com (wfout3-smtp.messagingengine.com [64.147.123.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A1D2017C7C; Tue, 2 Apr 2024 02:26:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.146 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712024811; cv=none; b=Bl5dBv2A6TMKzg6UqgvIskKrMY1tUQn/CPIDRo12MszwFGfootjKZ9H7jagQ70kQT5u9jhiug7NFQbMf45djoKUA/VBf55gxJ2eBm2OeGPUbumNCSppR20ARFX5iyrLa1MoGNG3a38Q+0onlMZjvNZTTAJ90LIpRx48Aq35hj3I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712024811; c=relaxed/simple; bh=DpU+90yzllWC8NY3lXLp9lfHmboCaJNtCEDWV7RIZnw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z4e29M4Mjw2H2Pkaq7frg6Nuf98MWOJ7/3V1MC5B79UCMZ4R0oBXTZs1r0/RM9JMXYyZsGsoAZLhKsh12ehRb7gDPxx/uS+92BMCJtPHyk36SnPwkIjQHZ4d4acQezDV+hJ41SxA4iHofe+ZcNA6yE7KxTsYGpyPZdi7U7Itljg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ljones.dev; spf=none smtp.mailfrom=ljones.dev; dkim=pass (2048-bit key) header.d=ljones.dev header.i=@ljones.dev header.b=L9GGML5O; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=g4ZqQrS4; arc=none smtp.client-ip=64.147.123.146 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ljones.dev Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ljones.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ljones.dev header.i=@ljones.dev header.b="L9GGML5O"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="g4ZqQrS4" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfout.west.internal (Postfix) with ESMTP id 5C5561C000CC; Mon, 1 Apr 2024 22:26:48 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Mon, 01 Apr 2024 22:26:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ljones.dev; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm3; t=1712024807; x= 1712111207; bh=EJJ/s7hSFzUoPuPOGWvFkDGMhyLn0Akl3eFtGSVwkcU=; b=L 9GGML5Odgd1DJJCPXJOIwmM9bwWHPF5rciuQefl424MIws360A/rqm/yaSkMRfri QezjMzAzo86LbO3Xl1zxywFolnhv09vzCCCUNed9n0vHy/5UvBq/fdkqvO1amExs UOoBJB2IEjj2KmWpXV3+Yjmw3tgdA4jUHj0IXakWDGTs7nq3+oizvbK20BX7fBKd 5Siomc+xxfQ94HCuMcrmYZOqSZI7y/BL6DFL30e2VH46Jdm6wxyhvtCpP9WWeQ/k EIqsM41dSjWEJbplkQqBTwxs5Pop0Z5nQhbCvGERFhSmmUQEZFVjvIyHbMIqMxz1 9VyWRKqMzZYwues14G6pg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1712024807; x= 1712111207; bh=EJJ/s7hSFzUoPuPOGWvFkDGMhyLn0Akl3eFtGSVwkcU=; b=g 4ZqQrS47WlPdmwD50wT79tbEBQliHeAB3XgrWbZLH2e9ClqXVy/6XRiXyEv+BqYp BZjdznbw5ToxeyiSwZAcr/+Xdmeyy5rnh/MN0pvLFm9bmL/jZPVRFBTsugOKgTQP uxO1Eht+PYEVIGA+grK1eAMaXY//J16whGLy+0W3qcIIVcSwhTdd/0bqjRG4oL38 7Kq7Zf6sEQAI10HyyCILGcsJwYc5nsSYGvBVUu1duEGipvxJv9isqUWM259rTw/+ JaPoqt3KOqY0NUVvquyTuYYL1EalMz4sBdwy6LTIkbjsAnkZQdHEi1qU6kVPu5Lr BjZk0qi33Qnaf+fXkbwFQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudefuddgheekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpedfnfhukhgvucffrdculfhonhgvshdfuceolhhukhgvsehl jhhonhgvshdruggvvheqnecuggftrfgrthhtvghrnhepgfetfedugfetudeuheetjefhue fggfelleetvdevtefhueeujeefvdegleevhefgnecuvehluhhsthgvrhfuihiivgeptden ucfrrghrrghmpehmrghilhhfrhhomheplhhukhgvsehljhhonhgvshdruggvvh X-ME-Proxy: Feedback-ID: i5ec1447f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 1 Apr 2024 22:26:44 -0400 (EDT) From: "Luke D. Jones" To: hdegoede@redhat.com Cc: corentin.chary@gmail.com, ilpo.jarvinen@linux.intel.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, "Luke D. Jones" Subject: [PATCH v2 7/9] platform/x86: asus-wmi: ROG Ally increase wait time, allow MCU powersave Date: Tue, 2 Apr 2024 15:26:05 +1300 Message-ID: <20240402022607.34625-8-luke@ljones.dev> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240402022607.34625-1-luke@ljones.dev> References: <20240402022607.34625-1-luke@ljones.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The previous work to allow the MCU to be resumed correctly after sleep and resume tried to take the shortest possible time. However as work continues in various other parts of the s2idle subsystems it has shown that it wasn't entirely reliable. If the MCU disable/enable call is done correctly the MCU fully removes its USB endpoints, and this shows as a full USB device reconnection on resume. When we tried to short this as much as possible sometimes the MCU doesn't get to complete what it needs to do before going to low-power and this affected the reconnection. Through trial it is found that the minimum time required is approx 1200ms to allow a proper disconnect and disable, and the same amount of time on resume is required to prevent a rapid disconnect/reconnect happening on seemingly random occasions. To be safe the time is now 1500ms for msleep. Signed-off-by: Luke D. Jones --- drivers/platform/x86/asus-wmi.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wm= i.c index 1743ff1eb0ac..ddf568ef8c5e 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -129,7 +129,7 @@ module_param(fnlock_default, bool, 0444); /* Controls the power state of the USB0 hub on ROG Ally which input is on = */ #define ASUS_USB0_PWR_EC0_CSEE "\\_SB.PCI0.SBRG.EC0.CSEE" /* 300ms so far seems to produce a reliable result on AC and battery */ -#define ASUS_USB0_PWR_EC0_CSEE_WAIT 300 +#define ASUS_USB0_PWR_EC0_CSEE_WAIT 1500 =20 static const char * const ashs_ids[] =3D { "ATK4001", "ATK4002", NULL }; =20 @@ -4811,6 +4811,7 @@ static int asus_hotk_resume_early(struct device *devi= ce) struct asus_wmi *asus =3D dev_get_drvdata(device); =20 if (asus->ally_mcu_usb_switch) { + /* sleep required to prevent USB0 being yanked then reappearing rapidly = */ if (ACPI_FAILURE(acpi_execute_simple_method(NULL, ASUS_USB0_PWR_EC0_CSEE= , 0xB8))) dev_err(device, "ROG Ally MCU failed to connect USB dev\n"); else @@ -4822,17 +4823,8 @@ static int asus_hotk_resume_early(struct device *dev= ice) static int asus_hotk_prepare(struct device *device) { struct asus_wmi *asus =3D dev_get_drvdata(device); - int result, err; =20 if (asus->ally_mcu_usb_switch) { - /* When powersave is enabled it causes many issues with resume of USB hu= b */ - result =3D asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_MCU_POWERSA= VE); - if (result =3D=3D 1) { - dev_warn(device, "MCU powersave enabled, disabling to prevent resume is= sues"); - err =3D asus_wmi_set_devstate(ASUS_WMI_DEVID_MCU_POWERSAVE, 0, &result); - if (err || result !=3D 1) - dev_err(device, "Failed to set MCU powersave mode: %d\n", err); - } /* sleep required to ensure USB0 is disabled before sleep continues */ if (ACPI_FAILURE(acpi_execute_simple_method(NULL, ASUS_USB0_PWR_EC0_CSEE= , 0xB7))) dev_err(device, "ROG Ally MCU failed to disconnect USB dev\n"); --=20 2.44.0 From nobody Mon Feb 9 19:26:46 2026 Received: from wfhigh3-smtp.messagingengine.com (wfhigh3-smtp.messagingengine.com [64.147.123.154]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 121AF18633; Tue, 2 Apr 2024 02:26:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.154 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712024815; cv=none; b=YvkjyrlfqLRQ/1kpWEgXfBrQkPyIUq2bYE3y3MRF2kBveBP1XRD4KZWPEzPkj62GDHLgHERB6qnVBceSYbBwlWh8RAJvrKVhovX3iixsZCwL41mFI0d3c13fhzn+9BZxiFYgw/Q2MFuiQ6qySEweVkR+jCS3CddILCF3EAXfuxs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712024815; c=relaxed/simple; bh=n99dCLRp8ISXkNDLjTLaMp+/5Ar652WbbI/D0ElRLqw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z2SNIpPsfPAL32TBl9195JNnLP9bObW3Qm1b1ssu1OTFzvWVza6Q9vypIK4OW0f4ibVyjHLngXldmQ3WnsdV9F9v2y+B44xyJ3lbHaFDAdVAuLi1+e4nXzZ/M/LIfNhJ6n6XsO3cYCrhUYLcKyzmaJ7FHVOggX+MqtLqrsqRQL8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ljones.dev; spf=none smtp.mailfrom=ljones.dev; dkim=pass (2048-bit key) header.d=ljones.dev header.i=@ljones.dev header.b=a6dNI14p; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=XS+AZFRp; arc=none smtp.client-ip=64.147.123.154 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ljones.dev Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ljones.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ljones.dev header.i=@ljones.dev header.b="a6dNI14p"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="XS+AZFRp" Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailfhigh.west.internal (Postfix) with ESMTP id D152218000D8; Mon, 1 Apr 2024 22:26:52 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Mon, 01 Apr 2024 22:26:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ljones.dev; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm3; t=1712024812; x= 1712111212; bh=7QfXQgaY7xZyYxNLvLcve7hd/L3NfO6jXnYr5RR0nC0=; b=a 6dNI14piOmudojHpxfnMeKbl8gJBDouXT77cYUD+/+yBaT4LWYxDYJUj83sHJJhu XINoVBkG5OHCvIplnZyE1FCYoOaW13bJdBtrmsx1hI/2kJrOkBVKyEmK6C9Mdjvi nVxFu5xKUHRFFNVdh8rerHkhR6hB4RrRQVufyjeVKMuI4lFHPmXoQH4tlMXuK7RQ xxawiPsH3Xv1b8+nsrySeUvxIWgC2d9+2E/7lzaRp9rj5fhyFckrTjgEp3JqY5H2 c0Exaob0PHozH5aDd5Mu5eZ6s1yje6wMSdosEAnWkQExV1Ye/cpPuiaTVkX29QII QXBGP9WTL1TveOtAMM5TA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1712024812; x= 1712111212; bh=7QfXQgaY7xZyYxNLvLcve7hd/L3NfO6jXnYr5RR0nC0=; b=X S+AZFRpfs5esCT+MCC9ZbEUCith2eUbdNZ2FY4Zdvf/FA0f9lIfs3jVl+rQhgV4N //E2Ln1R38vkr8QQrCGPxSz3KNjuJkZ3GjYeL5qGG71uKojp0SLZurslebmbe87C bJd5xLOEUEg0G12NzIruExNaKjTaemp4uJ+TQLjggVPqn11rWE6er4xPAz88teyy nTIZ23bKit9dvtOGKlybRnhYppukoYOgViN5zqB/rHoJlMBliy4kIoN41RmVgCnA oiOWow5cxaFH7Iy35Lw8QaV6f5MF8IcUetzJp2gcNcJO44N3LQxGotrhVThyYNmD R162EGRD2oFUL/nF5q9Gw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudefuddgheekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpedfnfhukhgvucffrdculfhonhgvshdfuceolhhukhgvsehl jhhonhgvshdruggvvheqnecuggftrfgrthhtvghrnhepgfetfedugfetudeuheetjefhue fggfelleetvdevtefhueeujeefvdegleevhefgnecuvehluhhsthgvrhfuihiivgepuden ucfrrghrrghmpehmrghilhhfrhhomheplhhukhgvsehljhhonhgvshdruggvvh X-ME-Proxy: Feedback-ID: i5ec1447f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 1 Apr 2024 22:26:49 -0400 (EDT) From: "Luke D. Jones" To: hdegoede@redhat.com Cc: corentin.chary@gmail.com, ilpo.jarvinen@linux.intel.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, "Luke D. Jones" Subject: [PATCH v2 8/9] platform/x86: asus-wmi: Add support for MCU powersave Date: Tue, 2 Apr 2024 15:26:06 +1300 Message-ID: <20240402022607.34625-9-luke@ljones.dev> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240402022607.34625-1-luke@ljones.dev> References: <20240402022607.34625-1-luke@ljones.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add support for an MCU powersave WMI call. This is intended to set the MCU in to a low-power mode when sleeping. This mode can cut sleep power use by around half. Signed-off-by: Luke D. Jones --- .../ABI/testing/sysfs-platform-asus-wmi | 11 +++- drivers/platform/x86/asus-wmi.c | 50 +++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/Documentation/ABI/testing/sysfs-platform-asus-wmi b/Documentat= ion/ABI/testing/sysfs-platform-asus-wmi index 41b92e53e88a..28144371a0f1 100644 --- a/Documentation/ABI/testing/sysfs-platform-asus-wmi +++ b/Documentation/ABI/testing/sysfs-platform-asus-wmi @@ -202,4 +202,13 @@ Contact: "Luke Jones" Description: Set if the BIOS POST sound is played on boot. * 0 - False, - * 1 - True \ No newline at end of file + * 1 - True + +What: /sys/devices/platform//mcu_powersave +Date: Apr 2024 +KernelVersion: 6.10 +Contact: "Luke Jones" +Description: + Set if the MCU can go in to low-power mode on system sleep + * 0 - False, + * 1 - True diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wm= i.c index ddf568ef8c5e..cf872eed0986 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -1292,6 +1292,53 @@ static ssize_t nv_temp_target_show(struct device *de= v, } static DEVICE_ATTR_RW(nv_temp_target); =20 +/* Ally MCU Powersave ****************************************************= ****/ +static ssize_t mcu_powersave_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct asus_wmi *asus =3D dev_get_drvdata(dev); + int result; + + result =3D asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_MCU_POWERSAV= E); + if (result < 0) + return result; + + return sysfs_emit(buf, "%d\n", result); +} + +static ssize_t mcu_powersave_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + int result, err; + u32 enable; + + struct asus_wmi *asus =3D dev_get_drvdata(dev); + + result =3D kstrtou32(buf, 10, &enable); + if (result) + return result; + + if (enable > 1) + return -EINVAL; + + err =3D asus_wmi_set_devstate(ASUS_WMI_DEVID_MCU_POWERSAVE, enable, &resu= lt); + if (err) { + pr_warn("Failed to set MCU powersave: %d\n", err); + return err; + } + + if (result > 1) { + pr_warn("Failed to set MCU powersave (result): 0x%x\n", result); + return -EIO; + } + + sysfs_notify(&asus->platform_device->dev.kobj, NULL, "mcu_powersave"); + + return count; +} +static DEVICE_ATTR_RW(mcu_powersave); + /* Battery ***************************************************************= *****/ =20 /* The battery maximum charging percentage */ @@ -4299,6 +4346,7 @@ static struct attribute *platform_attributes[] =3D { &dev_attr_ppt_platform_sppt.attr, &dev_attr_nv_dynamic_boost.attr, &dev_attr_nv_temp_target.attr, + &dev_attr_mcu_powersave.attr, &dev_attr_boot_sound.attr, &dev_attr_panel_od.attr, &dev_attr_mini_led_mode.attr, @@ -4352,6 +4400,8 @@ static umode_t asus_sysfs_is_visible(struct kobject *= kobj, devid =3D ASUS_WMI_DEVID_NV_DYN_BOOST; else if (attr =3D=3D &dev_attr_nv_temp_target.attr) devid =3D ASUS_WMI_DEVID_NV_THERM_TARGET; + else if (attr =3D=3D &dev_attr_mcu_powersave.attr) + devid =3D ASUS_WMI_DEVID_MCU_POWERSAVE; else if (attr =3D=3D &dev_attr_boot_sound.attr) devid =3D ASUS_WMI_DEVID_BOOT_SOUND; else if (attr =3D=3D &dev_attr_panel_od.attr) --=20 2.44.0 From nobody Mon Feb 9 19:26:46 2026 Received: from wfout3-smtp.messagingengine.com (wfout3-smtp.messagingengine.com [64.147.123.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B14F11C292; Tue, 2 Apr 2024 02:26:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.146 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712024820; cv=none; b=nJfEtpp05MkJrNi4DBxnIHBIFxSFzLxQ3SU0Yw7DznPwJWglcF3DeNbaLreJs6u/OYo2reAxTWyjfQF9GizRats69IEswCgCvDUxantvJ7brEB2K49/QsxqE4/9PRJ96EVkYX/WlVwI+qRA+cIL4ZrQyUyqC7y+3le1TyRg5zVs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712024820; c=relaxed/simple; bh=IvySbLvN0x2n9rr5E3rUiKz+vzOelwZwKBjqRKjCn0E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BLiN74oC/IZ7OBFx80MjNQz6w7i3vFfe+HeTq5d3Tu1kovnlNvu2aJBGcw8PoernYhCTS9Vw3nS69kJw/oKoMpuW4/TlI15UzIdrRgd3hoFBJULFt7N0/QNaQIdYXWbc13YJNyzz72OWEjjAmAzlJIQQaKEuFmh/cjYaH1Jv4IA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ljones.dev; spf=none smtp.mailfrom=ljones.dev; dkim=pass (2048-bit key) header.d=ljones.dev header.i=@ljones.dev header.b=rtkEOFh3; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=sgwVjwHv; arc=none smtp.client-ip=64.147.123.146 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ljones.dev Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ljones.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ljones.dev header.i=@ljones.dev header.b="rtkEOFh3"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="sgwVjwHv" Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfout.west.internal (Postfix) with ESMTP id 6D7CF1C000DA; Mon, 1 Apr 2024 22:26:57 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Mon, 01 Apr 2024 22:26:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ljones.dev; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm3; t=1712024816; x= 1712111216; bh=t003vrTNOcOKt/t5DUn3QjGdbpxhSKS+qSrgHTwtnoY=; b=r tkEOFh3CSAwpHd52SmoLDXx5etAtSQZWETFw5Kief1XeNfY7ZNzRl3fYu72P2rbz Pcg4sNU5oeq0hsFYkiLvFyIdoMxnMgEnBU6J5ePNQu0ZZ6c68jS1pa7g4GXiJGJs 5AQXEcPIPZ3luZSJTdFIoCMuHXgmu2e22ctQG6UPJelZ5t8FXO67qV3SXhicJfoD +GD0Jw405U8/bYj9xS5XoxsQcT6tW1Ig4zMlSCnweQk4SOVwO+aClnjp213GgdwB DKAa6xvHbn9zhHZaKa5Vm+AwiJvQTLr+MF915mz/dz6iFP1RNFhU1pt0S0HdQYcK I/7uaN0pGX9ZY84jaWxqw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1712024816; x= 1712111216; bh=t003vrTNOcOKt/t5DUn3QjGdbpxhSKS+qSrgHTwtnoY=; b=s gwVjwHv9eoJHLvgQKmjv93s/vXzMbxrrgVAWBahmyQ8g7P2Np8/Q0kSN619rFyAC V2FIIs22hGi5+aNROPeX/vY1gfHrUjcGrKMXTCDI7dCZ0/CxSklKd8jYvoB0tkQz pqW4BJ9VM1T7W+5GD3/q+hiGMiHMhhIVyk9dZpWAdA3+IsOYrt8XyiA1zu1aeW/z SLigEsZ06VZZThjAtplVxuBfhRnYUsAUCrX0+k3ucvvlDYL7YVsp5rsUMJjDbzNs 1CAqRWvXNwpC7jrH9xR66xjRXeyCw3dzhYR1KKakty86YsDU9NuuiusitsD4LFmK +YZeuGDrTvpW7lJWIyY0g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudefuddgheekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpedfnfhukhgvucffrdculfhonhgvshdfuceolhhukhgvsehl jhhonhgvshdruggvvheqnecuggftrfgrthhtvghrnhepgfetfedugfetudeuheetjefhue fggfelleetvdevtefhueeujeefvdegleevhefgnecuvehluhhsthgvrhfuihiivgepuden ucfrrghrrghmpehmrghilhhfrhhomheplhhukhgvsehljhhonhgvshdruggvvh X-ME-Proxy: Feedback-ID: i5ec1447f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 1 Apr 2024 22:26:53 -0400 (EDT) From: "Luke D. Jones" To: hdegoede@redhat.com Cc: corentin.chary@gmail.com, ilpo.jarvinen@linux.intel.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, "Luke D. Jones" Subject: [PATCH v2 9/9] platform/x86: asus-wmi: cleanup main struct to avoid some holes Date: Tue, 2 Apr 2024 15:26:07 +1300 Message-ID: <20240402022607.34625-10-luke@ljones.dev> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240402022607.34625-1-luke@ljones.dev> References: <20240402022607.34625-1-luke@ljones.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Reorganises some attr-available calls to remove a few unrequired booleans in the main driver struct which combined with some reorganisation prevents a series of large holes seen with pahole. Signed-off-by: Luke D. Jones Reviewed-by: Ilpo J=C3=A4rvinen --- drivers/platform/x86/asus-wmi.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wm= i.c index cf872eed0986..c8a8ddaeff29 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -243,6 +243,9 @@ struct asus_wmi { u32 tablet_switch_dev_id; bool tablet_switch_inverted; =20 + /* The ROG Ally device requires the MCU USB device be disconnected before= suspend */ + bool ally_mcu_usb_switch; + enum fan_type fan_type; enum fan_type gpu_fan_type; enum fan_type mid_fan_type; @@ -255,9 +258,7 @@ struct asus_wmi { u8 fan_boost_mode_mask; u8 fan_boost_mode; =20 - bool charge_mode_available; bool egpu_enable_available; - bool egpu_connect_available; bool dgpu_disable_available; u32 gpu_mux_dev; =20 @@ -298,9 +299,6 @@ struct asus_wmi { =20 bool fnlock_locked; =20 - /* The ROG Ally device requires the MCU USB device be disconnected before= suspend */ - bool ally_mcu_usb_switch; - struct asus_wmi_debug debug; =20 struct asus_wmi_driver *driver; @@ -4373,11 +4371,11 @@ static umode_t asus_sysfs_is_visible(struct kobject= *kobj, else if (attr =3D=3D &dev_attr_als_enable.attr) devid =3D ASUS_WMI_DEVID_ALS_ENABLE; else if (attr =3D=3D &dev_attr_charge_mode.attr) - ok =3D asus->charge_mode_available; + devid =3D ASUS_WMI_DEVID_CHARGE_MODE; else if (attr =3D=3D &dev_attr_egpu_enable.attr) ok =3D asus->egpu_enable_available; else if (attr =3D=3D &dev_attr_egpu_connected.attr) - ok =3D asus->egpu_connect_available; + devid =3D ASUS_WMI_DEVID_EGPU_CONNECTED; else if (attr =3D=3D &dev_attr_dgpu_disable.attr) ok =3D asus->dgpu_disable_available; else if (attr =3D=3D &dev_attr_gpu_mux_mode.attr) @@ -4405,7 +4403,7 @@ static umode_t asus_sysfs_is_visible(struct kobject *= kobj, else if (attr =3D=3D &dev_attr_boot_sound.attr) devid =3D ASUS_WMI_DEVID_BOOT_SOUND; else if (attr =3D=3D &dev_attr_panel_od.attr) - ok =3D asus->panel_overdrive_available; + devid =3D ASUS_WMI_DEVID_PANEL_OD; else if (attr =3D=3D &dev_attr_mini_led_mode.attr) ok =3D asus->mini_led_dev_id !=3D 0; else if (attr =3D=3D &dev_attr_available_mini_led_mode.attr) @@ -4656,12 +4654,9 @@ static int asus_wmi_add(struct platform_device *pdev) asus->nv_dynamic_boost =3D 5; asus->nv_temp_target =3D 75; =20 - asus->charge_mode_available =3D asus_wmi_dev_is_present(asus, ASUS_WMI_DE= VID_CHARGE_MODE); asus->egpu_enable_available =3D asus_wmi_dev_is_present(asus, ASUS_WMI_DE= VID_EGPU); - asus->egpu_connect_available =3D asus_wmi_dev_is_present(asus, ASUS_WMI_D= EVID_EGPU_CONNECTED); asus->dgpu_disable_available =3D asus_wmi_dev_is_present(asus, ASUS_WMI_D= EVID_DGPU); asus->kbd_rgb_state_available =3D asus_wmi_dev_is_present(asus, ASUS_WMI_= DEVID_TUF_RGB_STATE); - asus->panel_overdrive_available =3D asus_wmi_dev_is_present(asus, ASUS_WM= I_DEVID_PANEL_OD); asus->ally_mcu_usb_switch =3D acpi_has_method(NULL, ASUS_USB0_PWR_EC0_CSE= E) && dmi_match(DMI_BOARD_NAME, "RC71L"); =20 --=20 2.44.0