Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp3070514lqz; Wed, 3 Apr 2024 18:22:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW8nHOya/ld1Gm78CjKJ8ZNNw8KF4pbrwQ2j/U+GvlIHQE9f3Un+/JgxY2uA82vXuFkpZn2RcHzqxgdluAvc9QItwfL6ZJigvHoRB4xdg== X-Google-Smtp-Source: AGHT+IHvj2cN+83mXrETJOcjO6DyZ1OHepjq5ej4YTxMb4IALJ8WFfe8NIlHHPU1Wat1gD2wlq/F X-Received: by 2002:a05:6a21:271d:b0:1a7:23aa:d8f4 with SMTP id rm29-20020a056a21271d00b001a723aad8f4mr1187108pzb.27.1712193773764; Wed, 03 Apr 2024 18:22:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712193773; cv=pass; d=google.com; s=arc-20160816; b=N4NpVGoTnGRH3616koeHdLdRATGbgyyswA2Y8dMUqWjx4XKJnZWBCOC8mWanBs3jL7 nG39vRefFFAadz4zAQk+O+j6jCd11eSJ30vawPhYupAazw+a7SCFdzhPJEseqFtwYimA MqNk9fmpEXAZdx0O1M6T/l9ttUeOmfv5CUi5TLXoQ6iHxItJGy1wGEiMFnE+JKtGeh3L AzTzUtCHIKNnT76zHUcuQeDvERA4o/yTLHEy6V36SqRfYCIBue6DU0A5GFwTj0yYoqfn Xf/LnI4Xdb3iaaA1jaZwAwCF3i6kdQrixRBrf2kAslXU/0CvAS6TBQTWnh3CY93rEjkZ EJ2Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:feedback-id:dkim-signature:dkim-signature; bh=p9FSwkCbMAz+HXaWekWfWscMDEXU3+ZywSKVQIvHfE4=; fh=wDrqx0f+299Z9E/ydfQE0sLKgm4EkrYz7I1GVgXm5co=; b=Pt5RfkCSWJyrA6j6Ax2WuxRPitzqTLtQnM8vGXD3W9/EyNPAfP6nOiEXX4EClK2Wn8 nNcLQW94r5PYEF4xokr4m5z4Pg+PWZhIb1IEXwsOCoukVj7twzT3GeRwa3MAZprxlON0 gGYusYeRVyOR8O+ved+nJ+DI76upjkrGLBA8wCYYRBrC5KRUGLxpa+AgtVsBaMLFDS/t 9vou2aTnGXrZduWxmeC0YGk0swwf5JOV/OoH6Z+wRFBj91lURAXJVW7iCqqvGEtYnAaV W42/yC25lPwdxkj5UFvLRufZL/nD7TsU2P4urU/TasgWRl0AT3oXpjWGt97BqxVkgQ69 lqCA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ljones.dev header.s=fm3 header.b=krCXRW0s; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=rDtnrsjr; arc=pass (i=1 dkim=pass dkdomain=ljones.dev dkim=pass dkdomain=messagingengine.com); spf=pass (google.com: domain of linux-kernel+bounces-130766-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-130766-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id mf15-20020a170902fc8f00b001dda51f5c08si14636123plb.31.2024.04.03.18.22.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 18:22:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-130766-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@ljones.dev header.s=fm3 header.b=krCXRW0s; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=rDtnrsjr; arc=pass (i=1 dkim=pass dkdomain=ljones.dev dkim=pass dkdomain=messagingengine.com); spf=pass (google.com: domain of linux-kernel+bounces-130766-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-130766-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 3BBFCB274DC for ; Thu, 4 Apr 2024 00:17:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A49435C99; Thu, 4 Apr 2024 00:17:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ljones.dev header.i=@ljones.dev header.b="krCXRW0s"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="rDtnrsjr" Received: from wfout8-smtp.messagingengine.com (wfout8-smtp.messagingengine.com [64.147.123.151]) (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 A4AF54689; Thu, 4 Apr 2024 00:17:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.151 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712189835; cv=none; b=RJcFeKkahuw1UFNYastrA4FQMf5YTPIb+mzObGE5INz01AjfyPA9v3Ja3NfI3fH20qVtt0VO0UPUKCVlXRG1LjHTxJaJ6q++NWpE5J6/ziG/F0BrHxDyZntAujGeGxKPRzEHTl7wslHbhXdWLu90sys5BZEOjbpqOiFIAl5/XQU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712189835; c=relaxed/simple; bh=rRBy78XJkXwKq481LTr0KBcVt2ywwY9zR5Us2F6/UNw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=H+C4A0KktlXwigw+UGGszglfHbFOfytQNDVPkVcwjBUPNWVzB2G1MV7qrCrvCR2tLrVj3DajCWfbyxxADSc/Yrj4VpfaAVX68rHEHln4dcvziQMRBrm0r5qVJLqFRijSUuC8+h4VAUDyr9tg6diba/wu063x3FY1hA0oe8Qx2J4= 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=krCXRW0s; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=rDtnrsjr; arc=none smtp.client-ip=64.147.123.151 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 Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailfout.west.internal (Postfix) with ESMTP id 6B8CE1C000F7; Wed, 3 Apr 2024 20:17:12 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Wed, 03 Apr 2024 20:17:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ljones.dev; h=cc :cc:content-transfer-encoding:content-type: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=1712189831; x=1712276231; bh=p9FSwkCbMAz+HXaWekWfWscMDEXU3+ZywSKVQIvHfE4=; b= krCXRW0sVY/5ZcAeKOyq02mndGLKtJn2bJh1pUBoCVTXu3QwsVAuYTBgVWPf7GoV BJ7B2SFZY8rTCCPNNR9hnCoQc9JKlSOj4IPMK/1Nyckbgw+Wf9SnjuYnSsStCZdj 1XCVbSTLA59aCV0r9otJWKQjiUzj3spOluAxlHHxYTqrx0s/o7lMFpV6sIPwYAM3 9hWFdTdGygevg+SeH2lZU244Yb00r0TucmMPhxDsP3AkWjukC9EKIZjAuCM3I0mz f7EKI+RL4iXDt5HqK14KEvOTIxPeyHe78iYDBn3+bIgXAVnS8kkcmDknrNr+u47p w64e0sO4/+m1kxVNVCwC6Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type: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=1712189831; x= 1712276231; bh=p9FSwkCbMAz+HXaWekWfWscMDEXU3+ZywSKVQIvHfE4=; b=r Dtnrsjr5m+ncljyNktgceuh+CvjbzQniz02mwztnF1wK9VsnflrU//ZDyigZcBM5 aoF45RqIpl4RTRF2A7dLcwekMFVCv8V9XdS3jn/cdWLMcHGi+c81E2tTLG0De2gC oWqdOHMO7QtRkNAbMzNqlDb5BDXcFC4Lo2sO1rdFMLiJY+qD95SrHqjoR2BN7oO7 O5S9Z/KuLj8/yamG6Jh2F7z1VcUOZsTAKkrWE2KWYDrGzpUPaahWsbsMl9qV8clx IqgPEFXjpSVW2QK60K5dAh8B177oCrZ7p/YMA18P/ggvyLF0jJwzb1CbdS+RVRmD oF8k/k+67OCfe+nSRNZxQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudefjedgfeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvfevufffkffojghfgggtgfesth ekredtredtjeenucfhrhhomhepfdfnuhhkvgcuffdrucflohhnvghsfdcuoehluhhkvges lhhjohhnvghsrdguvghvqeenucggtffrrghtthgvrhhnpeduudetudehiedvvdevveelhf egkeefffdvfeetuefgveefgffgffeiffeitdelieenucevlhhushhtvghrufhiiigvpedt necurfgrrhgrmhepmhgrihhlfhhrohhmpehluhhkvgeslhhjohhnvghsrdguvghv X-ME-Proxy: Feedback-ID: i5ec1447f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 3 Apr 2024 20:17: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 v4 2/9] platform/x86: asus-wmi: add support for Vivobook GPU MUX Date: Thu, 4 Apr 2024 13:16:45 +1300 Message-ID: <20240404001652.86207-3-luke@ljones.dev> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240404001652.86207-1-luke@ljones.dev> References: <20240404001652.86207-1-luke@ljones.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. Reviewed-by: Ilpo Järvinen Signed-off-by: Luke D. Jones --- drivers/platform/x86/asus-wmi.c | 22 +++++++++++++--------- include/linux/platform_data/x86/asus-wmi.h | 1 + 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index aa2a3b402e33..1ab4380e9771 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -270,7 +270,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; @@ -693,8 +693,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; @@ -759,8 +759,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); @@ -813,7 +813,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; @@ -859,7 +859,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; @@ -4239,7 +4239,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) @@ -4505,7 +4505,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); @@ -4524,6 +4523,11 @@ static int asus_wmi_add(struct platform_device *pdev) else if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_MINI_LED_MODE2)) asus->mini_led_dev_id = 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 -- 2.44.0