Skip to contentSkip to conversation

platform/x86: uniwill-laptop: Remove cTGP control from unsupported devices

PATCH Superseded Werner Sembach 2 participants 3 messages Nov 24

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 platform/x86: uniwill-laptop: Remove cTGP control from unsupported devices

Some devices like the InfinityBook Pro series have Dynamic Boost support, but the cTGP setting is actually ignored.

This commit adds the ability to still initialize DB, but hide the noop cTGP sysfs attribute and applies this to the respective devices.

---
V2: Fix "force" mode not respecting mutual exclusivity of new feature bit.

 drivers/platform/x86/uniwill/uniwill-acpi.c | 30 ++++++++++++++-------
 1 file changed, 20 insertions(+), 10 deletions(-)
drivers/platform/x86/uniwill/uniwill-acpi.c +20 -10
index e2a6a704e942e..bef072f9f1b55 100644
@@ -366,10 +366,12 @@
 #define UNIWILL_FEATURE_PRIMARY_FAN		BIT(8)
 #define UNIWILL_FEATURE_SECONDARY_FAN		BIT(9)
 #define UNIWILL_FEATURE_NVIDIA_CTGP_CONTROL	BIT(10)
-#define UNIWILL_FEATURE_USB_C_POWER_PRIORITY	BIT(11)
-#define UNIWILL_FEATURE_KEYBOARD_BACKLIGHT	BIT(12)
-#define UNIWILL_FEATURE_AC_AUTO_BOOT		BIT(13)
-#define UNIWILL_FEATURE_USB_POWERSHARE		BIT(14)
+/* Mutually exclusive with the cTGP control feature */
+#define UNIWILL_FEATURE_NVIDIA_DB_SUPPORT_ONLY	BIT(11)
+#define UNIWILL_FEATURE_USB_C_POWER_PRIORITY	BIT(12)
+#define UNIWILL_FEATURE_KEYBOARD_BACKLIGHT	BIT(13)
+#define UNIWILL_FEATURE_AC_AUTO_BOOT		BIT(14)
+#define UNIWILL_FEATURE_USB_POWERSHARE		BIT(15)
 
 enum usb_c_power_priority_options {
 	USB_C_POWER_PRIORITY_CHARGING = 0,
@@ -1004,7 +1006,9 @@ static int uniwill_nvidia_ctgp_init(struct uniwill_data *data)
 {
 	int ret;
 
-	if (!uniwill_device_supports(data, UNIWILL_FEATURE_NVIDIA_CTGP_CONTROL))
+	if (!uniwill_device_supports_any(data,
+					 UNIWILL_FEATURE_NVIDIA_CTGP_CONTROL |
+					 UNIWILL_FEATURE_NVIDIA_DB_SUPPORT_ONLY))
 		return 0;
 
 	ret = regmap_write(data->regmap, EC_ADDR_CTGP_DB_CTGP_OFFSET, 0);
@@ -2577,7 +2581,9 @@ static int uniwill_suspend_usb_powershare(struct uniwill_data *data)
 
 static int uniwill_suspend_nvidia_ctgp(struct uniwill_data *data)
 {
-	if (!uniwill_device_supports(data, UNIWILL_FEATURE_NVIDIA_CTGP_CONTROL))
+	if (!uniwill_device_supports_any(data,
+					 UNIWILL_FEATURE_NVIDIA_CTGP_CONTROL |
+					 UNIWILL_FEATURE_NVIDIA_DB_SUPPORT_ONLY))
 		return 0;
 
 	return regmap_clear_bits(data->regmap, EC_ADDR_CTGP_DB_CTRL,
@@ -2686,7 +2692,9 @@ static int uniwill_resume_usb_powershare(struct uniwill_data *data)
 
 static int uniwill_resume_nvidia_ctgp(struct uniwill_data *data)
 {
-	if (!uniwill_device_supports(data, UNIWILL_FEATURE_NVIDIA_CTGP_CONTROL))
+	if (!uniwill_device_supports_any(data,
+					 UNIWILL_FEATURE_NVIDIA_CTGP_CONTROL |
+					 UNIWILL_FEATURE_NVIDIA_DB_SUPPORT_ONLY))
 		return 0;
 
 	return regmap_set_bits(data->regmap, EC_ADDR_CTGP_DB_CTRL,
@@ -2910,7 +2918,7 @@ static struct uniwill_device_descriptor phxtqxx_phxagxx_phxaqxx_phxpgxx_descript
 		    UNIWILL_FEATURE_GPU_TEMP |
 		    UNIWILL_FEATURE_PRIMARY_FAN |
 		    UNIWILL_FEATURE_SECONDARY_FAN |
-		    UNIWILL_FEATURE_NVIDIA_CTGP_CONTROL |
+		    UNIWILL_FEATURE_NVIDIA_DB_SUPPORT_ONLY |
 		    UNIWILL_FEATURE_USB_C_POWER_PRIORITY |
 		    UNIWILL_FEATURE_KEYBOARD_BACKLIGHT,
 	.kbd_led_single_color = true,
@@ -3106,7 +3114,7 @@ static int phxarxx_phxaqxx_probe(struct uniwill_data *data)
 
 	if (value & HAS_GPU)
 		data->features |= UNIWILL_FEATURE_GPU_TEMP |
-				  UNIWILL_FEATURE_NVIDIA_CTGP_CONTROL;
+				  UNIWILL_FEATURE_NVIDIA_DB_SUPPORT_ONLY;
 
 	return 0;
 };
@@ -3711,7 +3719,9 @@ static int __init uniwill_init(void)
 
 	if (force) {
 		/* Assume that the device supports all features except the charge limit */
-		device_descriptor.features = UINT_MAX & ~UNIWILL_FEATURE_BATTERY_CHARGE_LIMIT;
+		device_descriptor.features = UINT_MAX &
+			~(UNIWILL_FEATURE_BATTERY_CHARGE_LIMIT |
+			UNIWILL_FEATURE_NVIDIA_DB_SUPPORT_ONLY);
 		/* Some models only have a (white) single color keyboard backlight */
 		device_descriptor.kbd_led_single_color = false;
 		/* Some models only support 3 brightness levels */
Signature · 1 line
2.43.0
maintainer
#1 lore raw

Am 24.11.26 um 16:11 schrieb Werner Sembach:

Quoted 18 lines

Some devices like the InfinityBook Pro series have Dynamic Boost support, but the cTGP setting is actually ignored.

This commit adds the ability to still initialize DB, but hide the noop cTGP sysfs attribute and applies this to the respective devices.

---
V2: Fix "force" mode not respecting mutual exclusivity of new feature bit.

  drivers/platform/x86/uniwill/uniwill-acpi.c | 30 ++++++++++++++-------
  1 file changed, 20 insertions(+), 10 deletions(-)
drivers/platform/x86/uniwill/uniwill-acpi.c +0 -0
index e2a6a704e942e..bef072f9f1b55 100644

drivers/platform/x86/uniwill/uniwill-acpi.c line 370

Quoted 9 lines
drivers/platform/x86/uniwill/uniwill-acpi.c +2 -4
@@ -366,10 +366,12 @@
  #define UNIWILL_FEATURE_PRIMARY_FAN		BIT(8)
  #define UNIWILL_FEATURE_SECONDARY_FAN		BIT(9)
  #define UNIWILL_FEATURE_NVIDIA_CTGP_CONTROL	BIT(10)
-#define UNIWILL_FEATURE_USB_C_POWER_PRIORITY	BIT(11)
-#define UNIWILL_FEATURE_KEYBOARD_BACKLIGHT	BIT(12)
-#define UNIWILL_FEATURE_AC_AUTO_BOOT		BIT(13)
-#define UNIWILL_FEATURE_USB_POWERSHARE		BIT(14)
+/* Mutually exclusive with the cTGP control feature */
+#define UNIWILL_FEATURE_NVIDIA_DB_SUPPORT_ONLY	BIT(11)

Hi,

i think it would be better to instead split UNIWILL_FEATURE_NVIDIA_CTGP_CONTROL into UNIWILL_FEATURE_NVIDIA_CTGP_CONTROL and UNIWILL_FEATURE_NVIDIA_DB_CONTROL.

Devices that currently support cTGP control just need to also set UNIWILL_FEATURE_NVIDIA_DB_CONTROL, and devices that only support dynamic boost only need to set UNIWILL_FEATURE_NVIDIA_DB_CONTROL.

This way we can avoid having another set of mutally exclusive feature flags.

Quoted 8 lines
drivers/platform/x86/uniwill/uniwill-acpi.c +4 -0
+#define UNIWILL_FEATURE_USB_C_POWER_PRIORITY	BIT(12)
+#define UNIWILL_FEATURE_KEYBOARD_BACKLIGHT	BIT(13)
+#define UNIWILL_FEATURE_AC_AUTO_BOOT		BIT(14)
+#define UNIWILL_FEATURE_USB_POWERSHARE		BIT(15)
 
  enum usb_c_power_priority_options {
  	USB_C_POWER_PRIORITY_CHARGING = 0,

drivers/platform/x86/uniwill/uniwill-acpi.c static int uniwill_nvidia_ctgp_init(struct uniwill_data *data) · line 1012

Quoted 8 lines
drivers/platform/x86/uniwill/uniwill-acpi.c +3 -1
@@ -1004,7 +1006,9 @@ static int uniwill_nvidia_ctgp_init(struct uniwill_data *data)
  {
  	int ret;
 
-	if (!uniwill_device_supports(data, UNIWILL_FEATURE_NVIDIA_CTGP_CONTROL))
+	if (!uniwill_device_supports_any(data,
+					 UNIWILL_FEATURE_NVIDIA_CTGP_CONTROL |
+					 UNIWILL_FEATURE_NVIDIA_DB_SUPPORT_ONLY))
  		return 0;

Should we still set CTGP_DB_CTGP_ENABLE if cTGP control is not supported? Also i think we should not touch EC_ADDR_CTGP_DB_CTGP_OFFSET if cTGP support is not present, the same goes for dynamic boost.

Thanks,
Armin Wolf

Quoted 53 lines
drivers/platform/x86/uniwill/uniwill-acpi.c +11 -5
  	ret = regmap_write(data->regmap, EC_ADDR_CTGP_DB_CTGP_OFFSET, 0);
@@ -2577,7 +2581,9 @@ static int uniwill_suspend_usb_powershare(struct uniwill_data *data)
 
  static int uniwill_suspend_nvidia_ctgp(struct uniwill_data *data)
  {
-	if (!uniwill_device_supports(data, UNIWILL_FEATURE_NVIDIA_CTGP_CONTROL))
+	if (!uniwill_device_supports_any(data,
+					 UNIWILL_FEATURE_NVIDIA_CTGP_CONTROL |
+					 UNIWILL_FEATURE_NVIDIA_DB_SUPPORT_ONLY))
  		return 0;
 
  	return regmap_clear_bits(data->regmap, EC_ADDR_CTGP_DB_CTRL,
@@ -2686,7 +2692,9 @@ static int uniwill_resume_usb_powershare(struct uniwill_data *data)
 
  static int uniwill_resume_nvidia_ctgp(struct uniwill_data *data)
  {
-	if (!uniwill_device_supports(data, UNIWILL_FEATURE_NVIDIA_CTGP_CONTROL))
+	if (!uniwill_device_supports_any(data,
+					 UNIWILL_FEATURE_NVIDIA_CTGP_CONTROL |
+					 UNIWILL_FEATURE_NVIDIA_DB_SUPPORT_ONLY))
  		return 0;
 
  	return regmap_set_bits(data->regmap, EC_ADDR_CTGP_DB_CTRL,
@@ -2910,7 +2918,7 @@ static struct uniwill_device_descriptor phxtqxx_phxagxx_phxaqxx_phxpgxx_descript
  		    UNIWILL_FEATURE_GPU_TEMP |
  		    UNIWILL_FEATURE_PRIMARY_FAN |
  		    UNIWILL_FEATURE_SECONDARY_FAN |
-		    UNIWILL_FEATURE_NVIDIA_CTGP_CONTROL |
+		    UNIWILL_FEATURE_NVIDIA_DB_SUPPORT_ONLY |
  		    UNIWILL_FEATURE_USB_C_POWER_PRIORITY |
  		    UNIWILL_FEATURE_KEYBOARD_BACKLIGHT,
  	.kbd_led_single_color = true,
@@ -3106,7 +3114,7 @@ static int phxarxx_phxaqxx_probe(struct uniwill_data *data)
 
  	if (value & HAS_GPU)
  		data->features |= UNIWILL_FEATURE_GPU_TEMP |
-				  UNIWILL_FEATURE_NVIDIA_CTGP_CONTROL;
+				  UNIWILL_FEATURE_NVIDIA_DB_SUPPORT_ONLY;
 
  	return 0;
  };
@@ -3711,7 +3719,9 @@ static int __init uniwill_init(void)
 
  	if (force) {
  		/* Assume that the device supports all features except the charge limit */
-		device_descriptor.features = UINT_MAX & ~UNIWILL_FEATURE_BATTERY_CHARGE_LIMIT;
+		device_descriptor.features = UINT_MAX &
+			~(UNIWILL_FEATURE_BATTERY_CHARGE_LIMIT |
+			UNIWILL_FEATURE_NVIDIA_DB_SUPPORT_ONLY);
  		/* Some models only have a (white) single color keyboard backlight */
  		device_descriptor.kbd_led_single_color = false;
  		/* Some models only support 3 brightness levels */
#2 lore raw

Am 24.11.26 um 16:39 schrieb Armin Wolf:

Quoted 31 lines

Am 24.11.26 um 16:11 schrieb Werner Sembach:

Quoted 18 lines

Some devices like the InfinityBook Pro series have Dynamic Boost support, but the cTGP setting is actually ignored.

This commit adds the ability to still initialize DB, but hide the noop cTGP sysfs attribute and applies this to the respective devices.

---
V2: Fix "force" mode not respecting mutual exclusivity of new feature bit.

  drivers/platform/x86/uniwill/uniwill-acpi.c | 30 ++++++++++++++-------

  1 file changed, 20 insertions(+), 10 deletions(-)
drivers/platform/x86/uniwill/uniwill-acpi.c +0 -0
index e2a6a704e942e..bef072f9f1b55 100644

drivers/platform/x86/uniwill/uniwill-acpi.c line 370

Quoted 9 lines
drivers/platform/x86/uniwill/uniwill-acpi.c +2 -4
@@ -366,10 +366,12 @@
   #define UNIWILL_FEATURE_PRIMARY_FAN        BIT(8)
   #define UNIWILL_FEATURE_SECONDARY_FAN        BIT(9)
   #define UNIWILL_FEATURE_NVIDIA_CTGP_CONTROL    BIT(10)
-#define UNIWILL_FEATURE_USB_C_POWER_PRIORITY    BIT(11)
-#define UNIWILL_FEATURE_KEYBOARD_BACKLIGHT    BIT(12)
-#define UNIWILL_FEATURE_AC_AUTO_BOOT        BIT(13)
-#define UNIWILL_FEATURE_USB_POWERSHARE        BIT(14)
+/* Mutually exclusive with the cTGP control feature */
+#define UNIWILL_FEATURE_NVIDIA_DB_SUPPORT_ONLY    BIT(11)

Hi,

Quoted 5 lines

i think it would be better to instead split UNIWILL_FEATURE_NVIDIA_CTGP_CONTROL into UNIWILL_FEATURE_NVIDIA_CTGP_CONTROL and UNIWILL_FEATURE_NVIDIA_DB_CONTROL.

Devices that currently support cTGP control just need to also set UNIWILL_FEATURE_NVIDIA_DB_CONTROL, and devices that only support dynamic boost only need to set UNIWILL_FEATURE_NVIDIA_DB_CONTROL.

This way we can avoid having another set of mutally exclusive feature flags.

ok

Quoted 73 lines
Quoted 8 lines
drivers/platform/x86/uniwill/uniwill-acpi.c +4 -0
+#define UNIWILL_FEATURE_USB_C_POWER_PRIORITY    BIT(12)
+#define UNIWILL_FEATURE_KEYBOARD_BACKLIGHT    BIT(13)
+#define UNIWILL_FEATURE_AC_AUTO_BOOT        BIT(14)
+#define UNIWILL_FEATURE_USB_POWERSHARE        BIT(15)
     enum usb_c_power_priority_options {
       USB_C_POWER_PRIORITY_CHARGING = 0,

drivers/platform/x86/uniwill/uniwill-acpi.c static int uniwill_nvidia_ctgp_init(struct uniwill_data · line 1013

Quoted 8 lines
drivers/platform/x86/uniwill/uniwill-acpi.c +3 -0
@@ -1004,7 +1006,9 @@ static int uniwill_nvidia_ctgp_init(struct uniwill_data 
 *data)
   {
       int ret;
   -    if (!uniwill_device_supports(data, UNIWILL_FEATURE_NVIDIA_CTGP_CONTROL))
+    if (!uniwill_device_supports_any(data,
+                     UNIWILL_FEATURE_NVIDIA_CTGP_CONTROL |
+                     UNIWILL_FEATURE_NVIDIA_DB_SUPPORT_ONLY))
           return 0;

Should we still set CTGP_DB_CTGP_ENABLE if cTGP control is not supported? Also i think we should not touch EC_ADDR_CTGP_DB_CTGP_OFFSET if cTGP support is not present, the same goes for dynamic boost.

Thanks,
Armin Wolf

Quoted 50 lines
drivers/platform/x86/uniwill/uniwill-acpi.c +6 -2
         ret = regmap_write(data->regmap, EC_ADDR_CTGP_DB_CTGP_OFFSET, 0);
@@ -2577,7 +2581,9 @@ static int uniwill_suspend_usb_powershare(struct 
 uniwill_data *data)
     static int uniwill_suspend_nvidia_ctgp(struct uniwill_data *data)
   {
-    if (!uniwill_device_supports(data, UNIWILL_FEATURE_NVIDIA_CTGP_CONTROL))
+    if (!uniwill_device_supports_any(data,
+                     UNIWILL_FEATURE_NVIDIA_CTGP_CONTROL |
+                     UNIWILL_FEATURE_NVIDIA_DB_SUPPORT_ONLY))
           return 0;
         return regmap_clear_bits(data->regmap, EC_ADDR_CTGP_DB_CTRL,
@@ -2686,7 +2692,9 @@ static int uniwill_resume_usb_powershare(struct 
 uniwill_data *data)
     static int uniwill_resume_nvidia_ctgp(struct uniwill_data *data)
   {
-    if (!uniwill_device_supports(data, UNIWILL_FEATURE_NVIDIA_CTGP_CONTROL))
+    if (!uniwill_device_supports_any(data,
+                     UNIWILL_FEATURE_NVIDIA_CTGP_CONTROL |
+                     UNIWILL_FEATURE_NVIDIA_DB_SUPPORT_ONLY))
           return 0;
         return regmap_set_bits(data->regmap, EC_ADDR_CTGP_DB_CTRL,
@@ -2910,7 +2918,7 @@ static struct uniwill_device_descriptor 

phxtqxx_phxagxx_phxaqxx_phxpgxx_descript UNIWILL_FEATURE_GPU_TEMP | UNIWILL_FEATURE_PRIMARY_FAN | UNIWILL_FEATURE_SECONDARY_FAN | -            UNIWILL_FEATURE_NVIDIA_CTGP_CONTROL | +            UNIWILL_FEATURE_NVIDIA_DB_SUPPORT_ONLY | UNIWILL_FEATURE_USB_C_POWER_PRIORITY | UNIWILL_FEATURE_KEYBOARD_BACKLIGHT, .kbd_led_single_color = true,

drivers/platform/x86/uniwill/uniwill-acpi.c +0 -0
@@ -3106,7 +3114,7 @@ static int phxarxx_phxaqxx_probe(struct uniwill_data 
 *data)
         if (value & HAS_GPU)

          data->features |= UNIWILL_FEATURE_GPU_TEMP | -                  UNIWILL_FEATURE_NVIDIA_CTGP_CONTROL; +                  UNIWILL_FEATURE_NVIDIA_DB_SUPPORT_ONLY; return 0;
  };

drivers/platform/x86/uniwill/uniwill-acpi.c +3 -1
@@ -3711,7 +3719,9 @@ static int __init uniwill_init(void)
         if (force) {
           /* Assume that the device supports all features except the charge limit */
-        device_descriptor.features = UINT_MAX & 
 ~UNIWILL_FEATURE_BATTERY_CHARGE_LIMIT;
+        device_descriptor.features = UINT_MAX &
+            ~(UNIWILL_FEATURE_BATTERY_CHARGE_LIMIT |
+            UNIWILL_FEATURE_NVIDIA_DB_SUPPORT_ONLY);
           /* Some models only have a (white) single color keyboard backlight */
           device_descriptor.kbd_led_single_color = false;
           /* Some models only support 3 brightness levels */