From nobody Wed Oct 8 10:56:35 2025 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 600FF220689; Sun, 29 Jun 2025 13:14:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751202886; cv=none; b=AFWPCTLcedZQ2gsqUE0rkr+l5vaUyIO7kSuYFDb+jSwKCNmvN8Mrrzevcdpyu1fR9B+g9JplXLJDG0uJF26sBNSwmbveI+zZLriF7Krcr4BIIv6FJgrrgVXa01Ui9bGTgi4U5WTJm+1hatTcZzgUPVlw1DqXGyAiKrroQDVjmIU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751202886; c=relaxed/simple; bh=n8brHU06/WZS+wxA8k6rtpd/5/bH43akiypS2LMKNjU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EOnJf43JEYIKAvZua9FBYcBYfy+wnwjC+6W8K8NJKhUfC7nCOfB6ZyexMoCKR6GDR11ny+e8i2BJpvEvnlRuogEk1MuArl6Nsr6wlO7W6LfuKtoCtyQzz3RTj5PyKf3fAEgHzaDtmE90DfJ4aOh5NDskH7iJxAXhUvcPICvcTiU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RDvukQzY; arc=none smtp.client-ip=209.85.221.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RDvukQzY" Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-3a507e88b0aso987471f8f.1; Sun, 29 Jun 2025 06:14:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751202882; x=1751807682; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0fkbgeT8w5iNHuRxX2hKakPaBsIP0X1WqDdO/BuHWEo=; b=RDvukQzYVHrcWxMRQhGNjFx7zSRplXb6s5gIOqK25a8tjENQK6/2bNMD5KfLq6OiSC AtshqkR2n83VnVtLOhT5vpmgw68G2MUvoQV29JyFBoEFKZ/iNbM0tvL42/wvnnhV8J4h oLqj6YNZoE/hTF6VHCWvedvAd7COfnrcqgBUwdeBEoMAF8NCTRm642rCqzApAOh3/c4i g1tUq9r6qTpjM1y2O32echMYMea6MQzxTcepSfPMUgd8m/rXwHWzBF0/AKRYFlUzmxQc 6SpVuw+JM30K78w6VMZKaJ0Tts49juDV/HxifpIRoLmt4uPwmWn0Qu4aBbkwhsOlYbZy zIdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751202882; x=1751807682; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0fkbgeT8w5iNHuRxX2hKakPaBsIP0X1WqDdO/BuHWEo=; b=Bxs9rNNnfp3p9jBKK0S4t31PGLDxJ1/z3xPrsqO2AWtmG+u79boN2hLY0cTgBZ3psn U+P7y4Y3ZXU849c0vjUfZi9XqsNKZ0hhhSyZdMHRb/gVNgtjiXGFprgbe3NP81oODNVH 4YByQwLq/St8AVzbNb+3OiZ6ZX7i7FQwiABTL72RdsgGLUtmV+6sTlZTnG04FUwmSjhr AUPQ8zS8uwR/+7cs73dz/jLZd7ndCwHvyvfpuyl2cU+ztO4OjCB+xjXcj601oN96Acb7 +0GhQbxVYmYX5CH+Tk/0pJTfSNHogOKr+gTs70AAxddkSFX8/9fEFYN/TqGmbEHqoo8x +Caw== X-Forwarded-Encrypted: i=1; AJvYcCXvJzVaxlUwVvLtatAVXT3o8ncKwpu5g9L2Nh+4ypJ+osbm6ksKZBbvrI4P/ICwrrnL5GhkRg5zSaVuGTy+0LpKuk2r@vger.kernel.org X-Gm-Message-State: AOJu0Yz9XpUUATQxADSNGltOESfvHPUIoZRl9PGocAOb//GBpFQ0hYtY nic5cb3z9mX/eEuhQTjUolyJLgpqv6hBNKBhKpRgeYoWLDz7OWE5lpuFbfSSgg== X-Gm-Gg: ASbGnctx8TrGcfUk3jEmOx6Q+6wYjwoQSKtprB8ay5OB7yBRQL5/aQS8PUaE8t32a4L O4vV1nHo5C7DiqmDnPeZUGAriICCXordW7U2finIkuOdfTmzQnXVeJ/gud0W/8lH3vkkekgYCbJ wf86/vJczZAHdN4S+xSYWmEhjkKMQo2n249oPrKg8CE51BtijmxJM7Emt6cI7E7hk/jZyhGdfnB Uq+IQXtfMmsIV02Wnw/ZG6MOjpNj1tjk/XxX7dmtffBtdKD6IvfyTa3JNzliY/6UQlmVNuqwTJa Q2wOYEBm2GPLQkjwJ9+bb9KtB1SBRR+NxoV8ynRo58Rc0b65GTqW8i3tuKbMFrw= X-Google-Smtp-Source: AGHT+IGcCpFaJNeDwV1xaV6JeMEJOB09rF5HzbJRLIe/23F9vWAFzPDCeyz7yY61uG8G97dunknHtg== X-Received: by 2002:a05:6000:4186:b0:3a4:dc42:a0ac with SMTP id ffacd0b85a97d-3a8ffadf926mr7854470f8f.49.1751202882342; Sun, 29 Jun 2025 06:14:42 -0700 (PDT) Received: from denis-pc ([151.49.78.111]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4538a406ab6sm106301495e9.30.2025.06.29.06.14.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Jun 2025 06:14:42 -0700 (PDT) From: Denis Benato To: linux-kernel@vger.kernel.org Cc: hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, platform-driver-x86@vger.kernel.org, mario.limonciello@amd.com, "Luke D . Jones" , Denis Benato Subject: [PATCH v9 1/8] platform/x86: asus-wmi: export symbols used for read/write WMI Date: Sun, 29 Jun 2025 15:14:16 +0200 Message-ID: <20250629131423.9013-2-benato.denis96@gmail.com> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250629131423.9013-1-benato.denis96@gmail.com> References: <20250629131423.9013-1-benato.denis96@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Luke D. Jones" Export symbols for reading/writing WMI symbols using a namespace. Existing functions: - asus_wmi_evaluate_method - asus_wmi_set_devstate New function: - asus_wmi_get_devstate_dsts The new function is intended for use with DSTS WMI method only and avoids requiring the asus_wmi driver data to select the WMI method. Signed-off-by: Denis Benato Signed-off-by: Luke D. Jones Reviewed-by: Mario Limonciello --- drivers/platform/x86/asus-wmi.c | 40 ++++++++++++++++++++-- include/linux/platform_data/x86/asus-wmi.h | 9 +++++ 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wm= i.c index f7191fdded14..e31e0264a160 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -390,7 +390,7 @@ int asus_wmi_evaluate_method(u32 method_id, u32 arg0, u= 32 arg1, u32 *retval) { return asus_wmi_evaluate_method3(method_id, arg0, arg1, 0, retval); } -EXPORT_SYMBOL_GPL(asus_wmi_evaluate_method); +EXPORT_SYMBOL_NS_GPL(asus_wmi_evaluate_method, "ASUS_WMI"); =20 static int asus_wmi_evaluate_method5(u32 method_id, u32 arg0, u32 arg1, u32 arg2, u32 arg3, u32 arg4, u32 *retval) @@ -554,12 +554,46 @@ static int asus_wmi_get_devstate(struct asus_wmi *asu= s, u32 dev_id, u32 *retval) return 0; } =20 -int asus_wmi_set_devstate(u32 dev_id, u32 ctrl_param, - u32 *retval) +/** + * asus_wmi_get_devstate_dsts() - Get the WMI function state. + * @dev_id: The WMI method ID to call. + * @retval: A pointer to where to store the value returned from WMI. + * @return: 0 on success and retval is filled. + * @return: -ENODEV if the method ID is unsupported. + * @return: everything else is an error from WMI call. + */ +int asus_wmi_get_devstate_dsts(u32 dev_id, u32 *retval) +{ + int err; + + err =3D asus_wmi_evaluate_method(ASUS_WMI_METHODID_DSTS, dev_id, 0, retva= l); + if (err) + return err; + + if (*retval =3D=3D ASUS_WMI_UNSUPPORTED_METHOD) + return -ENODEV; + + return 0; +} +EXPORT_SYMBOL_NS_GPL(asus_wmi_get_devstate_dsts, "ASUS_WMI"); + +/** + * asus_wmi_set_devstate() - Set the WMI function state. + * @dev_id: The WMI function to call. + * @ctrl_param: The argument to be used for this WMI function. + * @retval: A pointer to where to store the value returned from WMI. + * @return: 0 on success and retval is filled. + * @return: everything else is an error from WMI call. + * + * A asus_wmi_set_devstate() call must be paired with a + * asus_wmi_get_devstate_dsts() to check if the WMI function is supported. + */ +int asus_wmi_set_devstate(u32 dev_id, u32 ctrl_param, u32 *retval) { return asus_wmi_evaluate_method(ASUS_WMI_METHODID_DEVS, dev_id, ctrl_param, retval); } +EXPORT_SYMBOL_NS_GPL(asus_wmi_set_devstate, "ASUS_WMI"); =20 /* Helper for special devices with magic return codes */ static int asus_wmi_get_devstate_bits(struct asus_wmi *asus, diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/pla= tform_data/x86/asus-wmi.h index 8a515179113d..b6f15b3d0959 100644 --- a/include/linux/platform_data/x86/asus-wmi.h +++ b/include/linux/platform_data/x86/asus-wmi.h @@ -166,6 +166,7 @@ enum asus_ally_mcu_hack { #if IS_REACHABLE(CONFIG_ASUS_WMI) void set_ally_mcu_hack(enum asus_ally_mcu_hack status); void set_ally_mcu_powersave(bool enabled); +int asus_wmi_get_devstate_dsts(u32 dev_id, u32 *retval); int asus_wmi_set_devstate(u32 dev_id, u32 ctrl_param, u32 *retval); int asus_wmi_evaluate_method(u32 method_id, u32 arg0, u32 arg1, u32 *retva= l); #else @@ -179,6 +180,14 @@ static inline int asus_wmi_set_devstate(u32 dev_id, u3= 2 ctrl_param, u32 *retval) { return -ENODEV; } +static inline int asus_wmi_get_devstate_dsts(u32 dev_id, u32 *retval) +{ + return -ENODEV; +} +static inline int asus_wmi_set_devstate(u32 dev_id, u32 ctrl_param, u32 *r= etval) +{ + return -ENODEV; +} static inline int asus_wmi_evaluate_method(u32 method_id, u32 arg0, u32 ar= g1, u32 *retval) { --=20 2.50.0 From nobody Wed Oct 8 10:56:35 2025 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 58672220F32; Sun, 29 Jun 2025 13:14:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751202888; cv=none; b=BcaQ1TIY1vNLfQATG4AtM0z/DAYceG2OLoLdE5Hijt8M2EdDvwcDfP69cU90XrDEPAtKC0LLiLeNZLwrWCOMnZuhH1puCXsWWsTvu/KaeobMHe/X1OZTG2NG533JGeewKX9K7oxj9UhPFx9zNUJL5IWcjeTXQ45LgV3YToRMnuo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751202888; c=relaxed/simple; bh=wFwimV7tPDV+QGMCoigK7mtL11IDvXMAabAvq5smQmA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jTrIILW1qspj9KR0bWu3iekEygi+b0c5v45lo61XF/lNvIFYXmPKOsY2Xx6/ATDnQUj3aDA3IzV/swiGDK+OdPUaCEQMGixfZbp4j721NPj58hQuGot9ApyWlx3LVZL2yNVj2dRjkumBbrKw/U/ZdHh96cUXIp9n+NGtjgSq5e0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=aVXH6nTt; arc=none smtp.client-ip=209.85.221.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aVXH6nTt" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-3a4fb9c2436so2009410f8f.1; Sun, 29 Jun 2025 06:14:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751202883; x=1751807683; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CNRZQCqw3FsNgNTqyr3yqD7e5bj4hp17Ra4/WTEbFek=; b=aVXH6nTtx8/FmaQCgcc2zakZdrUxCEEocB5/1J4Cog9saxO4IMLTFBq01a6lvpLaA+ CTOB+MvAZAvi7REK0av7AnHRE3Cral4NFfH3uovWeYDjOI9MZXkpm7RnqRdyYz/NE7qW f6Q4LJ8bYjVFwrqY9BgdISU8YBMq+pv/HVit+/WvDLpMAGHjNBhDX2Wue/nGfxbBfkDU tetSV7AJ62i7rTr4Fco6yA0rCMkfxcENTtI70OmorytNu4xDVixCXYzVT6zuCmzoFl3y a42CJ3dBvnCzMGDAgye0s9nSEuvh31UvdAv9pqeegwskjvRrO36Rrx+PZpjjAc0w0FbE NL/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751202883; x=1751807683; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CNRZQCqw3FsNgNTqyr3yqD7e5bj4hp17Ra4/WTEbFek=; b=lj/OI+Tqr4BPKpWrIH/KHWG6YNRa6S94awPgddFweFzWdsU09lMR0/pPI7t3+j4xzU JHRCBIlh7JlU03ds/lba0MR6QRuDv47KZ/8dyBT81jMSnYK+nLvgv4JRizMYTTKWgMzl UBnVDiNoDkEqSxXODIypMw0MFqzkpef+gb0FGNrF9/AaQTrB1tSIOHqIKv8FJogxjWNE x82/xLho9EbHsnLVt0bmujhPmhnqSVSyi0ARyGdns3rAAtHDE/gU7R77NS4vRiF7GqAl vEMUtn5dvia23UpPlWhmdJsCnf1SHhkDfbKtdeeVLVpRqp+Kf4RopyubQUXTMOIjZJCS mLAQ== X-Forwarded-Encrypted: i=1; AJvYcCXJtQCun2z0oZxEaOBM9HdeZXv0tN6ngcefGhV0BT44OYEoKOVz1F/Dw5FteX7Tv/iZ5obN2qgy+8GjU39O52RJafBN@vger.kernel.org X-Gm-Message-State: AOJu0YwYa+VBrF9WvRnCNy49p9Ka7emIniVsY/mWcH6u8JxzOjMmIaEo 5gOIZ3zpF+O+7Nz/zvEeoFFAobgY/6+PXyXmrXVi5LxGIf1kSd/u27BKJZCZjg== X-Gm-Gg: ASbGncurNQj/r7ScHioLOdrOdBmA76XCzDa8oIggaFFNK62mXZQjz1w0AEE3xNWjFN0 sIJFyNmOLV+yB0Nt1ldTNw7HQQuSDRFqDrKy88QsmHMNyWp/8ffpzdsaudmoSasq8W+3nIn656B 4+MM86UBr06i6y6eJ4Uhe7iW1REf/YWv6IKCYFPpSKVkmRZ3wGe46deA4oCWcE29dHXm7z2iZC+ 1FrQ3cR0NTx/VNBej9aCnO/mlAf/j3Uh1zIfMC8hwZB3T2VT5WH7TnHZ7NZwqA3F0lDWkD2Yuj3 ewKF6wDZEdfond2ZCf7v60icwrR93ci6HX/CTxppP4J0hi0Hm0DV/o4aqhAhIiE= X-Google-Smtp-Source: AGHT+IFWeFcuzbu28shmDYiIMRxsPRLqH69CcIT3NjLymx1Ypsq+hsNcuoIFdOFExBd3vOw0oT87aA== X-Received: by 2002:a05:6000:65c:b0:3a4:f7e6:284b with SMTP id ffacd0b85a97d-3a8fdb2ac5dmr9193935f8f.10.1751202883234; Sun, 29 Jun 2025 06:14:43 -0700 (PDT) Received: from denis-pc ([151.49.78.111]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4538a406ab6sm106301495e9.30.2025.06.29.06.14.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Jun 2025 06:14:42 -0700 (PDT) From: Denis Benato To: linux-kernel@vger.kernel.org Cc: hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, platform-driver-x86@vger.kernel.org, mario.limonciello@amd.com, "Luke D . Jones" , Denis Benato Subject: [PATCH v9 2/8] platform/x86: asus-armoury: move existing tunings to asus-armoury module Date: Sun, 29 Jun 2025 15:14:17 +0200 Message-ID: <20250629131423.9013-3-benato.denis96@gmail.com> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250629131423.9013-1-benato.denis96@gmail.com> References: <20250629131423.9013-1-benato.denis96@gmail.com> 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: quoted-printable From: "Luke D. Jones" The fw_attributes_class provides a much cleaner interface to all of the attributes introduced to asus-wmi. This patch moves all of these extra attributes over to fw_attributes_class, and shifts the bulk of these definitions to a new kernel module to reduce the clutter of asus-wmi with the intention of deprecating the asus-wmi attributes in future. The work applies only to WMI methods which don't have a clearly defined place within the sysfs and as a result ended up lumped together in /sys/devices/platform/asus-nb-wmi/ with no standard API. Where possible the fw attrs now implement defaults, min, max, scalar, choices, etc. As en example dgpu_disable becomes: /sys/class/firmware-attributes/asus-armoury/attributes/dgpu_disable/ =E2=94=9C=E2=94=80=E2=94=80 current_value =E2=94=9C=E2=94=80=E2=94=80 display_name =E2=94=9C=E2=94=80=E2=94=80 possible_values =E2=94=94=E2=94=80=E2=94=80 type as do other attributes. Signed-off-by: Denis Benato Signed-off-by: Luke D. Jones Reviewed-by: Mario Limonciello --- drivers/platform/x86/Kconfig | 12 + drivers/platform/x86/Makefile | 1 + drivers/platform/x86/asus-armoury.c | 547 +++++++++++++++++++++ drivers/platform/x86/asus-armoury.h | 164 ++++++ drivers/platform/x86/asus-wmi.c | 4 - include/linux/platform_data/x86/asus-wmi.h | 3 + 6 files changed, 727 insertions(+), 4 deletions(-) create mode 100644 drivers/platform/x86/asus-armoury.c create mode 100644 drivers/platform/x86/asus-armoury.h diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig index 49ca98df47fd..f3464e30bd23 100644 --- a/drivers/platform/x86/Kconfig +++ b/drivers/platform/x86/Kconfig @@ -250,6 +250,18 @@ config ASUS_WIRELESS If you choose to compile this driver as a module the module will be called asus-wireless. =20 +config ASUS_ARMOURY + tristate "ASUS Armoury driver" + depends on ASUS_WMI + select FW_ATTR_CLASS + help + Say Y here if you have a WMI aware Asus machine and would like to use t= he + firmware_attributes API to control various settings typically exposed in + the ASUS Armoury Crate application available on Windows. + + To compile this driver as a module, choose M here: the module will + be called asus-armoury. + config ASUS_WMI tristate "ASUS WMI Driver" depends on ACPI_WMI diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile index 0530a224bebd..efbd0787c851 100644 --- a/drivers/platform/x86/Makefile +++ b/drivers/platform/x86/Makefile @@ -32,6 +32,7 @@ obj-$(CONFIG_APPLE_GMUX) +=3D apple-gmux.o # ASUS obj-$(CONFIG_ASUS_LAPTOP) +=3D asus-laptop.o obj-$(CONFIG_ASUS_WIRELESS) +=3D asus-wireless.o +obj-$(CONFIG_ASUS_ARMOURY) +=3D asus-armoury.o obj-$(CONFIG_ASUS_WMI) +=3D asus-wmi.o obj-$(CONFIG_ASUS_NB_WMI) +=3D asus-nb-wmi.o obj-$(CONFIG_ASUS_TF103C_DOCK) +=3D asus-tf103c-dock.o diff --git a/drivers/platform/x86/asus-armoury.c b/drivers/platform/x86/asu= s-armoury.c new file mode 100644 index 000000000000..98b6a918f44f --- /dev/null +++ b/drivers/platform/x86/asus-armoury.c @@ -0,0 +1,547 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Asus Armoury (WMI) attributes driver. + * + * This driver uses the fw_attributes class to expose various WMI functions + * that are present in many gaming and some non-gaming ASUS laptops. + * + * These typically don't fit anywhere else in the sysfs such as under LED = class, + * hwmon or other, and are set in Windows using the ASUS Armoury Crate too= l. + * + * Copyright(C) 2024 Luke Jones + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "asus-armoury.h" +#include "firmware_attributes_class.h" + +#define ASUS_NB_WMI_EVENT_GUID "0B3CBB35-E3C2-45ED-91C2-4C5A6D195D1C" + +#define ASUS_MINI_LED_MODE_MASK 0x03 +/* Standard modes for devices with only on/off */ +#define ASUS_MINI_LED_OFF 0x00 +#define ASUS_MINI_LED_ON 0x01 +/* Like "on" but the effect is more vibrant or brighter */ +#define ASUS_MINI_LED_STRONG_MODE 0x02 +/* New modes for devices with 3 mini-led mode types */ +#define ASUS_MINI_LED_2024_WEAK 0x00 +#define ASUS_MINI_LED_2024_STRONG 0x01 +#define ASUS_MINI_LED_2024_OFF 0x02 + +static struct asus_armoury_priv { + struct device *fw_attr_dev; + struct kset *fw_attr_kset; + + u32 mini_led_dev_id; + u32 gpu_mux_dev_id; +} asus_armoury; + +struct fw_attrs_group { + bool pending_reboot; +}; + +static struct fw_attrs_group fw_attrs =3D { + .pending_reboot =3D false, +}; + +struct asus_attr_group { + const struct attribute_group *attr_group; + u32 wmi_devid; +}; + +static bool asus_wmi_is_present(u32 dev_id) +{ + u32 retval; + int status; + + status =3D asus_wmi_evaluate_method(ASUS_WMI_METHODID_DSTS, dev_id, 0, &r= etval); + pr_debug("%s called (0x%08x), retval: 0x%08x\n", __func__, dev_id, retval= ); + + return status =3D=3D 0 && (retval & ASUS_WMI_DSTS_PRESENCE_BIT); +} + +static void asus_set_reboot_and_signal_event(void) +{ + fw_attrs.pending_reboot =3D true; + kobject_uevent(&asus_armoury.fw_attr_dev->kobj, KOBJ_CHANGE); +} + +static ssize_t pending_reboot_show(struct kobject *kobj, struct kobj_attri= bute *attr, char *buf) +{ + return sysfs_emit(buf, "%d\n", fw_attrs.pending_reboot); +} + +static struct kobj_attribute pending_reboot =3D __ATTR_RO(pending_reboot); + +static bool asus_bios_requires_reboot(struct kobj_attribute *attr) +{ + return !strcmp(attr->attr.name, "gpu_mux_mode"); +} + +static int armoury_wmi_set_devstate(struct kobj_attribute *attr, u32 value= , u32 wmi_dev) +{ + u32 result; + int err; + + err =3D asus_wmi_set_devstate(wmi_dev, value, &result); + if (err) { + pr_err("Failed to set %s: %d\n", attr->attr.name, err); + return err; + } + /* + * !1 is usually considered a fail by ASUS, but some WMI methods do use >= 1 + * to return a status code or similar. + */ + if (result < 1) { + pr_err("Failed to set %s: (result): 0x%x\n", attr->attr.name, result); + return -EIO; + } + + return 0; +} + +/** + * attr_int_store() - Send an int to wmi method, checks if within min/max = exclusive. + * @kobj: Pointer to the driver object. + * @attr: Pointer to the attribute calling this function. + * @buf: The buffer to read from, this is parsed to `int` type. + * @count: Required by sysfs attribute macros, pass in from the callee att= r. + * @min: Minimum accepted value. Below this returns -EINVAL. + * @max: Maximum accepted value. Above this returns -EINVAL. + * @store_value: Pointer to where the parsed value should be stored. + * @wmi_dev: The WMI function ID to use. + * + * This function is intended to be generic so it can be called from any "_= store" + * attribute which works only with integers. The integer to be sent to the= WMI method + * is range checked and an error returned if out of range. + * + * If the value is valid and WMI is success, then the sysfs attribute is n= otified + * and if asus_bios_requires_reboot() is true then reboot attribute is als= o notified. + * + * Returns: Either count, or an error. + */ +static ssize_t attr_uint_store(struct kobject *kobj, struct kobj_attribute= *attr, const char *buf, + size_t count, u32 min, u32 max, u32 *store_value, u32 wmi_dev) +{ + u32 value; + int err; + + err =3D kstrtouint(buf, 10, &value); + if (err) + return err; + + if (value < min || value > max) + return -EINVAL; + + err =3D armoury_wmi_set_devstate(attr, value, wmi_dev); + if (err) + return err; + + if (store_value !=3D NULL) + *store_value =3D value; + sysfs_notify(kobj, NULL, attr->attr.name); + + if (asus_bios_requires_reboot(attr)) + asus_set_reboot_and_signal_event(); + + return count; +} + +static ssize_t enum_type_show(struct kobject *kobj, struct kobj_attribute = *attr, + char *buf) +{ + return sysfs_emit(buf, "enumeration\n"); +} + +/* Mini-LED mode *********************************************************= *****/ +static ssize_t mini_led_mode_current_value_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + u32 value; + int err; + + err =3D asus_wmi_get_devstate_dsts(asus_armoury.mini_led_dev_id, &value); + if (err) + return err; + + value &=3D ASUS_MINI_LED_MODE_MASK; + + /* + * Remap the mode values to match previous generation mini-LED. The last = gen + * WMI 0 =3D=3D off, while on this version WMI 2 =3D=3D off (flipped). + */ + if (asus_armoury.mini_led_dev_id =3D=3D ASUS_WMI_DEVID_MINI_LED_MODE2) { + switch (value) { + case ASUS_MINI_LED_2024_WEAK: + value =3D ASUS_MINI_LED_ON; + break; + case ASUS_MINI_LED_2024_STRONG: + value =3D ASUS_MINI_LED_STRONG_MODE; + break; + case ASUS_MINI_LED_2024_OFF: + value =3D ASUS_MINI_LED_OFF; + break; + } + } + + return sysfs_emit(buf, "%u\n", value); +} + +static ssize_t mini_led_mode_current_value_store(struct kobject *kobj, + struct kobj_attribute *attr, + const char *buf, size_t count) +{ + u32 mode; + int err; + + err =3D kstrtou32(buf, 10, &mode); + if (err) + return err; + + if (asus_armoury.mini_led_dev_id =3D=3D ASUS_WMI_DEVID_MINI_LED_MODE && + mode > ASUS_MINI_LED_ON) + return -EINVAL; + if (asus_armoury.mini_led_dev_id =3D=3D ASUS_WMI_DEVID_MINI_LED_MODE2 && + mode > ASUS_MINI_LED_STRONG_MODE) + return -EINVAL; + + /* + * Remap the mode values so expected behaviour is the same as the last + * generation of mini-LED with 0 =3D=3D off, 1 =3D=3D on. + */ + if (asus_armoury.mini_led_dev_id =3D=3D ASUS_WMI_DEVID_MINI_LED_MODE2) { + switch (mode) { + case ASUS_MINI_LED_OFF: + mode =3D ASUS_MINI_LED_2024_OFF; + break; + case ASUS_MINI_LED_ON: + mode =3D ASUS_MINI_LED_2024_WEAK; + break; + case ASUS_MINI_LED_STRONG_MODE: + mode =3D ASUS_MINI_LED_2024_STRONG; + break; + } + } + + err =3D armoury_wmi_set_devstate(attr, mode, asus_armoury.mini_led_dev_id= ); + if (err) + return err; + + sysfs_notify(kobj, NULL, attr->attr.name); + + return count; +} + +static ssize_t mini_led_mode_possible_values_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + switch (asus_armoury.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"); + default: + return -ENODEV; + } + + return sysfs_emit(buf, "0\n"); +} + +ATTR_GROUP_ENUM_CUSTOM(mini_led_mode, "mini_led_mode", "Set the mini-LED b= acklight mode"); + +static ssize_t gpu_mux_mode_current_value_store(struct kobject *kobj, + struct kobj_attribute *attr, const char *buf, + size_t count) +{ + int result, err; + u32 optimus; + + err =3D kstrtou32(buf, 10, &optimus); + if (err) + return err; + + if (optimus > 1) + return -EINVAL; + + if (asus_wmi_is_present(ASUS_WMI_DEVID_DGPU)) { + err =3D asus_wmi_get_devstate_dsts(ASUS_WMI_DEVID_DGPU, &result); + if (err) + return err; + if (result && !optimus) { + pr_warn("Can not switch MUX to dGPU mode when dGPU is disabled: %02X %0= 2X\n", + result, optimus); + return -ENODEV; + } + } + + if (asus_wmi_is_present(ASUS_WMI_DEVID_EGPU)) { + err =3D asus_wmi_get_devstate_dsts(ASUS_WMI_DEVID_EGPU, &result); + if (err) + return err; + if (result && !optimus) { + pr_warn("Can not switch MUX to dGPU mode when eGPU is enabled\n"); + return -EBUSY; + } + } + + err =3D armoury_wmi_set_devstate(attr, optimus, asus_armoury.gpu_mux_dev_= id); + if (err) + return err; + + sysfs_notify(kobj, NULL, attr->attr.name); + asus_set_reboot_and_signal_event(); + + return count; +} +WMI_SHOW_INT(gpu_mux_mode_current_value, "%u\n", asus_armoury.gpu_mux_dev_= id); +ATTR_GROUP_BOOL_CUSTOM(gpu_mux_mode, "gpu_mux_mode", "Set the GPU display = MUX mode"); + +/* + * A user may be required to store the value twice, typical store first, t= hen + * rescan PCI bus to activate power, then store a second time to save corr= ectly. + */ +static ssize_t dgpu_disable_current_value_store(struct kobject *kobj, + struct kobj_attribute *attr, const char *buf, + size_t count) +{ + int result, err; + u32 disable; + + err =3D kstrtou32(buf, 10, &disable); + if (err) + return err; + + if (disable > 1) + return -EINVAL; + + if (asus_armoury.gpu_mux_dev_id) { + err =3D asus_wmi_get_devstate_dsts(asus_armoury.gpu_mux_dev_id, &result); + if (err) + return err; + if (!result && disable) { + pr_warn("Can not disable dGPU when the MUX is in dGPU mode\n"); + return -EBUSY; + } + } + + err =3D armoury_wmi_set_devstate(attr, disable, ASUS_WMI_DEVID_DGPU); + if (err) + return err; + + sysfs_notify(kobj, NULL, attr->attr.name); + + return count; +} +WMI_SHOW_INT(dgpu_disable_current_value, "%d\n", ASUS_WMI_DEVID_DGPU); +ATTR_GROUP_BOOL_CUSTOM(dgpu_disable, "dgpu_disable", "Disable the dGPU"); + +/* The ACPI call to enable the eGPU also disables the internal dGPU */ +static ssize_t egpu_enable_current_value_store(struct kobject *kobj, struc= t kobj_attribute *attr, + const char *buf, size_t count) +{ + int result, err; + u32 enable; + + err =3D kstrtou32(buf, 10, &enable); + if (err) + return err; + + if (enable > 1) + return -EINVAL; + + err =3D asus_wmi_get_devstate_dsts(ASUS_WMI_DEVID_EGPU_CONNECTED, &result= ); + if (err) { + pr_warn("Failed to get eGPU connection status: %d\n", err); + return err; + } + + if (asus_armoury.gpu_mux_dev_id) { + err =3D asus_wmi_get_devstate_dsts(asus_armoury.gpu_mux_dev_id, &result); + if (err) { + pr_warn("Failed to get GPU MUX status: %d\n", result); + return result; + } + if (!result && enable) { + pr_warn("Can not enable eGPU when the MUX is in dGPU mode\n"); + return -ENODEV; + } + } + + err =3D armoury_wmi_set_devstate(attr, enable, ASUS_WMI_DEVID_EGPU); + if (err) + return err; + + sysfs_notify(kobj, NULL, attr->attr.name); + + return count; +} +WMI_SHOW_INT(egpu_enable_current_value, "%d\n", ASUS_WMI_DEVID_EGPU); +ATTR_GROUP_BOOL_CUSTOM(egpu_enable, "egpu_enable", "Enable the eGPU (also = disables dGPU)"); + +/* Simple attribute creation */ +ATTR_GROUP_ENUM_INT_RO(charge_mode, "charge_mode", ASUS_WMI_DEVID_CHARGE_M= ODE, "0;1;2", + "Show the current mode of charging"); + +ATTR_GROUP_BOOL_RW(boot_sound, "boot_sound", ASUS_WMI_DEVID_BOOT_SOUND, + "Set the boot POST sound"); +ATTR_GROUP_BOOL_RW(mcu_powersave, "mcu_powersave", ASUS_WMI_DEVID_MCU_POWE= RSAVE, + "Set MCU powersaving mode"); +ATTR_GROUP_BOOL_RW(panel_od, "panel_overdrive", ASUS_WMI_DEVID_PANEL_OD, + "Set the panel refresh overdrive"); +ATTR_GROUP_BOOL_RO(egpu_connected, "egpu_connected", ASUS_WMI_DEVID_EGPU_C= ONNECTED, + "Show the eGPU connection status"); + +/* If an attribute does not require any special case handling add it here = */ +static const struct asus_attr_group armoury_attr_groups[] =3D { + { &egpu_connected_attr_group, ASUS_WMI_DEVID_EGPU_CONNECTED }, + { &egpu_enable_attr_group, ASUS_WMI_DEVID_EGPU }, + { &dgpu_disable_attr_group, ASUS_WMI_DEVID_DGPU }, + + { &charge_mode_attr_group, ASUS_WMI_DEVID_CHARGE_MODE }, + { &boot_sound_attr_group, ASUS_WMI_DEVID_BOOT_SOUND }, + { &mcu_powersave_attr_group, ASUS_WMI_DEVID_MCU_POWERSAVE }, + { &panel_od_attr_group, ASUS_WMI_DEVID_PANEL_OD }, +}; + +static int asus_fw_attr_add(void) +{ + int err, i; + + asus_armoury.fw_attr_dev =3D device_create(&firmware_attributes_class, NU= LL, MKDEV(0, 0), + NULL, "%s", DRIVER_NAME); + if (IS_ERR(asus_armoury.fw_attr_dev)) { + err =3D PTR_ERR(asus_armoury.fw_attr_dev); + goto fail_class_get; + } + + asus_armoury.fw_attr_kset =3D kset_create_and_add("attributes", NULL, + &asus_armoury.fw_attr_dev->kobj); + if (!asus_armoury.fw_attr_kset) { + err =3D -ENOMEM; + goto err_destroy_classdev; + } + + err =3D sysfs_create_file(&asus_armoury.fw_attr_kset->kobj, &pending_rebo= ot.attr); + if (err) { + pr_err("Failed to create sysfs level attributes\n"); + goto err_destroy_kset; + } + + asus_armoury.mini_led_dev_id =3D 0; + if (asus_wmi_is_present(ASUS_WMI_DEVID_MINI_LED_MODE)) + asus_armoury.mini_led_dev_id =3D ASUS_WMI_DEVID_MINI_LED_MODE; + else if (asus_wmi_is_present(ASUS_WMI_DEVID_MINI_LED_MODE2)) + asus_armoury.mini_led_dev_id =3D ASUS_WMI_DEVID_MINI_LED_MODE2; + + if (asus_armoury.mini_led_dev_id) { + err =3D sysfs_create_group(&asus_armoury.fw_attr_kset->kobj, + &mini_led_mode_attr_group); + if (err) { + pr_err("Failed to create sysfs-group for mini_led\n"); + goto err_remove_file; + } + } + + asus_armoury.gpu_mux_dev_id =3D 0; + if (asus_wmi_is_present(ASUS_WMI_DEVID_GPU_MUX)) + asus_armoury.gpu_mux_dev_id =3D ASUS_WMI_DEVID_GPU_MUX; + else if (asus_wmi_is_present(ASUS_WMI_DEVID_GPU_MUX_VIVO)) + asus_armoury.gpu_mux_dev_id =3D ASUS_WMI_DEVID_GPU_MUX_VIVO; + + if (asus_armoury.gpu_mux_dev_id) { + err =3D sysfs_create_group(&asus_armoury.fw_attr_kset->kobj, + &gpu_mux_mode_attr_group); + if (err) { + pr_err("Failed to create sysfs-group for gpu_mux\n"); + goto err_remove_mini_led_group; + } + } + + for (i =3D 0; i < ARRAY_SIZE(armoury_attr_groups); i++) { + if (!asus_wmi_is_present(armoury_attr_groups[i].wmi_devid)) + continue; + + err =3D sysfs_create_group(&asus_armoury.fw_attr_kset->kobj, + armoury_attr_groups[i].attr_group); + if (err) { + pr_err("Failed to create sysfs-group for %s\n", + armoury_attr_groups[i].attr_group->name); + goto err_remove_groups; + } + } + + return 0; + +err_remove_groups: + while (i--) { + if (asus_wmi_is_present(armoury_attr_groups[i].wmi_devid)) + sysfs_remove_group(&asus_armoury.fw_attr_kset->kobj, + armoury_attr_groups[i].attr_group); + } + if (asus_armoury.gpu_mux_dev_id) + sysfs_remove_group(&asus_armoury.fw_attr_kset->kobj, &gpu_mux_mode_attr_= group); +err_remove_mini_led_group: + if (asus_armoury.mini_led_dev_id) + sysfs_remove_group(&asus_armoury.fw_attr_kset->kobj, &mini_led_mode_attr= _group); +err_remove_file: + sysfs_remove_file(&asus_armoury.fw_attr_kset->kobj, &pending_reboot.attr); +err_destroy_kset: + kset_unregister(asus_armoury.fw_attr_kset); +err_destroy_classdev: +fail_class_get: + device_destroy(&firmware_attributes_class, MKDEV(0, 0)); + return err; +} + +/* Init / exit ***********************************************************= *****/ + +static int __init asus_fw_init(void) +{ + char *wmi_uid; + + wmi_uid =3D wmi_get_acpi_device_uid(ASUS_WMI_MGMT_GUID); + if (!wmi_uid) + return -ENODEV; + + /* + * if equal to "ASUSWMI" then it's DCTS that can't be used for this + * driver, DSTS is required. + */ + if (!strcmp(wmi_uid, ASUS_ACPI_UID_ASUSWMI)) + return -ENODEV; + + return asus_fw_attr_add(); +} + +static void __exit asus_fw_exit(void) +{ + sysfs_remove_file(&asus_armoury.fw_attr_kset->kobj, &pending_reboot.attr); + kset_unregister(asus_armoury.fw_attr_kset); + device_destroy(&firmware_attributes_class, MKDEV(0, 0)); +} + +module_init(asus_fw_init); +module_exit(asus_fw_exit); + +MODULE_IMPORT_NS("ASUS_WMI"); +MODULE_AUTHOR("Luke Jones "); +MODULE_DESCRIPTION("ASUS BIOS Configuration Driver"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("wmi:" ASUS_NB_WMI_EVENT_GUID); diff --git a/drivers/platform/x86/asus-armoury.h b/drivers/platform/x86/asu= s-armoury.h new file mode 100644 index 000000000000..61675e7b5a60 --- /dev/null +++ b/drivers/platform/x86/asus-armoury.h @@ -0,0 +1,164 @@ +/* SPDX-License-Identifier: GPL-2.0 + * + * Definitions for kernel modules using asus-armoury driver + * + * Copyright (c) 2024 Luke Jones + */ + +#ifndef _ASUS_ARMOURY_H_ +#define _ASUS_ARMOURY_H_ + +#include +#include + +#define DRIVER_NAME "asus-armoury" + +#define __ASUS_ATTR_RO(_func, _name) \ + { \ + .attr =3D { .name =3D __stringify(_name), .mode =3D 0444 }, \ + .show =3D _func##_##_name##_show, \ + } + +#define __ASUS_ATTR_RO_AS(_name, _show) \ + { \ + .attr =3D { .name =3D __stringify(_name), .mode =3D 0444 }, \ + .show =3D _show, \ + } + +#define __ASUS_ATTR_RW(_func, _name) \ + __ATTR(_name, 0644, _func##_##_name##_show, _func##_##_name##_store) + +#define __WMI_STORE_INT(_attr, _min, _max, _wmi) \ + static ssize_t _attr##_store(struct kobject *kobj, \ + struct kobj_attribute *attr, \ + const char *buf, size_t count) \ + { \ + return attr_uint_store(kobj, attr, buf, count, _min, \ + _max, NULL, _wmi); \ + } + +#define WMI_SHOW_INT(_attr, _fmt, _wmi) \ + static ssize_t _attr##_show(struct kobject *kobj, \ + struct kobj_attribute *attr, char *buf) \ + { \ + u32 result; \ + int err; \ + \ + err =3D asus_wmi_get_devstate_dsts(_wmi, &result); \ + if (err) \ + return err; \ + return sysfs_emit(buf, _fmt, \ + result & ~ASUS_WMI_DSTS_PRESENCE_BIT); \ + } + +/* Create functions and attributes for use in other macros or on their own= */ + +/* Shows a formatted static variable */ +#define __ATTR_SHOW_FMT(_prop, _attrname, _fmt, _val) \ + static ssize_t _attrname##_##_prop##_show( \ + struct kobject *kobj, struct kobj_attribute *attr, char *buf) \ + { \ + return sysfs_emit(buf, _fmt, _val); \ + } \ + static struct kobj_attribute attr_##_attrname##_##_prop =3D \ + __ASUS_ATTR_RO(_attrname, _prop) + +#define __ATTR_RO_INT_GROUP_ENUM(_attrname, _wmi, _fsname, _possible, _dis= pname)\ + WMI_SHOW_INT(_attrname##_current_value, "%d\n", _wmi); \ + static struct kobj_attribute attr_##_attrname##_current_value =3D \ + __ASUS_ATTR_RO(_attrname, current_value); \ + __ATTR_SHOW_FMT(display_name, _attrname, "%s\n", _dispname); \ + __ATTR_SHOW_FMT(possible_values, _attrname, "%s\n", _possible); \ + static struct kobj_attribute attr_##_attrname##_type =3D \ + __ASUS_ATTR_RO_AS(type, enum_type_show); \ + static struct attribute *_attrname##_attrs[] =3D { \ + &attr_##_attrname##_current_value.attr, \ + &attr_##_attrname##_display_name.attr, \ + &attr_##_attrname##_possible_values.attr, \ + &attr_##_attrname##_type.attr, \ + NULL \ + }; \ + static const struct attribute_group _attrname##_attr_group =3D { \ + .name =3D _fsname, .attrs =3D _attrname##_attrs \ + } + +#define __ATTR_RW_INT_GROUP_ENUM(_attrname, _minv, _maxv, _wmi, _fsname,\ + _possible, _dispname) \ + __WMI_STORE_INT(_attrname##_current_value, _minv, _maxv, _wmi); \ + WMI_SHOW_INT(_attrname##_current_value, "%d\n", _wmi); \ + static struct kobj_attribute attr_##_attrname##_current_value =3D \ + __ASUS_ATTR_RW(_attrname, current_value); \ + __ATTR_SHOW_FMT(display_name, _attrname, "%s\n", _dispname); \ + __ATTR_SHOW_FMT(possible_values, _attrname, "%s\n", _possible); \ + static struct kobj_attribute attr_##_attrname##_type =3D \ + __ASUS_ATTR_RO_AS(type, enum_type_show); \ + static struct attribute *_attrname##_attrs[] =3D { \ + &attr_##_attrname##_current_value.attr, \ + &attr_##_attrname##_display_name.attr, \ + &attr_##_attrname##_possible_values.attr, \ + &attr_##_attrname##_type.attr, \ + NULL \ + }; \ + static const struct attribute_group _attrname##_attr_group =3D { \ + .name =3D _fsname, .attrs =3D _attrname##_attrs \ + } + +/* Boolean style enumeration, base macro. Requires adding show/store */ +#define __ATTR_GROUP_ENUM(_attrname, _fsname, _possible, _dispname) \ + __ATTR_SHOW_FMT(display_name, _attrname, "%s\n", _dispname); \ + __ATTR_SHOW_FMT(possible_values, _attrname, "%s\n", _possible); \ + static struct kobj_attribute attr_##_attrname##_type =3D \ + __ASUS_ATTR_RO_AS(type, enum_type_show); \ + static struct attribute *_attrname##_attrs[] =3D { \ + &attr_##_attrname##_current_value.attr, \ + &attr_##_attrname##_display_name.attr, \ + &attr_##_attrname##_possible_values.attr, \ + &attr_##_attrname##_type.attr, \ + NULL \ + }; \ + static const struct attribute_group _attrname##_attr_group =3D { \ + .name =3D _fsname, .attrs =3D _attrname##_attrs \ + } + +#define ATTR_GROUP_BOOL_RO(_attrname, _fsname, _wmi, _dispname) \ + __ATTR_RO_INT_GROUP_ENUM(_attrname, _wmi, _fsname, "0;1", _dispname) + + +#define ATTR_GROUP_BOOL_RW(_attrname, _fsname, _wmi, _dispname) \ + __ATTR_RW_INT_GROUP_ENUM(_attrname, 0, 1, _wmi, _fsname, "0;1", _dispname) + +#define ATTR_GROUP_ENUM_INT_RO(_attrname, _fsname, _wmi, _possible, _dispn= ame) \ + __ATTR_RO_INT_GROUP_ENUM(_attrname, _wmi, _fsname, _possible, _dispname) + +/* + * Requires _current_value_show(), _current_value_show() + */ +#define ATTR_GROUP_BOOL_CUSTOM(_attrname, _fsname, _dispname) \ + static struct kobj_attribute attr_##_attrname##_current_value =3D \ + __ASUS_ATTR_RW(_attrname, current_value); \ + __ATTR_GROUP_ENUM(_attrname, _fsname, "0;1", _dispname) + +/* + * Requires _current_value_show(), _current_value_show() + * and _possible_values_show() + */ +#define ATTR_GROUP_ENUM_CUSTOM(_attrname, _fsname, _dispname) \ + __ATTR_SHOW_FMT(display_name, _attrname, "%s\n", _dispname); \ + static struct kobj_attribute attr_##_attrname##_current_value =3D \ + __ASUS_ATTR_RW(_attrname, current_value); \ + static struct kobj_attribute attr_##_attrname##_possible_values =3D \ + __ASUS_ATTR_RO(_attrname, possible_values); \ + static struct kobj_attribute attr_##_attrname##_type =3D \ + __ASUS_ATTR_RO_AS(type, enum_type_show); \ + static struct attribute *_attrname##_attrs[] =3D { \ + &attr_##_attrname##_current_value.attr, \ + &attr_##_attrname##_display_name.attr, \ + &attr_##_attrname##_possible_values.attr, \ + &attr_##_attrname##_type.attr, \ + NULL \ + }; \ + static const struct attribute_group _attrname##_attr_group =3D { \ + .name =3D _fsname, .attrs =3D _attrname##_attrs \ + } + +#endif /* _ASUS_ARMOURY_H_ */ diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wm= i.c index e31e0264a160..9ffcd74c6328 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -55,8 +55,6 @@ module_param(fnlock_default, bool, 0444); #define to_asus_wmi_driver(pdrv) \ (container_of((pdrv), struct asus_wmi_driver, platform_driver)) =20 -#define ASUS_WMI_MGMT_GUID "97845ED0-4E6D-11DE-8A39-0800200C9A66" - #define NOTIFY_BRNUP_MIN 0x11 #define NOTIFY_BRNUP_MAX 0x1f #define NOTIFY_BRNDOWN_MIN 0x20 @@ -105,8 +103,6 @@ module_param(fnlock_default, bool, 0444); #define USB_INTEL_XUSB2PR 0xD0 #define PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI 0x9c31 =20 -#define ASUS_ACPI_UID_ASUSWMI "ASUSWMI" - #define WMI_EVENT_MASK 0xFFFF =20 #define FAN_CURVE_POINTS 8 diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/pla= tform_data/x86/asus-wmi.h index b6f15b3d0959..781e02623dc1 100644 --- a/include/linux/platform_data/x86/asus-wmi.h +++ b/include/linux/platform_data/x86/asus-wmi.h @@ -6,6 +6,9 @@ #include #include =20 +#define ASUS_WMI_MGMT_GUID "97845ED0-4E6D-11DE-8A39-0800200C9A66" +#define ASUS_ACPI_UID_ASUSWMI "ASUSWMI" + /* WMI Methods */ #define ASUS_WMI_METHODID_SPEC 0x43455053 /* BIOS SPECification */ #define ASUS_WMI_METHODID_SFBD 0x44424653 /* Set First Boot Device */ --=20 2.50.0 From nobody Wed Oct 8 10:56:35 2025 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D89EB222590; Sun, 29 Jun 2025 13:14:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751202887; cv=none; b=B0iYGE5au7NOURf5c6bEhTNul59j+hse1A8gvruURQ9etUdQx7NX1d4+Dus/IW01meHFaSnY6gcE43nwPGFVKiYpaRlrZSp36FVN7y6co5uJI6GPuCfPqLxhmMkCG1Us9L6XE8OsaT49IYfM/sQ/2R5DrV97uF6NFbIdFI+80ns= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751202887; c=relaxed/simple; bh=27nPmaPNuD4ssV22ZTaHQEKhxiVwGzO4Uh1MALuKLLU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MVKARwp2KErnGE+p8yJZq1WB/zP7Wv9uyVwESs5+AgciZyqwZbQaB6KuDqOAHOcH2dR9NDXZD3B0zIy3UmYuxotQevAB+8MmtoKnVURye5yvJTvfritGCgBkFjNwQY8UJVLSSv2emYvSbU+DdkTu8Za7oCQIBSZBbHOtzr/+FaQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=jbFOyOpV; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jbFOyOpV" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-451d6ade159so7653115e9.1; Sun, 29 Jun 2025 06:14:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751202884; x=1751807684; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=C4qO2NHkLOriQRO6tXgAApGWBpyjFgN/kHBQ4Aiaqqs=; b=jbFOyOpVGNkOQcXBAIoRLGNZ7aI+cwUSMfekQfaSNzWHdm4CrT9ISZAyRgrqeFtlDH 2GskFq4o0LxDJyoQ6nhbwGkS5AaA2zRy16VSVUO/t1RiDba0e3b27M1zTIj7zEe7ueN/ aWXdggEbtZP58AinSj5cpExv6dVer0V+3jmBl8uTomdkPs/jD314xheKDXqBn2u+/ls0 7WHnXHjESkUSleyTzJS+4cQ+Io5P/ymW9MsXQ3uK6x6/Df7g13XY/26iN8JMsCgLIt3E N/KxLt110vQJMj4cLFWcIMM3YLD54U5io6JfO5ZAXs9zPB6AeXYOmfdbBBmHMHQ3wDEz talA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751202884; x=1751807684; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=C4qO2NHkLOriQRO6tXgAApGWBpyjFgN/kHBQ4Aiaqqs=; b=qYPobtSlX0PplbnRQo5kFtufiAp+baCQjDhhdQtl9SBImtnMigZFxb7BAOb2fmYwX9 sfxBL2xUgZ8Cmh3gCP1uZ2CA4aa5P8BvQ+x3oPF6gc5YB22aGPv7I3OQfnTGLFYAKTVH FdJa2USZ8biy1RpklJGxgfrkA+AGxUcDj+cqLhnYEQ910rDxVEiX7C59pdHhE447tyFw G9m8wXnPjF4mkiogxnJ8Ijj/6/AtgRap+nombzsbKY1fGzYTFGm4g7HUc65RTsRZAZyl 2JGHp04foYLkfWL7BullwpBJYZfnAWMrQc8wER8YXd1zxLjDjWqNECrbABOarUmRh099 SHxQ== X-Forwarded-Encrypted: i=1; AJvYcCWDd0hLf3r4pLWJxm69S/e9s/H9MQDRhqyQcJ8CtkmG8G3xYSLWPspgihxXWkSF5CEUsaBvB7MoA30E8Osz6x2YiMzg@vger.kernel.org X-Gm-Message-State: AOJu0Yxtejj8O/YFoq4GzVgHq4MWwDsDoOL+RA4gbdVuMlpBNdNUcU06 N+giMsmKzvCImUOkDXG5B4RpAdNKpISNdFvAdb9J7mV5h8M7tusP+IysAPPMWg== X-Gm-Gg: ASbGncv198r7WeesvXCH9Zev3WjC5Bf2IrYjq+RWFlVOE0MQrcrsHiuHSFw/sGHnGq9 gaMRynv9qssJ/WvX52EJB0Y5czRoLtSWVC1MQ7dxWkTJYVH6nGZrsbfKxH14Tmpl60MveqKzNXY gjJqhXH4ztD7EOdfM+ASdyL3SxyIT05CHlgXsOIt/UF+NHydyF1vV4kHexOXTDUDSB1uKFwoPr1 MZRgbWfymfZm1v4dJ7fMg4iNwpsPjgasA2mlQrsZTD3NqLDjHgB2G5VLtjGD4BPU/G1Ht4yW/dU SQc3CniOQKBQTJ/1qdyO1HAMcL7WBY2hUel0V7rvQ+HeqoOnY3AxsyYnaa/du7A= X-Google-Smtp-Source: AGHT+IHsqsz75F4n7LJQr5XC0guSKdaed/rinhJpeZr61IhxYfIH8NhEqlWHsCtXzRE0FOvo171BVg== X-Received: by 2002:a05:600c:1f0e:b0:450:d5bf:6720 with SMTP id 5b1f17b1804b1-45391c499bbmr96659485e9.3.1751202883835; Sun, 29 Jun 2025 06:14:43 -0700 (PDT) Received: from denis-pc ([151.49.78.111]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4538a406ab6sm106301495e9.30.2025.06.29.06.14.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Jun 2025 06:14:43 -0700 (PDT) From: Denis Benato To: linux-kernel@vger.kernel.org Cc: hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, platform-driver-x86@vger.kernel.org, mario.limonciello@amd.com, "Luke D . Jones" Subject: [PATCH v9 3/8] platform/x86: asus-armoury: add panel_hd_mode attribute Date: Sun, 29 Jun 2025 15:14:18 +0200 Message-ID: <20250629131423.9013-4-benato.denis96@gmail.com> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250629131423.9013-1-benato.denis96@gmail.com> References: <20250629131423.9013-1-benato.denis96@gmail.com> 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: quoted-printable From: "Luke D. Jones" Add panel_hd_mode to toggle the panel mode between single and high definition modes. Signed-off-by: Luke D. Jones Reviewed-by: Mario Limonciello Reviewed-by: Ilpo J=C3=A4rvinen --- drivers/platform/x86/asus-armoury.c | 6 +++++- include/linux/platform_data/x86/asus-wmi.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/platform/x86/asus-armoury.c b/drivers/platform/x86/asu= s-armoury.c index 98b6a918f44f..26513338208c 100644 --- a/drivers/platform/x86/asus-armoury.c +++ b/drivers/platform/x86/asus-armoury.c @@ -92,7 +92,8 @@ static struct kobj_attribute pending_reboot =3D __ATTR_RO= (pending_reboot); =20 static bool asus_bios_requires_reboot(struct kobj_attribute *attr) { - return !strcmp(attr->attr.name, "gpu_mux_mode"); + return !strcmp(attr->attr.name, "gpu_mux_mode") || + !strcmp(attr->attr.name, "panel_hd_mode"); } =20 static int armoury_wmi_set_devstate(struct kobj_attribute *attr, u32 value= , u32 wmi_dev) @@ -405,6 +406,8 @@ ATTR_GROUP_BOOL_RW(mcu_powersave, "mcu_powersave", ASUS= _WMI_DEVID_MCU_POWERSAVE, "Set MCU powersaving mode"); ATTR_GROUP_BOOL_RW(panel_od, "panel_overdrive", ASUS_WMI_DEVID_PANEL_OD, "Set the panel refresh overdrive"); +ATTR_GROUP_BOOL_RW(panel_hd_mode, "panel_hd_mode", ASUS_WMI_DEVID_PANEL_HD, + "Set the panel HD mode to UHD<0> or FHD<1>"); ATTR_GROUP_BOOL_RO(egpu_connected, "egpu_connected", ASUS_WMI_DEVID_EGPU_C= ONNECTED, "Show the eGPU connection status"); =20 @@ -418,6 +421,7 @@ static const struct asus_attr_group armoury_attr_groups= [] =3D { { &boot_sound_attr_group, ASUS_WMI_DEVID_BOOT_SOUND }, { &mcu_powersave_attr_group, ASUS_WMI_DEVID_MCU_POWERSAVE }, { &panel_od_attr_group, ASUS_WMI_DEVID_PANEL_OD }, + { &panel_hd_mode_attr_group, ASUS_WMI_DEVID_PANEL_HD }, }; =20 static int asus_fw_attr_add(void) diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/pla= tform_data/x86/asus-wmi.h index 781e02623dc1..52c345de03a8 100644 --- a/include/linux/platform_data/x86/asus-wmi.h +++ b/include/linux/platform_data/x86/asus-wmi.h @@ -76,6 +76,7 @@ #define ASUS_WMI_DEVID_THROTTLE_THERMAL_POLICY_VIVO 0x00110019 =20 /* Misc */ +#define ASUS_WMI_DEVID_PANEL_HD 0x0005001C #define ASUS_WMI_DEVID_PANEL_OD 0x00050019 #define ASUS_WMI_DEVID_CAMERA 0x00060013 #define ASUS_WMI_DEVID_LID_FLIP 0x00060062 --=20 2.50.0 From nobody Wed Oct 8 10:56:35 2025 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC46222422D; Sun, 29 Jun 2025 13:14:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751202888; cv=none; b=Spbn4vMzdalquZ7KxVRhrkTtDih0ecRVlWxCKJB9pVUiQiw3rkSed4uo3TXlul1zEWaCC0pWS7PP5XaSYJaYpDsrONLamp56fsYagVH9EyWahGH4vKQAWXq+eOY+Nz7rf1ycsoWb0jH0mZ0RUq8Ys1LzxLXYZemr26vTjNgq/o8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751202888; c=relaxed/simple; bh=PFkyoH6RXYCH7Oc77ngWsYVhybmPGzBkI8FfJnlVTJM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dVkQfLNJlMZBPU2dtycjJSy0puh/Jy5BKvtt7kBd4/mp74693EBpGPNTmEr+YzbHiNstZ4Ln2Gez0RS5qMC3zANWSSjJIsobRIRVWLgZzUBP7G86KNORAfuBmjWXJO4MfYA14iXujTv7JVovzmEGsR4LnFPPf7dOjzASRbkeTus= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=XK+VEN20; arc=none smtp.client-ip=209.85.128.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XK+VEN20" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-451dbe494d6so13726435e9.1; Sun, 29 Jun 2025 06:14:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751202885; x=1751807685; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Y4ozp3RvzsMd9K6m9KNqjEeFwl7v82h3sF2+3BdGbYo=; b=XK+VEN2080AGyzeqRPeo2BbcE3U2HBE0hfPnaHoz9+v0uqFz16zm4xhpz3LdBGizTd GDkOA6M0dyWUwIvudJSRM3DECzxxFgEfXjYFigD6h6aMz8sMeLMYwcveyWpetzG2i6/V Q1surR744cKhAhtayZtOaWyitPqIzQBJs6HqM12TEqq7qCrQ1+1au01zWYDzAZYaeuR7 +k/17aIerQ0XmKPODl0mJBPjFTK+8cZmXmlQNH0hbWFwWedhkfMRujsUSqtbMQP3u1/b AuxX/c2sJBkPgueGNcojNjpE09FkUBf76/pGF2EECll03EDEj4OlSXlCQlxpsnZMZhYA grDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751202885; x=1751807685; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Y4ozp3RvzsMd9K6m9KNqjEeFwl7v82h3sF2+3BdGbYo=; b=v2yhegSQklEfrDO68sfofyIJnNZP15ilOmkZo69IaKMnI44D645o8b2G5Vv+t0Qswi MyC+4XD3fxPCrxwixEhaiQnoJpl718WEDx7P6aI46Af5sZY01FrJ1fZ/fwLZvhopD/oe oywXeJ3/EEzmmz7v4MRN6RAqaKhh+Xd20L7obfsa8oaTDTtfIQF2wARlFzR+in893m+r 8Hg4O93fAZpJE37kIQBBwaTRiLGStYliYjFloOEkgPYR7DtyRryBi1oJpIt6adVIqwlD psvhEmlYH1KRhQMo1+SMjrljGKr0QPZkSF0HHQ6osbCiR4Yk9zEClYk27A8pGvPOKfO8 mwlw== X-Forwarded-Encrypted: i=1; AJvYcCUBjgWjJVrAcshO3o+n0AQh4jj865ksLRc7sW0UsGMwbDM3CNbP27kNLbcc46cCWjFQVneNa2jUH3y2DaS4va8PXAi1@vger.kernel.org X-Gm-Message-State: AOJu0Yxt2fXsEppWI9xK1+7eURjHIHLnJiIc6PHlY76a3sH1HLk5JUln EuJg5AsEE2M8VfUZp/SB0oPJj16fZsWnZ5UnpgXFdO3KMzeirJwqSKrZLIxKZQ== X-Gm-Gg: ASbGncttVGt+meCZ1c6Ve7RMZRTHCcqT60iIftHbRcLhzcIPkksQ/m1dDxtDcrIuajp dVQOCOKp8gYbdMrCEbMjEEmHg5/t3YNuxjnVQXolUm1mW1bBNBM/zsQ9iwolIvpzUPrHdVM6+l7 vUheRqhjuAtgCyzBlHEhEBsb96m0DgnVHH+Ivtkl656ipS8/WUOb05/a0Hk+hN/A0mgalJ0qaES zmoZKhAeL7oSjlDBOukVCkgdBJyd6dDiAwMCb4FaMnhMJsqrwBfDBg3KxQfyTBSxZ5LmwF3zHst RNi2rGQWYg4zzlXO4YJiVqO4bTiSidTf7cpGfha9e8Cy2wFLv7m0zg9zx7nmBZQ= X-Google-Smtp-Source: AGHT+IHlNx7xuDPLjst1ikvMZs4nE9HL5mo/Ji+h/wMuqaoTAdvBR3z/KnW/32G4+jvJciQB5pwlNg== X-Received: by 2002:a05:600c:3b03:b0:453:5c30:a1d0 with SMTP id 5b1f17b1804b1-4538ee7da93mr99459785e9.21.1751202884443; Sun, 29 Jun 2025 06:14:44 -0700 (PDT) Received: from denis-pc ([151.49.78.111]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4538a406ab6sm106301495e9.30.2025.06.29.06.14.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Jun 2025 06:14:44 -0700 (PDT) From: Denis Benato To: linux-kernel@vger.kernel.org Cc: hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, platform-driver-x86@vger.kernel.org, mario.limonciello@amd.com, "Luke D . Jones" , Denis Benato Subject: [PATCH v9 4/8] platform/x86: asus-armoury: add apu-mem control support Date: Sun, 29 Jun 2025 15:14:19 +0200 Message-ID: <20250629131423.9013-5-benato.denis96@gmail.com> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250629131423.9013-1-benato.denis96@gmail.com> References: <20250629131423.9013-1-benato.denis96@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Luke D. Jones" Implement the APU memory size control under the asus-armoury module using the fw_attributes class. This allows the APU allocated memory size to be adjusted depending on the users priority. A reboot is required after change. Signed-off-by: Luke D. Jones Signed-off-by: Denis Benato --- drivers/platform/x86/asus-armoury.c | 81 ++++++++++++++++++++++ include/linux/platform_data/x86/asus-wmi.h | 2 + 2 files changed, 83 insertions(+) diff --git a/drivers/platform/x86/asus-armoury.c b/drivers/platform/x86/asu= s-armoury.c index 26513338208c..25b56d4fa53d 100644 --- a/drivers/platform/x86/asus-armoury.c +++ b/drivers/platform/x86/asus-armoury.c @@ -396,6 +396,86 @@ static ssize_t egpu_enable_current_value_store(struct = kobject *kobj, struct kobj WMI_SHOW_INT(egpu_enable_current_value, "%d\n", ASUS_WMI_DEVID_EGPU); ATTR_GROUP_BOOL_CUSTOM(egpu_enable, "egpu_enable", "Enable the eGPU (also = disables dGPU)"); =20 +/* Device memory available to APU */ + +/* Values map for APU memory: some looks out of order but are actually cor= rect */ +static u32 apu_mem_map[] =3D { + [0] =3D 0x000, /* called "AUTO" on the BIOS, is the minimum available */ + [1] =3D 0x102, + [2] =3D 0x103, + [3] =3D 0x104, + [4] =3D 0x105, + [5] =3D 0x107, + [6] =3D 0x108, + [7] =3D 0x109, + [8] =3D 0x106, +}; + +static ssize_t apu_mem_current_value_show(struct kobject *kobj, struct kob= j_attribute *attr, + char *buf) +{ + int err; + u32 mem; + + err =3D asus_wmi_get_devstate_dsts(ASUS_WMI_DEVID_APU_MEM, &mem); + if (err) + return err; + + if ((mem & ASUS_WMI_DSTS_PRESENCE_BIT) =3D=3D 0) + return -ENODEV; + + mem &=3D ~ASUS_WMI_DSTS_PRESENCE_BIT; + + /* After 0x000 is set, a read will return 0x100 */ + if (mem =3D=3D 0x100) + return sysfs_emit(buf, "0\n"); + + for (unsigned int i =3D 0; i < ARRAY_SIZE(apu_mem_map); i++) { + if (apu_mem_map[i] =3D=3D mem) + return sysfs_emit(buf, "%u\n", i); + } + + pr_warn("Unrecognised value for APU mem 0x%08x\n", mem); + return sysfs_emit(buf, "%u\n", mem); +} + +static ssize_t apu_mem_current_value_store(struct kobject *kobj, struct ko= bj_attribute *attr, + const char *buf, size_t count) +{ + int result, err; + u32 requested, mem; + + result =3D kstrtou32(buf, 10, &requested); + if (result) + return result; + + if (requested > ARRAY_SIZE(apu_mem_map)) + return -EINVAL; + + mem =3D apu_mem_map[requested]; + + err =3D asus_wmi_set_devstate(ASUS_WMI_DEVID_APU_MEM, mem, &result); + if (err) { + pr_warn("Failed to set apu_mem: %d\n", err); + return err; + } + + pr_info("APU memory changed to %uGB, reboot required\n", requested+1); + sysfs_notify(kobj, NULL, attr->attr.name); + + asus_set_reboot_and_signal_event(); + + return count; +} + +static ssize_t apu_mem_possible_values_show(struct kobject *kobj, struct k= obj_attribute *attr, + char *buf) +{ + BUILD_BUG_ON(ARRAY_SIZE(apu_mem_map) !=3D 9); + return sysfs_emit(buf, "0;1;2;3;4;5;6;7;8\n"); +} +ATTR_GROUP_ENUM_CUSTOM(apu_mem, "apu_mem", "Set available system RAM (in G= B) for the APU to use"); + /* Simple attribute creation */ ATTR_GROUP_ENUM_INT_RO(charge_mode, "charge_mode", ASUS_WMI_DEVID_CHARGE_M= ODE, "0;1;2", "Show the current mode of charging"); @@ -416,6 +496,7 @@ static const struct asus_attr_group armoury_attr_groups= [] =3D { { &egpu_connected_attr_group, ASUS_WMI_DEVID_EGPU_CONNECTED }, { &egpu_enable_attr_group, ASUS_WMI_DEVID_EGPU }, { &dgpu_disable_attr_group, ASUS_WMI_DEVID_DGPU }, + { &apu_mem_attr_group, ASUS_WMI_DEVID_APU_MEM }, =20 { &charge_mode_attr_group, ASUS_WMI_DEVID_CHARGE_MODE }, { &boot_sound_attr_group, ASUS_WMI_DEVID_BOOT_SOUND }, diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/pla= tform_data/x86/asus-wmi.h index 52c345de03a8..c0fcdad6443f 100644 --- a/include/linux/platform_data/x86/asus-wmi.h +++ b/include/linux/platform_data/x86/asus-wmi.h @@ -137,6 +137,8 @@ /* dgpu on/off */ #define ASUS_WMI_DEVID_DGPU 0x00090020 =20 +#define ASUS_WMI_DEVID_APU_MEM 0x000600C1 + /* gpu mux switch, 0 =3D dGPU, 1 =3D Optimus */ #define ASUS_WMI_DEVID_GPU_MUX 0x00090016 #define ASUS_WMI_DEVID_GPU_MUX_VIVO 0x00090026 --=20 2.50.0 From nobody Wed Oct 8 10:56:35 2025 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E357D22425E; Sun, 29 Jun 2025 13:14:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751202889; cv=none; b=sYRUdYMDhrrjgxRjmNOB3GNSsJTHzIflLd1OaHRnKdEXJH035kwcmExTCjb0HINUO01QT6Za/enXVRDB9TAq8cUBlj8Z5PA4oY/8lOom1shRIIaK0DK2ksEpljFtbaxBBayfYmCf71pYXMz9adb9NFIloYe+fZlYMRjKBEIU5yw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751202889; c=relaxed/simple; bh=BW77ZjxhmS59X+lBD7RgAB5xX+K944up4xZl+hVR3MQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HAXhEeUd2cJnrR7oBOwtpU9dI8apGEl6NrXCWP7mjiDtBpy9Yf2zLkeSMurs7L5QUq9nWoS6MhO5HA5fKy5gvVhj3Zh2d06uImB3TBdJvV8HMbkJqV/7CVKmGnWpIAboPTfNKwIOU5xdeP7v64MpTe8LkCWnnRrdYUBRL7wVf74= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ReIP9KfK; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ReIP9KfK" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-453634d8609so24614625e9.3; Sun, 29 Jun 2025 06:14:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751202885; x=1751807685; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MthvrZQhg2x1+stO+P5LXKAJUXRm/EkBkL67BjX3IWg=; b=ReIP9KfKA2UobWLvMmB1XS8yoKeTYioM2qHgUW2gRJrIgbrV/iExc+gkgfpYGSucAH qk5M5xlvL8kXymv9y8Lgc54bizXaJMUt2tGDGdSUPPrxXfiCTiBRZjbyWff8bPi0xS0/ b4i9txxE/wRjTQOSgWg5YX5HaxEAuicimU79AowZoj31Ue+Bev2IZdfdGjEj/CiD8cx2 6QbDL391HXewSgv16HG23nyncGogdXyPAC/QJPEc2lI7f0fO422N9TVbyVluWGtlJddg qvoerNVMGor5awhLWDZUHzbcCSi2V7zI+oyDf2SFHN8hz+iHG4QAwJKWHdFSvsI4D47s p9Yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751202885; x=1751807685; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MthvrZQhg2x1+stO+P5LXKAJUXRm/EkBkL67BjX3IWg=; b=s/svcANkyZlb7vDaLZRrZH4g6dwqLeK6GpSOKDiedFVyZaMDO/jXICZxm+gWGy05XJ Iy/Yg+iRMWC45MJuQf8KCLDtxZ4nuxyfKjCqz5DZQbzHMwyCgdjVMWRbqtdrt5OOHBDy tTGk8fJECBatCR/Updyj/gtegLJfBm7VehUvi+kLES/eJA4HG1XNatDiK404Tx3aaVXs sZ+5rjlhe0hqwoWB3NFexJU5+UyGYZCnmTdGW8OQlqWyIyUsWBbgAECFXB+A0Ziy7LtA TXHjFVh85dsFfiigmZzs3xOq3AbE+GQRmRRjvPspdroEoHVBP+uqzlzrPoOfvQkXwiYX 4SvQ== X-Forwarded-Encrypted: i=1; AJvYcCVfZR5lrJFAJzd5bFdszs/qY63MMjRvFHLV43ufiw9P1i2ntvVvX0bPv43vF7fOlSPkXL7s7bmYW0oqhHnd1n0N0J3t@vger.kernel.org X-Gm-Message-State: AOJu0YyW2TOfPZ7uvOaKECRGDh3C1km52ra9FmBESRjq6XjUHy7s/Tow Cx8jKn/cW+X49KVTIVBukMJHky9hsFTuBx3XLIHvDD7lnvVxfGRUFldgCno9/w== X-Gm-Gg: ASbGnctnYwUGbTTlwU9OfeRmoE0kFXqomfKh5kRlaKQhflrG1qU+bCmAaEDCVxVZ+em QCF0opgzMJzvyajBaquxHmq0up9YGvaqBWblN8DFe+GyZImDLROjrw1tAq/Eh7r1w0guttTIZHp ZMTjyDkdV+H1Vh5unPOe0GkVCvbNpK5PENUl/ydtbHwiXqqv5I+F/JDshhr+dLewVaR6m+85rNi WyoyhDM9heSlrQchhTKXyhjC3eUWUBRwXd3Gvc+HIRZGYi5K7QO9vZm133Aul2pHbHU72ks2Cq6 URrIeWjGNXBveaK66AANY4BRRjad2U4h0Y8N7NKZOaibTtu9zXvJ91EQLGnyFY8= X-Google-Smtp-Source: AGHT+IG1xSVSuQSoHyhApZnRRUOtXWRpLlAfb2mSTKmtqj8fd8txkoLhowc/2AZweOZuVV8CkDMalQ== X-Received: by 2002:a05:6000:648:b0:3a8:30b8:cb93 with SMTP id ffacd0b85a97d-3a8ffccac71mr7749237f8f.32.1751202885122; Sun, 29 Jun 2025 06:14:45 -0700 (PDT) Received: from denis-pc ([151.49.78.111]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4538a406ab6sm106301495e9.30.2025.06.29.06.14.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Jun 2025 06:14:44 -0700 (PDT) From: Denis Benato To: linux-kernel@vger.kernel.org Cc: hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, platform-driver-x86@vger.kernel.org, mario.limonciello@amd.com, "Luke D . Jones" , Denis Benato Subject: [PATCH v9 5/8] platform/x86: asus-armoury: add core count control Date: Sun, 29 Jun 2025 15:14:20 +0200 Message-ID: <20250629131423.9013-6-benato.denis96@gmail.com> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250629131423.9013-1-benato.denis96@gmail.com> References: <20250629131423.9013-1-benato.denis96@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Luke D. Jones" Implement Intel core enablement under the asus-armoury module using the fw_attributes class. This allows users to enable or disable preformance or efficiency cores depending on their requirements. After change a reboot is required. Signed-off-by: Denis Benato Signed-off-by: Luke D. Jones --- drivers/platform/x86/asus-armoury.c | 258 ++++++++++++++++++++- drivers/platform/x86/asus-armoury.h | 28 +++ include/linux/platform_data/x86/asus-wmi.h | 5 + 3 files changed, 290 insertions(+), 1 deletion(-) diff --git a/drivers/platform/x86/asus-armoury.c b/drivers/platform/x86/asu= s-armoury.c index 25b56d4fa53d..c94643138fbb 100644 --- a/drivers/platform/x86/asus-armoury.c +++ b/drivers/platform/x86/asus-armoury.c @@ -45,13 +45,49 @@ #define ASUS_MINI_LED_2024_STRONG 0x01 #define ASUS_MINI_LED_2024_OFF 0x02 =20 +#define ASUS_POWER_CORE_MASK GENMASK(15, 8) +#define ASUS_PERF_CORE_MASK GENMASK(7, 0) + +enum cpu_core_type { + CPU_CORE_PERF =3D 0, + CPU_CORE_POWER, +}; + +enum cpu_core_value { + CPU_CORE_DEFAULT =3D 0, + CPU_CORE_MIN, + CPU_CORE_MAX, + CPU_CORE_CURRENT, +}; + +#define CPU_PERF_CORE_COUNT_MIN 4 +#define CPU_POWR_CORE_COUNT_MIN 0 + +/* Tunables provided by ASUS for gaming laptops */ +struct cpu_cores { + u32 cur_perf_cores; + u32 min_perf_cores; + u32 max_perf_cores; + u32 cur_power_cores; + u32 min_power_cores; + u32 max_power_cores; +}; + static struct asus_armoury_priv { struct device *fw_attr_dev; struct kset *fw_attr_kset; =20 + struct cpu_cores *cpu_cores; u32 mini_led_dev_id; u32 gpu_mux_dev_id; -} asus_armoury; + /* + * Mutex to prevent big/little core count changes writing to same + * endpoint at the same time. Must lock during attr store. + */ + struct mutex cpu_core_mutex; +} asus_armoury =3D { + .cpu_core_mutex =3D __MUTEX_INITIALIZER(asus_armoury.cpu_core_mutex) +}; =20 struct fw_attrs_group { bool pending_reboot; @@ -93,6 +129,8 @@ static struct kobj_attribute pending_reboot =3D __ATTR_R= O(pending_reboot); static bool asus_bios_requires_reboot(struct kobj_attribute *attr) { return !strcmp(attr->attr.name, "gpu_mux_mode") || + !strcmp(attr->attr.name, "cores_performance") || + !strcmp(attr->attr.name, "cores_efficiency") || !strcmp(attr->attr.name, "panel_hd_mode"); } =20 @@ -171,6 +209,12 @@ static ssize_t enum_type_show(struct kobject *kobj, st= ruct kobj_attribute *attr, return sysfs_emit(buf, "enumeration\n"); } =20 +static ssize_t int_type_show(struct kobject *kobj, struct kobj_attribute *= attr, + char *buf) +{ + return sysfs_emit(buf, "integer\n"); +} + /* Mini-LED mode *********************************************************= *****/ static ssize_t mini_led_mode_current_value_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) @@ -476,6 +520,207 @@ static ssize_t apu_mem_possible_values_show(struct ko= bject *kobj, struct kobj_at } ATTR_GROUP_ENUM_CUSTOM(apu_mem, "apu_mem", "Set available system RAM (in G= B) for the APU to use"); =20 +static int init_max_cpu_cores(void) +{ + u32 cores; + int err; + + asus_armoury.cpu_cores =3D kzalloc(sizeof(struct cpu_cores), GFP_KERNEL); + if (!asus_armoury.cpu_cores) + return -ENOMEM; + + err =3D asus_wmi_get_devstate_dsts(ASUS_WMI_DEVID_CORES_MAX, &cores); + if (err) + return err; + + if ((cores & ASUS_WMI_DSTS_PRESENCE_BIT) =3D=3D 0) { + pr_err("ACPI does not support CPU core count control\n"); + err =3D -ENODEV; + goto init_max_cpu_cores_err; + } + + asus_armoury.cpu_cores->max_power_cores =3D FIELD_GET(ASUS_POWER_CORE_MAS= K, cores); + asus_armoury.cpu_cores->max_perf_cores =3D FIELD_GET(ASUS_PERF_CORE_MASK,= cores); + + err =3D asus_wmi_get_devstate_dsts(ASUS_WMI_DEVID_CORES, &cores); + if (err) { + pr_err("Could not get CPU core count: error %d\n", err); + goto init_max_cpu_cores_err; + } + + asus_armoury.cpu_cores->cur_perf_cores =3D FIELD_GET(ASUS_PERF_CORE_MASK,= cores); + asus_armoury.cpu_cores->cur_power_cores =3D FIELD_GET(ASUS_POWER_CORE_MAS= K, cores); + + asus_armoury.cpu_cores->min_perf_cores =3D CPU_PERF_CORE_COUNT_MIN; + asus_armoury.cpu_cores->min_power_cores =3D CPU_POWR_CORE_COUNT_MIN; + + return 0; + +init_max_cpu_cores_err: + kfree(asus_armoury.cpu_cores); + return err; +} + +static ssize_t cores_value_show(struct kobject *kobj, struct kobj_attribut= e *attr, char *buf, + enum cpu_core_type core_type, enum cpu_core_value core_value) +{ + u32 cores; + + switch (core_value) { + case CPU_CORE_DEFAULT: + case CPU_CORE_MAX: + if (core_type =3D=3D CPU_CORE_PERF) + return sysfs_emit(buf, "%u\n", + asus_armoury.cpu_cores->max_perf_cores); + else + return sysfs_emit(buf, "%u\n", + asus_armoury.cpu_cores->max_power_cores); + case CPU_CORE_MIN: + if (core_type =3D=3D CPU_CORE_PERF) + return sysfs_emit(buf, "%u\n", + asus_armoury.cpu_cores->min_perf_cores); + else + return sysfs_emit(buf, "%u\n", + asus_armoury.cpu_cores->min_power_cores); + default: + break; + } + + if (core_type =3D=3D CPU_CORE_PERF) + cores =3D asus_armoury.cpu_cores->cur_perf_cores; + else + cores =3D asus_armoury.cpu_cores->cur_power_cores; + + return sysfs_emit(buf, "%u\n", cores); +} + +static ssize_t cores_current_value_store(struct kobject *kobj, struct kobj= _attribute *attr, + const char *buf, enum cpu_core_type core_type) +{ + u32 new_cores, perf_cores, power_cores, out_val, min, max; + int result, err; + + result =3D kstrtou32(buf, 10, &new_cores); + if (result) + return result; + + scoped_guard(mutex, &asus_armoury.cpu_core_mutex) { + if (core_type =3D=3D CPU_CORE_PERF) { + perf_cores =3D new_cores; + power_cores =3D asus_armoury.cpu_cores->cur_power_cores; + min =3D asus_armoury.cpu_cores->min_perf_cores; + max =3D asus_armoury.cpu_cores->max_perf_cores; + } else { + perf_cores =3D asus_armoury.cpu_cores->cur_perf_cores; + power_cores =3D new_cores; + min =3D asus_armoury.cpu_cores->min_power_cores; + max =3D asus_armoury.cpu_cores->max_power_cores; + } + + if (new_cores < min || new_cores > max) + return -EINVAL; + + out_val =3D FIELD_PREP(ASUS_PERF_CORE_MASK, perf_cores) | + FIELD_PREP(ASUS_POWER_CORE_MASK, power_cores); + + err =3D asus_wmi_set_devstate(ASUS_WMI_DEVID_CORES, out_val, &result); + if (err) { + pr_warn("Failed to set CPU core count: %d\n", err); + return err; + } + + if (result > 1) { + pr_warn("Failed to set CPU core count (result): 0x%x\n", result); + return -EIO; + } + } + + pr_info("CPU core count changed, reboot required\n"); + + sysfs_notify(kobj, NULL, attr->attr.name); + asus_set_reboot_and_signal_event(); + + return 0; +} + +static ssize_t cores_performance_min_value_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + return cores_value_show(kobj, attr, buf, CPU_CORE_PERF, CPU_CORE_MIN); +} + +static ssize_t cores_performance_max_value_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + return cores_value_show(kobj, attr, buf, CPU_CORE_PERF, CPU_CORE_MAX); +} + +static ssize_t cores_performance_default_value_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + return cores_value_show(kobj, attr, buf, CPU_CORE_PERF, CPU_CORE_DEFAULT); +} + +static ssize_t cores_performance_current_value_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + return cores_value_show(kobj, attr, buf, CPU_CORE_PERF, CPU_CORE_CURRENT); +} + +static ssize_t cores_performance_current_value_store(struct kobject *kobj, + struct kobj_attribute *attr, + const char *buf, size_t count) +{ + int err; + + err =3D cores_current_value_store(kobj, attr, buf, CPU_CORE_PERF); + if (err) + return err; + + return count; +} +ATTR_GROUP_CORES_RW(cores_performance, "cores_performance", + "Set the max available performance cores"); + +static ssize_t cores_efficiency_min_value_show(struct kobject *kobj, struc= t kobj_attribute *attr, + char *buf) +{ + return cores_value_show(kobj, attr, buf, CPU_CORE_POWER, CPU_CORE_MIN); +} + +static ssize_t cores_efficiency_max_value_show(struct kobject *kobj, struc= t kobj_attribute *attr, + char *buf) +{ + return cores_value_show(kobj, attr, buf, CPU_CORE_POWER, CPU_CORE_MAX); +} + +static ssize_t cores_efficiency_default_value_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + return cores_value_show(kobj, attr, buf, CPU_CORE_POWER, CPU_CORE_DEFAULT= ); +} + +static ssize_t cores_efficiency_current_value_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + return cores_value_show(kobj, attr, buf, CPU_CORE_POWER, CPU_CORE_CURRENT= ); +} + +static ssize_t cores_efficiency_current_value_store(struct kobject *kobj, + struct kobj_attribute *attr, const char *buf, + size_t count) +{ + int err; + + err =3D cores_current_value_store(kobj, attr, buf, CPU_CORE_POWER); + if (err) + return err; + + return count; +} +ATTR_GROUP_CORES_RW(cores_efficiency, "cores_efficiency", + "Set the max available efficiency cores"); + /* Simple attribute creation */ ATTR_GROUP_ENUM_INT_RO(charge_mode, "charge_mode", ASUS_WMI_DEVID_CHARGE_M= ODE, "0;1;2", "Show the current mode of charging"); @@ -497,6 +742,8 @@ static const struct asus_attr_group armoury_attr_groups= [] =3D { { &egpu_enable_attr_group, ASUS_WMI_DEVID_EGPU }, { &dgpu_disable_attr_group, ASUS_WMI_DEVID_DGPU }, { &apu_mem_attr_group, ASUS_WMI_DEVID_APU_MEM }, + { &cores_efficiency_attr_group, ASUS_WMI_DEVID_CORES_MAX }, + { &cores_performance_attr_group, ASUS_WMI_DEVID_CORES_MAX }, =20 { &charge_mode_attr_group, ASUS_WMI_DEVID_CHARGE_MODE }, { &boot_sound_attr_group, ASUS_WMI_DEVID_BOOT_SOUND }, @@ -600,6 +847,7 @@ static int asus_fw_attr_add(void) static int __init asus_fw_init(void) { char *wmi_uid; + int err; =20 wmi_uid =3D wmi_get_acpi_device_uid(ASUS_WMI_MGMT_GUID); if (!wmi_uid) @@ -612,6 +860,14 @@ static int __init asus_fw_init(void) if (!strcmp(wmi_uid, ASUS_ACPI_UID_ASUSWMI)) return -ENODEV; =20 + if (asus_wmi_is_present(ASUS_WMI_DEVID_CORES_MAX)) { + err =3D init_max_cpu_cores(); + if (err) { + pr_err("Could not initialise CPU core control %d\n", err); + return err; + } + } + return asus_fw_attr_add(); } =20 diff --git a/drivers/platform/x86/asus-armoury.h b/drivers/platform/x86/asu= s-armoury.h index 61675e7b5a60..a6c4caefdef9 100644 --- a/drivers/platform/x86/asus-armoury.h +++ b/drivers/platform/x86/asus-armoury.h @@ -161,4 +161,32 @@ .name =3D _fsname, .attrs =3D _attrname##_attrs \ } =20 +/* CPU core attributes need a little different in setup */ +#define ATTR_GROUP_CORES_RW(_attrname, _fsname, _dispname) \ + __ATTR_SHOW_FMT(scalar_increment, _attrname, "%d\n", 1); \ + __ATTR_SHOW_FMT(display_name, _attrname, "%s\n", _dispname); \ + static struct kobj_attribute attr_##_attrname##_current_value =3D \ + __ASUS_ATTR_RW(_attrname, current_value); \ + static struct kobj_attribute attr_##_attrname##_default_value =3D \ + __ASUS_ATTR_RO(_attrname, default_value); \ + static struct kobj_attribute attr_##_attrname##_min_value =3D \ + __ASUS_ATTR_RO(_attrname, min_value); \ + static struct kobj_attribute attr_##_attrname##_max_value =3D \ + __ASUS_ATTR_RO(_attrname, max_value); \ + static struct kobj_attribute attr_##_attrname##_type =3D \ + __ASUS_ATTR_RO_AS(type, int_type_show); \ + static struct attribute *_attrname##_attrs[] =3D { \ + &attr_##_attrname##_current_value.attr, \ + &attr_##_attrname##_default_value.attr, \ + &attr_##_attrname##_min_value.attr, \ + &attr_##_attrname##_max_value.attr, \ + &attr_##_attrname##_scalar_increment.attr, \ + &attr_##_attrname##_display_name.attr, \ + &attr_##_attrname##_type.attr, \ + NULL \ + }; \ + static const struct attribute_group _attrname##_attr_group =3D { \ + .name =3D _fsname, .attrs =3D _attrname##_attrs \ + } + #endif /* _ASUS_ARMOURY_H_ */ diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/pla= tform_data/x86/asus-wmi.h index c0fcdad6443f..d356dfe5ee7c 100644 --- a/include/linux/platform_data/x86/asus-wmi.h +++ b/include/linux/platform_data/x86/asus-wmi.h @@ -137,6 +137,11 @@ /* dgpu on/off */ #define ASUS_WMI_DEVID_DGPU 0x00090020 =20 +/* Intel E-core and P-core configuration in a format 0x0[E]0[P] */ +#define ASUS_WMI_DEVID_CORES 0x001200D2 + /* Maximum Intel E-core and P-core availability */ +#define ASUS_WMI_DEVID_CORES_MAX 0x001200D3 + #define ASUS_WMI_DEVID_APU_MEM 0x000600C1 =20 /* gpu mux switch, 0 =3D dGPU, 1 =3D Optimus */ --=20 2.50.0 From nobody Wed Oct 8 10:56:35 2025 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B4E5D224AFB; Sun, 29 Jun 2025 13:14:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751202889; cv=none; b=YMNkq90ve8/4j7YF76x/BZQXMtb61QBr6YP34rfKIS9fvhTntSgQI7YXdGKOkSaK6xilqGjUOqS/ytBADEOSQHjUyAEDFcqOqtUJ3WRlZhdFv1D1miv0GiOsI2AzProFTb2Kc20C11yuXfJ7l+Hwx5JUZbu7Trmo1uJUem3GKtE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751202889; c=relaxed/simple; bh=WMRI84Xignjt8gR0NUqBgm0jb9KGCKVV6GOBqyJYv3U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=D0l5VMUOB5GmYKNUtB5DWuzlGjnrDZllKbIC9QD+0JUxtjKf5IL0ZjBPcE0JtHXjnBCyY0dlKVZkb0GtuTMat/X9AYOkeNHNvuf4O8op8r85YtC+MEyMEXNSc4sQNw9bK+M9iJxcVSlw7MvdONcWgP4Aog3jZtKrVvidoIVUNrg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=GJONMp7u; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GJONMp7u" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-451d7b50815so8103065e9.2; Sun, 29 Jun 2025 06:14:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751202886; x=1751807686; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fHgLJcoU0LPMw5A2wllDN+DVeE/H5DxKAogK6F++XI4=; b=GJONMp7uIic11RLEIgaMHtsparnrZQ38nrLmISKDlxFAEjyeB+x+aezGVhCu1JYIAC jcU8apqJgthCwRRDC0nLYU9s1UfTsW5lc/lJsENYrDAlnvKhkzEXDl6iLErO4hTl6F6c mYWwJIL+ibBTBhjdHwrsvNfq53EyxUT280LmDEa6WRctW92CwoLmRyHskF3rCrC/r3zn w798FHfsXgIQoZFurojZ0chVUhL059flEmD4WU41waVjwEdBoVLltnCevsQtA4cytaA/ h8xiGaALtoa2ZU3dJix8ZdzJhSfHij2E/HAqooQBcH9FuN2m22tWTj6S+jStvSiPAHVY +MQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751202886; x=1751807686; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fHgLJcoU0LPMw5A2wllDN+DVeE/H5DxKAogK6F++XI4=; b=jmiSayK51fsPYcfMqukbEqR+Be9BvtXcg1LZ1voOzoTuwyrcCAaoubBi56quJk93k9 QaTG+7O0ZslLhkTS2iCRwlBzs5eU3XDz7DLN/x/D4NZi+9zmokJzCC2xbfMvXSZSPrxs 7e/HyKhNl/pYhL7uc7JQk/1LTurbs6oGhw3PVmE7mRZo7yg5LeZBPHAiBOTHjJaCq1Ie upSIOtGGxpDjuLPThp9uER2x1hx/virsFL+E+wVzPAowTjbhDHFy9UxwYmmZMsns3/Ut JeXyqBTqgtfUoKY5VnqLXt41VvUd8cVVJze3OLC46TB4RdAwPhh9XU32Dg+6GvrEIBnq pksA== X-Forwarded-Encrypted: i=1; AJvYcCWj+znJ8xo+F0T3oan1uDLyzGgvfgbqUUhy8EWwX0O+HkotnQ9cT1VrsFfwbl2f6uP4hOX0+X+9ITRD8ZjQlA+s0aii@vger.kernel.org X-Gm-Message-State: AOJu0Yx3ER1HMY64HTAX/LfvC7CUiqXWnJXXN5qYGHjnD3FL7VRqAfuX mIu1U10oanhQveLwpzSDOeGF95I+vc28Ho4105V3hOKPKzk9cn4D/YW3TllswQ== X-Gm-Gg: ASbGnctsvRs+GC6HRE1wYxJYmKvWml4VMFNnX76RZWggnnveGKNBsh1T+i48EAP1gNG +/peVupQCWDhH9eAILF/lqRqPGjwBFEHmfI2FsmBkU3AMgQFYLBoj3KvDJm81wATTp+THAo/GQf 5+S3ZHpsNa46qbXPYhGsdwF5sNoLwI1Pz0dgZ+oktL9Jm+204NDP9Lem1Sgkld6D/qvwMgcBDgi UBRsZCNhR0Y7xCIuXR7qZ7lmtdu+0UXNv1Y3M++wp0R3hYV/Q027nB/q1EI27oNJtNdZ5sGo0sK oXT3QYM0L7T9AglgtsP7JesNpe969+fZmSjMXBHBz20uxg1vKNwIiXoPPiRVVSnGajGQInk5Mw= = X-Google-Smtp-Source: AGHT+IHYYHhUa2IXkIv3ocCtZf9L78v2udC+H5/y3Ky1HRKLtDafGP+bt0Nv0p6e3ZWfesNA7DJeqg== X-Received: by 2002:a05:600c:6383:b0:442:f482:c42d with SMTP id 5b1f17b1804b1-4538ee39977mr99914635e9.9.1751202885724; Sun, 29 Jun 2025 06:14:45 -0700 (PDT) Received: from denis-pc ([151.49.78.111]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4538a406ab6sm106301495e9.30.2025.06.29.06.14.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Jun 2025 06:14:45 -0700 (PDT) From: Denis Benato To: linux-kernel@vger.kernel.org Cc: hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, platform-driver-x86@vger.kernel.org, mario.limonciello@amd.com, "Luke D . Jones" Subject: [PATCH v9 6/8] platform/x86: asus-armoury: add screen auto-brightness toggle Date: Sun, 29 Jun 2025 15:14:21 +0200 Message-ID: <20250629131423.9013-7-benato.denis96@gmail.com> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250629131423.9013-1-benato.denis96@gmail.com> References: <20250629131423.9013-1-benato.denis96@gmail.com> 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: quoted-printable From: "Luke D. Jones" Add screen_auto_brightness toggle supported on some laptops. Signed-off-by: Luke D. Jones Reviewed-by: Mario Limonciello Reviewed-by: Ilpo J=C3=A4rvinen --- drivers/platform/x86/asus-armoury.c | 3 +++ include/linux/platform_data/x86/asus-wmi.h | 1 + 2 files changed, 4 insertions(+) diff --git a/drivers/platform/x86/asus-armoury.c b/drivers/platform/x86/asu= s-armoury.c index c94643138fbb..33d71bf64468 100644 --- a/drivers/platform/x86/asus-armoury.c +++ b/drivers/platform/x86/asus-armoury.c @@ -733,6 +733,9 @@ ATTR_GROUP_BOOL_RW(panel_od, "panel_overdrive", ASUS_WM= I_DEVID_PANEL_OD, "Set the panel refresh overdrive"); ATTR_GROUP_BOOL_RW(panel_hd_mode, "panel_hd_mode", ASUS_WMI_DEVID_PANEL_HD, "Set the panel HD mode to UHD<0> or FHD<1>"); +ATTR_GROUP_BOOL_RW(screen_auto_brightness, "screen_auto_brightness", + ASUS_WMI_DEVID_SCREEN_AUTO_BRIGHTNESS, + "Set the panel brightness to Off<0> or On<1>"); ATTR_GROUP_BOOL_RO(egpu_connected, "egpu_connected", ASUS_WMI_DEVID_EGPU_C= ONNECTED, "Show the eGPU connection status"); =20 diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/pla= tform_data/x86/asus-wmi.h index d356dfe5ee7c..72fd2fc88bb1 100644 --- a/include/linux/platform_data/x86/asus-wmi.h +++ b/include/linux/platform_data/x86/asus-wmi.h @@ -83,6 +83,7 @@ #define ASUS_WMI_DEVID_LID_FLIP_ROG 0x00060077 #define ASUS_WMI_DEVID_MINI_LED_MODE 0x0005001E #define ASUS_WMI_DEVID_MINI_LED_MODE2 0x0005002E +#define ASUS_WMI_DEVID_SCREEN_AUTO_BRIGHTNESS 0x0005002A =20 /* Storage */ #define ASUS_WMI_DEVID_CARDREADER 0x00080013 --=20 2.50.0 From nobody Wed Oct 8 10:56:35 2025 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 773AF2253B5; Sun, 29 Jun 2025 13:14:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751202891; cv=none; b=cQYcE6JwBf8Mi53TUCx6KqKWs6cI0Zu/aCif8EFh3b7k8b/+1CoG5LJBXaxb5VF4Aky/lHhXyEHj/Hg1S5oP/fmCfhS3M0Dg1dGM4ZMVRW2Afe/SFlz/Ag8EVRZkUYdrlRKZVjbXPBYiynfjsuSoOgnUtFeXG+kJea+3F3XBLww= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751202891; c=relaxed/simple; bh=mpSs5hLMVJMMzjRnslltEjL3KE3Pmy4BjxHZnvp/E7E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TfHsQVlQG4v9wyWOwBD5lPZULaBQq8Gzi7JcH7TgHL6Pl5MVIJ0HneL6hz7keougat7QLhw4z7KFOo0sxqpk8I9aIaP4WUOkwGJC412YJumHUe7DRWLiqlhGkRRG7VGi1dQXtUWf8yTmNV5nHtKz+yjJhcasD0YygEikqiI7cIw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=cw71ubHU; arc=none smtp.client-ip=209.85.128.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cw71ubHU" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-451d54214adso24660205e9.3; Sun, 29 Jun 2025 06:14:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751202887; x=1751807687; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DQQARNYUCU5YN+CTiKhKyW3fe32kcASuo1ORd1lgGYo=; b=cw71ubHUrznLoSLQrXZs2xAOBKkqY+CMg36k6lZKJtW9SpxQ74elMS4f+Cj+VrbY2g kxuLyCnAgJqY9RJi1cHA/PguhkBPeEb2EAzwnjBC+cBwdupmIpqtaqQlpD2SUukVZaKn kzfsq5o+XSdK22JT+yYk5MQJX1AVanihdkYJU1llu1YNC7PCNLcvmbnrNNoJeVlTTwHr gEpUt0TwIz32L+hrhZa+DOcmfVY/vtKTRT9p9TnkAcWVrKu7tVN2IAmeilTFI0A/qnyd g/w4GFauwMpVjXAL0/niyen5AFWjx/j6awmfI1BXbgf5/0sfywYjX3QiifRnwU0VnpEY XuqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751202887; x=1751807687; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DQQARNYUCU5YN+CTiKhKyW3fe32kcASuo1ORd1lgGYo=; b=SlrJi5/Qa4LE1MriJIx206mWHQe2jQ3o055mOKYuWIFHz6dHhPka5ER+Q2RC/fZo3t lZBL625Xup95LGzWXl9jB7cePy2wzdJtFk5eOGdv38aAZXLQKxzwmKbjZCA5rOvw8HeQ +aaTpg1CLW0PIuF4+OeLgiOX3c7f1tnKqhMZ2LKaFYMapnSbe8eCxFQz2WDmGc6WOTRl F/aRvfqct70V7z5BBYd0Ms861PqIXkN8HvhlY9qZCVTJUECeprYM1EX70xubsOLr0Jvs hL4T5/FB5Jx9Z4bzdfuizCPlO0DiI6npPiNMtxgpUZteBXC9/F50OSm5AAgVGRr1esd0 zCGw== X-Forwarded-Encrypted: i=1; AJvYcCUK5l255XgEaEdkP7ReDidINNOpvgRkrVrIfJFSx0n8Ix2vleHl5kaLN6J+0VVL0KnynUi6SlauAq3GYnVp8jKubvJU@vger.kernel.org X-Gm-Message-State: AOJu0YzCI/akPl1TAUu0cqT7ivvlW2YZ+Qq14DLIcUHg3utMs7/zCjBa tG60IZD05nYLAfLSq/2ren4AZZn1m0Xc56uRtd2WpyrlZkqtzWII4Yyvk6FQJg== X-Gm-Gg: ASbGncsdFoXX+YACk1PNGbISm4yQK61iA5xoqs52U34v287WXHwFcMr0+Ss2gRYwuoT rk7NqcomkUDx7RGL97/8/coBzislMIeHy7rNHhDfVHl6pbMdDr7JwKc6FzA3nmIFAtLSqIrgbW9 8CNNtCTMsbfLlJEPX8mHnbSh05pMlj+9wGsWZRUUlSR8KvOzq4vzfV6D9HZVSfA80i1F9Zb9b0j 9L8Ji4h54leLGukJcwM0Hk1xUG7nlJQBw2sQHo1Bk4gikGJ0T5mtMs578Yl85W+V/8lTTKjJPk9 hjni/f6S8hNS1WwWv+vC2N5u39HaUAfG8A3+EZxbxPsxt8CJgJ62Hjhou73XYEc= X-Google-Smtp-Source: AGHT+IEia35BJd3VFgs7aypFxX0bnnNYiiwNTL6aPSz8vsqL2UvwqOWrUg2tlF90avyDJR6s078bDA== X-Received: by 2002:a05:600c:8889:10b0:453:99f:b1b0 with SMTP id 5b1f17b1804b1-4538ee7df67mr54129475e9.20.1751202886356; Sun, 29 Jun 2025 06:14:46 -0700 (PDT) Received: from denis-pc ([151.49.78.111]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4538a406ab6sm106301495e9.30.2025.06.29.06.14.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Jun 2025 06:14:46 -0700 (PDT) From: Denis Benato To: linux-kernel@vger.kernel.org Cc: hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, platform-driver-x86@vger.kernel.org, mario.limonciello@amd.com, "Luke D . Jones" , Denis Benato Subject: [PATCH v9 7/8] platform/x86: asus-wmi: deprecate bios features Date: Sun, 29 Jun 2025 15:14:22 +0200 Message-ID: <20250629131423.9013-8-benato.denis96@gmail.com> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250629131423.9013-1-benato.denis96@gmail.com> References: <20250629131423.9013-1-benato.denis96@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Luke D. Jones" With the existence of the asus-armoury module the attributes no longer need to live under the /sys/devices/platform/asus-nb-wmi/ path. Deprecate all those that were implemented in asus-bioscfg with the goal of removing them fully in the next LTS cycle. Signed-off-by: Luke D. Jones Reviewed-by: Mario Limonciello Tested-by: Denis Benato --- .../ABI/testing/sysfs-platform-asus-wmi | 17 +++ drivers/platform/x86/Kconfig | 11 ++ drivers/platform/x86/asus-wmi.c | 121 ++++++++++++++---- 3 files changed, 124 insertions(+), 25 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-platform-asus-wmi b/Documentat= ion/ABI/testing/sysfs-platform-asus-wmi index 28144371a0f1..765d50b0d9df 100644 --- a/Documentation/ABI/testing/sysfs-platform-asus-wmi +++ b/Documentation/ABI/testing/sysfs-platform-asus-wmi @@ -63,6 +63,7 @@ Date: Aug 2022 KernelVersion: 6.1 Contact: "Luke Jones" Description: + DEPRECATED, WILL BE REMOVED SOON Switch the GPU hardware MUX mode. Laptops with this feature can can be toggled to boot with only the dGPU (discrete mode) or in standard Optimus/Hybrid mode. On switch a reboot is required: @@ -75,6 +76,7 @@ Date: Aug 2022 KernelVersion: 5.17 Contact: "Luke Jones" Description: + DEPRECATED, WILL BE REMOVED SOON Disable discrete GPU: * 0 - Enable dGPU, * 1 - Disable dGPU @@ -84,6 +86,7 @@ Date: Aug 2022 KernelVersion: 5.17 Contact: "Luke Jones" Description: + DEPRECATED, WILL BE REMOVED SOON Enable the external GPU paired with ROG X-Flow laptops. Toggling this setting will also trigger ACPI to disable the dGPU: =20 @@ -95,6 +98,7 @@ Date: Aug 2022 KernelVersion: 5.17 Contact: "Luke Jones" Description: + DEPRECATED, WILL BE REMOVED SOON Enable an LCD response-time boost to reduce or remove ghosting: * 0 - Disable, * 1 - Enable @@ -104,6 +108,7 @@ Date: Jun 2023 KernelVersion: 6.5 Contact: "Luke Jones" Description: + DEPRECATED, WILL BE REMOVED SOON Get the current charging mode being used: * 1 - Barrel connected charger, * 2 - USB-C charging @@ -114,6 +119,7 @@ Date: Jun 2023 KernelVersion: 6.5 Contact: "Luke Jones" Description: + DEPRECATED, WILL BE REMOVED SOON Show if the egpu (XG Mobile) is correctly connected: * 0 - False, * 1 - True @@ -123,6 +129,7 @@ Date: Jun 2023 KernelVersion: 6.5 Contact: "Luke Jones" Description: + DEPRECATED, WILL BE REMOVED SOON Change the mini-LED mode: * 0 - Single-zone, * 1 - Multi-zone @@ -133,6 +140,7 @@ Date: Apr 2024 KernelVersion: 6.10 Contact: "Luke Jones" Description: + DEPRECATED, WILL BE REMOVED SOON List the available mini-led modes. =20 What: /sys/devices/platform//ppt_pl1_spl @@ -140,6 +148,7 @@ Date: Jun 2023 KernelVersion: 6.5 Contact: "Luke Jones" Description: + DEPRECATED, WILL BE REMOVED SOON Set the Package Power Target total of CPU: PL1 on Intel, SPL on AMD. Shown on Intel+Nvidia or AMD+Nvidia based systems: =20 @@ -150,6 +159,7 @@ Date: Jun 2023 KernelVersion: 6.5 Contact: "Luke Jones" Description: + DEPRECATED, WILL BE REMOVED SOON Set the Slow Package Power Tracking Limit of CPU: PL2 on Intel, SPPT, on AMD. Shown on Intel+Nvidia or AMD+Nvidia based systems: =20 @@ -160,6 +170,7 @@ Date: Jun 2023 KernelVersion: 6.5 Contact: "Luke Jones" Description: + DEPRECATED, WILL BE REMOVED SOON Set the Fast Package Power Tracking Limit of CPU. AMD+Nvidia only: * min=3D5, max=3D250 =20 @@ -168,6 +179,7 @@ Date: Jun 2023 KernelVersion: 6.5 Contact: "Luke Jones" Description: + DEPRECATED, WILL BE REMOVED SOON Set the APU SPPT limit. Shown on full AMD systems only: * min=3D5, max=3D130 =20 @@ -176,6 +188,7 @@ Date: Jun 2023 KernelVersion: 6.5 Contact: "Luke Jones" Description: + DEPRECATED, WILL BE REMOVED SOON Set the platform SPPT limit. Shown on full AMD systems only: * min=3D5, max=3D130 =20 @@ -184,6 +197,7 @@ Date: Jun 2023 KernelVersion: 6.5 Contact: "Luke Jones" Description: + DEPRECATED, WILL BE REMOVED SOON Set the dynamic boost limit of the Nvidia dGPU: * min=3D5, max=3D25 =20 @@ -192,6 +206,7 @@ Date: Jun 2023 KernelVersion: 6.5 Contact: "Luke Jones" Description: + DEPRECATED, WILL BE REMOVED SOON Set the target temperature limit of the Nvidia dGPU: * min=3D75, max=3D87 =20 @@ -200,6 +215,7 @@ Date: Apr 2024 KernelVersion: 6.10 Contact: "Luke Jones" Description: + DEPRECATED, WILL BE REMOVED SOON Set if the BIOS POST sound is played on boot. * 0 - False, * 1 - True @@ -209,6 +225,7 @@ Date: Apr 2024 KernelVersion: 6.10 Contact: "Luke Jones" Description: + DEPRECATED, WILL BE REMOVED SOON Set if the MCU can go in to low-power mode on system sleep * 0 - False, * 1 - True diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig index f3464e30bd23..a8bde431d541 100644 --- a/drivers/platform/x86/Kconfig +++ b/drivers/platform/x86/Kconfig @@ -284,6 +284,17 @@ config ASUS_WMI To compile this driver as a module, choose M here: the module will be called asus-wmi. =20 +config ASUS_WMI_DEPRECATED_ATTRS + bool "BIOS option support in WMI platform (DEPRECATED)" + depends on ASUS_WMI + default y + help + Say Y to expose the configurable BIOS options through the asus-wmi + driver. + + This can be used with or without the asus-armoury driver which + has the same attributes, but more, and better features. + config ASUS_NB_WMI tristate "Asus Notebook WMI Driver" depends on ASUS_WMI diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wm= i.c index 9ffcd74c6328..153112502e34 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -336,6 +336,13 @@ struct asus_wmi { /* Global to allow setting externally without requiring driver data */ static enum asus_ally_mcu_hack use_ally_mcu_hack =3D ASUS_WMI_ALLY_MCU_HAC= K_INIT; =20 +#if IS_ENABLED(CONFIG_ASUS_WMI_DEPRECATED_ATTRS) +static void asus_wmi_show_deprecated(void) +{ + pr_notice_once("Accessing attributes through /sys/bus/platform/asus_wmi i= s deprecated and will be removed in a future release. Please switch over to= /sys/class/firmware_attributes.\n"); +} +#endif /* IS_ENABLED(CONFIG_ASUS_WMI_DEPRECATED_ATTRS) */ + /* WMI *******************************************************************= *****/ =20 static int asus_wmi_evaluate_method3(u32 method_id, @@ -722,6 +729,7 @@ static void asus_wmi_tablet_mode_get_state(struct asus_= wmi *asus) } =20 /* Charging mode, 1=3DBarrel, 2=3DUSB ************************************= ******/ +#if IS_ENABLED(CONFIG_ASUS_WMI_DEPRECATED_ATTRS) static ssize_t charge_mode_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -732,12 +740,16 @@ static ssize_t charge_mode_show(struct device *dev, if (result < 0) return result; =20 + asus_wmi_show_deprecated(); + return sysfs_emit(buf, "%d\n", value & 0xff); } =20 static DEVICE_ATTR_RO(charge_mode); +#endif /* IS_ENABLED(CONFIG_ASUS_WMI_DEPRECATED_ATTRS) */ =20 /* dGPU ******************************************************************= **/ +#if IS_ENABLED(CONFIG_ASUS_WMI_DEPRECATED_ATTRS) static ssize_t dgpu_disable_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -748,6 +760,8 @@ static ssize_t dgpu_disable_show(struct device *dev, if (result < 0) return result; =20 + asus_wmi_show_deprecated(); + return sysfs_emit(buf, "%d\n", result); } =20 @@ -801,8 +815,10 @@ static ssize_t dgpu_disable_store(struct device *dev, return count; } static DEVICE_ATTR_RW(dgpu_disable); +#endif /* IS_ENABLED(CONFIG_ASUS_WMI_DEPRECATED_ATTRS) */ =20 /* eGPU ******************************************************************= **/ +#if IS_ENABLED(CONFIG_ASUS_WMI_DEPRECATED_ATTRS) static ssize_t egpu_enable_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -813,6 +829,8 @@ static ssize_t egpu_enable_show(struct device *dev, if (result < 0) return result; =20 + asus_wmi_show_deprecated(); + return sysfs_emit(buf, "%d\n", result); } =20 @@ -869,8 +887,10 @@ static ssize_t egpu_enable_store(struct device *dev, return count; } static DEVICE_ATTR_RW(egpu_enable); +#endif /* IS_ENABLED(CONFIG_ASUS_WMI_DEPRECATED_ATTRS) */ =20 /* Is eGPU connected? ****************************************************= *****/ +#if IS_ENABLED(CONFIG_ASUS_WMI_DEPRECATED_ATTRS) static ssize_t egpu_connected_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -881,12 +901,16 @@ static ssize_t egpu_connected_show(struct device *dev, if (result < 0) return result; =20 + asus_wmi_show_deprecated(); + return sysfs_emit(buf, "%d\n", result); } =20 static DEVICE_ATTR_RO(egpu_connected); +#endif /* IS_ENABLED(CONFIG_ASUS_WMI_DEPRECATED_ATTRS) */ =20 /* gpu mux switch ********************************************************= *****/ +#if IS_ENABLED(CONFIG_ASUS_WMI_DEPRECATED_ATTRS) static ssize_t gpu_mux_mode_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -897,6 +921,8 @@ static ssize_t gpu_mux_mode_show(struct device *dev, if (result < 0) return result; =20 + asus_wmi_show_deprecated(); + return sysfs_emit(buf, "%d\n", result); } =20 @@ -955,6 +981,7 @@ static ssize_t gpu_mux_mode_store(struct device *dev, return count; } static DEVICE_ATTR_RW(gpu_mux_mode); +#endif /* IS_ENABLED(CONFIG_ASUS_WMI_DEPRECATED_ATTRS) */ =20 /* TUF Laptop Keyboard RGB Modes *****************************************= *****/ static ssize_t kbd_rgb_mode_store(struct device *dev, @@ -1078,6 +1105,7 @@ static const struct attribute_group *kbd_rgb_mode_gro= ups[] =3D { }; =20 /* Tunable: PPT: Intel=3DPL1, AMD=3DSPPT *********************************= ********/ +#if IS_ENABLED(CONFIG_ASUS_WMI_DEPRECATED_ATTRS) static ssize_t ppt_pl2_sppt_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) @@ -1116,6 +1144,8 @@ static ssize_t ppt_pl2_sppt_show(struct device *dev, { struct asus_wmi *asus =3D dev_get_drvdata(dev); =20 + asus_wmi_show_deprecated(); + return sysfs_emit(buf, "%u\n", asus->ppt_pl2_sppt); } static DEVICE_ATTR_RW(ppt_pl2_sppt); @@ -1158,6 +1188,8 @@ static ssize_t ppt_pl1_spl_show(struct device *dev, { struct asus_wmi *asus =3D dev_get_drvdata(dev); =20 + asus_wmi_show_deprecated(); + return sysfs_emit(buf, "%u\n", asus->ppt_pl1_spl); } static DEVICE_ATTR_RW(ppt_pl1_spl); @@ -1201,6 +1233,8 @@ static ssize_t ppt_fppt_show(struct device *dev, { struct asus_wmi *asus =3D dev_get_drvdata(dev); =20 + asus_wmi_show_deprecated(); + return sysfs_emit(buf, "%u\n", asus->ppt_fppt); } static DEVICE_ATTR_RW(ppt_fppt); @@ -1244,6 +1278,8 @@ static ssize_t ppt_apu_sppt_show(struct device *dev, { struct asus_wmi *asus =3D dev_get_drvdata(dev); =20 + asus_wmi_show_deprecated(); + return sysfs_emit(buf, "%u\n", asus->ppt_apu_sppt); } static DEVICE_ATTR_RW(ppt_apu_sppt); @@ -1287,6 +1323,8 @@ static ssize_t ppt_platform_sppt_show(struct device *= dev, { struct asus_wmi *asus =3D dev_get_drvdata(dev); =20 + asus_wmi_show_deprecated(); + return sysfs_emit(buf, "%u\n", asus->ppt_platform_sppt); } static DEVICE_ATTR_RW(ppt_platform_sppt); @@ -1330,6 +1368,8 @@ static ssize_t nv_dynamic_boost_show(struct device *d= ev, { struct asus_wmi *asus =3D dev_get_drvdata(dev); =20 + asus_wmi_show_deprecated(); + return sysfs_emit(buf, "%u\n", asus->nv_dynamic_boost); } static DEVICE_ATTR_RW(nv_dynamic_boost); @@ -1373,9 +1413,12 @@ static ssize_t nv_temp_target_show(struct device *de= v, { struct asus_wmi *asus =3D dev_get_drvdata(dev); =20 + asus_wmi_show_deprecated(); + return sysfs_emit(buf, "%u\n", asus->nv_temp_target); } static DEVICE_ATTR_RW(nv_temp_target); +#endif /* IS_ENABLED(CONFIG_ASUS_WMI_DEPRECATED_ATTRS) */ =20 /* Ally MCU Powersave ****************************************************= ****/ =20 @@ -1416,6 +1459,7 @@ void set_ally_mcu_powersave(bool enabled) } EXPORT_SYMBOL_NS_GPL(set_ally_mcu_powersave, "ASUS_WMI"); =20 +#if IS_ENABLED(CONFIG_ASUS_WMI_DEPRECATED_ATTRS) static ssize_t mcu_powersave_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -1426,6 +1470,8 @@ static ssize_t mcu_powersave_show(struct device *dev, if (result < 0) return result; =20 + asus_wmi_show_deprecated(); + return sysfs_emit(buf, "%d\n", result); } =20 @@ -1461,6 +1507,7 @@ static ssize_t mcu_powersave_store(struct device *dev, return count; } static DEVICE_ATTR_RW(mcu_powersave); +#endif /* IS_ENABLED(CONFIG_ASUS_WMI_DEPRECATED_ATTRS) */ =20 /* Battery ***************************************************************= *****/ =20 @@ -2334,6 +2381,7 @@ static int asus_wmi_rfkill_init(struct asus_wmi *asus) } =20 /* Panel Overdrive *******************************************************= *****/ +#if IS_ENABLED(CONFIG_ASUS_WMI_DEPRECATED_ATTRS) static ssize_t panel_od_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -2344,6 +2392,8 @@ static ssize_t panel_od_show(struct device *dev, if (result < 0) return result; =20 + asus_wmi_show_deprecated(); + return sysfs_emit(buf, "%d\n", result); } =20 @@ -2380,9 +2430,10 @@ static ssize_t panel_od_store(struct device *dev, return count; } static DEVICE_ATTR_RW(panel_od); +#endif /* IS_ENABLED(CONFIG_ASUS_WMI_DEPRECATED_ATTRS) */ =20 /* Bootup sound **********************************************************= *****/ - +#if IS_ENABLED(CONFIG_ASUS_WMI_DEPRECATED_ATTRS) static ssize_t boot_sound_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -2393,6 +2444,8 @@ static ssize_t boot_sound_show(struct device *dev, if (result < 0) return result; =20 + asus_wmi_show_deprecated(); + return sysfs_emit(buf, "%d\n", result); } =20 @@ -2428,8 +2481,10 @@ static ssize_t boot_sound_store(struct device *dev, return count; } static DEVICE_ATTR_RW(boot_sound); +#endif /* IS_ENABLED(CONFIG_ASUS_WMI_DEPRECATED_ATTRS) */ =20 /* Mini-LED mode *********************************************************= *****/ +#if IS_ENABLED(CONFIG_ASUS_WMI_DEPRECATED_ATTRS) static ssize_t mini_led_mode_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -2460,6 +2515,8 @@ static ssize_t mini_led_mode_show(struct device *dev, } } =20 + asus_wmi_show_deprecated(); + return sysfs_emit(buf, "%d\n", value); } =20 @@ -2530,10 +2587,13 @@ static ssize_t available_mini_led_mode_show(struct = device *dev, return sysfs_emit(buf, "0 1 2\n"); } =20 + asus_wmi_show_deprecated(); + return sysfs_emit(buf, "0\n"); } =20 static DEVICE_ATTR_RO(available_mini_led_mode); +#endif /* IS_ENABLED(CONFIG_ASUS_WMI_DEPRECATED_ATTRS) */ =20 /* Quirks ****************************************************************= *****/ =20 @@ -3821,6 +3881,7 @@ static int throttle_thermal_policy_set_default(struct= asus_wmi *asus) return throttle_thermal_policy_write(asus); } =20 +#if IS_ENABLED(CONFIG_ASUS_WMI_DEPRECATED_ATTRS) static ssize_t throttle_thermal_policy_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -3864,6 +3925,7 @@ static ssize_t throttle_thermal_policy_store(struct d= evice *dev, * Throttle thermal policy: 0 - default, 1 - overboost, 2 - silent */ static DEVICE_ATTR_RW(throttle_thermal_policy); +#endif /* IS_ENABLED(CONFIG_ASUS_WMI_DEPRECATED_ATTRS) */ =20 /* Platform profile ******************************************************= *****/ static int asus_wmi_platform_profile_get(struct device *dev, @@ -4465,27 +4527,29 @@ static struct attribute *platform_attributes[] =3D { &dev_attr_camera.attr, &dev_attr_cardr.attr, &dev_attr_touchpad.attr, - &dev_attr_charge_mode.attr, - &dev_attr_egpu_enable.attr, - &dev_attr_egpu_connected.attr, - &dev_attr_dgpu_disable.attr, - &dev_attr_gpu_mux_mode.attr, &dev_attr_lid_resume.attr, &dev_attr_als_enable.attr, &dev_attr_fan_boost_mode.attr, - &dev_attr_throttle_thermal_policy.attr, - &dev_attr_ppt_pl2_sppt.attr, - &dev_attr_ppt_pl1_spl.attr, - &dev_attr_ppt_fppt.attr, - &dev_attr_ppt_apu_sppt.attr, - &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, - &dev_attr_available_mini_led_mode.attr, +#if IS_ENABLED(CONFIG_ASUS_WMI_DEPRECATED_ATTRS) + &dev_attr_charge_mode.attr, + &dev_attr_egpu_enable.attr, + &dev_attr_egpu_connected.attr, + &dev_attr_dgpu_disable.attr, + &dev_attr_gpu_mux_mode.attr, + &dev_attr_ppt_pl2_sppt.attr, + &dev_attr_ppt_pl1_spl.attr, + &dev_attr_ppt_fppt.attr, + &dev_attr_ppt_apu_sppt.attr, + &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, + &dev_attr_available_mini_led_mode.attr, + &dev_attr_throttle_thermal_policy.attr, +#endif /* IS_ENABLED(CONFIG_ASUS_WMI_DEPRECATED_ATTRS) */ NULL }; =20 @@ -4507,7 +4571,11 @@ static umode_t asus_sysfs_is_visible(struct kobject = *kobj, devid =3D ASUS_WMI_DEVID_LID_RESUME; else if (attr =3D=3D &dev_attr_als_enable.attr) devid =3D ASUS_WMI_DEVID_ALS_ENABLE; - else if (attr =3D=3D &dev_attr_charge_mode.attr) + else if (attr =3D=3D &dev_attr_fan_boost_mode.attr) + ok =3D asus->fan_boost_mode_available; + +#if IS_ENABLED(CONFIG_ASUS_WMI_DEPRECATED_ATTRS) + if (attr =3D=3D &dev_attr_charge_mode.attr) devid =3D ASUS_WMI_DEVID_CHARGE_MODE; else if (attr =3D=3D &dev_attr_egpu_enable.attr) ok =3D asus->egpu_enable_available; @@ -4545,6 +4613,7 @@ static umode_t asus_sysfs_is_visible(struct kobject *= kobj, ok =3D asus->mini_led_dev_id !=3D 0; else if (attr =3D=3D &dev_attr_available_mini_led_mode.attr) ok =3D asus->mini_led_dev_id !=3D 0; +#endif /* IS_ENABLED(CONFIG_ASUS_WMI_DEPRECATED_ATTRS) */ =20 if (devid !=3D -1) { ok =3D !(asus_wmi_get_devstate_simple(asus, devid) < 0); @@ -4800,6 +4869,7 @@ static int asus_wmi_add(struct platform_device *pdev) } =20 /* ensure defaults for tunables */ +#if IS_ENABLED(CONFIG_ASUS_WMI_DEPRECATED_ATTRS) asus->ppt_pl2_sppt =3D 5; asus->ppt_pl1_spl =3D 5; asus->ppt_apu_sppt =3D 5; @@ -4822,17 +4892,18 @@ static int asus_wmi_add(struct platform_device *pde= v) asus->gpu_mux_dev =3D ASUS_WMI_DEVID_GPU_MUX; else if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_GPU_MUX_VIVO)) asus->gpu_mux_dev =3D ASUS_WMI_DEVID_GPU_MUX_VIVO; - - if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_TUF_RGB_MODE)) - asus->kbd_rgb_dev =3D ASUS_WMI_DEVID_TUF_RGB_MODE; - else if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_TUF_RGB_MODE2)) - asus->kbd_rgb_dev =3D ASUS_WMI_DEVID_TUF_RGB_MODE2; +#endif /* IS_ENABLED(CONFIG_ASUS_WMI_DEPRECATED_ATTRS) */ =20 if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_THROTTLE_THERMAL_POLICY)) asus->throttle_thermal_policy_dev =3D ASUS_WMI_DEVID_THROTTLE_THERMAL_PO= LICY; else if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_THROTTLE_THERMAL_PO= LICY_VIVO)) asus->throttle_thermal_policy_dev =3D ASUS_WMI_DEVID_THROTTLE_THERMAL_PO= LICY_VIVO; =20 + if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_TUF_RGB_MODE)) + asus->kbd_rgb_dev =3D ASUS_WMI_DEVID_TUF_RGB_MODE; + else if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_TUF_RGB_MODE2)) + asus->kbd_rgb_dev =3D ASUS_WMI_DEVID_TUF_RGB_MODE2; + err =3D fan_boost_mode_check_present(asus); if (err) goto fail_fan_boost_mode; --=20 2.50.0 From nobody Wed Oct 8 10:56:35 2025 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 38387225A24; Sun, 29 Jun 2025 13:14:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751202892; cv=none; b=LqsEbdG6Du3u0apa7PqhhViDfdL/ylE75BpHQ6bHIa4SY8+t8ieCszomBXaMiYqL1jrfdGvD49wFdpIMM3e/kz6OoIK3g4gVJlAOmQJ/4E1GTN6Ts6lnEGd2P5u983ALGr8daI4yeI4DbL2o0/7s14wh5tn1sG9l2CmUObhJMb0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751202892; c=relaxed/simple; bh=UMVwjH8YW/q+EnkKSrUIdPm1BpKxsUzd+HFMi3EMois=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DxvX9EkqI8j1ME6QToiGBk68yzrijP4q7+dph+NzkmcdaXjChoFWz3R+HU0x9ZbSZbD0SfIE1iyd10o8a3I+xC6wvt3evEWmIAhAt6tWz+cIEWZNVh++inSk3lgdOzEHTzjdKXUEaTbEi2JlElW0LES0Ozdcg8GD541fsBhpg+A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Sj4kQ8cL; arc=none smtp.client-ip=209.85.221.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Sj4kQ8cL" Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-3a57ae5cb17so697602f8f.0; Sun, 29 Jun 2025 06:14:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1751202887; x=1751807687; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BdNxA38PMbxLs9l2Z2AUjB43GlhVTtjka62TWuJscc0=; b=Sj4kQ8cLWZWeyUC2dq7ChxSRMSg95a2OLQ2AHFTc4RWhtmjej1FmLaGHPr9QpO6HgZ gG9xz1+jLjxc6860KslIyUrtwKesw5JefXPHJGmH+YRT+jeJmlHcIxyYYuULQlADCN/n TwcVxDmzw4y3iVoaeVqEa32K+2JT7Ntj487E5VtX70B+JEUWwWHxlHmeqXEXlerEL+7X itgJ97wQgvdLLe2OqznGA8EP9E+5TGOriMvyFJPPB7p31xpn4vuD0fidB44J9NP3ugUd rtUj8ATv5NpuePerfT7Py2Dc6/MNU0mWZZGPcE9OeOkSXaytf57CSNj6azcQkYmMCBOE tLvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751202887; x=1751807687; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BdNxA38PMbxLs9l2Z2AUjB43GlhVTtjka62TWuJscc0=; b=LOOnG+hhHS/sUNt+X9eot3A1hrBZOxdNoLW7uRFuI1KCslN+FpDW7FnsAic2EKpXRK Ovnry1boRff0oq/nxDJMblduVy6txJy6lDvcNaMkDi47PQBFieWPsStzllJlYvVHQyff ht9CgNb6u6yk7MJOW9RUD4jzE+21uCZLv+KSH9Bq8oOpbs3/ViisyNYkiiVpYFhfppOe 46U8s2AVPwbppgYbx0zZKz6WtDPSDR4yDAAR5b+mCHFe4B1VBhVq1LNg/c5ZSvjNvOrm Dy7I5KiXNY7L8Tpm/2nsBtQO2AmK1KVSfVm5KOtcHbTLpKHJcQXNYuitglVTO/cl/rHQ nT+A== X-Forwarded-Encrypted: i=1; AJvYcCUonvTiRgWctM052f7ndOKZSDZRhiaEyBvjCCfh/tK0bXCQ+A26jjKdpUH1tO9vTzLDcowfzTxxtgjoQdWp0hZjIDaq@vger.kernel.org X-Gm-Message-State: AOJu0Yw2KBrr3r0kSTYe/+Iq1dX+UngBzUfKVpxcfpx8HpHzlvLsDpkE nsQmo6P5VC0YsdQ2WXcpzxublHuRjQdWsnOxlpQWsD9RrIDu6Av9zHLKG5jCsA== X-Gm-Gg: ASbGncud+lRrNS1INmxfYdMvxgf9yL118vZ01tadJXJth2Bp73Gl0mCmTRReTCnqvY1 kOduDsm8pTqGNErjyfNfdGX0m2WDYmhjJtJKNJC8xM1oRic7LnBjti2ny0rC0XZMpqLsCvlyIfv FEdIS7phnc4uLg1CM0a2iMSZwOkQeeyNsVQTdgDG56j9jxk1ZaBiCekwu/H7h6UdI0MSCMQlybY Taf1cC8tHXqTFpT48fwVYx3QXicoQ86+RKgKj7GEGdpiGpxs7r02hfdOJMAsIQJuPJCNH50ed7w KIx7AgzEV+G+8Nc54MJ530ShjCkxX+J83j49k70rxQPVGyD8dL59aKqtN09QULg= X-Google-Smtp-Source: AGHT+IGbNloarW4SsUWnb0J27qWLUg1F1qNDpTL5MqmKQrfWGcaH9nS6bqGBe6cHSdzG7+Kx9jMEJA== X-Received: by 2002:a05:6000:2dc4:b0:3a5:2182:bce2 with SMTP id ffacd0b85a97d-3a8f4c00b15mr8742488f8f.17.1751202887099; Sun, 29 Jun 2025 06:14:47 -0700 (PDT) Received: from denis-pc ([151.49.78.111]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4538a406ab6sm106301495e9.30.2025.06.29.06.14.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Jun 2025 06:14:46 -0700 (PDT) From: Denis Benato To: linux-kernel@vger.kernel.org Cc: hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, platform-driver-x86@vger.kernel.org, mario.limonciello@amd.com, "Luke D . Jones" , Denis Benato Subject: [PATCH v9 8/8] platform/x86: asus-armoury: add ppt_* and nv_* tuning knobs Date: Sun, 29 Jun 2025 15:14:23 +0200 Message-ID: <20250629131423.9013-9-benato.denis96@gmail.com> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250629131423.9013-1-benato.denis96@gmail.com> References: <20250629131423.9013-1-benato.denis96@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: "Luke D. Jones" Adds the ppt_* and nv_* tuning knobs that are available via WMI methods and adds proper min/max levels plus defaults. The min/max are defined by ASUS and typically gained by looking at what they allow in the ASUS Armoury Crate application - ASUS does not share the values outside of this. It could also be possible to gain the AMD values by use of ryzenadj and testing for the minimum stable value. The general rule of thumb for adding to the match table is that if the model range has a single CPU used throughout, then the DMI match can omit the last letter of the model number as this is the GPU model. If a min or max value is not provided it is assumed that the particular setting is not supported. for example ppt_pl2_sppt_min/max is not set. If a _def is not set then the default is assumed to be _max It is assumed that at least AC settings are available so that the firmware attributes will be created - if no DC table is available and power is on DC, then reading the attributes is -ENODEV. Signed-off-by: Denis Benato Signed-off-by: Luke D. Jones Reviewed-by: Mario Limonciello --- drivers/platform/x86/asus-armoury.c | 296 +++++- drivers/platform/x86/asus-armoury.h | 1086 ++++++++++++++++++++ include/linux/platform_data/x86/asus-wmi.h | 3 + 3 files changed, 1379 insertions(+), 6 deletions(-) diff --git a/drivers/platform/x86/asus-armoury.c b/drivers/platform/x86/asu= s-armoury.c index 33d71bf64468..261a1b182cac 100644 --- a/drivers/platform/x86/asus-armoury.c +++ b/drivers/platform/x86/asus-armoury.c @@ -27,6 +27,7 @@ #include #include #include +#include #include =20 #include "asus-armoury.h" @@ -45,6 +46,17 @@ #define ASUS_MINI_LED_2024_STRONG 0x01 #define ASUS_MINI_LED_2024_OFF 0x02 =20 +/* Power tunable attribute name defines */ +#define ATTR_PPT_PL1_SPL "ppt_pl1_spl" +#define ATTR_PPT_PL2_SPPT "ppt_pl2_sppt" +#define ATTR_PPT_PL3_FPPT "ppt_pl3_fppt" +#define ATTR_PPT_APU_SPPT "ppt_apu_sppt" +#define ATTR_PPT_PLATFORM_SPPT "ppt_platform_sppt" +#define ATTR_NV_DYNAMIC_BOOST "nv_dynamic_boost" +#define ATTR_NV_TEMP_TARGET "nv_temp_target" +#define ATTR_NV_BASE_TGP "nv_base_tgp" +#define ATTR_NV_TGP "nv_tgp" + #define ASUS_POWER_CORE_MASK GENMASK(15, 8) #define ASUS_PERF_CORE_MASK GENMASK(7, 0) =20 @@ -73,11 +85,26 @@ struct cpu_cores { u32 max_power_cores; }; =20 +struct rog_tunables { + const struct power_limits *power_limits; + u32 ppt_pl1_spl; // cpu + u32 ppt_pl2_sppt; // cpu + u32 ppt_pl3_fppt; // cpu + u32 ppt_apu_sppt; // plat + u32 ppt_platform_sppt; // plat + + u32 nv_dynamic_boost; + u32 nv_temp_target; + u32 nv_tgp; +}; + static struct asus_armoury_priv { struct device *fw_attr_dev; struct kset *fw_attr_kset; =20 struct cpu_cores *cpu_cores; + /* Index 0 for DC, 1 for AC */ + struct rog_tunables *rog_tunables[2]; u32 mini_led_dev_id; u32 gpu_mux_dev_id; /* @@ -721,7 +748,34 @@ static ssize_t cores_efficiency_current_value_store(st= ruct kobject *kobj, ATTR_GROUP_CORES_RW(cores_efficiency, "cores_efficiency", "Set the max available efficiency cores"); =20 +/* Define helper to access the current power mode tunable values */ +static inline struct rog_tunables *get_current_tunables(void) +{ + return asus_armoury + .rog_tunables[power_supply_is_system_supplied() ? 1 : 0]; +} + /* Simple attribute creation */ +ATTR_GROUP_ROG_TUNABLE(ppt_pl1_spl, ATTR_PPT_PL1_SPL, ASUS_WMI_DEVID_PPT_P= L1_SPL, + "Set the CPU slow package limit"); +ATTR_GROUP_ROG_TUNABLE(ppt_pl2_sppt, ATTR_PPT_PL2_SPPT, ASUS_WMI_DEVID_PPT= _PL2_SPPT, + "Set the CPU fast package limit"); +ATTR_GROUP_ROG_TUNABLE(ppt_pl3_fppt, ATTR_PPT_PL3_FPPT, ASUS_WMI_DEVID_PPT= _FPPT, + "Set the CPU fastest package limit"); +ATTR_GROUP_ROG_TUNABLE(ppt_apu_sppt, ATTR_PPT_APU_SPPT, ASUS_WMI_DEVID_PPT= _APU_SPPT, + "Set the APU package limit"); +ATTR_GROUP_ROG_TUNABLE(ppt_platform_sppt, ATTR_PPT_PLATFORM_SPPT, ASUS_WMI= _DEVID_PPT_PLAT_SPPT, + "Set the platform package limit"); +ATTR_GROUP_ROG_TUNABLE(nv_dynamic_boost, ATTR_NV_DYNAMIC_BOOST, ASUS_WMI_D= EVID_NV_DYN_BOOST, + "Set the Nvidia dynamic boost limit"); +ATTR_GROUP_ROG_TUNABLE(nv_temp_target, ATTR_NV_TEMP_TARGET, ASUS_WMI_DEVID= _NV_THERM_TARGET, + "Set the Nvidia max thermal limit"); +ATTR_GROUP_ROG_TUNABLE(nv_tgp, "nv_tgp", ASUS_WMI_DEVID_DGPU_SET_TGP, + "Set the additional TGP on top of the base TGP"); +ATTR_GROUP_INT_VALUE_ONLY_RO(nv_base_tgp, ATTR_NV_BASE_TGP, ASUS_WMI_DEVID= _DGPU_BASE_TGP, + "Read the base TGP value"); + + ATTR_GROUP_ENUM_INT_RO(charge_mode, "charge_mode", ASUS_WMI_DEVID_CHARGE_M= ODE, "0;1;2", "Show the current mode of charging"); =20 @@ -748,6 +802,16 @@ static const struct asus_attr_group armoury_attr_group= s[] =3D { { &cores_efficiency_attr_group, ASUS_WMI_DEVID_CORES_MAX }, { &cores_performance_attr_group, ASUS_WMI_DEVID_CORES_MAX }, =20 + { &ppt_pl1_spl_attr_group, ASUS_WMI_DEVID_PPT_PL1_SPL }, + { &ppt_pl2_sppt_attr_group, ASUS_WMI_DEVID_PPT_PL2_SPPT }, + { &ppt_pl3_fppt_attr_group, ASUS_WMI_DEVID_PPT_FPPT }, + { &ppt_apu_sppt_attr_group, ASUS_WMI_DEVID_PPT_APU_SPPT }, + { &ppt_platform_sppt_attr_group, ASUS_WMI_DEVID_PPT_PLAT_SPPT }, + { &nv_dynamic_boost_attr_group, ASUS_WMI_DEVID_NV_DYN_BOOST }, + { &nv_temp_target_attr_group, ASUS_WMI_DEVID_NV_THERM_TARGET }, + { &nv_base_tgp_attr_group, ASUS_WMI_DEVID_DGPU_BASE_TGP }, + { &nv_tgp_attr_group, ASUS_WMI_DEVID_DGPU_SET_TGP }, + { &charge_mode_attr_group, ASUS_WMI_DEVID_CHARGE_MODE }, { &boot_sound_attr_group, ASUS_WMI_DEVID_BOOT_SOUND }, { &mcu_powersave_attr_group, ASUS_WMI_DEVID_MCU_POWERSAVE }, @@ -755,8 +819,75 @@ static const struct asus_attr_group armoury_attr_group= s[] =3D { { &panel_hd_mode_attr_group, ASUS_WMI_DEVID_PANEL_HD }, }; =20 +/** + * is_power_tunable_attr - Determines if an attribute is a power-related t= unable + * @name: The name of the attribute to check + * + * This function checks if the given attribute name is related to power tu= ning. + * + * Return: true if the attribute is a power-related tunable, false otherwi= se + */ +static bool is_power_tunable_attr(const char *name) +{ + static const char * const power_tunable_attrs[] =3D { + ATTR_PPT_PL1_SPL, ATTR_PPT_PL2_SPPT, + ATTR_PPT_PL3_FPPT, ATTR_PPT_APU_SPPT, + ATTR_PPT_PLATFORM_SPPT, ATTR_NV_DYNAMIC_BOOST, + ATTR_NV_TEMP_TARGET, ATTR_NV_BASE_TGP, + ATTR_NV_TGP + }; + + for (unsigned int i =3D 0; i < ARRAY_SIZE(power_tunable_attrs); i++) { + if (!strcmp(name, power_tunable_attrs[i])) + return true; + } + + return false; +} + +/** + * has_valid_limit - Checks if a power-related attribute has a valid limit= value + * @name: The name of the attribute to check + * @limits: Pointer to the power_limits structure containing limit values + * + * This function checks if a power-related attribute has a valid limit val= ue. + * It returns false if limits is NULL or if the corresponding limit value = is zero. + * + * Return: true if the attribute has a valid limit value, false otherwise + */ +static bool has_valid_limit(const char *name, const struct power_limits *l= imits) +{ + u32 limit_value =3D 0; + + if (!limits) + return false; + + if (!strcmp(name, ATTR_PPT_PL1_SPL)) + limit_value =3D limits->ppt_pl1_spl_max; + else if (!strcmp(name, ATTR_PPT_PL2_SPPT)) + limit_value =3D limits->ppt_pl2_sppt_max; + else if (!strcmp(name, ATTR_PPT_PL3_FPPT)) + limit_value =3D limits->ppt_pl3_fppt_max; + else if (!strcmp(name, ATTR_PPT_APU_SPPT)) + limit_value =3D limits->ppt_apu_sppt_max; + else if (!strcmp(name, ATTR_PPT_PLATFORM_SPPT)) + limit_value =3D limits->ppt_platform_sppt_max; + else if (!strcmp(name, ATTR_NV_DYNAMIC_BOOST)) + limit_value =3D limits->nv_dynamic_boost_max; + else if (!strcmp(name, ATTR_NV_TEMP_TARGET)) + limit_value =3D limits->nv_temp_target_max; + else if (!strcmp(name, ATTR_NV_BASE_TGP) || + !strcmp(name, ATTR_NV_TGP)) + limit_value =3D limits->nv_tgp_max; + + return limit_value > 0; +} + static int asus_fw_attr_add(void) { + const struct power_limits *limits; + bool should_create; + const char *name; int err, i; =20 asus_armoury.fw_attr_dev =3D device_create(&firmware_attributes_class, NU= LL, MKDEV(0, 0), @@ -813,12 +944,30 @@ static int asus_fw_attr_add(void) if (!asus_wmi_is_present(armoury_attr_groups[i].wmi_devid)) continue; =20 - err =3D sysfs_create_group(&asus_armoury.fw_attr_kset->kobj, - armoury_attr_groups[i].attr_group); - if (err) { - pr_err("Failed to create sysfs-group for %s\n", - armoury_attr_groups[i].attr_group->name); - goto err_remove_groups; + /* Always create by default, unless PPT is not present */ + should_create =3D true; + name =3D armoury_attr_groups[i].attr_group->name; + + /* Check if this is a power-related tunable requiring limits */ + if (asus_armoury.rog_tunables[1] && asus_armoury.rog_tunables[1]->power_= limits && + is_power_tunable_attr(name)) { + limits =3D asus_armoury.rog_tunables[1]->power_limits; + /* Check only AC, if DC is not present then AC won't be either */ + should_create =3D has_valid_limit(name, limits); + if (!should_create) { + pr_debug("Missing max value on %s for tunable: %s\n", + dmi_get_system_info(DMI_BOARD_NAME), name); + } + } + + if (should_create) { + err =3D sysfs_create_group(&asus_armoury.fw_attr_kset->kobj, + armoury_attr_groups[i].attr_group); + if (err) { + pr_err("Failed to create sysfs-group for %s\n", + armoury_attr_groups[i].attr_group->name); + goto err_remove_groups; + } } } =20 @@ -847,6 +996,135 @@ static int asus_fw_attr_add(void) =20 /* Init / exit ***********************************************************= *****/ =20 +/* Set up the min/max and defaults for ROG tunables */ +static void init_rog_tunables(void) +{ + const struct power_limits *ac_limits, *dc_limits; + const struct power_data *power_data; + const struct dmi_system_id *dmi_id; + bool ac_initialized =3D false, dc_initialized =3D false; + + /* Match the system against the power_limits table */ + dmi_id =3D dmi_first_match(power_limits); + if (!dmi_id) { + pr_warn("No matching power limits found for this system\n"); + return; + } + + /* Get the power data for this system */ + power_data =3D dmi_id->driver_data; + if (!power_data) { + pr_info("No power data available for this system\n"); + return; + } + + /* Initialize AC power tunables */ + ac_limits =3D power_data->ac_data; + if (ac_limits) { + asus_armoury.rog_tunables[1] =3D + kzalloc(sizeof(*asus_armoury.rog_tunables[1]), GFP_KERNEL); + if (!asus_armoury.rog_tunables[1]) + goto err_nomem; + + asus_armoury.rog_tunables[1]->power_limits =3D ac_limits; + + /* Set initial AC values */ + asus_armoury.rog_tunables[1]->ppt_pl1_spl =3D + ac_limits->ppt_pl1_spl_def ? + ac_limits->ppt_pl1_spl_def : + ac_limits->ppt_pl1_spl_max; + + asus_armoury.rog_tunables[1]->ppt_pl2_sppt =3D + ac_limits->ppt_pl2_sppt_def ? + ac_limits->ppt_pl2_sppt_def : + ac_limits->ppt_pl2_sppt_max; + + asus_armoury.rog_tunables[1]->ppt_pl3_fppt =3D + ac_limits->ppt_pl3_fppt_def ? + ac_limits->ppt_pl3_fppt_def : + ac_limits->ppt_pl3_fppt_max; + + asus_armoury.rog_tunables[1]->ppt_apu_sppt =3D + ac_limits->ppt_apu_sppt_def ? + ac_limits->ppt_apu_sppt_def : + ac_limits->ppt_apu_sppt_max; + + asus_armoury.rog_tunables[1]->ppt_platform_sppt =3D + ac_limits->ppt_platform_sppt_def ? + ac_limits->ppt_platform_sppt_def : + ac_limits->ppt_platform_sppt_max; + + asus_armoury.rog_tunables[1]->nv_dynamic_boost =3D + ac_limits->nv_dynamic_boost_max; + asus_armoury.rog_tunables[1]->nv_temp_target =3D + ac_limits->nv_temp_target_max; + asus_armoury.rog_tunables[1]->nv_tgp =3D ac_limits->nv_tgp_max; + + ac_initialized =3D true; + pr_debug("AC power limits initialized for %s\n", dmi_id->matches[0].subs= tr); + } + + /* Initialize DC power tunables */ + dc_limits =3D power_data->dc_data; + if (dc_limits) { + asus_armoury.rog_tunables[0] =3D + kzalloc(sizeof(*asus_armoury.rog_tunables[0]), GFP_KERNEL); + if (!asus_armoury.rog_tunables[0]) { + if (ac_initialized) + kfree(asus_armoury.rog_tunables[1]); + goto err_nomem; + } + + asus_armoury.rog_tunables[0]->power_limits =3D dc_limits; + + /* Set initial DC values */ + asus_armoury.rog_tunables[0]->ppt_pl1_spl =3D + dc_limits->ppt_pl1_spl_def ? + dc_limits->ppt_pl1_spl_def : + dc_limits->ppt_pl1_spl_max; + + asus_armoury.rog_tunables[0]->ppt_pl2_sppt =3D + dc_limits->ppt_pl2_sppt_def ? + dc_limits->ppt_pl2_sppt_def : + dc_limits->ppt_pl2_sppt_max; + + asus_armoury.rog_tunables[0]->ppt_pl3_fppt =3D + dc_limits->ppt_pl3_fppt_def ? + dc_limits->ppt_pl3_fppt_def : + dc_limits->ppt_pl3_fppt_max; + + asus_armoury.rog_tunables[0]->ppt_apu_sppt =3D + dc_limits->ppt_apu_sppt_def ? + dc_limits->ppt_apu_sppt_def : + dc_limits->ppt_apu_sppt_max; + + asus_armoury.rog_tunables[0]->ppt_platform_sppt =3D + dc_limits->ppt_platform_sppt_def ? + dc_limits->ppt_platform_sppt_def : + dc_limits->ppt_platform_sppt_max; + + asus_armoury.rog_tunables[0]->nv_dynamic_boost =3D + dc_limits->nv_dynamic_boost_max; + asus_armoury.rog_tunables[0]->nv_temp_target =3D + dc_limits->nv_temp_target_max; + asus_armoury.rog_tunables[0]->nv_tgp =3D dc_limits->nv_tgp_max; + + dc_initialized =3D true; + pr_debug("DC power limits initialized for %s\n", dmi_id->matches[0].subs= tr); + } + + if (!ac_initialized) + pr_debug("No AC PPT limits defined\n"); + + if (!dc_initialized) + pr_debug("No DC PPT limits defined\n"); + + return; + +err_nomem: + pr_err("Failed to allocate memory for tunables\n"); +} + static int __init asus_fw_init(void) { char *wmi_uid; @@ -871,6 +1149,9 @@ static int __init asus_fw_init(void) } } =20 + init_rog_tunables(); + + /* Must always be last step to ensure data is available */ return asus_fw_attr_add(); } =20 @@ -879,6 +1160,9 @@ static void __exit asus_fw_exit(void) sysfs_remove_file(&asus_armoury.fw_attr_kset->kobj, &pending_reboot.attr); kset_unregister(asus_armoury.fw_attr_kset); device_destroy(&firmware_attributes_class, MKDEV(0, 0)); + + kfree(asus_armoury.rog_tunables[0]); + kfree(asus_armoury.rog_tunables[1]); } =20 module_init(asus_fw_init); diff --git a/drivers/platform/x86/asus-armoury.h b/drivers/platform/x86/asu= s-armoury.h index a6c4caefdef9..438768ea14cc 100644 --- a/drivers/platform/x86/asus-armoury.h +++ b/drivers/platform/x86/asus-armoury.h @@ -8,6 +8,7 @@ #ifndef _ASUS_ARMOURY_H_ #define _ASUS_ARMOURY_H_ =20 +#include #include #include =20 @@ -189,4 +190,1089 @@ .name =3D _fsname, .attrs =3D _attrname##_attrs \ } =20 +#define ATTR_GROUP_INT_VALUE_ONLY_RO(_attrname, _fsname, _wmi, _dispname) \ + WMI_SHOW_INT(_attrname##_current_value, "%d\n", _wmi); \ + static struct kobj_attribute attr_##_attrname##_current_value =3D \ + __ASUS_ATTR_RO(_attrname, current_value); \ + __ATTR_SHOW_FMT(display_name, _attrname, "%s\n", _dispname); \ + static struct kobj_attribute attr_##_attrname##_type =3D \ + __ASUS_ATTR_RO_AS(type, int_type_show); \ + static struct attribute *_attrname##_attrs[] =3D { \ + &attr_##_attrname##_current_value.attr, \ + &attr_##_attrname##_display_name.attr, \ + &attr_##_attrname##_type.attr, NULL \ + }; \ + static const struct attribute_group _attrname##_attr_group =3D { \ + .name =3D _fsname, .attrs =3D _attrname##_attrs \ + } + +/* + * ROG PPT attributes need a little different in setup as they + * require rog_tunables members. + */ + +#define __ROG_TUNABLE_SHOW(_prop, _attrname, _val) \ + static ssize_t _attrname##_##_prop##_show( \ + struct kobject *kobj, struct kobj_attribute *attr, char *buf) \ + { \ + struct rog_tunables *tunables =3D get_current_tunables(); \ + \ + if (!tunables || !tunables->power_limits) \ + return -ENODEV; \ + \ + return sysfs_emit(buf, "%d\n", tunables->power_limits->_val); \ + } \ + static struct kobj_attribute attr_##_attrname##_##_prop =3D \ + __ASUS_ATTR_RO(_attrname, _prop) + +#define __ROG_TUNABLE_SHOW_DEFAULT(_attrname) \ + static ssize_t _attrname##_default_value_show( \ + struct kobject *kobj, struct kobj_attribute *attr, char *buf) \ + { \ + struct rog_tunables *tunables =3D get_current_tunables(); \ + \ + if (!tunables || !tunables->power_limits) \ + return -ENODEV; \ + \ + return sysfs_emit( \ + buf, "%d\n", \ + tunables->power_limits->_attrname##_def ? \ + tunables->power_limits->_attrname##_def : \ + tunables->power_limits->_attrname##_max); \ + } \ + static struct kobj_attribute attr_##_attrname##_default_value =3D \ + __ASUS_ATTR_RO(_attrname, default_value) + +#define __ROG_TUNABLE_RW(_attr, _wmi) \ + static ssize_t _attr##_current_value_store( \ + struct kobject *kobj, struct kobj_attribute *attr, \ + const char *buf, size_t count) \ + { \ + struct rog_tunables *tunables =3D get_current_tunables(); \ + \ + if (!tunables || !tunables->power_limits) \ + return -ENODEV; \ + \ + return attr_uint_store(kobj, attr, buf, count, \ + tunables->power_limits->_attr##_min, \ + tunables->power_limits->_attr##_max, \ + &tunables->_attr, _wmi); \ + } \ + static ssize_t _attr##_current_value_show( \ + struct kobject *kobj, struct kobj_attribute *attr, char *buf) \ + { \ + struct rog_tunables *tunables =3D get_current_tunables(); \ + \ + if (!tunables) \ + return -ENODEV; \ + \ + return sysfs_emit(buf, "%u\n", tunables->_attr); \ + } \ + static struct kobj_attribute attr_##_attr##_current_value =3D \ + __ASUS_ATTR_RW(_attr, current_value) + +#define ATTR_GROUP_ROG_TUNABLE(_attrname, _fsname, _wmi, _dispname) \ + __ROG_TUNABLE_RW(_attrname, _wmi); \ + __ROG_TUNABLE_SHOW_DEFAULT(_attrname); \ + __ROG_TUNABLE_SHOW(min_value, _attrname, _attrname##_min); \ + __ROG_TUNABLE_SHOW(max_value, _attrname, _attrname##_max); \ + __ATTR_SHOW_FMT(scalar_increment, _attrname, "%d\n", 1); \ + __ATTR_SHOW_FMT(display_name, _attrname, "%s\n", _dispname); \ + static struct kobj_attribute attr_##_attrname##_type =3D \ + __ASUS_ATTR_RO_AS(type, int_type_show); \ + static struct attribute *_attrname##_attrs[] =3D { \ + &attr_##_attrname##_current_value.attr, \ + &attr_##_attrname##_default_value.attr, \ + &attr_##_attrname##_min_value.attr, \ + &attr_##_attrname##_max_value.attr, \ + &attr_##_attrname##_scalar_increment.attr, \ + &attr_##_attrname##_display_name.attr, \ + &attr_##_attrname##_type.attr, \ + NULL \ + }; \ + static const struct attribute_group _attrname##_attr_group =3D { \ + .name =3D _fsname, .attrs =3D _attrname##_attrs \ + } + +/* Default is always the maximum value unless *_def is specified */ +struct power_limits { + u8 ppt_pl1_spl_min; + u8 ppt_pl1_spl_def; + u8 ppt_pl1_spl_max; + u8 ppt_pl2_sppt_min; + u8 ppt_pl2_sppt_def; + u8 ppt_pl2_sppt_max; + u8 ppt_pl3_fppt_min; + u8 ppt_pl3_fppt_def; + u8 ppt_pl3_fppt_max; + u8 ppt_apu_sppt_min; + u8 ppt_apu_sppt_def; + u8 ppt_apu_sppt_max; + u8 ppt_platform_sppt_min; + u8 ppt_platform_sppt_def; + u8 ppt_platform_sppt_max; + /* Nvidia GPU specific, default is always max */ + u8 nv_dynamic_boost_def; // unused. exists for macro + u8 nv_dynamic_boost_min; + u8 nv_dynamic_boost_max; + u8 nv_temp_target_def; // unused. exists for macro + u8 nv_temp_target_min; + u8 nv_temp_target_max; + u8 nv_tgp_def; // unused. exists for macro + u8 nv_tgp_min; + u8 nv_tgp_max; +}; + +struct power_data { + const struct power_limits *ac_data; + const struct power_limits *dc_data; + bool requires_fan_curve; +}; + +/* + * For each avilable attribute there must be a min and a max. + * _def is not required and will be assumed to be default =3D=3D max if mi= ssing. + */ +static const struct dmi_system_id power_limits[] =3D { + { + .matches =3D { + DMI_MATCH(DMI_BOARD_NAME, "FA401W"), + }, + .driver_data =3D &(struct power_data) { + .ac_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 15, + .ppt_pl1_spl_max =3D 80, + .ppt_pl2_sppt_min =3D 35, + .ppt_pl2_sppt_max =3D 80, + .ppt_pl3_fppt_min =3D 35, + .ppt_pl3_fppt_max =3D 80, + .nv_dynamic_boost_min =3D 5, + .nv_dynamic_boost_max =3D 25, + .nv_temp_target_min =3D 75, + .nv_temp_target_max =3D 87, + .nv_tgp_min =3D 55, + .nv_tgp_max =3D 75, + }, + .dc_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 25, + .ppt_pl1_spl_max =3D 30, + .ppt_pl2_sppt_min =3D 31, + .ppt_pl2_sppt_max =3D 44, + .ppt_pl3_fppt_min =3D 45, + .ppt_pl3_fppt_max =3D 65, + .nv_temp_target_min =3D 75, + .nv_temp_target_max =3D 87, + }, + }, + }, + { + .matches =3D { + DMI_MATCH(DMI_BOARD_NAME, "FA507N"), + }, + .driver_data =3D &(struct power_data) { + .ac_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 15, + .ppt_pl1_spl_max =3D 80, + .ppt_pl2_sppt_min =3D 35, + .ppt_pl2_sppt_max =3D 80, + .ppt_pl3_fppt_min =3D 35, + .ppt_pl3_fppt_max =3D 80, + .nv_dynamic_boost_min =3D 5, + .nv_dynamic_boost_max =3D 25, + .nv_temp_target_min =3D 75, + .nv_temp_target_max =3D 87, + }, + .dc_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 15, + .ppt_pl1_spl_def =3D 45, + .ppt_pl1_spl_max =3D 65, + .ppt_pl2_sppt_min =3D 35, + .ppt_pl2_sppt_def =3D 54, + .ppt_pl2_sppt_max =3D 65, + .ppt_pl3_fppt_min =3D 35, + .ppt_pl3_fppt_max =3D 65, + .nv_temp_target_min =3D 75, + .nv_temp_target_max =3D 87, + } + }, + }, + { + .matches =3D { + DMI_MATCH(DMI_BOARD_NAME, "FA507R"), + }, + .driver_data =3D &(struct power_data) { + .ac_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 15, + .ppt_pl1_spl_max =3D 80, + .ppt_pl2_sppt_min =3D 25, + .ppt_pl2_sppt_max =3D 80, + .ppt_pl3_fppt_min =3D 35, + .ppt_pl3_fppt_max =3D 80 + }, + .dc_data =3D NULL + }, + }, + { + .matches =3D { + DMI_MATCH(DMI_BOARD_NAME, "FA507X"), + }, + .driver_data =3D &(struct power_data) { + .ac_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 15, + .ppt_pl1_spl_max =3D 80, + .ppt_pl2_sppt_min =3D 35, + .ppt_pl2_sppt_max =3D 80, + .ppt_pl3_fppt_min =3D 35, + .ppt_pl3_fppt_max =3D 80, + .nv_dynamic_boost_min =3D 5, + .nv_dynamic_boost_max =3D 20, + .nv_temp_target_min =3D 75, + .nv_temp_target_max =3D 87, + .nv_tgp_min =3D 55, + .nv_tgp_max =3D 85, + }, + .dc_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 15, + .ppt_pl1_spl_def =3D 45, + .ppt_pl1_spl_max =3D 65, + .ppt_pl2_sppt_min =3D 35, + .ppt_pl2_sppt_def =3D 54, + .ppt_pl2_sppt_max =3D 65, + .ppt_pl3_fppt_min =3D 35, + .ppt_pl3_fppt_max =3D 65, + .nv_temp_target_min =3D 75, + .nv_temp_target_max =3D 87, + } + }, + }, + { + .matches =3D { + DMI_MATCH(DMI_BOARD_NAME, "FA507Z"), + }, + .driver_data =3D &(struct power_data) { + .ac_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 28, + .ppt_pl1_spl_max =3D 65, + .ppt_pl2_sppt_min =3D 28, + .ppt_pl2_sppt_max =3D 105, + .nv_dynamic_boost_min =3D 5, + .nv_dynamic_boost_max =3D 15, + .nv_temp_target_min =3D 75, + .nv_temp_target_max =3D 87, + .nv_tgp_min =3D 55, + .nv_tgp_max =3D 85, + }, + .dc_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 25, + .ppt_pl1_spl_max =3D 45, + .ppt_pl2_sppt_min =3D 35, + .ppt_pl2_sppt_max =3D 60, + .nv_temp_target_min =3D 75, + .nv_temp_target_max =3D 87, + } + }, + }, + { + .matches =3D { + DMI_MATCH(DMI_BOARD_NAME, "FA607P"), + }, + .driver_data =3D &(struct power_data) { + .ac_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 30, + .ppt_pl1_spl_def =3D 100, + .ppt_pl1_spl_max =3D 135, + .ppt_pl2_sppt_min =3D 30, + .ppt_pl2_sppt_def =3D 115, + .ppt_pl2_sppt_max =3D 135, + .ppt_pl3_fppt_min =3D 30, + .ppt_pl3_fppt_max =3D 135, + .nv_dynamic_boost_min =3D 5, + .nv_dynamic_boost_max =3D 25, + .nv_temp_target_min =3D 75, + .nv_temp_target_max =3D 87, + .nv_tgp_min =3D 55, + .nv_tgp_max =3D 115, + }, + .dc_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 25, + .ppt_pl1_spl_def =3D 45, + .ppt_pl1_spl_max =3D 80, + .ppt_pl2_sppt_min =3D 25, + .ppt_pl2_sppt_def =3D 60, + .ppt_pl2_sppt_max =3D 80, + .ppt_pl3_fppt_min =3D 25, + .ppt_pl3_fppt_max =3D 80, + .nv_temp_target_min =3D 75, + .nv_temp_target_max =3D 87, + } + }, + }, + { + .matches =3D { + DMI_MATCH(DMI_BOARD_NAME, "FA617NS"), + }, + .driver_data =3D &(struct power_data) { + .ac_data =3D &(struct power_limits) { + .ppt_apu_sppt_min =3D 15, + .ppt_apu_sppt_max =3D 80, + .ppt_platform_sppt_min =3D 30, + .ppt_platform_sppt_max =3D 120 + }, + .dc_data =3D &(struct power_limits) { + .ppt_apu_sppt_min =3D 25, + .ppt_apu_sppt_max =3D 35, + .ppt_platform_sppt_min =3D 45, + .ppt_platform_sppt_max =3D 100 + } + }, + }, + { + .matches =3D { + DMI_MATCH(DMI_BOARD_NAME, "FA617NT"), + }, + .driver_data =3D &(struct power_data) { + .ac_data =3D &(struct power_limits) { + .ppt_apu_sppt_min =3D 15, + .ppt_apu_sppt_max =3D 80, + .ppt_platform_sppt_min =3D 30, + .ppt_platform_sppt_max =3D 115 + }, + .dc_data =3D &(struct power_limits) { + .ppt_apu_sppt_min =3D 15, + .ppt_apu_sppt_max =3D 45, + .ppt_platform_sppt_min =3D 30, + .ppt_platform_sppt_max =3D 50 + } + }, + }, + { + .matches =3D { + DMI_MATCH(DMI_BOARD_NAME, "FA617XS"), + }, + .driver_data =3D &(struct power_data) { + .ac_data =3D &(struct power_limits) { + .ppt_apu_sppt_min =3D 15, + .ppt_apu_sppt_max =3D 80, + .ppt_platform_sppt_min =3D 30, + .ppt_platform_sppt_max =3D 120, + .nv_temp_target_min =3D 75, + .nv_temp_target_max =3D 87, + }, + .dc_data =3D &(struct power_limits) { + .ppt_apu_sppt_min =3D 25, + .ppt_apu_sppt_max =3D 35, + .ppt_platform_sppt_min =3D 45, + .ppt_platform_sppt_max =3D 100, + .nv_temp_target_min =3D 75, + .nv_temp_target_max =3D 87, + } + }, + }, + { + .matches =3D { + DMI_MATCH(DMI_BOARD_NAME, "FX507Z"), + }, + .driver_data =3D &(struct power_data) { + .ac_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 28, + .ppt_pl1_spl_max =3D 90, + .ppt_pl2_sppt_min =3D 28, + .ppt_pl2_sppt_max =3D 135, + .nv_dynamic_boost_min =3D 5, + .nv_dynamic_boost_max =3D 15, + }, + .dc_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 25, + .ppt_pl1_spl_max =3D 45, + .ppt_pl2_sppt_min =3D 35, + .ppt_pl2_sppt_max =3D 60, + }, + .requires_fan_curve =3D true, + }, + }, + { + .matches =3D { + DMI_MATCH(DMI_BOARD_NAME, "GA401Q"), + }, + .driver_data =3D &(struct power_data) { + .ac_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 15, + .ppt_pl1_spl_max =3D 80, + .ppt_pl2_sppt_min =3D 15, + .ppt_pl2_sppt_max =3D 80, + }, + .dc_data =3D NULL + }, + }, + { + .matches =3D { + // This model is full AMD. No Nvidia dGPU. + DMI_MATCH(DMI_BOARD_NAME, "GA402R"), + }, + .driver_data =3D &(struct power_data) { + .ac_data =3D &(struct power_limits) { + .ppt_apu_sppt_min =3D 15, + .ppt_apu_sppt_max =3D 80, + .ppt_platform_sppt_min =3D 30, + .ppt_platform_sppt_max =3D 115, + }, + .dc_data =3D &(struct power_limits) { + .ppt_apu_sppt_min =3D 25, + .ppt_apu_sppt_def =3D 30, + .ppt_apu_sppt_max =3D 45, + .ppt_platform_sppt_min =3D 40, + .ppt_platform_sppt_max =3D 60, + } + }, + }, + { + .matches =3D { + DMI_MATCH(DMI_BOARD_NAME, "GA402X"), + }, + .driver_data =3D &(struct power_data) { + .ac_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 15, + .ppt_pl1_spl_def =3D 35, + .ppt_pl1_spl_max =3D 80, + .ppt_pl2_sppt_min =3D 25, + .ppt_pl2_sppt_def =3D 65, + .ppt_pl2_sppt_max =3D 80, + .ppt_pl3_fppt_min =3D 35, + .ppt_pl3_fppt_max =3D 80, + .nv_temp_target_min =3D 75, + .nv_temp_target_max =3D 87, + }, + .dc_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 15, + .ppt_pl1_spl_max =3D 35, + .ppt_pl2_sppt_min =3D 25, + .ppt_pl2_sppt_max =3D 35, + .ppt_pl3_fppt_min =3D 35, + .ppt_pl3_fppt_max =3D 65, + .nv_temp_target_min =3D 75, + .nv_temp_target_max =3D 87, + }, + .requires_fan_curve =3D true, + }, + }, + { + .matches =3D { + DMI_MATCH(DMI_BOARD_NAME, "GA403U"), + }, + .driver_data =3D &(struct power_data) { + .ac_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 15, + .ppt_pl1_spl_max =3D 80, + .ppt_pl2_sppt_min =3D 25, + .ppt_pl2_sppt_max =3D 80, + .ppt_pl3_fppt_min =3D 35, + .ppt_pl3_fppt_max =3D 80, + .nv_dynamic_boost_min =3D 5, + .nv_dynamic_boost_max =3D 25, + .nv_temp_target_min =3D 75, + .nv_temp_target_max =3D 87, + .nv_tgp_min =3D 55, + .nv_tgp_max =3D 65, + }, + .dc_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 15, + .ppt_pl1_spl_max =3D 35, + .ppt_pl2_sppt_min =3D 25, + .ppt_pl2_sppt_max =3D 35, + .ppt_pl3_fppt_min =3D 35, + .ppt_pl3_fppt_max =3D 65, + .nv_temp_target_min =3D 75, + .nv_temp_target_max =3D 87, + }, + .requires_fan_curve =3D true, + }, + }, + { + .matches =3D { + DMI_MATCH(DMI_BOARD_NAME, "GA503R"), + }, + .driver_data =3D &(struct power_data) { + .ac_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 15, + .ppt_pl1_spl_def =3D 35, + .ppt_pl1_spl_max =3D 80, + .ppt_pl2_sppt_min =3D 35, + .ppt_pl2_sppt_def =3D 65, + .ppt_pl2_sppt_max =3D 80, + .ppt_pl3_fppt_min =3D 35, + .ppt_pl3_fppt_max =3D 80, + .nv_dynamic_boost_min =3D 5, + .nv_dynamic_boost_max =3D 20, + .nv_temp_target_min =3D 75, + .nv_temp_target_max =3D 87, + }, + .dc_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 15, + .ppt_pl1_spl_def =3D 25, + .ppt_pl1_spl_max =3D 65, + .ppt_pl2_sppt_min =3D 35, + .ppt_pl2_sppt_def =3D 54, + .ppt_pl2_sppt_max =3D 60, + .ppt_pl3_fppt_min =3D 35, + .ppt_pl3_fppt_max =3D 65 + } + }, + }, + { + .matches =3D { + DMI_MATCH(DMI_BOARD_NAME, "GA605W"), + }, + .driver_data =3D &(struct power_data) { + .ac_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 15, + .ppt_pl1_spl_max =3D 80, + .ppt_pl2_sppt_min =3D 35, + .ppt_pl2_sppt_max =3D 80, + .ppt_pl3_fppt_min =3D 35, + .ppt_pl3_fppt_max =3D 80, + .nv_dynamic_boost_min =3D 5, + .nv_dynamic_boost_max =3D 20, + .nv_temp_target_min =3D 75, + .nv_temp_target_max =3D 87, + .nv_tgp_min =3D 55, + .nv_tgp_max =3D 85, + }, + .dc_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 25, + .ppt_pl1_spl_max =3D 35, + .ppt_pl2_sppt_min =3D 31, + .ppt_pl2_sppt_max =3D 44, + .ppt_pl3_fppt_min =3D 45, + .ppt_pl3_fppt_max =3D 65, + .nv_temp_target_min =3D 75, + .nv_temp_target_max =3D 87, + }, + .requires_fan_curve =3D true, + }, + }, + { + .matches =3D { + DMI_MATCH(DMI_BOARD_NAME, "GU603Z"), + }, + .driver_data =3D &(struct power_data) { + .ac_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 25, + .ppt_pl1_spl_max =3D 60, + .ppt_pl2_sppt_min =3D 25, + .ppt_pl2_sppt_max =3D 135, + /* Only allowed in AC mode */ + .nv_dynamic_boost_min =3D 5, + .nv_dynamic_boost_max =3D 20, + .nv_temp_target_min =3D 75, + .nv_temp_target_max =3D 87, + }, + .dc_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 25, + .ppt_pl1_spl_max =3D 40, + .ppt_pl2_sppt_min =3D 25, + .ppt_pl2_sppt_max =3D 40, + .nv_temp_target_min =3D 75, + .nv_temp_target_max =3D 87, + } + }, + }, + { + .matches =3D { + DMI_MATCH(DMI_BOARD_NAME, "GU604V"), + }, + .driver_data =3D &(struct power_data) { + .ac_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 65, + .ppt_pl1_spl_max =3D 120, + .ppt_pl2_sppt_min =3D 65, + .ppt_pl2_sppt_max =3D 150, + /* Only allowed in AC mode */ + .nv_dynamic_boost_min =3D 5, + .nv_dynamic_boost_max =3D 25, + .nv_temp_target_min =3D 75, + .nv_temp_target_max =3D 87, + }, + .dc_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 25, + .ppt_pl1_spl_max =3D 40, + .ppt_pl2_sppt_min =3D 35, + .ppt_pl2_sppt_def =3D 40, + .ppt_pl2_sppt_max =3D 60, + .nv_temp_target_min =3D 75, + .nv_temp_target_max =3D 87, + } + }, + }, + { + .matches =3D { + DMI_MATCH(DMI_BOARD_NAME, "GU605M"), + }, + .driver_data =3D &(struct power_data) { + .ac_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 28, + .ppt_pl1_spl_max =3D 90, + .ppt_pl2_sppt_min =3D 28, + .ppt_pl2_sppt_max =3D 135, + .nv_dynamic_boost_min =3D 5, + .nv_dynamic_boost_max =3D 20, + .nv_temp_target_min =3D 75, + .nv_temp_target_max =3D 87, + }, + .dc_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 25, + .ppt_pl1_spl_max =3D 35, + .ppt_pl2_sppt_min =3D 38, + .ppt_pl2_sppt_max =3D 53, + .nv_temp_target_min =3D 75, + .nv_temp_target_max =3D 87, + }, + .requires_fan_curve =3D true, + }, + }, + { + .matches =3D { + DMI_MATCH(DMI_BOARD_NAME, "GV301Q"), + }, + .driver_data =3D &(struct power_data) { + .ac_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 15, + .ppt_pl1_spl_max =3D 45, + .ppt_pl2_sppt_min =3D 65, + .ppt_pl2_sppt_max =3D 80, + }, + .dc_data =3D NULL + }, + }, + { + .matches =3D { + DMI_MATCH(DMI_BOARD_NAME, "GV301R"), + }, + .driver_data =3D &(struct power_data) { + .ac_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 15, + .ppt_pl1_spl_max =3D 45, + .ppt_pl2_sppt_min =3D 25, + .ppt_pl2_sppt_max =3D 54, + .ppt_pl3_fppt_min =3D 35, + .ppt_pl3_fppt_max =3D 65, + .nv_temp_target_min =3D 75, + .nv_temp_target_max =3D 87, + }, + .dc_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 15, + .ppt_pl1_spl_max =3D 35, + .ppt_pl2_sppt_min =3D 25, + .ppt_pl2_sppt_max =3D 35, + .ppt_pl3_fppt_min =3D 35, + .ppt_pl3_fppt_max =3D 65, + .nv_temp_target_min =3D 75, + .nv_temp_target_max =3D 87, + } + }, + }, + { + .matches =3D { + DMI_MATCH(DMI_BOARD_NAME, "GV601R"), + }, + .driver_data =3D &(struct power_data) { + .ac_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 15, + .ppt_pl1_spl_def =3D 35, + .ppt_pl1_spl_max =3D 90, + .ppt_pl2_sppt_min =3D 35, + .ppt_pl2_sppt_def =3D 54, + .ppt_pl2_sppt_max =3D 100, + .ppt_pl3_fppt_min =3D 35, + .ppt_pl3_fppt_def =3D 80, + .ppt_pl3_fppt_max =3D 125, + .nv_dynamic_boost_min =3D 5, + .nv_dynamic_boost_max =3D 25, + .nv_temp_target_min =3D 75, + .nv_temp_target_max =3D 87, + }, + .dc_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 15, + .ppt_pl1_spl_def =3D 28, + .ppt_pl1_spl_max =3D 65, + .ppt_pl2_sppt_min =3D 35, + .ppt_pl2_sppt_def =3D 54, + .ppt_pl2_sppt_def =3D 40, + .ppt_pl2_sppt_max =3D 60, + .ppt_pl3_fppt_min =3D 35, + .ppt_pl3_fppt_def =3D 80, + .ppt_pl3_fppt_max =3D 65, + .nv_temp_target_min =3D 75, + .nv_temp_target_max =3D 87, + } + }, + }, + { + .matches =3D { + DMI_MATCH(DMI_BOARD_NAME, "GV601V"), + }, + .driver_data =3D &(struct power_data) { + .ac_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 28, + .ppt_pl1_spl_def =3D 100, + .ppt_pl1_spl_max =3D 110, + .ppt_pl2_sppt_min =3D 28, + .ppt_pl2_sppt_max =3D 135, + .nv_dynamic_boost_min =3D 5, + .nv_dynamic_boost_max =3D 20, + .nv_temp_target_min =3D 75, + .nv_temp_target_max =3D 87, + }, + .dc_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 25, + .ppt_pl1_spl_max =3D 40, + .ppt_pl2_sppt_min =3D 35, + .ppt_pl2_sppt_def =3D 40, + .ppt_pl2_sppt_max =3D 60, + .nv_temp_target_min =3D 75, + .nv_temp_target_max =3D 87, + } + }, + }, + { + .matches =3D { + DMI_MATCH(DMI_BOARD_NAME, "GX650P"), + }, + .driver_data =3D &(struct power_data) { + .ac_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 15, + .ppt_pl1_spl_def =3D 110, + .ppt_pl1_spl_max =3D 130, + .ppt_pl2_sppt_min =3D 35, + .ppt_pl2_sppt_def =3D 125, + .ppt_pl2_sppt_max =3D 130, + .ppt_pl3_fppt_min =3D 35, + .ppt_pl3_fppt_def =3D 125, + .ppt_pl3_fppt_max =3D 135, + .nv_dynamic_boost_min =3D 5, + .nv_dynamic_boost_max =3D 25, + .nv_temp_target_min =3D 75, + .nv_temp_target_max =3D 87, + }, + .dc_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 15, + .ppt_pl1_spl_def =3D 25, + .ppt_pl1_spl_max =3D 65, + .ppt_pl2_sppt_min =3D 35, + .ppt_pl2_sppt_def =3D 35, + .ppt_pl2_sppt_max =3D 65, + .ppt_pl3_fppt_min =3D 35, + .ppt_pl3_fppt_def =3D 42, + .ppt_pl3_fppt_max =3D 65, + .nv_temp_target_min =3D 75, + .nv_temp_target_max =3D 87, + } + }, + }, + { + .matches =3D { + DMI_MATCH(DMI_BOARD_NAME, "G513I"), + }, + .driver_data =3D &(struct power_data) { + .ac_data =3D &(struct power_limits) { + /* Yes this laptop is very limited */ + .ppt_pl1_spl_min =3D 15, + .ppt_pl1_spl_max =3D 80, + .ppt_pl2_sppt_min =3D 15, + .ppt_pl2_sppt_max =3D 80, + }, + .dc_data =3D NULL, + .requires_fan_curve =3D true, + }, + }, + { + .matches =3D { + DMI_MATCH(DMI_BOARD_NAME, "G513QM"), + }, + .driver_data =3D &(struct power_data) { + .ac_data =3D &(struct power_limits) { + /* Yes this laptop is very limited */ + .ppt_pl1_spl_min =3D 15, + .ppt_pl1_spl_max =3D 100, + .ppt_pl2_sppt_min =3D 15, + .ppt_pl2_sppt_max =3D 190, + }, + .dc_data =3D NULL, + .requires_fan_curve =3D true, + }, + }, + { + .matches =3D { + DMI_MATCH(DMI_BOARD_NAME, "G513R"), + }, + .driver_data =3D &(struct power_data) { + .ac_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 35, + .ppt_pl1_spl_max =3D 90, + .ppt_pl2_sppt_min =3D 54, + .ppt_pl2_sppt_max =3D 100, + .ppt_pl3_fppt_min =3D 54, + .ppt_pl3_fppt_max =3D 125, + .nv_dynamic_boost_min =3D 5, + .nv_dynamic_boost_max =3D 25, + .nv_temp_target_min =3D 75, + .nv_temp_target_max =3D 87, + }, + .dc_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 28, + .ppt_pl1_spl_max =3D 50, + .ppt_pl2_sppt_min =3D 28, + .ppt_pl2_sppt_max =3D 50, + .ppt_pl3_fppt_min =3D 28, + .ppt_pl3_fppt_max =3D 65, + .nv_temp_target_min =3D 75, + .nv_temp_target_max =3D 87, + }, + .requires_fan_curve =3D true, + }, + }, + { + .matches =3D { + DMI_MATCH(DMI_BOARD_NAME, "G614J"), + }, + .driver_data =3D &(struct power_data) { + .ac_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 28, + .ppt_pl1_spl_max =3D 140, + .ppt_pl2_sppt_min =3D 28, + .ppt_pl2_sppt_max =3D 175, + .nv_temp_target_min =3D 75, + .nv_temp_target_max =3D 87, + .nv_dynamic_boost_min =3D 5, + .nv_dynamic_boost_max =3D 25, + }, + .dc_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 25, + .ppt_pl1_spl_max =3D 55, + .ppt_pl2_sppt_min =3D 25, + .ppt_pl2_sppt_max =3D 70, + .nv_temp_target_min =3D 75, + .nv_temp_target_max =3D 87, + }, + .requires_fan_curve =3D true, + }, + }, + { + .matches =3D { + DMI_MATCH(DMI_BOARD_NAME, "G634J"), + }, + .driver_data =3D &(struct power_data) { + .ac_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 28, + .ppt_pl1_spl_max =3D 140, + .ppt_pl2_sppt_min =3D 28, + .ppt_pl2_sppt_max =3D 175, + .nv_temp_target_min =3D 75, + .nv_temp_target_max =3D 87, + .nv_dynamic_boost_min =3D 5, + .nv_dynamic_boost_max =3D 25, + }, + .dc_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 25, + .ppt_pl1_spl_max =3D 55, + .ppt_pl2_sppt_min =3D 25, + .ppt_pl2_sppt_max =3D 70, + .nv_temp_target_min =3D 75, + .nv_temp_target_max =3D 87, + }, + .requires_fan_curve =3D true, + }, + }, + { + .matches =3D { + DMI_MATCH(DMI_BOARD_NAME, "G733C"), + }, + .driver_data =3D &(struct power_data) { + .ac_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 28, + .ppt_pl1_spl_max =3D 170, + .ppt_pl2_sppt_min =3D 28, + .ppt_pl2_sppt_max =3D 175, + .nv_temp_target_min =3D 75, + .nv_temp_target_max =3D 87, + .nv_dynamic_boost_min =3D 5, + .nv_dynamic_boost_max =3D 25, + }, + .dc_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 28, + .ppt_pl1_spl_max =3D 35, + .ppt_pl2_sppt_min =3D 28, + .ppt_pl2_sppt_max =3D 35, + .nv_temp_target_min =3D 75, + .nv_temp_target_max =3D 87, + }, + .requires_fan_curve =3D true, + }, + }, + { + .matches =3D { + DMI_MATCH(DMI_BOARD_NAME, "G733P"), + }, + .driver_data =3D &(struct power_data) { + .ac_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 30, + .ppt_pl1_spl_def =3D 100, + .ppt_pl1_spl_max =3D 130, + .ppt_pl2_sppt_min =3D 65, + .ppt_pl2_sppt_def =3D 125, + .ppt_pl2_sppt_max =3D 130, + .ppt_pl3_fppt_min =3D 65, + .ppt_pl3_fppt_def =3D 125, + .ppt_pl3_fppt_max =3D 130, + .nv_temp_target_min =3D 75, + .nv_temp_target_max =3D 87, + .nv_dynamic_boost_min =3D 5, + .nv_dynamic_boost_max =3D 25, + }, + .dc_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 25, + .ppt_pl1_spl_max =3D 65, + .ppt_pl2_sppt_min =3D 25, + .ppt_pl2_sppt_max =3D 65, + .ppt_pl3_fppt_min =3D 35, + .ppt_pl3_fppt_max =3D 75, + .nv_temp_target_min =3D 75, + .nv_temp_target_max =3D 87, + }, + .requires_fan_curve =3D true, + }, + }, + { + .matches =3D { + DMI_MATCH(DMI_BOARD_NAME, "G814J"), + }, + .driver_data =3D &(struct power_data) { + .ac_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 28, + .ppt_pl1_spl_max =3D 140, + .ppt_pl2_sppt_min =3D 28, + .ppt_pl2_sppt_max =3D 140, + .nv_dynamic_boost_min =3D 5, + .nv_dynamic_boost_max =3D 25, + }, + .dc_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 25, + .ppt_pl1_spl_max =3D 55, + .ppt_pl2_sppt_min =3D 25, + .ppt_pl2_sppt_max =3D 70, + }, + .requires_fan_curve =3D true, + }, + }, + { + .matches =3D { + DMI_MATCH(DMI_BOARD_NAME, "G834J"), + }, + .driver_data =3D &(struct power_data) { + .ac_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 28, + .ppt_pl1_spl_max =3D 140, + .ppt_pl2_sppt_min =3D 28, + .ppt_pl2_sppt_max =3D 175, + .nv_dynamic_boost_min =3D 5, + .nv_dynamic_boost_max =3D 25, + .nv_temp_target_min =3D 75, + .nv_temp_target_max =3D 87, + }, + .dc_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 25, + .ppt_pl1_spl_max =3D 55, + .ppt_pl2_sppt_min =3D 25, + .ppt_pl2_sppt_max =3D 70, + .nv_temp_target_min =3D 75, + .nv_temp_target_max =3D 87, + }, + .requires_fan_curve =3D true, + }, + }, + { + .matches =3D { + DMI_MATCH(DMI_BOARD_NAME, "H7606W"), + }, + .driver_data =3D &(struct power_data) { + .ac_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 15, + .ppt_pl1_spl_max =3D 80, + .ppt_pl2_sppt_min =3D 35, + .ppt_pl2_sppt_max =3D 80, + .ppt_pl3_fppt_min =3D 35, + .ppt_pl3_fppt_max =3D 80, + .nv_dynamic_boost_min =3D 5, + .nv_dynamic_boost_max =3D 20, + .nv_temp_target_min =3D 75, + .nv_temp_target_max =3D 87, + .nv_tgp_min =3D 55, + .nv_tgp_max =3D 85, + }, + .dc_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 25, + .ppt_pl1_spl_max =3D 35, + .ppt_pl2_sppt_min =3D 31, + .ppt_pl2_sppt_max =3D 44, + .ppt_pl3_fppt_min =3D 45, + .ppt_pl3_fppt_max =3D 65, + .nv_temp_target_min =3D 75, + .nv_temp_target_max =3D 87, + } + }, + }, + { + .matches =3D { + DMI_MATCH(DMI_BOARD_NAME, "RC71"), + }, + .driver_data =3D &(struct power_data) { + .ac_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 7, + .ppt_pl1_spl_max =3D 30, + .ppt_pl2_sppt_min =3D 15, + .ppt_pl2_sppt_max =3D 43, + .ppt_pl3_fppt_min =3D 15, + .ppt_pl3_fppt_max =3D 53 + }, + .dc_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 7, + .ppt_pl1_spl_def =3D 15, + .ppt_pl1_spl_max =3D 25, + .ppt_pl2_sppt_min =3D 15, + .ppt_pl2_sppt_def =3D 20, + .ppt_pl2_sppt_max =3D 30, + .ppt_pl3_fppt_min =3D 15, + .ppt_pl3_fppt_def =3D 25, + .ppt_pl3_fppt_max =3D 35 + } + }, + }, + { + .matches =3D { + DMI_MATCH(DMI_BOARD_NAME, "RC72"), + }, + .driver_data =3D &(struct power_data) { + .ac_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 7, + .ppt_pl1_spl_max =3D 30, + .ppt_pl2_sppt_min =3D 15, + .ppt_pl2_sppt_max =3D 43, + .ppt_pl3_fppt_min =3D 15, + .ppt_pl3_fppt_max =3D 53 + }, + .dc_data =3D &(struct power_limits) { + .ppt_pl1_spl_min =3D 7, + .ppt_pl1_spl_def =3D 17, + .ppt_pl1_spl_max =3D 25, + .ppt_pl2_sppt_min =3D 15, + .ppt_pl2_sppt_def =3D 24, + .ppt_pl2_sppt_max =3D 30, + .ppt_pl3_fppt_min =3D 15, + .ppt_pl3_fppt_def =3D 30, + .ppt_pl3_fppt_max =3D 35 + } + }, + }, + {} +}; + #endif /* _ASUS_ARMOURY_H_ */ diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/pla= tform_data/x86/asus-wmi.h index 72fd2fc88bb1..78261ea49995 100644 --- a/include/linux/platform_data/x86/asus-wmi.h +++ b/include/linux/platform_data/x86/asus-wmi.h @@ -145,6 +145,9 @@ =20 #define ASUS_WMI_DEVID_APU_MEM 0x000600C1 =20 +#define ASUS_WMI_DEVID_DGPU_BASE_TGP 0x00120099 +#define ASUS_WMI_DEVID_DGPU_SET_TGP 0x00120098 + /* gpu mux switch, 0 =3D dGPU, 1 =3D Optimus */ #define ASUS_WMI_DEVID_GPU_MUX 0x00090016 #define ASUS_WMI_DEVID_GPU_MUX_VIVO 0x00090026 --=20 2.50.0