Re: [PATCH 2/5] platform/x86: asus-bioscfg: add dgpu tgp control

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 7/16/2024 00:16, Luke D. Jones wrote:
Implement the dgpu TGP control under the asus-bioscfg module using the
fw_attributes class.

A layman will probably have no idea what a TGP is.

Can you please explain what TGP is in the commit message?


Signed-off-by: Luke D. Jones <luke@xxxxxxxxxx>
---
  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");

 Could you expand the description for these in the next version?

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





[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux