From patchwork Tue Apr 2 01:34:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Luke D. Jones" X-Patchwork-Id: 13613216 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 B58DAD2F0; Tue, 2 Apr 2024 01:35:09 +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=1712021711; cv=none; b=KRcq0xgKdsHc2+hQ3I/3Ngi6WeViB788GzfVsGh/JMBaZNGpkr5cO1ASUT1LqvzCmvLAFswazVIC68v3aPXTduVUgKvW+mgvmOsJXq0cI+I/yhNB0U56ckmca01nfgJs7UwgRhAv7Hb15SDLmWu7Kkp0JxXVviySBud0jELiHyc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712021711; c=relaxed/simple; bh=U/5HX71yMtXLmeg1iJt3uuic/UkcY76yM6g877qjXmk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GR26Sc8Mz5OfaORnlUF2ziWqPr5WDcpo+WxsaYX7cifvIibUaucDbvGQ+4t4XKsMnEM0xLYIxLghjDwcdoSLhpPiEzOsrLGrFKe6AmVrl2ZhmV4eLEGdV7q+P1fY8YDu2SaT+Qm+r8rX2ryhZlTQbP8nlhLRxUPPk8g7/nqol78= 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=ADyaeMRQ; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=hElgFkt2; 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="ADyaeMRQ"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="hElgFkt2" Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailfhigh.west.internal (Postfix) with ESMTP id 4B9A318000D8; Mon, 1 Apr 2024 21:35:08 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Mon, 01 Apr 2024 21:35:08 -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=1712021707; x= 1712108107; bh=0JQOwz8rf0pum+ZqVXBwCd1NCtFvIMp1akk1TfIHeXM=; b=A DyaeMRQ3pGV0sX7sf0cj5cX9eDFU+P+ay5tJdNfE6AIPUZ35Fx8GxndTtj+8sBut m6jNWWsfsV/lU2CxUq3y8fnsPbr/kAQ5LG9tXOWjIplWGU7rQVVCcfCHa62lTW8B Yblk+JXgDorx+LsnxM1umn1tk+DUQ3t0FfCoUHdxazBZRkhKpao/yQyGnsY6K2XJ G+JhCtjREc5G9vnEtsAnlG+Ht8hSH3I6pr8JyIs/VrGUdtkWL42X6BS0OZtEt5cL jKqTdL/R67YjH6H7nkB5UBzfl6u52vUcb44zNeDRhcoYgFhvUR8Eegvac1I0HyjM ouZsuNu4p2Z1/t/FGmt9A== 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=1712021707; x= 1712108107; bh=0JQOwz8rf0pum+ZqVXBwCd1NCtFvIMp1akk1TfIHeXM=; b=h ElgFkt22MVd/RUfIGyv8xa7RlWvZiL3FjRQmzWR2QJlkKCkzMLHGr9PCf8qglGnH PAI/VfzKIM06AExTQSHVGmu21bJ8yU5zHvYR05EeVZfNVsEmMYtMiPZpS154G4Sh MsgfdG6FCmgn3KtTJ22CD5gkRyqWLjL8e9qS63kbbQ/NaG9W/FFabNUASDvRfOm3 /dePoLyskZ83OrPMIs/fX2ErpIXgxWcUSktm4Qo3ymq3SIrkmB3mePL4+Au+nCnq wP+MOyj8fOND0ge4u2hbfcuXP91qjDXWuOGnHxKsVV0CNjOXAhboIbbQ2RrMDU8m NR/a5ju3KPSvNMOaewglQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudefuddggeekucetufdoteggodetrfdotf 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 21:35:04 -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 v1 1/9] platform/x86: asus-wmi: add support for 2024 ROG Mini-LED Date: Tue, 2 Apr 2024 14:34:45 +1300 Message-ID: <20240402013453.18205-2-luke@ljones.dev> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240402013453.18205-1-luke@ljones.dev> References: <20240402013453.18205-1-luke@ljones.dev> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 | 81 ++++++++++++++++--- include/linux/platform_data/x86/asus-wmi.h | 1 + 3 files changed, 79 insertions(+), 11 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-platform-asus-wmi b/Documentation/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. What: /sys/devices/platform//ppt_pl1_spl Date: Jun 2023 diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index 3f07bbf809ef..646f70c65097 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; bool panel_overdrive_available; - bool mini_led_mode_available; + u32 mini_led_dev_id; struct hotplug_slot hotplug_slot; struct mutex hotplug_lock; @@ -2108,13 +2108,30 @@ static ssize_t mini_led_mode_show(struct device *dev, struct device_attribute *attr, char *buf) { struct asus_wmi *asus = dev_get_drvdata(dev); - int result; + u32 value; - result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_MINI_LED_MODE); - if (result < 0) - return result; + asus_wmi_get_devstate(asus, asus->mini_led_dev_id, &value); + value = value & 0x03; // only 3 modes on 2024 version - 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 == ASUS_WMI_DEVID_MINI_LED_MODE2) { + switch (value) { + case 0: + value = 1; + break; + case 1: + value = 2; + break; + case 2: + value = 0; + } + } else if (value < 0) { + return value; + } + return sysfs_emit(buf, "%d\n", value); } static ssize_t mini_led_mode_store(struct device *dev, @@ -2130,11 +2147,28 @@ static ssize_t mini_led_mode_store(struct device *dev, if (result) return result; - if (mode > 1) + if (mode > 1 && asus->mini_led_dev_id == ASUS_WMI_DEVID_MINI_LED_MODE) return -EINVAL; + if (mode > 2 && asus->mini_led_dev_id == ASUS_WMI_DEVID_MINI_LED_MODE2) + 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 == ASUS_WMI_DEVID_MINI_LED_MODE2) { + switch (mode) { + case 0: + mode = 2; + break; + case 1: + mode = 0; + break; + case 2: + mode = 1; + } + } - err = asus_wmi_set_devstate(ASUS_WMI_DEVID_MINI_LED_MODE, mode, &result); - + err = 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 *dev, } static DEVICE_ATTR_RW(mini_led_mode); +static ssize_t available_mini_led_mode_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct asus_wmi *asus = 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 *********************************************************************/ static void asus_wmi_set_xusb2pr(struct asus_wmi *asus) @@ -4139,6 +4190,7 @@ static struct attribute *platform_attributes[] = { &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 }; @@ -4191,7 +4243,9 @@ static umode_t asus_sysfs_is_visible(struct kobject *kobj, else if (attr == &dev_attr_panel_od.attr) ok = asus->panel_overdrive_available; else if (attr == &dev_attr_mini_led_mode.attr) - ok = asus->mini_led_mode_available; + ok = asus->mini_led_dev_id != 0; + else if (attr == &dev_attr_available_mini_led_mode.attr) + ok = asus->mini_led_dev_id != 0; if (devid != -1) ok = !(asus_wmi_get_devstate_simple(asus, devid) < 0); @@ -4444,10 +4498,15 @@ static int asus_wmi_add(struct platform_device *pdev) asus->nv_dyn_boost_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_NV_DYN_BOOST); asus->nv_temp_tgt_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_NV_THERM_TARGET); asus->panel_overdrive_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_PANEL_OD); - asus->mini_led_mode_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_MINI_LED_MODE); asus->ally_mcu_usb_switch = acpi_has_method(NULL, ASUS_USB0_PWR_EC0_CSEE) && dmi_match(DMI_BOARD_NAME, "RC71L"); + if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_MINI_LED_MODE)) { + asus->mini_led_dev_id = 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 = ASUS_WMI_DEVID_MINI_LED_MODE2; + } + err = 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/platform_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 /* Storage */ #define ASUS_WMI_DEVID_CARDREADER 0x00080013 From patchwork Tue Apr 2 01:34:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Luke D. Jones" X-Patchwork-Id: 13613217 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 743C7DF5C; Tue, 2 Apr 2024 01:35:14 +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=1712021716; cv=none; b=HN2sIII+aaNZlbgt9W3j8HQAXPjKq/WJmJ04BCqVeX9o826Sy25ric0zNaINDZuuBfqKUu3ATdRWYKqVsg/0v79eNJJg+kvwzGH3SBo+gjN4abnFQi+H6OZDVygDkW7zZhXWn1gqZDDyMOgri5qUp+2QXEfz9vQJsJQJoF8dpzk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712021716; c=relaxed/simple; bh=GZWEVn8G/uQMwOWqYVr7CTuehidwQQATMJGfjS7zqxU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DYnHkeoIvG+w29mlfN5BpkRfk70ngSH/V0lzOr6sh6T2+KzFGD6HZsEK1eA+o3tK79jMY2I24/uAGOTY8NphQdzevyGgnqp7D6WKSQxhwRIYF0WijOhs5Dwgr5bGRCeQ5YXofr1noAqRkyYueX9FJUk7fxlVAUW5dhOeLcqA1+w= 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=TL6aR5T5; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=jxjJRl7l; 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="TL6aR5T5"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="jxjJRl7l" Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfhigh.west.internal (Postfix) with ESMTP id 03B4C18000D8; Mon, 1 Apr 2024 21:35:12 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Mon, 01 Apr 2024 21:35:13 -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=1712021712; x= 1712108112; bh=AVkTFXHHLbT1e2e17mF5uzhsB1HTTSXhK3RoWMmKN4E=; b=T L6aR5T5YnlG5vjI6YRsciXOURmKmOVFXVJwZ+ykf5RxGQ0i+j+uBdr6Ccr6YsjlZ BEbMvgEL1UvagMBx39nLqMrCimEnDpsBiFWhiuj7KTa9JNoR5McP51cXWPADr9Ep SsqjTe908OU945I4SBVnKAvi9CRU1vVXFU+zhVFtTzcPGSJ3JKXDzmYovFd6pGkr S1pd0mPWubzoRMtQM2EMlPhpgc/ij0ogUJyxGtueHWdmlf5j6yp2AELERtZ0qAnl TSKvV7ec+a5xWBq5EvZV9Do/PeeH5ZLTHwEXifDPos7HfjyBufrVi33m4mxh6BnU yCyw+DZRwvDwA+J70MB+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=1712021712; x= 1712108112; bh=AVkTFXHHLbT1e2e17mF5uzhsB1HTTSXhK3RoWMmKN4E=; b=j xjJRl7lBItyK/Ph9eZDceJFWf+e4ql/cMAhZa5g7on3FI9slJGmNCHZ2H3b0hxgO TECgyfy83Fj4wD+Q2jvYDOVU+gKkvUgGMqJQe+sBDvSEIGPdP419eRWd803Ws8pp v/lPm59VEoyVEN5czLop+ODQgt7zfRwFMsX14kh8UZ2YKEwUOilh2jZGkMniJeUE vt5LgeqmMTsWie+x8oFaSHE+ZdTh2A9vAdTm0Qnv8qn7TgrCUz5zJWYpfsnZPORi Q/2zcs3OadIuWTtlUfvD8l64AKckYq74ll1HOeW4sjsOzpD8mTSdHhefEsUzkXA+ PODI44OUlRzmJX6ibo9sw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudefuddggeejucetufdoteggodetrfdotf 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 21:35:09 -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 v1 2/9] platform/x86: asus-wmi: add support for Vivobook GPU MUX Date: Tue, 2 Apr 2024 14:34:46 +1300 Message-ID: <20240402013453.18205-3-luke@ljones.dev> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240402013453.18205-1-luke@ljones.dev> References: <20240402013453.18205-1-luke@ljones.dev> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 --- drivers/platform/x86/asus-wmi.c | 23 +++++++++++++--------- include/linux/platform_data/x86/asus-wmi.h | 1 + 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index 646f70c65097..7d7a9c8ee529 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; /* 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; - if (asus->gpu_mux_mode_available) { - result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_GPU_MUX); + if (asus->gpu_mux_dev) { + result = 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; } - if (asus->gpu_mux_mode_available) { - result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_GPU_MUX); + if (asus->gpu_mux_dev) { + result = 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 = dev_get_drvdata(dev); int result; - result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_GPU_MUX); + result = asus_wmi_get_devstate_simple(asus, asus->gpu_mux_dev); if (result < 0) return result; @@ -848,7 +848,7 @@ static ssize_t gpu_mux_mode_store(struct device *dev, } } - err = asus_wmi_set_devstate(ASUS_WMI_DEVID_GPU_MUX, optimus, &result); + err = 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 == &dev_attr_dgpu_disable.attr) ok = asus->dgpu_disable_available; else if (attr == &dev_attr_gpu_mux_mode.attr) - ok = asus->gpu_mux_mode_available; + ok = asus->gpu_mux_dev != 0; else if (attr == &dev_attr_fan_boost_mode.attr) ok = asus->fan_boost_mode_available; else if (attr == &dev_attr_throttle_thermal_policy.attr) @@ -4487,7 +4487,6 @@ static int asus_wmi_add(struct platform_device *pdev) asus->egpu_enable_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_EGPU); asus->egpu_connect_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_EGPU_CONNECTED); asus->dgpu_disable_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_DGPU); - asus->gpu_mux_mode_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_GPU_MUX); asus->kbd_rgb_mode_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_TUF_RGB_MODE); asus->kbd_rgb_state_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_TUF_RGB_STATE); asus->ppt_pl2_sppt_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_PPT_PL2_SPPT); @@ -4507,6 +4506,12 @@ static int asus_wmi_add(struct platform_device *pdev) asus->mini_led_dev_id = ASUS_WMI_DEVID_MINI_LED_MODE2; } + if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_GPU_MUX)) { + asus->gpu_mux_dev = ASUS_WMI_DEVID_GPU_MUX; + } else if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_GPU_MUX_VIVO)) { + asus->gpu_mux_dev = ASUS_WMI_DEVID_GPU_MUX_VIVO; + } + err = 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/platform_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 @@ /* gpu mux switch, 0 = dGPU, 1 = Optimus */ #define ASUS_WMI_DEVID_GPU_MUX 0x00090016 +#define ASUS_WMI_DEVID_GPU_MUX_VIVO 0x00090026 /* TUF laptop RGB modes/colours */ #define ASUS_WMI_DEVID_TUF_RGB_MODE 0x00100056 From patchwork Tue Apr 2 01:34:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Luke D. Jones" X-Patchwork-Id: 13613218 Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) (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 04D8AEAF0; Tue, 2 Apr 2024 01:35:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712021720; cv=none; b=Do0WmgNfD9jQaHTUwJ5MzBhQK58FLgqlOxjp47OR5V/J5KppZ5DNyZXHWgAlH3ZWNXBZ8l0QEuvPk+73jeiBlYD2LUoCeNBTtDybOJ741BjoL2djONEuO/6VaIMdGSEkgRdfbSc/rWnSJtDoPd9LtGzSPYOnp/plHGLVbXJT+aU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712021720; c=relaxed/simple; bh=VlFnQWohpOZ9H8lYI15ZLOMd+VWAsFfD7NYlWG/+vlw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=R2eTR9BvZXbLIKxHUcmDdU2Cwajy7Na5chedtojcF7LStLqq6q2y5HK0ovFp+R63elAbt1jmKvCjVRtla1Fs+JmMpzdb1iU28bTfKIkzuKpt/CdmyduzxvWHuB5IQkpsCoqHbJ+lf7/eLqenlJj4gwQATErrkGEogR4h/Z0EyuM= 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=Mnv44cG4; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=PXUAWk47; arc=none smtp.client-ip=64.147.123.21 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="Mnv44cG4"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="PXUAWk47" Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailout.west.internal (Postfix) with ESMTP id A602C3200063; Mon, 1 Apr 2024 21:35:17 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Mon, 01 Apr 2024 21:35:18 -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=1712021717; x= 1712108117; bh=sxh/Rrmhzz2YW/e0eSDoLDFtMzpiCcqlo7diCdJKm7I=; b=M nv44cG47I0hF5pwvqQkbelwgogN51qis37p7eeeIZG21wL9FU1ys3ZmgAp+GvaEe T22xei5rMnKzoazgnHivIpMM9L7Ylll4vK/pYyHD9xAhifYkMrjKkvVoRAvWt1ed D8Z8Le6YSRn2yuF0b3izzos1B22fdqi5jmHe0E8dYfoBIAwxuc3cB8wD5zF64ofm 0Fbp1d/cdt1gw5iBhlbeG+CIbZtaOpS9cHaBQ3IJNkw3oPZFuk9My5e6yNUzdZOK mArJyreFPxQnw6MJ6BMFLoFLhHI4vY1MFdIoBQohdziiQgoMoCXRXacgj5VbwDQV n9tiL1E0TWinOXmYrJAWg== 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=1712021717; x= 1712108117; bh=sxh/Rrmhzz2YW/e0eSDoLDFtMzpiCcqlo7diCdJKm7I=; b=P XUAWk47lPqxrzu1jrDc+fzHCL2licxXQA/TD3YbWxHmTIY90cs7bZ4Wv0FVpHgVR Ax2Q/PE36sfcu2EhRQKuHVSgH19On0lBNkkA600rc2gX3A8F4FgT6bqzVP3xR3aE 2phD41x+fsVfADCBm3HWfHvg72p6lwXPZGuA5hyC23Z6wBUZzW/N/7N08xlyrVGz RDyjVo3hBoc2mBaP4pM6YUId9yCJbmmEth8keQTZw/rlXhLTVYqU2zC5gyP6z98v rSBaP+1/PMGFdo1uT/hF7blfsB+zaD0FfdkZtVDWfziko1BFMe6dvdzMB45h+wqB ecoMDoBlyw2BHK89cxe/A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudefuddggeekucetufdoteggodetrfdotf 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 21:35:14 -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 v1 3/9] platform/x86: asus-wmi: add support variant of TUF RGB Date: Tue, 2 Apr 2024 14:34:47 +1300 Message-ID: <20240402013453.18205-4-luke@ljones.dev> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240402013453.18205-1-luke@ljones.dev> References: <20240402013453.18205-1-luke@ljones.dev> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 --- drivers/platform/x86/asus-wmi.c | 14 ++++++++++---- include/linux/platform_data/x86/asus-wmi.h | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index 7d7a9c8ee529..fa5735af7675 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; - bool kbd_rgb_mode_available; + u32 kbd_rgb_dev; bool kbd_rgb_state_available; 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 = dev_get_drvdata(dev); u32 cmd, mode, r, g, b, speed; int err; @@ -906,7 +907,7 @@ static ssize_t kbd_rgb_mode_store(struct device *dev, speed = 0xeb; } - err = asus_wmi_evaluate_method3(ASUS_WMI_METHODID_DEVS, ASUS_WMI_DEVID_TUF_RGB_MODE, + err = asus_wmi_evaluate_method3(ASUS_WMI_METHODID_DEVS, asus->kbd_rgb_dev, 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 = 0, num_rgb_groups = 0, led_val; - if (asus->kbd_rgb_mode_available) + if (asus->kbd_rgb_dev) kbd_rgb_mode_groups[num_rgb_groups++] = &kbd_rgb_mode_group; if (asus->kbd_rgb_state_available) kbd_rgb_mode_groups[num_rgb_groups++] = &kbd_rgb_state_group; @@ -4487,7 +4488,6 @@ static int asus_wmi_add(struct platform_device *pdev) asus->egpu_enable_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_EGPU); asus->egpu_connect_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_EGPU_CONNECTED); asus->dgpu_disable_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_DGPU); - asus->kbd_rgb_mode_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_TUF_RGB_MODE); asus->kbd_rgb_state_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_TUF_RGB_STATE); asus->ppt_pl2_sppt_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_PPT_PL2_SPPT); asus->ppt_pl1_spl_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_PPT_PL1_SPL); @@ -4512,6 +4512,12 @@ static int asus_wmi_add(struct platform_device *pdev) asus->gpu_mux_dev = ASUS_WMI_DEVID_GPU_MUX_VIVO; } + if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_TUF_RGB_MODE)) { + asus->kbd_rgb_dev = ASUS_WMI_DEVID_TUF_RGB_MODE; + } else if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_TUF_RGB_MODE2)) { + asus->kbd_rgb_dev = ASUS_WMI_DEVID_TUF_RGB_MODE2; + } + err = 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/platform_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 @@ /* TUF laptop RGB modes/colours */ #define ASUS_WMI_DEVID_TUF_RGB_MODE 0x00100056 +#define ASUS_WMI_DEVID_TUF_RGB_MODE2 0x0010005A /* TUF laptop RGB power/state */ #define ASUS_WMI_DEVID_TUF_RGB_STATE 0x00100057 From patchwork Tue Apr 2 01:34:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Luke D. Jones" X-Patchwork-Id: 13613219 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 59DB2134B0; Tue, 2 Apr 2024 01:35:23 +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=1712021724; cv=none; b=jynbf4snE3uI3pNE7jtT0FZ4tkzrTLJ9aaiNzzT1XKA/TliUhkkzCxW00Rvgid3xMMEnNGO4RnDgwSUmIExnSkheV0Ne6r7tWMKiQQPcrpQ3SnW+bU7UwWYDpeBVJiig1T2Xuv5ksCbQ1affuBZkQaLjTZHsds4yj1ig0P92W2w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712021724; c=relaxed/simple; bh=OrHplRfcnZ2imM1ewc/Kt6UGrLNoK8qKbR3ImRe298w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CEU5voQrc6snaCoxTaxrw/cjWM7YzzGC5PUkqnBG0Qwjcl8zFRXsqJtejxrJF/WPhqz2vYGIFr1TqHWXk5SxUp12G+OWhCWA+IMp20/lw7apgeybKcEO5OdSNRfAtBkvB/PIQgOiFdVpYzZldILZ1UQT3sV/xKLxk4KPP4TvTII= 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=iAMm8R7d; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=PFU8mhr5; 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="iAMm8R7d"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="PFU8mhr5" Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailfhigh.west.internal (Postfix) with ESMTP id 292AF18000C3; Mon, 1 Apr 2024 21:35:22 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Mon, 01 Apr 2024 21:35: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=1712021721; x= 1712108121; bh=CBr/0u1bSUYQwQ6YOzePLq+t60cDxs4sgmMsCMugwHQ=; b=i AMm8R7d0GZlut1/+lwInZai5HG0PWYpSeL8r5WZKDjToe+XFXkskl/p1XZxWYyix YPUn4y1OVskh5o/01xl0coFSHMs9lrKqdEUeBE4sg4p1UVaFOZeeZ+AVQua0B3PI pHEYkCXRfVYkp8VLjPrwDPfzaDDn585pe1QUouEmcYVqXJ0gos9onD8oIbK3Gn9k PMoL5qlCtVs6LhuFVtC00D9aXbT//zD8OvBG+okdh8qOBsf9xB3909u9AXbicGI2 wKMC5jgRInAfovOpv8J7ZKNGPZn5EY4SMFul4Jg6MLQiw69O63bVcqtDp52v5Yd8 J/g8m+HFaYmt3ViQF9cjg== 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=1712021721; x= 1712108121; bh=CBr/0u1bSUYQwQ6YOzePLq+t60cDxs4sgmMsCMugwHQ=; b=P FU8mhr5UReJZ0Ne48pRWe4UC/bQqZ156QtHQgwW8TsJKBn10hYESV93wfLoJC28W r24EK+q9f2spb00rvx/poDOzlOsUklcari8YMMW3uTVMy/Iij4ldFob0CFbiJvLk QWcoND66dJV/psPzTBlB5KNBNB7I1EEcPMqbL62AJGRLiNCk3Oa9jBcs0iYB+vfG yu/eoSQ7ORZw7o6BYIxW4DpX8NsHzNUXq97mEfwmPgD4P5wHmMcIXbkD20e4u2Rz jCNzxo13g4h+be69oTOgbaLlHmAaYPQoNlDLKt1clnKHAAzs1cz7mNqK37H7VdxZ 3PVdzrAPc4bNoCyNtBZTw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudefuddggeekucetufdoteggodetrfdotf 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 21:35: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 v1 4/9] platform/x86: asus-wmi: support toggling POST sound Date: Tue, 2 Apr 2024 14:34:48 +1300 Message-ID: <20240402013453.18205-5-luke@ljones.dev> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240402013453.18205-1-luke@ljones.dev> References: <20240402013453.18205-1-luke@ljones.dev> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add support for toggling the BIOS POST sound on some ASUS laptops. Signed-off-by: Luke D. Jones --- .../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/Documentation/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=75, max=87 + +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-wmi.c index fa5735af7675..fcf976967325 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); +/* Bootup sound ***************************************************************/ + +static ssize_t boot_sound_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct asus_wmi *asus = dev_get_drvdata(dev); + int result; + + result = 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 = dev_get_drvdata(dev); + + result = kstrtou32(buf, 10, &snd); + if (result) + return result; + + if (snd > 1) + return -EINVAL; + + err = 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[] = { &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 = asus->nv_dyn_boost_available; else if (attr == &dev_attr_nv_temp_target.attr) ok = asus->nv_temp_tgt_available; + else if (attr == &dev_attr_boot_sound.attr) + devid = ASUS_WMI_DEVID_BOOT_SOUND; else if (attr == &dev_attr_panel_od.attr) ok = asus->panel_overdrive_available; else if (attr == &dev_attr_mini_led_mode.attr) diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_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 +/* 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 From patchwork Tue Apr 2 01:34:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Luke D. Jones" X-Patchwork-Id: 13613220 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 6AC4913FFC; Tue, 2 Apr 2024 01:35:28 +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=1712021730; cv=none; b=FdzGWjWa0+WAahMtuFCEjeeB6g+J99TERre7roKaX13V1qG5M0ljsS3XMVOLYFW3y/XeGgoZMorr4syt90bSD1dDHlnNJFH/XRNGaHOOK4VK5BgLhgH1GLbj+UYk8I+tCTtJUctMyK7lC2qhTNa7XOL3aex7Ty+YbYcZHto/NxM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712021730; c=relaxed/simple; bh=xsREb+57Vt9lCHgSGnNOYko9mfC1XEVGwBFhnsuKUgU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JsCcCHW/e5SBf5ObsSpaWquLAIbMEszsT+alCaxuy9tmpe68vJDp2NqEPtgDO7IqChSEDAfPFN2sLoPRCGe/k8kVPm63v5QGS7K36NcD4Ltdyeo/0WiN5EXmsYFX3ob7GObZt2A5vIExGEcNjMNh1eHh/LlxhzqvxTWN4IHHptc= 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=i49jY0pf; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=opJbV/27; 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="i49jY0pf"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="opJbV/27" Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailfout.west.internal (Postfix) with ESMTP id 1181A1C000A6; Mon, 1 Apr 2024 21:35:26 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Mon, 01 Apr 2024 21:35:27 -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=1712021726; x= 1712108126; bh=trk5TzQgKhZg9saEMdevl4e54pGOqEYoUzRD6rKvezo=; b=i 49jY0pfB1wkeT7cFY7fzCQaKQOs4OCi0Zy7Gip38b3zLTst40gY1cBLLEyBxm5+b wPRnlgmR4AiUgPN906QvoXxfY9hVLdAC3R+TPH03vne+p0welXS19l2w5U7tRdpJ m/70r+RBBtI/D41aZCa/v/u8XdeKvBiQBXHuL5imG83wR+9ws6evUSXBURhY9dkF +0WUBpvdL5QRJDdOPQikK4j48MfMehfWbWl2nLFfxwdSWwg03im+ESUJ4weGEfvL u6RaOM9Ox573pGDKiMj+Rxlhh4RnBCPe0/8kmmYHUnmZXHby5e9AXDXgB5OSrbC9 I9tRJwL5PZPY6EhNhVe4A== 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=1712021726; x= 1712108126; bh=trk5TzQgKhZg9saEMdevl4e54pGOqEYoUzRD6rKvezo=; b=o pJbV/27ixvo+725nZBBr/7P6TDGF2k6L3a5BH5bQ2c6GH0ECF6QTegtW6WIayNUU 1RPI8x5kGnFF3XZ99QOyeei8ngIT6do8HiamePLvuT/e/W5XOorwotYimf/9NhEo GcDtJkMb7jq66zGPufPB6oWUMm52KJpc8IkeWtC7U8ku0PaPpZpAyc1INujVGjcS WF3s0Og4zfjC+101/GuUOjYYTZVSrs8NTy3TUPIZuV0bcUlLjzKQtk5W5gPm1WaX rN/TItdiR2g+e2naXD1cHKK+hR9mB7PYBJBpWFVh2+a60bDc2+FIVS00iFk5qdeX fwtLr4UdupiIwGaI6YYwg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudefuddggeekucetufdoteggodetrfdotf 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 21:35:23 -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 v1 5/9] platform/x86: asus-wmi: store a min default for ppt options Date: Tue, 2 Apr 2024 14:34:49 +1300 Message-ID: <20240402013453.18205-6-luke@ljones.dev> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240402013453.18205-1-luke@ljones.dev> References: <20240402013453.18205-1-luke@ljones.dev> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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-wmi.c index fcf976967325..0d304a04e7de 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; /* 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; u32 kbd_rgb_dev; bool kbd_rgb_state_available; @@ -1020,11 +1020,21 @@ static ssize_t ppt_pl2_sppt_store(struct device *dev, return -EIO; } + asus->ppt_pl2_sppt = value; sysfs_notify(&asus->platform_device->dev.kobj, NULL, "ppt_pl2_sppt"); 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 = dev_get_drvdata(dev); + + return sysfs_emit(buf, "%d\n", asus->ppt_pl2_sppt); +} +static DEVICE_ATTR_RW(ppt_pl2_sppt); /* Tunable: PPT, Intel=PL1, AMD=SPL ******************************************/ 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; } + asus->ppt_pl1_spl = value; sysfs_notify(&asus->platform_device->dev.kobj, NULL, "ppt_pl1_spl"); 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 = dev_get_drvdata(dev); + + return sysfs_emit(buf, "%d\n", asus->ppt_pl1_spl); +} +static DEVICE_ATTR_RW(ppt_pl1_spl); /* 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; } + asus->ppt_fppt = value; sysfs_notify(&asus->platform_device->dev.kobj, NULL, "ppt_fpu_sppt"); 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 = dev_get_drvdata(dev); + + return sysfs_emit(buf, "%d\n", asus->ppt_fppt); +} +static DEVICE_ATTR_RW(ppt_fppt); /* 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 *dev, return -EIO; } + asus->ppt_apu_sppt = value; sysfs_notify(&asus->platform_device->dev.kobj, NULL, "ppt_apu_sppt"); 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 = dev_get_drvdata(dev); + + return sysfs_emit(buf, "%d\n", asus->ppt_apu_sppt); +} +static DEVICE_ATTR_RW(ppt_apu_sppt); /* 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 device *dev, return -EIO; } + asus->ppt_platform_sppt = value; sysfs_notify(&asus->platform_device->dev.kobj, NULL, "ppt_platform_sppt"); 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 = dev_get_drvdata(dev); + + return sysfs_emit(buf, "%d\n", asus->ppt_platform_sppt); +} +static DEVICE_ATTR_RW(ppt_platform_sppt); /* 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; } + asus->nv_dynamic_boost = value; sysfs_notify(&asus->platform_device->dev.kobj, NULL, "nv_dynamic_boost"); 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 = dev_get_drvdata(dev); + + return sysfs_emit(buf, "%d\n", asus->nv_dynamic_boost); +} +static DEVICE_ATTR_RW(nv_dynamic_boost); /* 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; } + asus->nv_temp_target = value; sysfs_notify(&asus->platform_device->dev.kobj, NULL, "nv_temp_target"); 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 = dev_get_drvdata(dev); + + return sysfs_emit(buf, "%d\n", asus->nv_temp_target); +} +static DEVICE_ATTR_RW(nv_temp_target); /* Battery ********************************************************************/ @@ -4277,19 +4346,19 @@ static umode_t asus_sysfs_is_visible(struct kobject *kobj, else if (attr == &dev_attr_throttle_thermal_policy.attr) ok = asus->throttle_thermal_policy_available; else if (attr == &dev_attr_ppt_pl2_sppt.attr) - ok = asus->ppt_pl2_sppt_available; + devid = ASUS_WMI_DEVID_PPT_PL2_SPPT; else if (attr == &dev_attr_ppt_pl1_spl.attr) - ok = asus->ppt_pl1_spl_available; + devid = ASUS_WMI_DEVID_PPT_PL1_SPL; else if (attr == &dev_attr_ppt_fppt.attr) - ok = asus->ppt_fppt_available; + devid = ASUS_WMI_DEVID_PPT_FPPT; else if (attr == &dev_attr_ppt_apu_sppt.attr) - ok = asus->ppt_apu_sppt_available; + devid = ASUS_WMI_DEVID_PPT_APU_SPPT; else if (attr == &dev_attr_ppt_platform_sppt.attr) - ok = asus->ppt_plat_sppt_available; + devid = ASUS_WMI_DEVID_PPT_PLAT_SPPT; else if (attr == &dev_attr_nv_dynamic_boost.attr) - ok = asus->nv_dyn_boost_available; + devid = ASUS_WMI_DEVID_NV_DYN_BOOST; else if (attr == &dev_attr_nv_temp_target.attr) - ok = asus->nv_temp_tgt_available; + devid = ASUS_WMI_DEVID_NV_THERM_TARGET; else if (attr == &dev_attr_boot_sound.attr) devid = ASUS_WMI_DEVID_BOOT_SOUND; else if (attr == &dev_attr_panel_od.attr) @@ -4535,18 +4604,20 @@ static int asus_wmi_add(struct platform_device *pdev) if (err) goto fail_platform; + /* ensure defaults for tunables */ + asus->ppt_pl2_sppt = 5; + asus->ppt_pl1_spl = 5; + asus->ppt_apu_sppt = 5; + asus->ppt_platform_sppt = 5; + asus->ppt_fppt = 5; + asus->nv_dynamic_boost = 5; + asus->nv_temp_target = 75; + asus->charge_mode_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_CHARGE_MODE); asus->egpu_enable_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_EGPU); asus->egpu_connect_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_EGPU_CONNECTED); asus->dgpu_disable_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_DGPU); asus->kbd_rgb_state_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_TUF_RGB_STATE); - asus->ppt_pl2_sppt_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_PPT_PL2_SPPT); - asus->ppt_pl1_spl_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_PPT_PL1_SPL); - asus->ppt_fppt_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_PPT_FPPT); - asus->ppt_apu_sppt_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_PPT_APU_SPPT); - asus->ppt_plat_sppt_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_PPT_PLAT_SPPT); - asus->nv_dyn_boost_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_NV_DYN_BOOST); - asus->nv_temp_tgt_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_NV_THERM_TARGET); asus->panel_overdrive_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_PANEL_OD); asus->ally_mcu_usb_switch = acpi_has_method(NULL, ASUS_USB0_PWR_EC0_CSEE) && dmi_match(DMI_BOARD_NAME, "RC71L"); From patchwork Tue Apr 2 01:34:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Luke D. Jones" X-Patchwork-Id: 13613221 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 CC25214A99; Tue, 2 Apr 2024 01:35:32 +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=1712021734; cv=none; b=Wyzo93M+hROhaMA5Yvnd6l3T7PY2oLz/v8hMyWowbVweg/4EldRAxfjwLNJoosDEA9h9RC3dPMMMkODkVeHijgkY55QzLfpjQH1b/EX3Vq91pwBbune89Qa9KS2Q03ihf8hflq3HnFpI33m1pGMsPhfIITBngbf6ynp08qEyxFg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712021734; c=relaxed/simple; bh=YGnLU4DMgKySQEjPe0P6Ui/q2SAR7zugjDjW5DXFI3E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FHaSAD8edWSKc/9o8HQqAl+F5jZodphe0U0V/jptv9rhCr+Ob//X28M0TOIEspeRwf0lJbNPNi8Vfw724YMWmgktu3ioEy65YOkEXIHUkXtniGQLgR7Sx16mkaNasTPYrTxjAJYZx3l2FM+szB38/P3Quw3+bP60k9n4UugeHD0= 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=Z3i7c9dm; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=UCdpp33s; 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="Z3i7c9dm"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="UCdpp33s" Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailfout.west.internal (Postfix) with ESMTP id 95EE31C000A0; Mon, 1 Apr 2024 21:35:31 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Mon, 01 Apr 2024 21:35:32 -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=1712021731; x= 1712108131; bh=tXgXU16gHPPexP/een5uEQeJLLKmVvpOpyL4QaBKpWs=; b=Z 3i7c9dm6kFDlCJimnST8X5SysefqCCnjrcJ/X32o6LwN3koVyNmvuApcJ3cVGYlP ZOE2iw3EaFP/0BlVdRTaXegKfvR2Y0a0NNYBHWi3OxNRCrzWPstuhxFjf8NRWh6l tnTKSIq1hwD6AqiOL9QRuCpiWWshm+25/PrwanWAWCIyCKRxd4BV6LUGx9xpqiFQ v3TQTyPuIp9zifkNnFcA5G7ynnKaQbwXH8XGBawE81q2UYa4k3lRJc4IW/uHWeQc c5RAYbH9hQRQb8PbsY/7wLi0AG9uI1nzUNg6Jbfa6IDGZBs239l6xVeJ5b5TcvCX gkZFWrkNSmHyI53uteSAA== 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=1712021731; x= 1712108131; bh=tXgXU16gHPPexP/een5uEQeJLLKmVvpOpyL4QaBKpWs=; b=U Cdpp33sM5AIWk6Bmp1/qrBdsFhzQFAag0VQ+y0h2mEXhI0+eKW5Y4XfoYcgk1cxJ oNFxpxyx4kPCU2Kff7n0tAPLZEZOXHNvEKncRI2m9/V7nkfSttMurYcn3FX05lQM dxyWubY3szSJOvK1n1ytd+6GiZT9atrNxdLBNiXCamrJxOd2SPw8Vk4lGSSiQdHb ABtqaZDw5VlWRKin+dVZdZ67yjpKCMC35ydCwPX/NrfG5zpHe4uPSF5LXrY0fWwh 1DdO5ahULampn44YU+WX1Rh8heZUrB8pnSI5XZlxlY9pTQNaxieSCGM5+fxV0eeB xO1vkKZZsPPBVCNKBMTDw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudefuddggeekucetufdoteggodetrfdotf 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 21:35:28 -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 v1 6/9] platform/x86: asus-wmi: adjust formatting of ppt-() functions Date: Tue, 2 Apr 2024 14:34:50 +1300 Message-ID: <20240402013453.18205-7-luke@ljones.dev> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240402013453.18205-1-luke@ljones.dev> References: <20240402013453.18205-1-luke@ljones.dev> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 --- 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-wmi.c index 0d304a04e7de..2ff78e194801 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 = dev_get_drvdata(dev); int result, err; u32 value; - struct asus_wmi *asus = dev_get_drvdata(dev); - result = 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 = dev_get_drvdata(dev); int result, err; u32 value; - struct asus_wmi *asus = dev_get_drvdata(dev); - result = 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 = dev_get_drvdata(dev); int result, err; u32 value; - struct asus_wmi *asus = dev_get_drvdata(dev); - result = kstrtou32(buf, 10, &value); if (result) return result; @@ -1128,11 +1125,10 @@ static ssize_t ppt_apu_sppt_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { + struct asus_wmi *asus = dev_get_drvdata(dev); int result, err; u32 value; - struct asus_wmi *asus = dev_get_drvdata(dev); - result = kstrtou32(buf, 10, &value); if (result) return result; @@ -1172,11 +1168,10 @@ static ssize_t ppt_platform_sppt_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { + struct asus_wmi *asus = dev_get_drvdata(dev); int result, err; u32 value; - struct asus_wmi *asus = dev_get_drvdata(dev); - result = 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 = dev_get_drvdata(dev); int result, err; u32 value; - struct asus_wmi *asus = dev_get_drvdata(dev); - result = 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 = dev_get_drvdata(dev); int result, err; u32 value; - struct asus_wmi *asus = dev_get_drvdata(dev); - result = kstrtou32(buf, 10, &value); if (result) return result; From patchwork Tue Apr 2 01:34:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Luke D. Jones" X-Patchwork-Id: 13613222 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 6E609168B1; Tue, 2 Apr 2024 01:35:37 +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=1712021739; cv=none; b=aTaoLfP5OMS4UDUXThZGGtoPRmchVAFDM58jUaMWDaMUulR+A2yJrF2RiVI7JX3jdm+82Odd+WeEXNwC+uj8PN0sy2avZRmBdm2fVFJp3rS7gT0gDH8jkRRCufq4bdON9gb41Q3uYFVAbvLQVHDpb981rKrgMCUPC+WfV+qJ4tc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712021739; c=relaxed/simple; bh=XwuityfWCS6QCNXlBVjFpQpGfUVldGXg4D5s4omri9g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=M5hPvjAHjVJ0YtqMaNB93vtPkUrj9dTaEDT0JFPDJK1VxaYn0hh+6jECwvEQiNklGV78+u3bDVzPThD0sQ+KME6Qx9BvnKMo/HwujQmmzKp0nF09XIp3THGNLX8A2MMsO/204NxhQ1bnU+w1lchVpQhhOvTQ2A5rHmsOclxWU6Q= 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=A0uzR67R; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=vBxTb17E; 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="A0uzR67R"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="vBxTb17E" Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailfhigh.west.internal (Postfix) with ESMTP id 3A7A518000C3; Mon, 1 Apr 2024 21:35:36 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Mon, 01 Apr 2024 21:35:36 -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=1712021735; x= 1712108135; bh=+lG+H/t6TDkZc72SdaZDtgLUZmp5G4uRmubnYfLzyJg=; b=A 0uzR67RL+V2I12RQA2sDLGmkJniUHZbS5FRw5Bron15xuJx708+Wxzdt7xt4yvn+ lBJ5drLlITS9m2fDNVaLzEfPxAJ1YVeZaRUb/AcTOugkS6dU9HZ1O8wgtbVhhLEM 0t1Wq1yEQC31SK3lJAJVUw7i7BqwATvKSf7Qlm/QRHKpP9MMr/4GvweQxZxnRmcI sXhBNZ6Zw2s92rSgrpj2gvj2+KUIn3NZDgj8UL0Csja9/yHMf2QzwcaKfIPiXW64 HT/kqw64vpYwumLyY2MFk9wInNlEXUDGGBu5EapNfosGiGXMiBxlLxfTf8NFP9EF BtKpYGpGAiIOZFQ5xrCwQ== 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=1712021735; x= 1712108135; bh=+lG+H/t6TDkZc72SdaZDtgLUZmp5G4uRmubnYfLzyJg=; b=v BxTb17EasduJkLsQk7VXMt6qsjJ1zGXbo6XO3xGr06BPnFQxemalKTFJ7QhIXq5r K60Sw6CE1Yc+DiBFEoTZgxcOWCvrMnyX6CMzD/OcxT7WqjLKSt+0ccVLVxzYnI+E EB1/EFrFdEf4hjurV0sRbvm7hVUgQEPIBzpiymtIJeeWj2/0k1VnA3SlR1cIr4Dl eEazrFnE1qVi+2sdRtczTIIOKj0B0B5W8y6NnIMZEbTzcPcOBaQ5EYez2Uf+ah6h UVgE1FTsMUg6S34KDflPLW7T/+91xjeXT8SWePE3tLcFquxmeJBqxq4cb5OVJcI6 wxKlJzI3ahjMVbuESOwWg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudefuddggeekucetufdoteggodetrfdotf 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 21:35:32 -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 v1 7/9] platform/x86: asus-wmi: ROG Ally increase wait time, allow MCU powersave Date: Tue, 2 Apr 2024 14:34:51 +1300 Message-ID: <20240402013453.18205-8-luke@ljones.dev> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240402013453.18205-1-luke@ljones.dev> References: <20240402013453.18205-1-luke@ljones.dev> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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-wmi.c index 2ff78e194801..ec249eca0d94 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 static const char * const ashs_ids[] = { "ATK4001", "ATK4002", NULL }; @@ -4814,6 +4814,7 @@ static int asus_hotk_resume_early(struct device *device) struct asus_wmi *asus = dev_get_drvdata(device); 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 @@ -4825,17 +4826,8 @@ static int asus_hotk_resume_early(struct device *device) static int asus_hotk_prepare(struct device *device) { struct asus_wmi *asus = dev_get_drvdata(device); - int result, err; if (asus->ally_mcu_usb_switch) { - /* When powersave is enabled it causes many issues with resume of USB hub */ - result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_MCU_POWERSAVE); - if (result == 1) { - dev_warn(device, "MCU powersave enabled, disabling to prevent resume issues"); - err = asus_wmi_set_devstate(ASUS_WMI_DEVID_MCU_POWERSAVE, 0, &result); - if (err || result != 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"); From patchwork Tue Apr 2 01:34:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Luke D. Jones" X-Patchwork-Id: 13613223 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 EC05E17588; Tue, 2 Apr 2024 01:35:41 +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=1712021743; cv=none; b=MZy/MOAztRbX97DULJ2+h/fYvwwPLWKWV8hxkPREAdkfxb9qB0jLPscyZNVcwRK9oZNdrx/kwpB5AsNQLyN72xaCF1X6z0J3GGToVmVmWUTuWPqTrXMXBwimoDyWDw7cj6axoD3Hx0sHUPDO6a4f71UbfnS+vmzjBnqBh9vkgn0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712021743; c=relaxed/simple; bh=B+Xe+RhdulHyjEF5aQf1N4ZtOVABSIAh+4mj8BwCcYU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aR/dnvPaZbYHk37hj9oIV1jAXAHiusu4mPiC0sb4B9OQXlGpR6ESFLo8Ai/3XHhK7Hg9BHb3eRBfo2m5/nNs/A13hKf34fbjmKXYDjxhJ095P9QxSQByMgzPqCDqRLGWWLiy1ZBxaOX7OYCN0UQXP9ssbe6+mwL2OGSG8Fm0fzw= 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=uAOHm4W5; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=VqmFyQpX; 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="uAOHm4W5"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="VqmFyQpX" Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfout.west.internal (Postfix) with ESMTP id 9A1D21C000CA; Mon, 1 Apr 2024 21:35:40 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Mon, 01 Apr 2024 21:35:41 -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=1712021740; x= 1712108140; bh=p0y/6qz2boqJMyIjEzVzES4qtksoRSl4qOsq7TVgRYo=; b=u AOHm4W5pbE+0TuFkGAUp82b/5SZsfTkUIrKKllu4UpSDToozbbJRw6y+ZFVT0U74 UROv1V+m8/fgVwayiPjQVdPO6Iu7vxRjyc/eMAzC3yLz4LG3tlufGlf4DitgJrbq 830+u7fhkDOB9Cv3FU59ZRRFlreJnfjL38wqywZP6Z3+1rSJK/LMG/GG/D2RfNpA EE+YQimApaD8X7P5RbM43LfpK73YXt51VnGMAvjX0RAeLDRA3fc0zzGGvIcaRW7Y 7J/gf2Sch50AHof41lGsLkCknP1wBSKj3Luv2cXQDjHdVU0363b/wuA/apy4ohs/ IZocvdpY0aKo3TfxqxcCg== 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=1712021740; x= 1712108140; bh=p0y/6qz2boqJMyIjEzVzES4qtksoRSl4qOsq7TVgRYo=; b=V qmFyQpXRgP5GQ/DU92ii34PjCPW30VH6Y270W57frEBYx/b5BrJ1T2I8GX0UKm/r oHScH8O9WUmcE1Tvnw30/KuNCDRtBWUYD30zMGDv+DtCDj36MOW0cY3vgedRR8Mi Js927e4O48HXGqLtIzcMTdgnEZL9gLQ9uQPidof4otjmSKzntNYbEQMrWKddx6kb 3sjSlX09SlHe6oLnVSfmhY2SEQ7KZHb5iz93Y+VILp2+3aC71Ano6nvOgAokz3Af /lgpxxZ5kcrV+e7WkthvOgRABPieHHU5cnfp//NPVvRSrb6MVBI5hUYdvGxsQp7D YGOK+UWPPEPdGqtxc4zSw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudefuddggeekucetufdoteggodetrfdotf 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 21:35:37 -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 v1 8/9] platform/x86: asus-wmi: Add support for MCU powersave Date: Tue, 2 Apr 2024 14:34:52 +1300 Message-ID: <20240402013453.18205-9-luke@ljones.dev> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240402013453.18205-1-luke@ljones.dev> References: <20240402013453.18205-1-luke@ljones.dev> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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/Documentation/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-wmi.c index ec249eca0d94..a6b648457908 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 *dev, } static DEVICE_ATTR_RW(nv_temp_target); +/* Ally MCU Powersave ********************************************************/ +static ssize_t mcu_powersave_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct asus_wmi *asus = dev_get_drvdata(dev); + int result; + + result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_MCU_POWERSAVE); + 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 = dev_get_drvdata(dev); + + result = kstrtou32(buf, 10, &enable); + if (result) + return result; + + if (enable > 1) + return -EINVAL; + + err = asus_wmi_set_devstate(ASUS_WMI_DEVID_MCU_POWERSAVE, enable, &result); + 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 ********************************************************************/ /* The battery maximum charging percentage */ @@ -4299,6 +4346,7 @@ static struct attribute *platform_attributes[] = { &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 = ASUS_WMI_DEVID_NV_DYN_BOOST; else if (attr == &dev_attr_nv_temp_target.attr) devid = ASUS_WMI_DEVID_NV_THERM_TARGET; + else if (attr == &dev_attr_mcu_powersave.attr) + devid = ASUS_WMI_DEVID_MCU_POWERSAVE; else if (attr == &dev_attr_boot_sound.attr) devid = ASUS_WMI_DEVID_BOOT_SOUND; else if (attr == &dev_attr_panel_od.attr) From patchwork Tue Apr 2 01:34:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Luke D. Jones" X-Patchwork-Id: 13613224 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 7C3C5175AD; Tue, 2 Apr 2024 01:35:45 +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=1712021747; cv=none; b=HnEg1sdNtBxKkyQNYP1/w/CIu4l1JB9uaIAukBCYKPz4zwAnVf5wk1BnqwFaEKg1fxcwRx0j8wX8+fz6kj0EG9yl4XR8WPibaX0M25erDLZT+XBKvZWG5t4Ofi+2dR5nbg4N3iBxnA5GIDXL4T5OGEzcCRaQdFnNRPYat2NKczg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712021747; c=relaxed/simple; bh=LWvRLZ6ZP/TG24Y7QiIJ886vAPHlgfmu6CJrx56yyWc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hnMSaR1QSAS/YLIOCzKE5UBSixgs1ZO0h8d/BTJ6ms9Syg6LaWT1KK9O4IAct5h07zx99vq1wQZ0k4PkT2RxgURgifSYkWKM43u2JPjnJ458k5dVm/jQYxqQCJVzAvOKNOtMFQ0c/YYot4rkx5KKfsAR0RgeyNEXUr+YJypCny0= 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=uN3cdGK3; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=sU5OpiXS; 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="uN3cdGK3"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="sU5OpiXS" Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailfout.west.internal (Postfix) with ESMTP id 75ADA1C000CA; Mon, 1 Apr 2024 21:35:44 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Mon, 01 Apr 2024 21:35:45 -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=1712021743; x= 1712108143; bh=wqpLB8ycW4eZTT9R9plE9TxSPiwaqargq3piwMKd6n4=; b=u N3cdGK3RN275pgn9YiiCkTZiY0kjZ8GQJBSqfeI5dV6RD333wIjK3GIFJTCOOjW6 2tj38b65EOyBe5wHOQA2/pHrC++6x+Qd8eZ3mj6iFYOejjyZdufbk7RN454+VkAf wy16iicukeSz8/2HsBQue9fhD7JleLltrkWv1hxBzIix8xvdi423ZnmjJTHDUZvy zdalZEmS+O7+5YF5aSvkiAUXtoKtPrYqLmxnikxAYZMZpQe83LU2sqm6vmrdbIxk RBd0Aaee0De8xtvcbWQkKygMhZTS9/ABafxwYaHZ2zOsF2ZExsaMHA1iDdQYGJ5T sHk7tIqI1R1BAIs2/HSjQ== 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=1712021743; x= 1712108143; bh=wqpLB8ycW4eZTT9R9plE9TxSPiwaqargq3piwMKd6n4=; b=s U5OpiXSP42ECADu6bl16rJiNPfUpIVYKbloIRU0RcRpKzCFV7D/HOLdZWU4CeZXu IVMjHIA+baeOWy43UZDzHuiZLUmBIEYwmP7JnGL7BGn9hOLzcJdpFlfbwvZrByec JWyDtIv963LgYcnypQ8KibIOhGzRibRbfLvFRmQZA0oeOHwza19t3MtpejzFMIMZ Iz1SgpRB5jJwhJwaCXYBROQS4msURa3LdhLywpcYLhkY8tcq6ksPjvOBSH5iIlH0 KrQtWmx18sk/iXeJMI4JrD6iQRGtEytSpqMwpZAqVRj5E6lF680f6yv46HsM94Ow AzlYgyTLsz9YCpf/cc2Dg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudefuddggeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtke ertdertddtnecuhfhrohhmpedfnfhukhgvucffrdculfhonhgvshdfuceolhhukhgvsehl jhhonhgvshdruggvvheqnecuggftrfgrthhtvghrnhepgfetfedugfetudeuheetjefhue fggfelleetvdevtefhueeujeefvdegleevhefgnecuvehluhhsthgvrhfuihiivgepfeen ucfrrghrrghmpehmrghilhhfrhhomheplhhukhgvsehljhhonhgvshdruggvvh X-ME-Proxy: Feedback-ID: i5ec1447f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 1 Apr 2024 21:35:41 -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 v1 9/9] platform/x86: asus-wmi: cleanup main struct to avoid some holes Date: Tue, 2 Apr 2024 14:34:53 +1300 Message-ID: <20240402013453.18205-10-luke@ljones.dev> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240402013453.18205-1-luke@ljones.dev> References: <20240402013453.18205-1-luke@ljones.dev> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 --- 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-wmi.c index a6b648457908..7163cce7079c 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; + /* 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; - bool charge_mode_available; bool egpu_enable_available; - bool egpu_connect_available; bool dgpu_disable_available; u32 gpu_mux_dev; @@ -298,9 +299,6 @@ struct asus_wmi { bool fnlock_locked; - /* The ROG Ally device requires the MCU USB device be disconnected before suspend */ - bool ally_mcu_usb_switch; - struct asus_wmi_debug debug; struct asus_wmi_driver *driver; @@ -4373,11 +4371,11 @@ static umode_t asus_sysfs_is_visible(struct kobject *kobj, else if (attr == &dev_attr_als_enable.attr) devid = ASUS_WMI_DEVID_ALS_ENABLE; else if (attr == &dev_attr_charge_mode.attr) - ok = asus->charge_mode_available; + devid = ASUS_WMI_DEVID_CHARGE_MODE; else if (attr == &dev_attr_egpu_enable.attr) ok = asus->egpu_enable_available; else if (attr == &dev_attr_egpu_connected.attr) - ok = asus->egpu_connect_available; + devid = ASUS_WMI_DEVID_EGPU_CONNECTED; else if (attr == &dev_attr_dgpu_disable.attr) ok = asus->dgpu_disable_available; else if (attr == &dev_attr_gpu_mux_mode.attr) @@ -4405,7 +4403,7 @@ static umode_t asus_sysfs_is_visible(struct kobject *kobj, else if (attr == &dev_attr_boot_sound.attr) devid = ASUS_WMI_DEVID_BOOT_SOUND; else if (attr == &dev_attr_panel_od.attr) - ok = asus->panel_overdrive_available; + devid = ASUS_WMI_DEVID_PANEL_OD; else if (attr == &dev_attr_mini_led_mode.attr) ok = asus->mini_led_dev_id != 0; else if (attr == &dev_attr_available_mini_led_mode.attr) @@ -4656,12 +4654,9 @@ static int asus_wmi_add(struct platform_device *pdev) asus->nv_dynamic_boost = 5; asus->nv_temp_target = 75; - asus->charge_mode_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_CHARGE_MODE); asus->egpu_enable_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_EGPU); - asus->egpu_connect_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_EGPU_CONNECTED); asus->dgpu_disable_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_DGPU); asus->kbd_rgb_state_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_TUF_RGB_STATE); - asus->panel_overdrive_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_PANEL_OD); asus->ally_mcu_usb_switch = acpi_has_method(NULL, ASUS_USB0_PWR_EC0_CSEE) && dmi_match(DMI_BOARD_NAME, "RC71L");