From patchwork Fri Nov 24 08:27:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luke Jones X-Patchwork-Id: 169277 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp1000056vqx; Fri, 24 Nov 2023 00:28:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IEeWMOuaXd6QX//7KPBGlLj+B6P6Ml6g7DkkHNxQPCxMksk8gNwsCCFd6DDiEsAw54FDjyp X-Received: by 2002:a05:6870:2b1c:b0:1ef:a87f:5d52 with SMTP id ld28-20020a0568702b1c00b001efa87f5d52mr2539517oab.6.1700814495040; Fri, 24 Nov 2023 00:28:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700814495; cv=none; d=google.com; s=arc-20160816; b=GI2JDfRR2+vJbyPeOsmIrdP4AacQjYCecEQYs11WM4GUp7OfPYp05exqTZ5Ww/hNai 6BVxKJNfCEpamueV3jo4U3qnLdnN+rGNB6ioASCBORp6FMDSQhTp9GCi/oAA2S+bPbWH wfiFsRZqOX1v6W2h7Sm9FP67q+KvBkhIbadPk0ddGVjKoHaxQGDPuyJiUhXGQlLfZRip 6thtVfA16Tua7ZRbJF0DXf9d/FFLSK6ZSnndHGVHY/3MTJwGtd8EiVcj7a2WpClDlEcC ICFSZE2UsepW6dcEh5ALf8rqN9JjoAdIZTvtdBIQY2KJXiGab7bLG/VNzrYZGEbxx483 LcXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:feedback-id:dkim-signature :dkim-signature; bh=KiR+qoWmJgGddW07+jSsQyLAITJ4G6vi0xmsj0T3ZiU=; fh=KBOOsaW3YEneVcYsdRdNlUHz1Q41m6vPI9Uc3mM7Mz4=; b=E5dQi6ZtTbWYQBRLrkVMRojy1dvVmf3dtRP592ysVCpSFgae8xZnH9YPNfyIqezbzy fm0GJJ3dDEBC+dAh7agNjOQFja78nG49cxIWt2ldxDl8xQiLvIoM+JHORAOQnEZdlcI1 ImrhwDiBIXyOGrfSojbIF2ca5ZKCaJUM600iiiboX41EPdLYPGWjbVhbQxW9uO8Ro5uR OojNtR/msJzQZSKBvhacePvFiUSSxY18Im/HYbnMdwrl1tysJMQNNYhPieGSIk9QUSFp gFAklgERBr59LDgAP1gTn+qi8VeJEYJNyhty9rvF9/PV8wveN7dyPeUd7G8FZ4Xx8ZlR JX7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ljones.dev header.s=fm2 header.b=VXEWHu8h; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=Z9t2qg4s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id f22-20020a056a00229600b006cb8ea1f1besi3204081pfe.65.2023.11.24.00.28.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Nov 2023 00:28:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@ljones.dev header.s=fm2 header.b=VXEWHu8h; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=Z9t2qg4s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id C59A380AD08F; Fri, 24 Nov 2023 00:28:09 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344912AbjKXI17 (ORCPT + 99 others); Fri, 24 Nov 2023 03:27:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229742AbjKXI15 (ORCPT ); Fri, 24 Nov 2023 03:27:57 -0500 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF234D5A; Fri, 24 Nov 2023 00:28:01 -0800 (PST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id A18EB5C0181; Fri, 24 Nov 2023 03:27:58 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Fri, 24 Nov 2023 03:27:58 -0500 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:message-id:mime-version:reply-to:sender:subject :subject:to:to; s=fm2; t=1700814478; x=1700900878; bh=KiR+qoWmJg GddW07+jSsQyLAITJ4G6vi0xmsj0T3ZiU=; b=VXEWHu8hoavivVlXlKLMWSNhYq L/4D/jIPkOSk27AHBhPslwqa742Fzm7u4NIs5ckkUl9B/HFs5mD2kN8YASGqgqMz tRIx15yAT+gWC5HuV1F2OMPlvpAE+X07iRNNmnXlWRedxKXTluBerZyGSIw1F2jr 7RzSks79ZyG6Toij+GsGztHsiKxSZtKV4yfOqq+R9N1gO7G4N6J/+AZmUn/ESyqu tIT5Fk37lK3DgtJ1OEL9EMTo8crOA6ckTy4CJqYptO5bjR+lQFPESh5r58nr4ll4 EwP2fttKFSLIuoGVipLPmhSm/DSXQLRPxiVcYdUl4UaANDVZt8GIiDS/TV3g== 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:message-id:mime-version:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1700814478; x=1700900878; bh=KiR+qoWmJgGdd W07+jSsQyLAITJ4G6vi0xmsj0T3ZiU=; b=Z9t2qg4sUTI5LtPJXqEhlfrQN5uGr tmEnTPNBhG5O59oVQpYOiusmaEr2Bg26IuGcoXfVCH9gi8PKUcbNmNJQzI8UlHWC xK/SCdDViJr9hVcTnpS5xodbfdbuSMaITRvtmnO5eXWsFjOqGZt9iOVsTw9O9u6S 14n9QlqXuofFbqhEyHjeBK8L3Zt3y0bP2zbs0lvbPuZsG94Fx3DjZ+/SvhcCyyqX XqSUcqhYYkNdLeINnSCl8Gul9Q1dISiAMPM60IkT0R/NfYm5iL0eQA+jgXdNM3gB BWYUKYHKgGKTNENlktzLIYVA2itim2TlKgxU6QwUYJhwTVAEIJvziqzVQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudehgedguddvtdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgggfestdekre dtredttdenucfhrhhomhepfdfnuhhkvgcuffdrucflohhnvghsfdcuoehluhhkvgeslhhj ohhnvghsrdguvghvqeenucggtffrrghtthgvrhhnpefgudejtdfhuddukefffeekiefftd dtvdfhgeduudeuffeuhfefgfegfeetvedvgeenucevlhhushhtvghrufhiiigvpedtnecu rfgrrhgrmhepmhgrihhlfhhrohhmpehluhhkvgeslhhjohhnvghsrdguvghv X-ME-Proxy: Feedback-ID: i5ec1447f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 24 Nov 2023 03:27:55 -0500 (EST) From: "Luke D. Jones" To: hdegoede@redhat.com Cc: ilpo.jarvinen@linux.intel.com, corentin.chary@gmail.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, "Luke D. Jones" Subject: [PATCH] platform/x86: asus-wmi: disable USB0 hub on ROG Ally before suspend Date: Fri, 24 Nov 2023 21:27:48 +1300 Message-ID: <20231124082749.23353-1-luke@ljones.dev> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Fri, 24 Nov 2023 00:28:10 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783433259845537040 X-GMAIL-MSGID: 1783433259845537040 ASUS have worked around an issue in XINPUT in Windows by tweaking the MCU firmware to disable the USB0 hub on screen disable when suspending. The issue we have with this however is one of timing - the call the tells the MCU to this isn't able to complete before suspend is done so we call this in a prepare() and add a small msleep() to ensure it is done. Without this the MCU is unable to initialise itself correctly on resume. Signed-off-by: Luke D. Jones Reviewed-by: Hans de Goede --- drivers/platform/x86/asus-wmi.c | 43 +++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index 6a79f16233ab..c28829d45fb5 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -132,6 +133,9 @@ module_param(fnlock_default, bool, 0444); #define ASUS_SCREENPAD_BRIGHT_MAX 255 #define ASUS_SCREENPAD_BRIGHT_DEFAULT 60 +/* Controls the power state of the USB0 hub on ROG Ally which input is on */ +#define ASUS_USB0_PWR_SB_PCI0_SBRG_EC0_CSEE "\\_SB.PCI0.SBRG.EC0.CSEE" + static const char * const ashs_ids[] = { "ATK4001", "ATK4002", NULL }; static int throttle_thermal_policy_write(struct asus_wmi *); @@ -300,6 +304,9 @@ struct asus_wmi { bool fnlock_locked; + /* The ROG Ally device requires the USB hub to be disabled before suspend */ + bool pre_suspend_ec0_csee_disable; + struct asus_wmi_debug debug; struct asus_wmi_driver *driver; @@ -4488,6 +4495,8 @@ static int asus_wmi_add(struct platform_device *pdev) 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->pre_suspend_ec0_csee_disable = acpi_has_method(NULL, ASUS_USB0_PWR_SB_PCI0_SBRG_EC0_CSEE) + && dmi_match(DMI_BOARD_NAME, "RC71L"); err = fan_boost_mode_check_present(asus); if (err) @@ -4654,6 +4663,38 @@ static int asus_hotk_resume(struct device *device) asus_wmi_fnlock_update(asus); asus_wmi_tablet_mode_get_state(asus); + + return 0; +} + +static int asus_hotk_resume_early(struct device *device) +{ + struct asus_wmi *asus = dev_get_drvdata(device); + acpi_status status; + + if (asus->pre_suspend_ec0_csee_disable) { + status = acpi_execute_simple_method(NULL, ASUS_USB0_PWR_SB_PCI0_SBRG_EC0_CSEE, 0xB8); + if (ACPI_FAILURE(status)) { + pr_warn("failed to set USB hub power on\n"); + return 1; + } + } + return 0; +} + +static int asus_hotk_prepare(struct device *device) +{ + struct asus_wmi *asus = dev_get_drvdata(device); + acpi_status status; + + if (asus->pre_suspend_ec0_csee_disable) { + status = acpi_execute_simple_method(NULL, ASUS_USB0_PWR_SB_PCI0_SBRG_EC0_CSEE, 0xB7); + msleep(500); /* sleep required to ensure n-key is disabled before sleep continues */ + if (ACPI_FAILURE(status)) { + pr_warn("failed to set USB hub power off\n"); + // return 1; + } + } return 0; } @@ -4701,6 +4742,8 @@ static const struct dev_pm_ops asus_pm_ops = { .thaw = asus_hotk_thaw, .restore = asus_hotk_restore, .resume = asus_hotk_resume, + .resume_early = asus_hotk_resume_early, + .prepare = asus_hotk_prepare, }; /* Registration ***************************************************************/