From: "Luke D. Jones" <luke@ljones.dev>
To: platform-driver-x86@vger.kernel.org
Cc: corentin.chary@gmail.com, hdegoede@redhat.com,
ilpo.jarvinen@linux.intel.com, mario.limonciello@amd.com,
linux-kernel@vger.kernel.org, "Luke D. Jones" <luke@ljones.dev>
Subject: [PATCH 2/5] platform/x86: asus-bioscfg: add dgpu tgp control
Date: Tue, 16 Jul 2024 17:16:09 +1200 [thread overview]
Message-ID: <20240716051612.64842-3-luke@ljones.dev> (raw)
In-Reply-To: <20240716051612.64842-1-luke@ljones.dev>
Implement the dgpu TGP control under the asus-bioscfg module using the
fw_attributes class.
Signed-off-by: Luke D. Jones <luke@ljones.dev>
---
drivers/platform/x86/asus-bioscfg.c | 9 +++++++
drivers/platform/x86/asus-bioscfg.h | 30 ++++++++++++++++++++++
include/linux/platform_data/x86/asus-wmi.h | 3 +++
3 files changed, 42 insertions(+)
diff --git a/drivers/platform/x86/asus-bioscfg.c b/drivers/platform/x86/asus-bioscfg.c
index 0b34e727aab4..551b7dbd8fe7 100644
--- a/drivers/platform/x86/asus-bioscfg.c
+++ b/drivers/platform/x86/asus-bioscfg.c
@@ -52,6 +52,7 @@ MODULE_ALIAS("wmi:"ASUS_NB_WMI_EVENT_GUID);
#define NVIDIA_BOOST_MAX 25
#define NVIDIA_TEMP_MIN 75
#define NVIDIA_TEMP_MAX 87
+#define NVIDIA_GPU_POWER_MAX 70
/* Tunables provided by ASUS for gaming laptops */
struct rog_tunables {
@@ -443,6 +444,10 @@ ATTR_GROUP_PPT_RW(nv_dynamic_boost, "nv_dynamic_boost", ASUS_WMI_DEVID_NV_DYN_BO
nv_boost_default, 5, nv_boost_max, 1, "Set the Nvidia dynamic boost limit");
ATTR_GROUP_PPT_RW(nv_temp_target, "nv_temp_target", ASUS_WMI_DEVID_NV_THERM_TARGET,
nv_temp_default, 75, nv_temp_max, 1, "Set the Nvidia max thermal limit");
+ATTR_GROUP_INT_VALUE_ONLY_RO(dgpu_base_tgp, "dgpu_base_tgp", ASUS_WMI_DEVID_DGPU_BASE_TGP,
+ "Read the base TGP value")
+ATTR_GROUP_INT_RW(dgpu_tgp, "dgpu_tgp", ASUS_WMI_DEVID_DGPU_SET_TGP,
+ 70, 0, NVIDIA_GPU_POWER_MAX, 1, "Set the additional TGP on top of the base TGP");
ATTR_GROUP_ENUM_INT_RO(charge_mode, "charge_mode", ASUS_WMI_DEVID_CHARGE_MODE,
"0;1;2", "Show the current mode of charging");
@@ -534,6 +539,10 @@ static int asus_fw_attr_add(void)
sysfs_create_group(&asus_bioscfg.fw_attr_kset->kobj, &nv_dynamic_boost_attr_group);
if (asus_wmi_is_present(ASUS_WMI_DEVID_NV_THERM_TARGET))
sysfs_create_group(&asus_bioscfg.fw_attr_kset->kobj, &nv_temp_target_attr_group);
+ if (asus_wmi_is_present(ASUS_WMI_DEVID_DGPU_BASE_TGP))
+ sysfs_create_group(&asus_bioscfg.fw_attr_kset->kobj, &dgpu_base_tgp_attr_group);
+ if (asus_wmi_is_present(ASUS_WMI_DEVID_DGPU_SET_TGP))
+ sysfs_create_group(&asus_bioscfg.fw_attr_kset->kobj, &dgpu_tgp_attr_group);
if (asus_wmi_is_present(ASUS_WMI_DEVID_CHARGE_MODE))
sysfs_create_group(&asus_bioscfg.fw_attr_kset->kobj, &charge_mode_attr_group);
diff --git a/drivers/platform/x86/asus-bioscfg.h b/drivers/platform/x86/asus-bioscfg.h
index 403563c25f53..2da55a91ff0b 100644
--- a/drivers/platform/x86/asus-bioscfg.h
+++ b/drivers/platform/x86/asus-bioscfg.h
@@ -113,6 +113,22 @@ static ssize_t _attrname##_##_prop##_show(struct kobject *kobj, \
static struct kobj_attribute attr_##_attrname##_##_prop = \
__ASUS_ATTR_RO(_attrname, _prop)
+/* Requires current_value show&|store */
+#define __ATTR_GROUP_INT_VALUE_ONLY(_attrname, _fsname, _dispname) \
+__ATTR_SHOW_FMT(display_name, _attrname, "%s\n", _dispname); \
+static struct kobj_attribute attr_##_attrname##_type = \
+ __ASUS_ATTR_RO_AS(type, int_type_show); \
+static struct attribute *_attrname##_attrs[] = { \
+ &attr_##_attrname##_current_value.attr, \
+ &attr_##_attrname##_display_name.attr, \
+ &attr_##_attrname##_type.attr, \
+ NULL \
+}; \
+static const struct attribute_group _attrname##_attr_group = { \
+ .name = _fsname, \
+ .attrs = _attrname##_attrs \
+}
+
/* Int style min/max range, base macro. Requires current_value show&|store */
#define __ATTR_GROUP_INT(_attrname, _fsname, _default, \
_min, _max, _incstep, _dispname)\
@@ -156,6 +172,20 @@ static const struct attribute_group _attrname##_attr_group = { \
.attrs = _attrname##_attrs \
}
+#define ATTR_GROUP_INT_VALUE_ONLY_RO(_attrname, _fsname, _wmi, _dispname) \
+do { \
+ __ATTR_CURRENT_INT_RO(_attrname, _wmi); \
+ __ATTR_GROUP_INT_VALUE_ONLY(_attrname, _fsname, _dispname); \
+} while (0)
+
+#define ATTR_GROUP_INT_RW(_attrname, _fsname, _wmi, _default, _min, \
+ _max, _incstep, _dispname) \
+do { \
+ __ATTR_CURRENT_INT_RW(_attrname, _min, _max, _wmi); \
+ __ATTR_GROUP_INT(_attrname, _fsname, _default, _min, _max, \
+ _incstep, _dispname); \
+} while (0)
+
#define ATTR_GROUP_BOOL_RO(_attrname, _fsname, _wmi, _dispname) \
do { \
__ATTR_CURRENT_INT_RO(_attrname, _wmi); \
diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h
index 889336a932fb..c54264653d75 100644
--- a/include/linux/platform_data/x86/asus-wmi.h
+++ b/include/linux/platform_data/x86/asus-wmi.h
@@ -128,6 +128,9 @@
/* dgpu on/off */
#define ASUS_WMI_DEVID_DGPU 0x00090020
+#define ASUS_WMI_DEVID_DGPU_BASE_TGP 0x00120099
+#define ASUS_WMI_DEVID_DGPU_SET_TGP 0x00120098
+
/* gpu mux switch, 0 = dGPU, 1 = Optimus */
#define ASUS_WMI_DEVID_GPU_MUX 0x00090016
#define ASUS_WMI_DEVID_GPU_MUX_VIVO 0x00090026
--
2.45.2
next prev parent reply other threads:[~2024-07-16 5:16 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-16 5:16 [PATCH 0/5] platform/x86: introduce asus-bioscfg Luke D. Jones
2024-07-16 5:16 ` [PATCH 1/5] platform/x86 asus-bioscfg: move existing tunings to asus-bioscfg module Luke D. Jones
2024-07-16 9:45 ` Ilpo Järvinen
2024-07-16 10:41 ` Luke Jones
2024-07-16 11:06 ` Ilpo Järvinen
2024-07-16 9:50 ` Hans de Goede
2024-07-16 10:48 ` Luke Jones
2024-07-16 5:16 ` Luke D. Jones [this message]
2024-08-21 21:18 ` [PATCH 2/5] platform/x86: asus-bioscfg: add dgpu tgp control Mario Limonciello
2024-07-16 5:16 ` [PATCH 3/5] platform/x86: asus-bioscfg: add apu-mem control support Luke D. Jones
2024-07-16 5:16 ` [PATCH 4/5] platform/x86: asus-bios: add core count control Luke D. Jones
2024-07-16 9:25 ` Hans de Goede
2024-07-16 9:41 ` Luke Jones
2024-07-16 9:43 ` Luke Jones
2024-07-16 5:16 ` [PATCH 5/5] asus-wmi: deprecate bios features Luke D. Jones
2024-07-16 9:20 ` [PATCH 0/5] platform/x86: introduce asus-bioscfg Hans de Goede
2024-07-16 15:11 ` Ilpo Järvinen
2024-07-17 2:34 ` Luke Jones
2024-08-05 15:18 ` Hans de Goede
2024-08-05 21:41 ` Luke Jones
2024-08-06 9:34 ` Hans de Goede
2024-08-21 21:16 ` Mario Limonciello
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240716051612.64842-3-luke@ljones.dev \
--to=luke@ljones.dev \
--cc=corentin.chary@gmail.com \
--cc=hdegoede@redhat.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mario.limonciello@amd.com \
--cc=platform-driver-x86@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®